Patch level : 10.0

Files correlati     : 768
Ricompilazione Demo : [ ]
Commento            :
Errore 0001657:
Creazione pdf dalla stampa fattura , interlinea scorretta e campi sovrapposti


git-svn-id: svn://10.65.10.50/trunk@20617 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-06-22 13:41:46 +00:00
parent d63de600f5
commit c231e99439
9 changed files with 104 additions and 87 deletions

View File

@ -7,7 +7,7 @@ BEGIN
PROMPT 1 0 "@bStampa su..." PROMPT 1 0 "@bStampa su..."
ITEM "0|Stampante" ITEM "0|Stampante"
MESSAGE SHOW,1@|HIDE,2@ MESSAGE SHOW,1@|HIDE,2@
ITEM "2|Visualizzazione" ITEM "2|Anteprima"
MESSAGE SHOW,1@|HIDE,2@ MESSAGE SHOW,1@|HIDE,2@
ITEM "1|File su disco" ITEM "1|File su disco"
MESSAGE HIDE,1@|SHOW,2@ MESSAGE HIDE,1@|SHOW,2@
@ -24,13 +24,13 @@ BEGIN
GROUP 1 GROUP 1
END END
LIST MSK_PRINTERS 64 LIST MSK_PRINTERS 63
BEGIN BEGIN
PROMPT 1 4 "Stampante " PROMPT 1 4 "Stampante "
GROUP 1 GROUP 1
END END
STRING MSK_FILENAME 256 68 STRING MSK_FILENAME 256 64
BEGIN BEGIN
PROMPT 1 4 "File " PROMPT 1 4 "File "
CHECKTYPE REQUIRED CHECKTYPE REQUIRED

View File

@ -83,9 +83,9 @@ void advanced_draw_text_line(WINDOW w, const char* text, const RCT& r, char hali
xvt_dwin_get_font_metrics(w, &leading, &ascent, &descent); xvt_dwin_get_font_metrics(w, &leading, &ascent, &descent);
switch (valign) switch (valign)
{ {
case 'C': y -= (dy - ascent)/2; break; case 'C': y -= (dy - ascent-descent)/2; break;
case 'T': y = r.top + leading + ascent; break; case 'T': y = r.top + ascent; break;
default : y -= descent; break; default : y -= descent+leading; break;
} }
bool can_draw = true; bool can_draw = true;
RCT orig; xvt_dwin_get_clip(w, &orig); RCT orig; xvt_dwin_get_clip(w, &orig);
@ -423,8 +423,8 @@ void TPrint_preview_window::popup_menu(EVENT* ep)
menu[2].tag = POPUP_NEXT; menu[2].text = (char*)TR("Avanti"); menu[2].enabled = _page < _book->pages(); menu[2].tag = POPUP_NEXT; menu[2].text = (char*)TR("Avanti"); menu[2].enabled = _page < _book->pages();
menu[3].tag = POPUP_LAST; menu[3].text = (char*)TR("Ultima"); menu[3].enabled = _page < _book->pages(); menu[3].tag = POPUP_LAST; menu[3].text = (char*)TR("Ultima"); menu[3].enabled = _page < _book->pages();
menu[4].tag = -1; menu[4].separator = true; menu[4].tag = -1; menu[4].separator = true;
menu[5].tag = POPUP_ZOOMIN; menu[5].text = (char*)TR("Zoom +"); menu[5].enabled = _zoom < 300; menu[5].tag = POPUP_ZOOMIN; menu[5].text = (char*)TR("Zoom +"); menu[5].enabled = _zoom < SCREENDPI*4;
menu[6].tag = POPUP_ZOOMOUT; menu[6].text = (char*)TR("Zoom -"); menu[6].enabled = _zoom > 35; menu[6].tag = POPUP_ZOOMOUT; menu[6].text = (char*)TR("Zoom -"); menu[6].enabled = _zoom > SCREENDPI/4;
menu[7].tag = -1; menu[7].separator = true; menu[7].tag = -1; menu[7].separator = true;
menu[8].tag = POPUP_GRID; menu[8].text = (char*)TR("Griglia"); menu[8].enabled = true; menu[8].tag = POPUP_GRID; menu[8].text = (char*)TR("Griglia"); menu[8].enabled = true;
menu[8].checkable = true; menu[8].checked = _grid; menu[8].checkable = true; menu[8].checked = _grid;
@ -537,8 +537,8 @@ long TPrint_preview_window::handler(WINDOW win, EVENT* ep)
processed = _page < _book->pages(); processed = _page < _book->pages();
if (processed) _page = _book->pages(); if (processed) _page = _book->pages();
break; break;
case POPUP_ZOOMIN : if (_zoom < 300) { _zoom += 10; update_scroll_range(); } break; case POPUP_ZOOMIN : if (_zoom < SCREENDPI*4) { _zoom += SCREENDPI/8; update_scroll_range(); } break;
case POPUP_ZOOMOUT: if (_zoom > 35) { _zoom -= 10; update_scroll_range(); } break; case POPUP_ZOOMOUT: if (_zoom > SCREENDPI/4) { _zoom -= SCREENDPI/8; update_scroll_range(); } break;
case POPUP_GRID : _grid = !_grid; break; case POPUP_GRID : _grid = !_grid; break;
default:processed = false; break; default:processed = false; break;
} }
@ -618,7 +618,7 @@ bool TPrint_preview_window::on_key(KEY k)
TPrint_preview_window::TPrint_preview_window(int x, int y, int dx, int dy, WINDOW parent, TPrint_preview_window::TPrint_preview_window(int x, int y, int dx, int dy, WINDOW parent,
TWindowed_field* owner, TBook* book) TWindowed_field* owner, TBook* book)
: TField_window(x, y, dx, dy, parent, owner), _book(book), : TField_window(x, y, dx, dy, parent, owner), _book(book),
_page(1), _zoom(100), _grid(false) _page(1), _zoom(SCREENDPI), _grid(false)
{ {
_pixmap = true; _pixmap = true;
_grid = ini_get_bool(CONFIG_GUI, "Preview", "Grid"); _grid = ini_get_bool(CONFIG_GUI, "Preview", "Grid");

View File

@ -5,7 +5,7 @@
#include <report.h> #include <report.h>
#endif #endif
enum {BOOKDPI = 720}; enum { SCREENDPI = 96, BOOKDPI = 720};
class TBook : public TObject class TBook : public TObject
{ {

View File

@ -974,16 +974,9 @@ void xvt_dwin_draw_roundrect(WINDOW win, const RCT *rctp, int oval_width, int ov
void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp) void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp)
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
static int can_draw_dots = -1; CAST_DC(win, dc);
if (can_draw_dots < 0) OsWin32_DrawDottedRect(dc.GetHDC(), rctp->left, rctp->top, rctp->right, rctp->bottom);
can_draw_dots = xvt_sys_get_os_version() >= XVT_WS_WIN_NT; #else
if (can_draw_dots)
{
CAST_DC(win, dc);
OsWin32_DrawDottedRect(dc.GetHDC(), rctp->left, rctp->top, rctp->right, rctp->bottom);
return;
}
#endif
DRAW_CTOOLS dct; DRAW_CTOOLS dct;
xvt_dwin_get_draw_ctools(win, &dct); xvt_dwin_get_draw_ctools(win, &dct);
@ -1000,6 +993,7 @@ void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp)
xvt_dwin_set_cbrush(win, &brush); xvt_dwin_set_cbrush(win, &brush);
xvt_dwin_draw_rect(win, rctp); xvt_dwin_draw_rect(win, rctp);
xvt_dwin_set_draw_ctools(win, &dct); xvt_dwin_set_draw_ctools(win, &dct);
#endif
} }
void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt) void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt)
@ -1009,6 +1003,10 @@ void xvt_dwin_draw_set_pos(WINDOW win, PNT pnt)
dc._pnt.y = pnt.v; dc._pnt.y = pnt.v;
} }
// x refers to to the left of the text
// y refers to the baseline of the text
// s is the text
// len is the klenght of the text (-1 stands for all the null terminated text)
void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len) void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len)
{ {
if (s && *s && len != 0) if (s && *s && len != 0)
@ -1023,28 +1021,28 @@ void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len)
str.Truncate(len); str.Truncate(len);
wxDC& dc = tdc.GetDC(); // Prima getto il DC ... wxDC& dc = tdc.GetDC(); // Prima getto il DC ...
const int delta = tdc.GetFontDelta(); // ... poi faccio la GetFontDelta! const int delta = tdc.GetFontDelta(); // ... poi faccio la GetFontDelta!
#ifdef LINUX /*
if (tdc._dct.opaque_text) #ifndef NDEBUG
{ // Disegna linee base del testo
RCT back; int width = ::xvt_dwin_get_text_width(win, s, len);
back.left = x; int leading, ascent, descent; xvt_dwin_get_font_metrics(win, &leading, &ascent, &descent);
back.right = x + xvt_dwin_get_text_width(win, str, -1);
back.top = y - delta;
back.bottom = y;
CAST_COLOR(tdc._dct.back_color, brush_color);
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(brush_color, wxSOLID); dc.SetPen(*wxMEDIUM_GREY_PEN);
const wxBrush & old_brush = dc.GetBrush(); dc.DrawLine(x, y, x+width, y);
const wxPen & old_pen = dc.GetPen();
const wxRect rct = RCT2Rect(&back);
dc.SetBrush(*brush); dc.SetPen(*wxCYAN_PEN);
dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawLine(x, y-ascent, x+width, y-ascent);
dc.DrawRectangle(rct);
dc.SetBrush(old_brush); dc.SetPen(*wxGREEN_PEN);
dc.SetPen(old_pen); dc.DrawLine(x, y+descent, x+width, y+descent);
}
if (leading > 0)
{
dc.SetPen(*wxRED_PEN);
dc.DrawLine(x, y+descent+leading, x+width, y+descent+leading);
}
#endif #endif
*/
dc.DrawText(str, x, y-delta); dc.DrawText(str, x, y-delta);
} }
} }
@ -1075,13 +1073,13 @@ void xvt_dwin_get_font_metrics(WINDOW win, int *leadingp, int *ascentp, int *des
{ {
// Attenzione: non funziona la chiamate in cascata a xvt_font_get_metrics // Attenzione: non funziona la chiamate in cascata a xvt_font_get_metrics
CAST_DC(win, dc); CAST_DC(win, dc);
const wxString str = "Mg"; const wxString str = "Kpfx";
int height, desc, lead; int height, desc, lead;
dc.GetTextExtent(str, NULL, &height, &desc, &lead); dc.GetTextExtent(str, NULL, &height, &desc, &lead);
if (leadingp) if (leadingp)
*leadingp = lead; *leadingp = lead;
if (ascentp) if (ascentp)
*ascentp = height-lead-desc; *ascentp = height-desc;
if (descentp) if (descentp)
*descentp = desc; *descentp = desc;
} }
@ -1376,7 +1374,7 @@ void xvt_font_get_metrics(XVT_FNTID font_id, int *leadingp, int *ascentp, int *d
win = TASK_WIN; // Non mi fido troppo della finestra su cui il font e' mappato win = TASK_WIN; // Non mi fido troppo della finestra su cui il font e' mappato
CAST_DC(win, dc); CAST_DC(win, dc);
const wxString str = "Mq"; const wxString str = "Kpfx";
int height = 0, desc = 0, lead = 0; int height = 0, desc = 0, lead = 0;
const wxFont& ff = font.Font(&dc, win); const wxFont& ff = font.Font(&dc, win);
dc.GetTextExtent(str, NULL, &height, &desc, &lead, (wxFont*)&ff); dc.GetTextExtent(str, NULL, &height, &desc, &lead, (wxFont*)&ff);
@ -1390,7 +1388,7 @@ void xvt_font_get_metrics(XVT_FNTID font_id, int *leadingp, int *ascentp, int *d
if (leadingp) if (leadingp)
*leadingp = lead; *leadingp = lead;
if (ascentp) if (ascentp)
*ascentp = height-desc-lead; *ascentp = height-desc; //*ascentp = height-desc-lead;
if (descentp) if (descentp)
*descentp = desc; *descentp = desc;
} }

View File

@ -111,6 +111,7 @@ XVTDLL void xvt_dwin_draw_gradient_circular(WINDOW win, const RCT* r, C
XVTDLL void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR col2, int angle); // Added by AGA XVTDLL void xvt_dwin_draw_gradient_linear(WINDOW win, const RCT* r, COLOR col1, COLOR col2, int angle); // Added by AGA
XVTDLL void xvt_dwin_draw_image_on_pdf(WINDOW win, const char* name, RCT* dest); // Added by AGA XVTDLL void xvt_dwin_draw_image_on_pdf(WINDOW win, const char* name, RCT* dest); // Added by AGA
XVTDLL void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, const RCT* dest, const RCT* source); XVTDLL void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, const RCT* dest, const RCT* source);
XVTDLL void xvt_dwin_draw_line(WINDOW win, PNT pnt);
XVTDLL void xvt_dwin_draw_oval(WINDOW Win, const RCT* r); XVTDLL void xvt_dwin_draw_oval(WINDOW Win, const RCT* r);
XVTDLL void xvt_dwin_draw_pie(WINDOW win, const RCT *rctp, int start_x, int start_y, int stop_x, int stop_y); XVTDLL void xvt_dwin_draw_pie(WINDOW win, const RCT *rctp, int start_x, int start_y, int stop_x, int stop_y);
XVTDLL void xvt_dwin_draw_polygon(WINDOW win, const PNT *lpnts, int npnts); XVTDLL void xvt_dwin_draw_polygon(WINDOW win, const PNT *lpnts, int npnts);
@ -140,7 +141,6 @@ XVTDLL void xvt_dwin_set_font(WINDOW win, XVT_FNTID font_id);
XVTDLL void xvt_dwin_set_fore_color(WINDOW win, COLOR color); XVTDLL void xvt_dwin_set_fore_color(WINDOW win, COLOR color);
XVTDLL void xvt_dwin_set_std_cbrush(WINDOW win, long flag); XVTDLL void xvt_dwin_set_std_cbrush(WINDOW win, long flag);
XVTDLL void xvt_dwin_set_std_cpen(WINDOW win, long flag); XVTDLL void xvt_dwin_set_std_cpen(WINDOW win, long flag);
XVTDLL void xvt_dwin_draw_line(WINDOW win, PNT pnt);
XVTDLL void xvt_dwin_update(WINDOW win); XVTDLL void xvt_dwin_update(WINDOW win);
XVTDLL XVT_ERRSEV xvt_errmsg_get_sev_id(XVT_ERRMSG err); XVTDLL XVT_ERRSEV xvt_errmsg_get_sev_id(XVT_ERRMSG err);

View File

@ -51,6 +51,27 @@ static int RoundToIcon(int nSize)
return nSize; return nSize;
} }
void Image2Colors(const wxImage& img, wxColour& mean, wxColour& dark, wxColour& light)
{
dark = *wxWHITE;
mean = *wxLIGHT_GREY;
light = *wxBLACK;
double r=0, g=0, b=0;
const int h = img.GetHeight();
for (int i = 0; i < h; i++)
{
const wxColourBase::ChannelType cr = img.GetRed(i,i);
const wxColourBase::ChannelType cg = img.GetGreen(i,i);
const wxColourBase::ChannelType cb = img.GetBlue(i,i);
r += cr; g += cg; b += cb;
}
r/=h; g/=h; b/=h;
mean = wxColour(r, g, b);
dark = wxColour(r*0.8, g*0.8, b*0.8);
light = wxColour(min(r*1.2,255), min(g*1.2,255), min(b*1.2,255));
}
static wxAuiDockArt* FindArtist(wxWindow* pWindow) static wxAuiDockArt* FindArtist(wxWindow* pWindow)
{ {
@ -2036,9 +2057,20 @@ void TwxToolBar::OnEraseBackground(wxEraseEvent& evt)
} }
else else
{ {
wxBrush brush(GetBackgroundColour()); if (xvt_sys_get_oem_int("OEM", -1) == 0)
dc.SetBackground(brush); {
dc.Clear(); wxCoord cw, ch; dc.GetSize(&cw, &ch);
const wxColour b0 = GetBackgroundColour();
const wxColour b1 = ModulateColour(b0, -10);
const wxColour b2 = ModulateColour(b0, +70);
dc.GradientFillLinear(wxRect(0,0,cw,ch),b1,b2,wxSOUTH);
}
else
{
wxBrush brush(GetBackgroundColour());
dc.SetBackground(brush);
dc.Clear();
}
} }
} }
@ -2059,25 +2091,11 @@ void TwxToolBar::SetBackgroundTexture(XVT_IMAGE xvt_img)
if (xvt_img != NULL) if (xvt_img != NULL)
{ {
const wxImage& img = *(wxImage*)xvt_img; const wxImage& img = *(wxImage*)xvt_img;
m_texture = wxBitmap(img); wxColour mean, dark, light;
Image2Colors(img, mean, dark, light);
SetBackgroundColour(mean);
wxImageHistogram histogram; m_texture = wxBitmap(img);
if (img.ComputeHistogram(histogram))
{
unsigned long nModa = 0;
wxColour cModa;
for(wxImageHistogram::iterator it = histogram.begin(); it != histogram.end(); ++it)
{
const wxImageHistogramEntry& e = it->second;
if (e.value > nModa)
{
cModa = it->first;
nModa = e.value;
}
}
if (nModa > 0)
SetBackgroundColour(cModa);
}
} }
else else
m_texture = wxNullBitmap; m_texture = wxNullBitmap;

View File

@ -735,7 +735,7 @@ void TwxPDFDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
PDF_TRY_DL(m_PDFlib, m_p) PDF_TRY_DL(m_PDFlib, m_p)
{ {
m_PDFlib->PDF_set_text_pos(m_p, x, y + m_fontsize); m_PDFlib->PDF_set_text_pos(m_p, x, y + m_ascent);
m_PDFlib->PDF_show(m_p, text); m_PDFlib->PDF_show(m_p, text);
wxCoord text_w = m_PDFlib->PDF_stringwidth(m_p, text, m_fontnr, m_fontsize); wxCoord text_w = m_PDFlib->PDF_stringwidth(m_p, text, m_fontnr, m_fontsize);
CalcBoundingBox( x, y ); CalcBoundingBox( x, y );
@ -805,8 +805,9 @@ void TwxPDFDC::DoGetTextExtent(const wxString& text,
if (m_font.Ok() && (theFont==NULL || *theFont==m_font)) if (m_font.Ok() && (theFont==NULL || *theFont==m_font))
{ {
if (x) *x = m_PDFlib->PDF_stringwidth(m_p, text, m_fontnr, m_fontsize); if (x) *x = m_PDFlib->PDF_stringwidth(m_p, text, m_fontnr, m_fontsize);
if (y) *y = 5*m_fontsize/4; if (y) *y = m_fontsize;
if (d) *d = m_fontsize/4; if (d) *d = m_descent;
if (e) *e = m_leading;
} }
else else
{ {
@ -818,11 +819,11 @@ void TwxPDFDC::DoGetTextExtent(const wxString& text,
double fontsize = theFont->GetPointSize(); double fontsize = theFont->GetPointSize();
int fontnr = m_PDFlib->PDF_load_font(m_p, strFamily, 0, "auto", "fontstyle {" + strStyle + "}"); int fontnr = m_PDFlib->PDF_load_font(m_p, strFamily, 0, "auto", "fontstyle {" + strStyle + "}");
if (x) *x = m_PDFlib->PDF_stringwidth(m_p, text, fontnr, fontsize); if (x) *x = m_PDFlib->PDF_stringwidth(m_p, text, fontnr, fontsize);
if (y) *y = 5*fontsize/4; if (y) *y = fontsize;
if (d) *d = fontsize/4; if (d) *d = fontsize/5;
if (e) *e = fontsize/10;
} }
} }
} }
PDF_CATCH_DL(m_PDFlib, m_p) PDF_CATCH_DL(m_PDFlib, m_p)
{ {
@ -905,6 +906,9 @@ void TwxPDFDC::SetFont( const wxFont& font )
// molto molto minore di quello effettivo // molto molto minore di quello effettivo
if (m_fontsize < 36) if (m_fontsize < 36)
m_fontsize *= 9; m_fontsize *= 9;
m_descent = m_fontsize/5;
m_ascent = m_fontsize-m_descent;
m_leading = m_descent/2;
m_font = font; m_font = font;
m_fontnr = m_PDFlib->PDF_load_font(m_p, strFamily, 0, "host", ""); m_fontnr = m_PDFlib->PDF_load_font(m_p, strFamily, 0, "host", "");
@ -1057,23 +1061,18 @@ void TwxPDFDC::SetBrush( const wxBrush& brush )
} }
} }
void TwxPDFDC::SetFontColor( const wxColor& color ) const void TwxPDFDC::SetFontColor( const wxColour& color ) const
{ {
wxCHECK_RET( m_ok, wxT("invalid PDF dc") ); wxCHECK_RET( m_ok, wxT("invalid PDF dc") );
if (!color.Ok()) if (!color.Ok())
return; return;
unsigned char red = color.Red();
unsigned char blue = color.Blue();
unsigned char green = color.Green();
double redPDF = (double)(red) / 255.0;
double bluePDF = (double)(blue) / 255.0;
double greenPDF = (double)(green) / 255.0;
PDF_TRY_DL(m_PDFlib, m_p) PDF_TRY_DL(m_PDFlib, m_p)
{ {
const double redPDF = color.Red() / 255.0;
const double bluePDF = color.Blue() / 255.0;
const double greenPDF = color.Green() / 255.0;
m_PDFlib->PDF_setcolor(m_p, "fill", "rgb", redPDF, greenPDF, bluePDF, 0); m_PDFlib->PDF_setcolor(m_p, "fill", "rgb", redPDF, greenPDF, bluePDF, 0);
} }
PDF_CATCH_DL(m_PDFlib, m_p) PDF_CATCH_DL(m_PDFlib, m_p)

View File

@ -119,7 +119,9 @@ protected:
bool m_clipping; bool m_clipping;
bool m_topDown; bool m_topDown;
bool m_pageopen; bool m_pageopen;
double m_fontsize;
double m_fontsize; // m_ascent + m_descent
double m_ascent, m_descent, m_leading;
wxString m_filenames[PDF_IMG_CACHE_SIZE]; wxString m_filenames[PDF_IMG_CACHE_SIZE];
int m_handles[PDF_IMG_CACHE_SIZE]; int m_handles[PDF_IMG_CACHE_SIZE];

View File

@ -337,9 +337,9 @@ wxDC& TDC::GetDC(bool bPaint)
_dc->SetFont(f); _dc->SetFont(f);
_real_font = _font; _real_font = _font;
int height, desc, lead; int height, desc, lead;
_dc->GetTextExtent("Mg", NULL, &height, &desc, &lead); _dc->GetTextExtent("Kpfx", NULL, &height, &desc, &lead);
_deltaf = height-desc+1; _deltaf = height-desc; // Baseline offset from top
} }
if (_dirty < 0 || ClipChanged()) if (_dirty < 0 || ClipChanged())