Patch level : 2.2

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Implementate un sacco di funzioni che erano SORRY_BOX,
supporto per wxWidgets 2.6.1,
riveduta gestione stampe


git-svn-id: svn://10.65.10.50/trunk@13367 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-09-23 15:55:44 +00:00
parent fcddf48484
commit 8b6695fd19
8 changed files with 544 additions and 445 deletions

View File

@ -191,6 +191,7 @@ void OsWin32_SetCaptionStyle(unsigned int handle, bool set)
s |= WS_CAPTION;
else
s &= ~WS_CAPTION;
s |= WS_CLIPSIBLINGS; // Forzatura necessaria da wx261
::SetWindowLong(hwnd, GWL_STYLE, s);
}
@ -198,12 +199,6 @@ void OsWin32_SetCaptionStyle(unsigned int handle, bool set)
// Drawing bitmaps
///////////////////////////////////////////////////////////
static bool IsWin95()
{
int major, minor;
return ::wxGetOsVersion(&major, &minor) == wxWIN95;
}
HBITMAP OsWin32_CreateBitmap(const wxImage& img, wxDC& dc)
{
static wxPalette pal;

View File

@ -27,7 +27,8 @@ extern "C" {
#include <errno.h>
#include <unistd.h>
#include "oslinux.h"
#include <wx/generic/dcpsg.h>
#include <wx/dcps.h>
#include <wx/hash.h>
#endif
#define CAST_WIN(win,w) XVT_ASSERT(win != NULL_WIN); wxWindow& w = *(wxWindow*)win
@ -212,7 +213,7 @@ public:
void SetPos(int x, int y);
void SetSize(int x, int y) { _size.x = x; _size.y = y; }
void Show(WINDOW w, bool on = true);
void Hide() { Show(false); }
void Hide() { Show(NULL_WIN, false); }
bool IsVisible() const { return _visible; }
WINDOW Owner() const { return _owner; }
void Kill();
@ -247,7 +248,7 @@ void TwxCaret::Show(WINDOW w, bool on)
}
else
{
if (w == _owner)
if (w == _owner || w == NULL_WIN)
Kill();
}
}
@ -482,7 +483,11 @@ void TDC::KillDC()
{
if (_dc != NULL)
{
#if wxCHECK_VERSION(2,6,1)
SetClippingBox(NULL);
#else
SetClippingBox(NULL);
#endif
delete _dc;
_dc = NULL;
}
@ -490,13 +495,11 @@ void TDC::KillDC()
void TDC::SetClippingBox(const RCT* pRct)
{
#if wxCHECK_VERSION(2,3,0)
if (_dc != NULL)
_dc->DestroyClippingRegion();
#endif
if (pRct)
{
wxRect rct = NormalizeRCT(pRct);
const wxRect rct = NormalizeRCT(pRct);
GetDC().SetClippingRegion(rct);
_clip = *pRct;
}
@ -549,8 +552,7 @@ void TDCMapper::DestroyDC(WINDOW owner)
}
else
{
TDCMapper::iterator it;
for (it = begin(); it != end(); ++it)
for (TDCMapper::iterator it = begin(); it != end(); ++it)
{
TDC* pTDC = it->second;
if (pTDC)
@ -590,7 +592,7 @@ TDC& TDCMapper::GetTDC(WINDOW owner)
TDC* pTDC = (*this)[owner];
if (pTDC == NULL)
{
if (owner == _print_win)
if (owner == PRINTER_WIN)
pTDC = new TPrintDC((wxWindow*)owner);
else
pTDC = new TDC((wxWindow*)owner);
@ -621,13 +623,6 @@ bool TDCMapper::HasValidDC(WINDOW owner) const
class TwxWindowBase : public wxWindow
{
#ifdef LINUX
public:
wxString m_strTitle;
virtual void SetTitle(const wxString& title) { wxWindow::SetTitle(m_strTitle = title); }
virtual wxString GetTitle() const { return m_strTitle; }
#endif
public:
TwxWindowBase() { }
TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title,
@ -640,13 +635,23 @@ IMPLEMENT_DYNAMIC_CLASS(TwxWindowBase, wxWindow)
TwxWindowBase::TwxWindowBase(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, long style)
: wxWindow(parent, id, pos, size, style)
{
SetTitle(title);
// Evita inutili sfarfallamenti in quanto wxWidgets crea le finestre visibili per default
wxWindowBase::Show(false);
Create(parent, id, pos, size, style, title);
}
class TwxWindow : public TwxWindowBase
{
#ifdef LINUX
private:
wxString m_strTitle;
public:
virtual void SetTitle(const wxString& title) { wxWindow::SetTitle(m_strTitle = title); }
virtual wxString GetTitle() const { return m_strTitle; }
#endif
private:
MENU_ITEM* m_menu;
protected:
@ -700,9 +705,9 @@ protected:
virtual void OnClose(wxCloseEvent& event);
virtual void OnMenu(wxCommandEvent& event);
virtual void OnSize(wxSizeEvent& event);
public:
virtual void OnPaint();
virtual void OnPaint(wxPaintEvent& event);
public:
void SetMenuTree(const MENU_ITEM* tree);
@ -757,9 +762,9 @@ void TwxWindow::OnChar(wxKeyEvent& event)
if (nSkipNextDotKey == -883) // Devo stabilire se attivare la gestione o no
{
const char* campoini = xvt_fsys_get_campo_ini();
char strPoint2Comma[2];
xvt_sys_get_profile_string(campoini, "Main", "Point2Comma", "1", strPoint2Comma, 2);
nSkipNextDotKey = atoi(strPoint2Comma) != 0 ? 0 : -1; // Dis/Abilita conversione punto in virgola
char str[2];
xvt_sys_get_profile_string(campoini, "Main", "Point2Comma", "1", str, sizeof(str));
nSkipNextDotKey = strchr("1XY", *str) != NULL ? 0 : -1; // Dis/Abilita conversione punto in virgola
}
EVENT e; memset(&e, 0, sizeof(EVENT));
@ -800,15 +805,15 @@ void TwxWindow::OnChar(wxKeyEvent& event)
nSkipNextDotKey = 1;
}
break;
case WXK_NUMPAD_ADD: k = '+'; break;
case WXK_DOWN : k = K_DOWN; break;
case WXK_END: k = K_LEND; break;
case WXK_HOME: k = K_LHOME; break;
case WXK_LEFT : k = K_LEFT; break;
case WXK_NEXT : k = K_NEXT; break;
case WXK_PRIOR: k = K_PREV; break;
case WXK_NUMPAD_ADD: k = '+';break;
case WXK_DOWN : k = K_DOWN; break;
case WXK_END : k = K_LEND; break;
case WXK_HOME : k = K_LHOME; break;
case WXK_LEFT : k = K_LEFT; break;
case WXK_NEXT : k = K_NEXT; break;
case WXK_PRIOR: k = K_PREV; break;
case WXK_RIGHT: k = K_RIGHT; break;
case WXK_UP : k = K_UP; break;
case WXK_UP : k = K_UP; break;
case WXK_TAB:
if (event.ShiftDown())
k = K_BTAB;
@ -913,6 +918,10 @@ void TwxWindow::OnMouseDown(wxMouseEvent& event)
e.v.mouse.where.h = event.GetX();
e.v.mouse.where.v = event.GetY();
DoXvtEvent(e);
#if wxCHECK_VERSION(2,6,1)
SetFocus(); // Triste necessita'
#endif
}
void TwxWindow::OnMouseMove(wxMouseEvent& event)
@ -952,7 +961,7 @@ void TwxWindow::OnMouseWheel(wxMouseEvent& event)
}
}
void TwxWindow::OnPaint(wxPaintEvent& event)
void TwxWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
{
EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_UPDATE;
@ -1126,7 +1135,7 @@ void TTaskWin::OnMenu(wxCommandEvent& event)
((TwxWindow*)m_MenuOwner)->_eh((WINDOW)m_MenuOwner, &e);
}
void TTaskWin::OnPaint()
void TTaskWin::OnPaint(wxPaintEvent& WXUNUSED(event))
{
EVENT e; memset(&e, 0, sizeof(EVENT));
e.type = E_UPDATE;
@ -1330,7 +1339,11 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
}
_task_win = new TTaskWin(NULL, ICON_RSRC, title, pos, size, style);
_nice_windows.Put((WINDOW)_task_win, _task_win);
#if wxCHECK_VERSION(2,6,1)
_task_win->SetBackgroundStyle(wxBG_STYLE_CUSTOM); // Lo sfondo viene disegnato nella OnPaint
#endif
_nice_windows.Put((WINDOW)_task_win, _task_win);
wxMenu* Menus[3];
wxString Title[3];
@ -1366,16 +1379,26 @@ void xvt_app_create(int argc, char **argv, unsigned long flags,
#endif
((wxFrame*)_task_win)->SetMenuBar(pMenubar);
_task_win->Show();
if (style & wxMAXIMIZE)
((wxFrame*)_task_win)->Maximize();
_task_win->Show();
wxApp* a = wxTheApp;
a->SetTopWindow(_task_win);
EVENT e; memset(&e, 0, sizeof(e));
e.type = E_CREATE;
long ret = _task_win_handler((WINDOW)_task_win, &e);
if (ret != 0)
wxTheApp->MainLoop();
wxTheApp->ExitMainLoop(); // Non entrare nel main loop di wxWindows
{
// Simula main loop
#if wxCHECK_VERSION(2,6,1)
xvt_app_process_pending_events();
#else
a->MainLoop();
#endif
}
a->ExitMainLoop(); // Non entrare nel main loop di wxWindows
}
void xvt_app_destroy(void)
@ -1398,10 +1421,17 @@ DRAW_CTOOLS* xvt_app_get_default_ctools(DRAW_CTOOLS *ct)
void xvt_app_process_pending_events(void)
{
if (wxTheApp != NULL)
wxApp* a = wxTheApp; // Memorizzo il risultato di wxGetInstance
if (a != NULL)
{
for (int m = 0; m < 4 && wxTheApp->Pending(); m++)
wxTheApp->Dispatch();
#if wxCHECK_VERSION(2,6,1)
while (a->Pending())
a->Dispatch();
a->Yield(true);
#else
for (int m = 0; m < 4 && a->Pending(); m++)
a->Dispatch();
#endif
}
}
@ -1478,8 +1508,16 @@ BOOLEAN xvt_cb_put_data(CB_FORMAT cbfmt, char *name, long size, PICTURE pic)
// Controls functions (NOT used)
///////////////////////////////////////////////////////////
void xvt_ctl_check_radio_button(WINDOW Win, WINDOW* Wins, int NbrWindows)
{ SORRY_BOX(); } // Ignored
class TwxScrollBar : public wxScrollBar
{
protected:
virtual bool AcceptsFocus() const { return false; } // Altrimenti mette il flag wxTAB_TRAVERSAL
public:
TwxScrollBar(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style)
{ Create(parent, id, pos, size, style); }
};
WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data)
{
@ -1491,9 +1529,8 @@ WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data)
{
const wxRect rct = NormalizeRCT(&win_def_p->rct);
long style = win_def_p->wtype == WC_HSCROLL ? wxSB_HORIZONTAL : wxSB_VERTICAL;
wxScrollBar* sb = new wxScrollBar((wxWindow*)parent_win,
win_def_p->v.ctl.ctrl_id,
rct.GetPosition(), rct.GetSize(), style);
TwxScrollBar* sb = new TwxScrollBar((wxWindow*)parent_win, win_def_p->v.ctl.ctrl_id,
rct.GetPosition(), rct.GetSize(), style);
win = (WINDOW)sb;
}
break;
@ -1503,6 +1540,9 @@ WINDOW xvt_ctl_create_def(WIN_DEF *win_def_p, WINDOW parent_win, long app_data)
return win;
}
void xvt_ctl_check_radio_button(WINDOW Win, WINDOW* Wins, int NbrWindows)
{ SORRY_BOX(); } // Ignored
void xvt_ctl_set_checked(WINDOW Win, BOOLEAN Check)
{ SORRY_BOX(); } // Ignored
@ -1767,13 +1807,21 @@ static FL_STATUS xvt_dm_post_file_ask(FILE_SPEC *fsp, const char *msg, int flags
FL_STATUS xvt_dm_post_file_open(FILE_SPEC *fsp, const char *msg)
{
#if wxCHECK_VERSION(2,6,1)
const int flags = wxOPEN | wxFILE_MUST_EXIST;
#else
const int flags = wxOPEN | wxHIDE_READONLY | wxFILE_MUST_EXIST;
#endif
return xvt_dm_post_file_ask(fsp, msg, flags);
}
FL_STATUS xvt_dm_post_file_save(FILE_SPEC *fsp, const char *msg)
{
#if wxCHECK_VERSION(2,6,1)
const int flags = wxSAVE;
#else
const int flags = wxSAVE | wxHIDE_READONLY;
#endif
return xvt_dm_post_file_ask(fsp, msg, flags);
}
@ -1962,7 +2010,6 @@ TXVT_IMAGE::~TXVT_IMAGE()
Destroy();
}
///////////////////////////////////////////////////////////
// Font Handling
///////////////////////////////////////////////////////////
@ -2021,24 +2068,30 @@ bool TFontId::Underline() const
wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
{
int nSize = PointSize();
if (win == _print_win)
if (win == PRINTER_WIN)
{
static wxDC* lastDC = NULL;
static double dPrintScale = 1.0;
if (dc != lastDC)
{
#ifdef WIN32
const char* strDefaultFaceName = "Courier New";
#else
const char* strDefaultFaceName = "Courier";
#endif
const wxSize ppi = dc->GetPPI();
const int nTarget10 = 10 * ppi.x;
const int cpi10 = 10 * 120 / nSize;
const wxString str('M', cpi10);
int nMin = 1, nMax = nSize*12; // Limiti arbitrari
int nMin = 1, nMax = nSize*15; // Limiti arbitrari
int nBest = 0;
while (nMin <= nMax)
{
const int nFontSize = (nMin+nMax)/2;
wxFont courier(-nFontSize, Family(), wxNORMAL, wxNORMAL, FALSE, FaceName());
wxFont courier(-nFontSize, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, strDefaultFaceName);
dc->SetFont(courier);
int tw; dc->GetTextExtent(str, &tw, NULL);
if (tw <= nTarget10)
@ -2054,26 +2107,33 @@ wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
if (nBest == 0)
nBest = nMax;
#ifdef WIN32
// Pezza per cercare di ovviare a dimensioni assurde calcolate dai sistemi NON XP
bool bPrevGood = true;
for (int i = 15; i > 0; i--)
int major, minor;
const int nVer = ::wxGetOsVersion(&major, &minor);
if (nVer != wxWINDOWS_NT)
{
const int nFontSize = nBest-i;
wxFont courier(-nFontSize, Family(), wxNORMAL, wxNORMAL, FALSE, FaceName());
dc->SetFont(courier);
int tw; dc->GetTextExtent(str, &tw, NULL);
if (tw > nTarget10 && bPrevGood)
bool bPrevGood = true;
for (int i = 15; i > 0; i--)
{
nBest = nFontSize-1;
break;
const int nFontSize = nBest-i;
wxFont courier(-nFontSize, Family(), wxNORMAL, wxNORMAL, FALSE, strDefaultFaceName);
dc->SetFont(courier);
int tw; dc->GetTextExtent(str, &tw, NULL);
if (tw > nTarget10 && bPrevGood)
{
nBest = nFontSize-1;
break;
}
bPrevGood = tw <= nTarget10;
}
bPrevGood = tw <= nTarget10;
}
#endif
dPrintScale = double(nBest) / double(nSize);
#ifdef LINUX
if (is_printer_dc(dc)) // test inutile
dPrintScale *= 0.1; // * wxPostScriptDC::GetResolution()) / 72.0);
dPrintScale /= 10.0; // * wxPostScriptDC::GetResolution()) / 72.0);
#endif
lastDC = dc;
}
@ -2120,13 +2180,19 @@ void xvt_dwin_clear(WINDOW win, COLOR col)
dc.Clear();
}
void xvt_dwin_draw_arc(WINDOW Win, RCT* r, int sx, int sy, int ex, int ey)
{ SORRY_BOX(); }
void xvt_dwin_draw_arc(WINDOW win, const RCT* r, int sx, int sy, int ex, int ey)
{
if (r != NULL)
{
CAST_DC(win, dc);
dc.DrawArc(sx, sy, ex, ey, (r->right+r->left)/2, (r->top+r->bottom)/2);
}
}
void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid)
{
wxIcon* ico = ::GetIconResource(rid);
if (ico)
if (ico != NULL)
{
CAST_DC(win, dc);
dc.DrawIcon(*ico, x, y);
@ -2156,7 +2222,8 @@ static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const
wxRect source = ComputeRect(src, h, v, k);
wxImage img = image->Image().GetSubImage(source);
source.x = source.y = 0;
OsWin32_DrawBitmap((HBITMAP)img.ConvertToBitmap().GetHBITMAP(), dc, destin, source);
wxBitmap bmp(img);
OsWin32_DrawBitmap((HBITMAP)bmp.GetHBITMAP(), dc, destin, source);
}
}
}
@ -2174,8 +2241,9 @@ static void DrawImageOnDC(wxDC& dc, TXVT_IMAGE* image, const wxRect& dst, const
dst.GetWidth() < src.GetWidth())
img.Rescale(dst.GetWidth() * 4, dst.GetHeight() * 4);
img.Rescale(dst.GetWidth(), dst.GetHeight());
dc.DrawBitmap(img.ConvertToBitmap(), dst.GetX(), dst.GetY(), !printing);
}
wxBitmap bmp(img);
dc.DrawBitmap(bmp, dst.GetX(), dst.GetY(), !printing);
}
#endif
}
@ -2194,15 +2262,41 @@ void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source)
}
}
void xvt_dwin_draw_oval(WINDOW win, RCT* rctp)
void xvt_dwin_draw_oval(WINDOW win, const RCT* rctp)
{
CAST_DC(win, dc);
const wxRect rct = NormalizeRCT(rctp);
dc.DrawEllipse(rct);
}
void xvt_dwin_draw_pie(WINDOW win, RCT *rctp, int start_x, int start_y, int stop_x, int stop_y) { SORRY_BOX(); }
void xvt_dwin_draw_polygon(WINDOW win, PNT *lpnts, int npnts) { SORRY_BOX(); }
void xvt_dwin_draw_pie(WINDOW win, const RCT *rctp, int start_x, int start_y, int stop_x, int stop_y)
{ SORRY_BOX(); }
void xvt_dwin_draw_polygon(WINDOW win, const PNT *lpnts, int npnts)
{
if (lpnts != NULL && npnts > 1)
{
CAST_DC(win, dc);
wxPoint* pt = new wxPoint[npnts];
for (int i = 0; i < npnts; i++)
{
pt[i].x = lpnts[i].h;
pt[i].y = lpnts[i].v;
}
dc.DrawPolygon(npnts, pt);
delete pt;
}
}
void xvt_dwin_draw_polyline(WINDOW win, const PNT *lpnts, int npnts)
{
if (lpnts != NULL && npnts > 1)
{
xvt_dwin_draw_set_pos(win, lpnts[0]);
for (int i = 1; i < npnts; i++)
xvt_dwin_draw_line(win, lpnts[i]);
}
}
void xvt_dwin_draw_rect(WINDOW win, RCT *rctp)
{
@ -2227,7 +2321,7 @@ void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp)
if (can_draw_dots)
{
CAST_DC(win, dc);
OsWin32_DrawDottedRect(dc.GetHDC(), rctp->left, rctp->top, rctp->right, rctp->bottom);
OsWin32_DrawDottedRect((unsigned int)dc.GetHDC(), rctp->left, rctp->top, rctp->right, rctp->bottom);
return;
}
#endif
@ -2284,8 +2378,8 @@ void xvt_dwin_draw_text(WINDOW win, int x, int y, const char *s, int len)
CAST_COLOR(tdc._dct.back_color, brush_color);
wxBrush* brush = wxTheBrushList->FindOrCreateBrush(brush_color, wxSOLID);
wxBrush & old_brush = dc.GetBrush();
wxPen & old_pen = dc.GetPen();
const wxBrush & old_brush = dc.GetBrush();
const wxPen & old_pen = dc.GetPen();
const wxRect rct = NormalizeRCT(&back);
dc.SetBrush(*brush);
@ -2383,7 +2477,7 @@ BOOLEAN xvt_dwin_is_update_needed(WINDOW win, RCT* rctp)
{
if (win != NULL_WIN && rctp != NULL)
{
if (win == _print_win)
if (win == PRINTER_WIN)
return TRUE;
CAST_WIN(win, w);
const wxRect rect1 = NormalizeRCT(rctp);
@ -2428,7 +2522,7 @@ void xvt_dwin_set_cbrush(WINDOW win, CBRUSH* cbrush)
dc.SetDirty();
}
void xvt_dwin_set_clip(WINDOW win, RCT* rctp)
void xvt_dwin_set_clip(WINDOW win, const RCT* rctp)
{
CAST_TDC(win, dc);
dc.SetClippingBox(rctp);
@ -2474,16 +2568,33 @@ void xvt_dwin_set_fore_color(WINDOW win, COLOR color)
dc.SetDirty();
}
void xvt_dwin_set_std_cbrush(WINDOW win, long flag)
{
CBRUSH brush;
brush.pat = PAT_SOLID;
switch (flag)
{
case TL_BRUSH_BLACK: brush.color = COLOR_BLACK; break;
case TL_BRUSH_WHITE: brush.color = COLOR_WHITE; break;
default: SORRY_BOX(); break;
}
xvt_dwin_set_cbrush(win, &brush);
}
void xvt_dwin_set_std_cpen(WINDOW win, long flag)
{
CPEN pen; memset(&pen, 0, sizeof(CPEN));
pen.style = P_SOLID;
pen.pat = PAT_SOLID;
switch(flag)
{
case TL_PEN_BLACK: pen.color = COLOR_BLACK; pen.pat = PAT_SOLID; break;
case TL_PEN_BLACK : pen.color = COLOR_BLACK; break;
case TL_PEN_DKGRAY: pen.color = COLOR_DKGRAY; break;
case TL_PEN_GRAY : pen.color = COLOR_GRAY; break;
case TL_PEN_LTGRAY: pen.color = COLOR_LTGRAY; break;
case TL_PEN_WHITE : pen.color = COLOR_WHITE; break;
case TL_PEN_HOLLOW: pen.pat = PAT_HOLLOW; break;
case TL_PEN_WHITE: pen.color = COLOR_WHITE; pen.pat = PAT_SOLID; break;
case TL_PEN_RUBBER: pen.pat = PAT_RUBBER; break;
default: SORRY_BOX(); break;
}
@ -2652,7 +2763,7 @@ void xvt_font_map_using_default(XVT_FNTID font_id)
xvt_font_map(font_id, TASK_WIN);
}
void xvt_font_set_family(XVT_FNTID font_id, char* family)
void xvt_font_set_family(XVT_FNTID font_id, const char* family)
{
TFontId& font = *(TFontId*)font_id;
font.SetFaceName(family);
@ -2935,7 +3046,6 @@ XVT_IMAGE xvt_image_capture(WINDOW win, const RCT* src)
mdc.Blit(wxPoint(0,0), r.GetSize(), &wdc, r.GetPosition());
TXVT_IMAGE* i = new TXVT_IMAGE;
i->Image().Create(r.GetWidth(), r.GetHeight());
i->Image() = bmp.ConvertToImage();
return (XVT_IMAGE)i;
@ -3026,13 +3136,10 @@ XVT_IMAGE xvt_image_read(const char* filenamep)
#ifdef WIN32
const wxString name = filenamep;
#else
wxString name = "";
wxString name;
if (isalpha(filenamep[0u]))
{
DIRECTORY dirp;
xvt_fsys_get_dir(&dirp);
name = dirp.path;
name = *_startup_dir;
name += "/";
}
name += filenamep;
@ -3101,7 +3208,7 @@ void xvt_image_transfer(XVT_IMAGE dstimage, XVT_IMAGE srcimage, RCT *dstrctp, RC
wxBitmap bmp(dst);
dc.SelectObject(bmp);
DrawImageOnDC(dc, (TXVT_IMAGE*)srcimage, rctDst, rctSrc);
dst = bmp;
dst = bmp.ConvertToImage();
dc.SelectObject(wxNullBitmap);
}
@ -3664,7 +3771,11 @@ SLIST xvt_scr_list_wins()
SLIST list = xvt_slist_create();
_nice_windows.BeginFind();
#if wxCHECK_VERSION(2,6,1)
for (wxHashTable_Node* node = _nice_windows.Next(); node; node = _nice_windows.Next())
#else
for (wxNode* node = _nice_windows.Next(); node; node = _nice_windows.Next())
#endif
{
wxObject* pWin = node->GetData();
AddWinToList(list, (WINDOW)pWin);
@ -4037,7 +4148,7 @@ unsigned int xvt_sys_load_icon(const char* file)
else
{
#ifdef WIN32
WXHICON hicon = OsWin32_LoadIcon(file);
WXHICON hicon = (WXHICON)OsWin32_LoadIcon(file);
if (hicon)
{
icon = new wxIcon;
@ -4235,7 +4346,7 @@ void xvt_timer_destroy(long id)
void xvt_vobj_destroy(WINDOW win)
{
if (win != _print_win)
if (win != PRINTER_WIN)
{
if (_TheCaret.Owner() == win)
_TheCaret.Kill();
@ -4243,8 +4354,8 @@ void xvt_vobj_destroy(WINDOW win)
if (_nice_windows.Get(win) != NULL)
{
CAST_TWIN(win, w);
GetTDCMapper().DestroyTDC(win);
w.Close(true);
GetTDCMapper().DestroyTDC(win);
}
#ifdef DBG
else
@ -4261,50 +4372,52 @@ long xvt_vobj_get_attr(WINDOW win, long data)
case ATTR_APP_CTL_COLORS:
{
XVT_COLOR_COMPONENT* xcc = (XVT_COLOR_COMPONENT*)xvt_mem_zalloc(sizeof(XVT_COLOR_COMPONENT)*6);
xcc[0].type = XVT_COLOR_FOREGROUND;
xcc[0].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNTEXT));
xcc[0].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
xcc[1].type = XVT_COLOR_BACKGROUND;
xcc[1].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_BTNFACE));
xcc[1].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
xcc[2].type = XVT_COLOR_CAPTIONLT;
xcc[2].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_ACTIVECAPTION));
xcc[2].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
xcc[3].type = XVT_COLOR_CAPTIONDK;
xcc[3].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_INACTIVECAPTION));
xcc[3].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION));
xcc[4].type = XVT_COLOR_CAPTIONTEXT;
xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_CAPTIONTEXT));
xcc[4].color = MAKE_XVT_COLOR(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
xcc[5].type = XVT_COLOR_NULL;
xcc[5].color = 0;
ret = (long)xcc;
ret = (long)xcc;
}
break;
case ATTR_FRAME_WIDTH:
#ifdef LINUX
ret = 8; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_X);
ret = wxSystemSettings::GetMetric(wxSYS_FRAMESIZE_X);
#endif
break;
case ATTR_FRAME_HEIGHT:
#ifdef LINUX
ret = 8; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_FRAMESIZE_Y);
ret = wxSystemSettings::GetMetric(wxSYS_FRAMESIZE_Y);
#endif
break;
case ATTR_MENU_HEIGHT:
ret = wxSystemSettings::GetSystemMetric(wxSYS_MENU_Y);
ret = wxSystemSettings::GetMetric(wxSYS_MENU_Y);
break;
case ATTR_TITLE_HEIGHT:
#ifdef LINUX
ret = 32; //verificare not impl
#else
ret = wxSystemSettings::GetSystemMetric(wxSYS_CAPTION_Y);
ret = wxSystemSettings::GetMetric(wxSYS_CAPTION_Y);
#endif
break;
case ATTR_CTL_VERT_SBAR_WIDTH:
ret = wxSystemSettings::GetSystemMetric(wxSYS_VSCROLL_X);
ret = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
break;
case ATTR_CTL_HORZ_SBAR_HEIGHT:
ret = wxSystemSettings::GetSystemMetric(wxSYS_HSCROLL_Y);
ret = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
break;
case ATTR_DISPLAY_TYPE:
switch (::wxDisplayDepth())
@ -4326,17 +4439,17 @@ long xvt_vobj_get_attr(WINDOW win, long data)
{
#ifdef WIN32
CAST_WIN(win, w);
ret = w.GetHandle();
ret = (long)w.GetHandle();
#else
ret = win;
#endif
}
break;
case ATTR_SCREEN_HEIGHT:
ret = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_Y);
ret = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
break;
case ATTR_SCREEN_WIDTH:
ret = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_X);
ret = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
break;
case ATTR_SCREEN_WINDOW:
ret = NULL_WIN; // Non bellissimo ma per ora...
@ -4347,6 +4460,9 @@ long xvt_vobj_get_attr(WINDOW win, long data)
case ATTR_TASK_WINDOW:
ret = long(_task_win);
break;
case ATTR_PRINTER_WINDOW:
ret = 883L; // Scelta arbitraria ma accettabile
break;
case ATTR_WIN_INSTANCE:
ret = 0;
break;
@ -4367,7 +4483,7 @@ RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp)
int l, h;
if (win != NULL_WIN)
{
if (win == _print_win)
if (win == PRINTER_WIN)
{
l = h = 6000; // circa A4 height
}
@ -4379,8 +4495,8 @@ RCT* xvt_vobj_get_client_rect(WINDOW win, RCT *rctp)
}
else // NULL_WIN -> SREEN_WINDOW
{
l = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_X);
h = wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_Y);
l = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
h = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
}
rctp->left = rctp->top = 0;
@ -4426,10 +4542,22 @@ char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title)
WIN_TYPE xvt_vobj_get_type(WINDOW win)
{
if (win == TASK_WIN)
return W_TASK;
if (win == SCREEN_WIN)
return W_SCREEN;
if (win == PRINTER_WIN)
return W_PRINT;
CAST_TWIN(win, w);
return w._type;
}
BOOLEAN xvt_vobj_is_focusable(WINDOW win)
{
return win != NULL_WIN && win != PRINTER_WIN;
}
void xvt_vobj_maximize(WINDOW win)
{
wxFrame* pMain = (wxFrame*)_task_win;
@ -4453,7 +4581,7 @@ void xvt_vobj_minimize(WINDOW win)
SORRY_BOX();
}
void xvt_vobj_move(WINDOW win, RCT *rctp)
void xvt_vobj_move(WINDOW win, const RCT* rctp)
{
CAST_WIN(win, w);
wxRect rct = NormalizeRCT(rctp);
@ -4498,7 +4626,7 @@ void xvt_vobj_set_palet(WINDOW win, XVT_PALETTE palet)
// Do not implement!
}
void xvt_vobj_set_title(WINDOW win, char *title)
void xvt_vobj_set_title(WINDOW win, const char* title)
{
CAST_WIN(win, w);
w.SetTitle(title);
@ -4531,7 +4659,7 @@ void xvt_vobj_translate_points(WINDOW from_win, WINDOW to_win, PNT *pntp, int np
// Real windows
///////////////////////////////////////////////////////////
WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WINDOW parent, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data)
WINDOW xvt_win_create(WIN_TYPE wtype, const RCT* rct_p, const char* title, int menu_rid, WINDOW parent, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data)
{
XVT_ASSERT(rct_p != NULL);
@ -4539,9 +4667,7 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
const wxPoint pos(rct_p->left, rct_p->top);
const wxSize size(rct_p->right-rct_p->left, rct_p->bottom-rct_p->top);
long style = wxNO_3D | wxWANTS_CHARS |
wxCLIP_CHILDREN | wxCLIP_SIBLINGS | // Clippa per bene
wxPOPUP_WINDOW; // Inizialmente invisibile!
long style = wxCLIP_CHILDREN | wxCLIP_SIBLINGS;
if (win_flags & WSF_VSCROLL)
style |= wxVSCROLL;
@ -4552,16 +4678,13 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
switch (wtype)
{
case W_DOC:
#ifdef WIN32
style |= wxBORDER;
#else
style |= wxRAISED_BORDER;
#endif
if (!caption.IsEmpty())
style |= (wxCAPTION | wxSYSTEM_MENU);
style |= wxSYSTEM_MENU;
break;
case W_PLAIN:
// style |= wxBORDER; // Non attivare MAI il bordo!
if (win_flags & WSF_TRANSPARENT)
style |= wxTRANSPARENT_WINDOW;
break;
default:
SORRY_BOX(); break;
@ -4570,14 +4693,12 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
w->_type = wtype;
w->_app_data = app_data;
if (win_flags & WSF_INVISIBLE)
w->Hide();
else
w->Show();
#if wxCHECK_VERSION(2,6,1)
w->SetBackgroundStyle(wxBG_STYLE_CUSTOM); // Lo sfondo viene disegnato nella OnPaint
#endif
#ifdef WIN32
OsWin32_SetCaptionStyle(w->GetHWND(), wtype == W_DOC);
OsWin32_SetCaptionStyle((unsigned int)w->GetHWND(), wtype == W_DOC);
#else
OsLinux_SetCaptionStyle((wxWindow*)w, style);
#endif
@ -4597,12 +4718,17 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
if (style & wxVSCROLL)
w->SetScrollbar(wxVERTICAL, 0, 1, 100);
if (win_flags & WSF_DISABLED)
xvt_vobj_move((WINDOW)w, rct_p);
if (win_flags & WSF_DISABLED)
w->Disable();
else
w->Enable();
xvt_vobj_move((WINDOW)w, rct_p);
if (win_flags & WSF_INVISIBLE)
w->Hide();
else
w->Show();
// Accetta messaggi solo da ora!
w->_eh = eh;
@ -4611,7 +4737,8 @@ WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WIN
e.type = E_CREATE;
eh((WINDOW)w, &e);
xvt_app_process_pending_events();
// Rende visibili i giusti flag di visibilita e disabilitazione
xvt_app_process_pending_events();
return (WINDOW)w;
}

View File

@ -4,8 +4,14 @@ extern int xvt_main(int argc, char** argv);
class TMainApp : public wxApp
{
protected:
virtual bool OnInit();
virtual int OnExit();
#if wxCHECK_VERSION(2,6,1)
bool m_bInited;
virtual void OnIdle(wxIdleEvent& event);
DECLARE_EVENT_TABLE()
#endif
DECLARE_DYNAMIC_CLASS(TMainApp);
};
@ -16,13 +22,35 @@ DECLARE_APP(TMainApp)
IMPLEMENT_APP(TMainApp)
bool TMainApp::OnInit()
#if wxCHECK_VERSION(2,6,1)
BEGIN_EVENT_TABLE(TMainApp, wxApp)
EVT_IDLE(TMainApp::OnIdle)
END_EVENT_TABLE()
void TMainApp::OnIdle(wxIdleEvent& event)
{
xvt_main(argc, argv);
return false; // Prevents entering the Main Loop
if (!m_bInited)
{
m_bInited = true;
xvt_main(argc, argv);
}
}
int TMainApp::OnExit()
#endif
bool TMainApp::OnInit()
{
return wxApp::OnExit();
#ifdef __WXDEBUG__
// wxLog::SetTraceMask(wxTraceMessages);
#endif
#if wxCHECK_VERSION(2,6,1)
m_bInited = false;
return true;
#else
xvt_main(argc, argv);
return false;
#endif
}

View File

@ -1,8 +1,6 @@
#ifndef __XVINTERN_H
#define __XVINTERN_H
const WINDOW _print_win = 883L;
class TFontId
{
wxString m_strFace;

View File

@ -88,12 +88,13 @@ XVTDLL BOOLEAN xvt_dongle_sl_read_block(unsigned short reg, unsigned short size,
XVTDLL BOOLEAN xvt_dongle_sl_write_block(unsigned short reg, unsigned short size, const unsigned short* data);
XVTDLL void xvt_dwin_clear(WINDOW win, COLOR col);
XVTDLL void xvt_dwin_draw_arc(WINDOW Win, RCT* r, int sx, int sy, int ex, int ey);
XVTDLL void xvt_dwin_draw_arc(WINDOW win, const RCT* r, int sx, int sy, int ex, int ey);
XVTDLL void xvt_dwin_draw_icon(WINDOW win, int x, int y, int rid);
XVTDLL void xvt_dwin_draw_image(WINDOW win, XVT_IMAGE image, RCT* dest, RCT* source);
XVTDLL void xvt_dwin_draw_oval(WINDOW Win, RCT* r);
XVTDLL void xvt_dwin_draw_pie(WINDOW win, RCT *rctp, int start_x, int start_y, int stop_x, int stop_y);
XVTDLL void xvt_dwin_draw_polygon(WINDOW win, PNT *lpnts, int npnts);
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_polygon(WINDOW win, const PNT *lpnts, int npnts);
XVTDLL void xvt_dwin_draw_polyline(WINDOW win, const PNT *lpnts, int npnts);
XVTDLL void xvt_dwin_draw_rect(WINDOW win, RCT *rctp);
XVTDLL void xvt_dwin_draw_roundrect(WINDOW win, const RCT *rctp, int oval_width, int oval_height);
XVTDLL void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp); // Added by Guy
@ -110,15 +111,16 @@ XVTDLL BOOLEAN xvt_dwin_is_update_needed(WINDOW Win, RCT* rctp);
XVTDLL void xvt_dwin_scroll_rect(WINDOW win, RCT *rctp, int dh, int dv);
XVTDLL void xvt_dwin_set_back_color(WINDOW win, COLOR color);
XVTDLL void xvt_dwin_set_cbrush(WINDOW win, CBRUSH* cbrush);
XVTDLL void xvt_dwin_set_clip(WINDOW win, RCT* rct);
XVTDLL void xvt_dwin_set_clip(WINDOW win, const RCT* rct);
XVTDLL void xvt_dwin_set_cpen(WINDOW win, CPEN* cpen);
XVTDLL void xvt_dwin_set_draw_ctools(WINDOW win, DRAW_CTOOLS* xct);
XVTDLL void xvt_dwin_set_draw_mode(WINDOW win, DRAW_MODE mode);
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_std_cbrush(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);
@ -139,7 +141,7 @@ XVTDLL WINDOW xvt_font_get_win(XVT_FNTID font_id);
XVTDLL BOOLEAN xvt_font_is_mapped(XVT_FNTID font_id);
XVTDLL void xvt_font_map(XVT_FNTID font_id, WINDOW font_win );
XVTDLL void xvt_font_map_using_default(XVT_FNTID font_id);
XVTDLL void xvt_font_set_family(XVT_FNTID font_id, char* family);
XVTDLL void xvt_font_set_family(XVT_FNTID font_id, const char* family);
XVTDLL void xvt_font_set_size(XVT_FNTID font_id, long size);
XVTDLL void xvt_font_set_style(XVT_FNTID font_id, XVT_FONT_STYLE_MASK mask);
XVTDLL long xvt_font_serialize(XVT_FNTID font_id, char *buf, long max_buf);
@ -222,7 +224,7 @@ XVTDLL BOOLEAN xvt_print_close_page(PRINT_RCD *precp);
XVTDLL PRINT_RCD* xvt_print_create(int *sizep);
XVTDLL PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name); // Added by Aga
XVTDLL int xvt_print_get_name(PRINT_RCD *precp, char* name, int sz_s); // Added by Aga
XVTDLL WINDOW xvt_print_create_win(PRINT_RCD *precp, char *title);
XVTDLL WINDOW xvt_print_create_win(PRINT_RCD *precp, const char* title);
XVTDLL void xvt_print_destroy(PRINT_RCD *precp);
XVTDLL RCT* xvt_print_get_next_band(void);
XVTDLL BOOLEAN xvt_print_is_valid(PRINT_RCD *precp);
@ -314,16 +316,16 @@ XVTDLL char* xvt_vobj_get_title(WINDOW win, char *title, int sz_title);
XVTDLL WIN_TYPE xvt_vobj_get_type(WINDOW win);
XVTDLL void xvt_vobj_maximize(WINDOW win); // Added by XVAGA
XVTDLL void xvt_vobj_minimize(WINDOW win); // Added by XVAGA
XVTDLL void xvt_vobj_move(WINDOW win, RCT *rctp);
XVTDLL void xvt_vobj_move(WINDOW win, const RCT* rctp);
XVTDLL void xvt_vobj_raise(WINDOW win);
XVTDLL void xvt_vobj_set_attr(WINDOW win, long data, long value);
XVTDLL void xvt_vobj_set_data(WINDOW win, long AppData);
XVTDLL void xvt_vobj_set_enabled(WINDOW win, BOOLEAN enabled);
XVTDLL void xvt_vobj_set_palet(WINDOW win, XVT_PALETTE palet);
XVTDLL void xvt_vobj_set_title(WINDOW win, char *title);
XVTDLL void xvt_vobj_set_title(WINDOW win, const char* title);
XVTDLL void xvt_vobj_set_visible(WINDOW win, BOOLEAN show);
XVTDLL void xvt_vobj_translate_points(WINDOW from_win, WINDOW to_win, PNT *pntp, int npnts);
XVTDLL WINDOW xvt_win_create(WIN_TYPE wtype, RCT *rct_p, char *title, int menu_rid, WINDOW parent_win, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data);
XVTDLL WINDOW xvt_win_create(WIN_TYPE wtype, const RCT* rct_p, const char* title, int menu_rid, WINDOW parent_win, long win_flags, EVENT_MASK mask, EVENT_HANDLER eh, long app_data);
XVTDLL long xvt_win_dispatch_event(WINDOW win, EVENT* event_p);
XVTDLL void xvt_win_post_event(WINDOW win, EVENT* event_p); // Added by XVAGA
XVTDLL void xvt_win_release_pointer(void);

View File

@ -5,7 +5,7 @@
* Agreement with XVT Software.
*
* $RCSfile: xvt_defs.h,v $
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* Purpose: Global XVT macro definitions.
*
@ -259,9 +259,10 @@
#define WSF_ICONIZED 0x00000100L /* is initially iconized */
#define WSF_SIZEONLY 0x00000200L /* lacks border rectangles (Mac only) */
#define WSF_NO_MENUBAR 0x00000800L /* has no menu bar of its own */
#define WSF_MAXIMIZED 0x00001000L /* initially maximized */
#define WSF_MAXIMIZED 0x00001000L /* initially maximized */
#define WSF_PLACE_EXACT 0x00002000L /* do not auto-place */
#define WSF_DEFER_MODAL 0x00008000L /* defer modal state for W_MODAL windows */
#define WSF_TRANSPARENT 0x00010000L /* trasparent */
#define DLG_FLAG_DISABLED 0x00000001L
#define DLG_FLAG_INVISIBLE 0x00000002L
@ -273,6 +274,9 @@
#define TL_PEN_HOLLOW 2L
#define TL_PEN_RUBBER 3L
#define TL_PEN_WHITE 4L
#define TL_PEN_DKGRAY 5L
#define TL_PEN_GRAY 6L
#define TL_PEN_LTGRAY 7L
#define TL_BRUSH_BLACK 0L
#define TL_BRUSH_WHITE 1L
@ -384,8 +388,10 @@
#define NULL_TXEDIT NULL_WIN
#define BAD_TXEDIT NULL_TXEDIT
#define TASK_WIN ((WINDOW)xvt_vobj_get_attr(NULL_WIN, ATTR_TASK_WINDOW))
#define SCREEN_WIN ((WINDOW)xvt_vobj_get_attr(NULL_WIN, ATTR_SCREEN_WINDOW))
#define TASK_WIN ((WINDOW)xvt_vobj_get_attr(NULL_WIN, ATTR_TASK_WINDOW))
#define SCREEN_WIN ((WINDOW)xvt_vobj_get_attr(NULL_WIN, ATTR_SCREEN_WINDOW))
//#define PRINTER_WIN ((WINDOW)xvt_vobj_get_attr(NULL_WIN, ATTR_PRINTER_WINDOW)) // Guy optimization
#define PRINTER_WIN 883L
#define PTR_LONG(p) ((long)(char *)(p))
@ -425,6 +431,7 @@
/* Predefined windows */
#define ATTR_SCREEN_WINDOW (ATTR_BASE + 300)
#define ATTR_TASK_WINDOW (ATTR_BASE + 301)
#define ATTR_PRINTER_WINDOW (ATTR_BASE + 302)
/* System metric attributes */
#define ATTR_SCREEN_HEIGHT (ATTR_BASE + 400)

View File

@ -219,7 +219,7 @@ WC_EDIT, /* edit control */
WC_TEXT, /* static text control */
WC_LBOX, /* list box control */
WC_LISTBUTTON, /* button with list */
WC_CHECKBUTTON, /* check button control */
WC_LISTEDIT, /* edit with field list */
WC_GROUPBOX, /* group box */
WC_TEXTEDIT, /* text edit object */

View File

@ -3,10 +3,14 @@
#include "wx/printdlg.h"
#include "xvt.h"
#ifdef WIN32
#include "wx/dcps.h"
#include "wx/msw/printdlg.h"
#include "oswin32.h"
#else
#include "wx/setup.h"
#include "wx/dcps.h"
#include "oslinux.h"
#include "incstr.h"
#endif
@ -17,29 +21,21 @@
struct TPRINT_RCD : public PRINT_RCD
{
#ifdef WIN32
unsigned char m_data[16*1024];
unsigned int m_size; // Dimensione della struct DEVMODE
#ifdef WIN32
void SetData(void * data, unsigned int nSize);
#else
unsigned int GetSize() {return m_size;}
void SetBoolElement(bool v, unsigned int * nSize);
void SetUnsignedElement(unsigned char v, unsigned int * nSize);
void SetIntElement(int v, unsigned int * nSize);
void SetLongElement(long v, unsigned int * nSize);
void SetDoubleElement(double v, unsigned int * nSize);
void SetStringElement(const char * p, unsigned int * nSize);
void SetData(wxPrintData & data);
bool GetBoolElement(unsigned int * nPos) const ;
unsigned char GetUnsignedElement(unsigned int * nPos) const ;
int GetIntElement(unsigned int * nPos) const ;
long GetLongElement(unsigned int * nPos) const ;
double GetDoubleElement(unsigned int * nPos) const ;
const char * GetStringElement(unsigned int * nPos) const ;
void GetData(wxPrintData & data) const ;
wxPrintNativeDataBase * m_data;
unsigned int m_size; // Dimensione di wxPostScriptPrintNativeData
void GetData(wxPrintNativeDataBase * data) const;
void SetData(void * data);
#endif
unsigned int GetSize() const { return m_size; }
TPRINT_RCD();
~TPRINT_RCD();
};
@ -47,8 +43,7 @@ struct TPRINT_RCD : public PRINT_RCD
#pragma pack()
#ifdef WIN32
#ifdef WIN32
void TPRINT_RCD::SetData(void* data, unsigned int nSize)
{
if (nSize <= sizeof(m_data))
@ -60,176 +55,6 @@ void TPRINT_RCD::SetData(void* data, unsigned int nSize)
xvt_dm_post_error("Printer info exceeds 16K");
}
#else
void TPRINT_RCD::SetBoolElement(bool v, unsigned int * nSize)
{
if (*nSize < sizeof(m_data))
m_data[(*nSize)++] = (unsigned char) v;
else
xvt_dm_post_error("Printer info exceeds 16K");
}
void TPRINT_RCD::SetUnsignedElement(unsigned char v, unsigned int * nSize)
{
if (*nSize < sizeof(m_data))
m_data[(*nSize)++] = v;
else
xvt_dm_post_error("Printer info exceeds 16K");
}
void TPRINT_RCD::SetIntElement(int v, unsigned int * nSize)
{
if (*nSize + sizeof(int) <= sizeof(m_data))
{
memcpy(&m_data[*nSize], (void *) &v, sizeof(int));
*nSize += sizeof(int);
}
else
xvt_dm_post_error("Printer info exceeds 16K");
}
void TPRINT_RCD::SetLongElement(long v, unsigned int * nSize)
{
if (*nSize + sizeof(long) <= sizeof(m_data))
{
memcpy(&m_data[*nSize], (void *) &v, sizeof(long));
*nSize += sizeof(long);
}
else
xvt_dm_post_error("Printer info exceeds 16K");
}
void TPRINT_RCD::SetDoubleElement(double v, unsigned int * nSize)
{
if (*nSize + sizeof(double) <= sizeof(m_data))
{
memcpy(&m_data[*nSize], (void *) &v, sizeof(double));
*nSize += sizeof(double);
}
else
xvt_dm_post_error("Printer info exceeds 16K");
}
void TPRINT_RCD::SetStringElement(const char * p, unsigned int *nSize)
{
if (*nSize + strlen(p) + 1<= sizeof(m_data))
{
strcpy((char *) &m_data[*nSize], p);
*nSize += strlen(p);
m_data[(*nSize)++] = '\0';
}
else
xvt_dm_post_error("Printer info exceeds 16K");
}
void TPRINT_RCD::SetData(wxPrintData & data)
{
m_size = 0;
SetBoolElement(data.GetCollate(), &m_size);
SetBoolElement(data.GetColour(), &m_size);
SetUnsignedElement(data.GetDuplex(), &m_size);
SetIntElement(data.GetNoCopies(), &m_size);
SetIntElement(data.GetOrientation(), &m_size);
SetUnsignedElement(data.GetPaperId(), &m_size);
SetStringElement((const char *) data.GetPrinterName(), &m_size);
SetUnsignedElement(data.GetQuality(), &m_size);
// PostScript Members
SetStringElement((const char *) data.GetPrinterCommand(), &m_size);
wxString Options = data.GetPrinterOptions();
if (Options.IsEmpty())
Options = "-P" + data.GetPrinterName();
SetStringElement((const char *) Options, &m_size);
SetStringElement((const char *) data.GetPreviewCommand(), &m_size);
SetStringElement((const char *) data.GetFilename(), &m_size);
SetStringElement((const char *) data.GetFontMetricPath(), &m_size);
SetDoubleElement(data.GetPrinterScaleX(), &m_size);
SetDoubleElement(data.GetPrinterScaleY(), &m_size);
SetLongElement(data.GetPrinterTranslateX(), &m_size);
SetLongElement(data.GetPrinterTranslateY(), &m_size);
SetUnsignedElement(wxPRINT_MODE_PRINTER, &m_size);
}
bool TPRINT_RCD::GetBoolElement(unsigned int * nPos) const
{
bool * p = (bool *) &m_data[*nPos];
*nPos += sizeof(bool);
return *p;
}
unsigned char TPRINT_RCD::GetUnsignedElement(unsigned int * nPos) const
{
unsigned char * p = (unsigned char *) &m_data[*nPos];
*nPos += sizeof(unsigned char);
return *p;
}
int TPRINT_RCD::GetIntElement(unsigned int * nPos) const
{
int * p = (int *) &m_data[*nPos];
*nPos += sizeof(int);
return *p;
}
long TPRINT_RCD::GetLongElement(unsigned int * nPos) const
{
long * p = (long *) &m_data[*nPos];
*nPos += sizeof(long);
return *p;
}
double TPRINT_RCD::GetDoubleElement(unsigned int * nPos) const
{
double * p = (double *) &m_data[*nPos];
*nPos += sizeof(double);
return *p;
}
const char * TPRINT_RCD::GetStringElement(unsigned int * nPos) const
{
const char * p = (const char *) &m_data[*nPos];
*nPos += (strlen(p) +1);
return p;
}
void TPRINT_RCD::GetData(wxPrintData & data) const
{
unsigned int nPos = 0;
wxString Str;
data.SetCollate(GetBoolElement(&nPos));
data.SetColour(GetBoolElement(&nPos));
data.SetDuplex((wxDuplexMode) GetUnsignedElement(&nPos));
data.SetNoCopies(GetIntElement(&nPos));
data.SetOrientation(GetIntElement(&nPos));
data.SetPaperId((wxPaperSize) GetUnsignedElement(&nPos));
Str = GetStringElement(&nPos);
data.SetPrinterName(Str);
data.SetQuality(GetUnsignedElement(&nPos));
// PostScript Members
Str = GetStringElement(&nPos);
data.SetPrinterCommand(Str);
Str = GetStringElement(&nPos);
data.SetPrinterOptions(Str);
Str = GetStringElement(&nPos);
data.SetPreviewCommand(Str);
Str = GetStringElement(&nPos);
data.SetFilename(Str);
Str = GetStringElement(&nPos);
data.SetFontMetricPath(Str);
data.SetPrinterScaleX(GetDoubleElement(&nPos));
data.SetPrinterScaleY(GetDoubleElement(&nPos));
data.SetPrinterTranslateX(GetLongElement(&nPos));
data.SetPrinterTranslateY(GetLongElement(&nPos));
data.SetPrintMode((wxPrintMode) GetUnsignedElement(&nPos));
}
#endif
TPRINT_RCD::TPRINT_RCD() : m_size(0)
{
pr = NULL;
@ -241,6 +66,30 @@ TPRINT_RCD::~TPRINT_RCD()
memset(m_data, 0, sizeof(m_data));
m_size = 0;
}
#else
void TPRINT_RCD::GetData(wxPrintNativeDataBase * data) const
{
memcpy(data, m_data, GetSize());
}
void TPRINT_RCD::SetData(void* data)
{
memcpy(m_data, data, GetSize());
}
wxNativePrintFactory __factory;
TPRINT_RCD::TPRINT_RCD()
{
m_data = __factory.CreatePrintNativeData();
m_size = sizeof(*m_data);
}
TPRINT_RCD::~TPRINT_RCD()
{
delete m_data;
}
#endif
///////////////////////////////////////////////////////////
// TwxPrintOut
@ -249,24 +98,25 @@ TPRINT_RCD::~TPRINT_RCD()
class TwxPrintOut : public wxPrintout
{
protected:
TPRINT_RCD* m_prcd;
const TPRINT_RCD* m_prcd;
bool m_bBadDriver;
virtual bool HasPage(int pageNum);
virtual bool OnPrintPage(int pageNum);
void ResetDC();
#if wxCHECK_VERSION(2,6,1)
wxDC* CreateDC(const TPRINT_RCD* prcd);
#endif
public:
void SetBadDriver(bool bd) { m_bBadDriver = bd; }
bool HasBadDriver() const { return m_bBadDriver; }
void InitDC(TPRINT_RCD* prcd);
TwxPrintOut(TPRINT_RCD* prcd = NULL);
void InitDC(const TPRINT_RCD* prcd);
TwxPrintOut(const TPRINT_RCD* prcd = NULL);
virtual ~TwxPrintOut();
};
static TwxPrintOut* m_po = NULL;
bool TwxPrintOut::HasPage(int pageNum)
{ return true; }
@ -280,12 +130,37 @@ void TwxPrintOut::ResetDC()
delete dc;
}
void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
#if wxCHECK_VERSION(2,6,1)
static void RCD2data(const TPRINT_RCD* prcd, wxPrintData& data)
{
ResetDC();
wxDC* dc = NULL;
#ifdef WIN32
wxWindowsPrintNativeData ndb;
ndb.SetDevMode(OsWin32_ConvertToNativePrinterInfo((void*)prcd->m_data, prcd->m_size));
ndb.TransferTo(data);
#else
prcd->GetData(data.GetNativeData());
data.ConvertFromNative();
#endif
}
static void data2RCD(const wxPrintData& data, TPRINT_RCD* prcd)
{
#ifdef WIN32
wxWindowsPrintNativeData* pNative = (wxWindowsPrintNativeData*)data.GetNativeData();
unsigned int nSize = 0;
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pNative->GetDevMode(), nSize);
prcd->SetData(ptr, nSize);
delete ptr;
#else
((wxPrintData&)data).ConvertToNative();
prcd->SetData(data.GetNativeData());
#endif
}
wxDC* TwxPrintOut::CreateDC(const TPRINT_RCD* prcd)
{
m_prcd = prcd;
wxDC* dc = NULL;
if (m_prcd == NULL)
{
@ -293,24 +168,49 @@ void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
#ifdef WIN32
dc = new wxPrinterDC(printer.GetPrintDialogData().GetPrintData());
#else
dc = new wxPostScriptDC(printer.GetPrintDialogData().GetPrintData());
dc = new wxPostScriptDC(printer.GetPrintDialogData().GetPrintData());
#endif
}
else
{
wxPrintData data;
RCD2data(prcd, data);
#ifdef WIN32
dc = new wxPrinterDC(data);
#else
dc = new wxPostScriptDC(data);
#endif
}
return dc;
}
#endif
void TwxPrintOut::InitDC(const TPRINT_RCD* prcd)
{
ResetDC();
#if wxCHECK_VERSION(2,6,1)
wxDC* dc = CreateDC(prcd);
#else
wxDC* dc = NULL;
m_prcd = prcd;
if (m_prcd == NULL)
{
wxPrinter printer;
dc = new wxPrinterDC(printer.GetPrintDialogData().GetPrintData());
}
else
{
wxPrintData data;
#ifdef WIN32
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(prcd->m_data, prcd->m_size));
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo((void*)prcd->m_data, prcd->m_size));
data.ConvertFromNative();
dc = new wxPrinterDC(data);
#else
prcd->GetData(data);
dc = new wxPostScriptDC(data);
#endif
}
wxSize s = dc->GetPPI();
#endif
wxSize s = dc->GetPPI();
SetPPIPrinter(s.x, s.y);
s = dc->GetSize();
@ -319,7 +219,7 @@ void TwxPrintOut::InitDC(TPRINT_RCD* prcd)
SetDC(dc);
}
TwxPrintOut::TwxPrintOut(TPRINT_RCD* prcd)
TwxPrintOut::TwxPrintOut(const TPRINT_RCD* prcd)
: wxPrintout(_GetAppTitle()), m_bBadDriver(false)
{
InitDC(prcd);
@ -338,25 +238,33 @@ class TwxPrintOutCache
{
unsigned long m_signature;
TwxPrintOut* m_po;
bool m_bLocked;
protected:
unsigned long Signature(TPRINT_RCD* prcd) const;
unsigned long Signature(const TPRINT_RCD* prcd) const;
public:
TwxPrintOut* Get(TPRINT_RCD* prcd);
TwxPrintOut& Get(const TPRINT_RCD* prcd);
void Reset();
void Lock() { m_bLocked = true; }
void Unlock() { m_bLocked = false; }
bool Ok() const { return m_po != NULL; }
bool Locked() const { return m_bLocked; }
bool Printing() const { return Ok() && Locked(); }
TwxPrintOutCache() : m_signature(0), m_po(NULL) { }
~TwxPrintOutCache() { Reset(); }
} m_PrintoutCache;
unsigned long TwxPrintOutCache::Signature(TPRINT_RCD* prcd) const
unsigned long TwxPrintOutCache::Signature(const TPRINT_RCD* prcd) const
{
unsigned long h = 0;
if (prcd != NULL)
{
const unsigned char* data = (const unsigned char*)prcd;
for (size_t c = 0; c < prcd->m_size; c++)
for (size_t c = 0; c < prcd->GetSize(); c++)
{
h = (h << 2) + data[c];
const unsigned long i = h & 0xC0000000;
@ -364,11 +272,11 @@ unsigned long TwxPrintOutCache::Signature(TPRINT_RCD* prcd) const
}
}
return h;
}
void TwxPrintOutCache::Reset()
{
wxASSERT(!Locked());
if (m_po != NULL)
{
delete m_po;
@ -376,16 +284,28 @@ void TwxPrintOutCache::Reset()
}
}
TwxPrintOut* TwxPrintOutCache::Get(TPRINT_RCD* prcd)
TwxPrintOut& TwxPrintOutCache::Get(const TPRINT_RCD* prcd)
{
unsigned long signature = Signature(prcd);
if (m_po != NULL && m_signature == signature)
return m_po;
Reset();
m_po = new TwxPrintOut(prcd);
m_signature = signature;
return m_po;
if (!Locked())
{
if (prcd == NULL)
{
if (m_po == NULL)
m_po = new TwxPrintOut;
}
else
{
unsigned long signature = Signature(prcd);
if (m_po != NULL && m_signature == signature)
return *m_po;
Reset();
m_po = new TwxPrintOut(prcd);
m_signature = signature;
}
}
wxASSERT(m_po != NULL);
return *m_po;
}
///////////////////////////////////////////////////////////
@ -400,7 +320,7 @@ void TPrintDC::SetPageStart()
wxDC& TPrintDC::GetDC(bool)
{
_dc = m_po->GetDC(); // Forza display context corrente
_dc = m_PrintoutCache.Get(NULL).GetDC(); // Forza display context corrente
if (_page_start)
{
_dirty = -1;
@ -436,49 +356,49 @@ BOOLEAN xvt_app_escape(int esc_code, PRINT_RCD* rcd, long* ph, long* pw, long* p
*ph = *pw = *pvr = *phr = 0;
if (rcd == NULL || xvt_print_is_valid(rcd))
{
const TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)rcd);
int w, h;
if (m_po == NULL)
{
TwxPrintOut* po = m_PrintoutCache.Get((TPRINT_RCD*)rcd);
po->GetPPIPrinter(&w, &h);
*phr = w; *pvr = h;
po->GetPageSizePixels(&w, &h);
*pw = w; *ph = h;
}
else
{
m_po->GetPPIPrinter(&w, &h);
*phr = w; *pvr = h;
m_po->GetPageSizePixels(&w, &h);
*pw = w; *ph = h;
}
po.GetPPIPrinter(&w, &h);
*phr = w; *pvr = h;
po.GetPageSizePixels(&w, &h);
*pw = w; *ph = h;
return TRUE;
}
break;
case XVT_ESC_SET_PRINTER_INFO:
if (rcd != NULL && xvt_print_is_valid(rcd) && ph != NULL && pw != NULL)
if (xvt_print_is_valid(rcd) && ph != NULL && pw != NULL)
{
wxPrintData data;
#ifdef WIN32
TPRINT_RCD* prcd = (TPRINT_RCD*)rcd;
#ifdef WIN32
#if wxCHECK_VERSION(2,6,1)
RCD2data(prcd, data);
#else
data.SetNativeData(OsWin32_ConvertToNativePrinterInfo(prcd->m_data, prcd->m_size));
#endif
data.ConvertFromNative();
#endif
data.SetOrientation(*ph > *pw ? 1 : 2);
data.ConvertToNative();
#ifdef WIN32
#if wxCHECK_VERSION(2,6,1)
data2RCD(data, prcd);
#else
void* pHandle = data.GetNativeData();
unsigned int nSize = 0;
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pHandle, nSize);
prcd->SetData(ptr, nSize);
delete ptr;
#endif
#else
RCD2data(prcd, data);
data.SetOrientation(*ph > *pw ? 1 : 2);
data2RCD(data, prcd);
#endif
return TRUE;
return true;
}
break;
default:
@ -495,9 +415,15 @@ BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
wxPageSetupData& pdd = dlg.GetPageSetupData();
wxPrintData& data = pdd.GetPrintData();
#ifdef WIN32
#if wxCHECK_VERSION(2,6,1)
RCD2data(rcd, data);
#else
void* pHandle = OsWin32_ConvertToNativePrinterInfo(rcd->m_data, rcd->m_size);
data.SetNativeData(pHandle);
data.ConvertFromNative();
#endif
#else
RCD2data(rcd, data);
#endif
pdd.EnableMargins(false);
@ -505,13 +431,17 @@ BOOLEAN xvt_dm_post_page_setup(PRINT_RCD* precp)
if (ok)
{
#ifdef WIN32
#if wxCHECK_VERSION(2,6,1)
data2RCD(data, rcd);
#else
pHandle = data.GetNativeData();
unsigned int nSize = 0;
void* ptr = OsWin32_ConvertFromNativePrinterInfo(pHandle, nSize);
rcd->SetData(ptr, nSize);
delete ptr;
#endif
#else
rcd->SetData(data);
RCD2data(rcd, data);
#endif
m_PrintoutCache.Reset();
}
@ -525,11 +455,11 @@ long xvt_fmap_get_family_sizes(PRINT_RCD *precp, char *family, long *size_array,
*scalable = FALSE;
#ifdef WIN32
if (precp != NULL)
if (xvt_print_is_valid(precp))
{
TwxPrintOut* po = m_PrintoutCache.Get((TPRINT_RCD*)precp);
if (!po->HasBadDriver())
size = OsWin32_EnumerateSizes(po->GetDC()->GetHDC(), family, size_array, scalable, max_sizes);
const TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)precp);
if (!po.HasBadDriver())
size = OsWin32_EnumerateSizes((unsigned int)po.GetDC()->GetHDC(), family, size_array, scalable, max_sizes);
}
else
{
@ -548,18 +478,18 @@ long xvt_fmap_get_families(PRINT_RCD *precp, char **family_array, long max_famil
family_array[0] = NULL;
#ifdef WIN32
if (precp != NULL)
if (xvt_print_is_valid(precp))
{
TwxPrintOut* po = m_PrintoutCache.Get((TPRINT_RCD*)precp);
size = OsWin32_EnumerateFamilies(po->GetDC()->GetHDC(), family_array, max_families);
TwxPrintOut& po = m_PrintoutCache.Get((TPRINT_RCD*)precp);
size = OsWin32_EnumerateFamilies((unsigned int)po.GetDC()->GetHDC(), family_array, max_families);
if (size == 0)
po->SetBadDriver(true);
po.SetBadDriver(true);
}
else
{
wxWindow* tw = (wxWindow*)TASK_WIN;
wxFrame* tw = (wxFrame*)TASK_WIN;
wxClientDC dc(tw);
size = OsWin32_EnumerateFamilies(dc.GetHDC(), family_array, max_families);
size = OsWin32_EnumerateFamilies((unsigned int)dc.GetHDC(), family_array, max_families);
}
#else
size = OsLinux_EnumerateFamilies(family_array, max_families);
@ -576,18 +506,19 @@ void xvt_print_close(void)
BOOLEAN xvt_print_close_page(PRINT_RCD* precp)
{
BOOLEAN ok = m_po != NULL;
if (ok)
BOOLEAN ok = m_PrintoutCache.Printing();
if (ok)
{
wxDC* dc = m_po->GetDC();
dc->EndPage();
const TwxPrintOut& po = m_PrintoutCache.Get(NULL);
wxDC* dc = po.GetDC();
dc->EndPage();
#ifdef WIN32
TPRINT_RCD* prcd = (TPRINT_RCD*)precp;
if (OsWin32_IsGenericTextOnly(prcd->m_data))
OsWin32_SpoolNewLine(dc->GetHDC());
OsWin32_SpoolNewLine((unsigned int)dc->GetHDC());
#endif
}
return ok;
return ok;
}
PRINT_RCD* xvt_print_create(int *sizep)
@ -609,9 +540,8 @@ PRINT_RCD* xvt_print_create(int *sizep)
data.SetPrinterName("");
pr = new TPRINT_RCD;
pr->SetData(data);
data2RCD(data, pr);
*sizep = pr->GetSize();
#endif
return pr;
@ -637,25 +567,29 @@ PRINT_RCD* xvt_print_create_by_name(int* sizep, const char* name)
data.SetPrinterName(name);
pr = new TPRINT_RCD;
pr->SetData(data);
data2RCD(data, pr);
*sizep = pr->GetSize();
#endif
return pr;
}
WINDOW xvt_print_create_win(PRINT_RCD* precp, char* /* title */)
WINDOW xvt_print_create_win(PRINT_RCD* precp, const char* title)
{
WINDOW win = NULL_WIN;
if (m_po != NULL)
{
m_po->InitDC((TPRINT_RCD*)precp);
m_po->OnBeginPrinting();
m_po->OnBeginDocument(1, 32000);
win = _print_win;
}
return win;
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
if (m_PrintoutCache.Printing())
{
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
po.InitDC(rcd);
po.OnBeginPrinting();
po.OnBeginDocument(1, 32000);
}
else
{
TwxPrintOut& po = m_PrintoutCache.Get(rcd);
po.InitDC(rcd);
}
return PRINTER_WIN;
}
void xvt_print_destroy(PRINT_RCD* precp)
@ -669,11 +603,12 @@ RCT* xvt_print_get_next_band(void)
static RCT rct;
yes = !yes;
if (m_po == NULL || !yes)
if (!yes)
return NULL;
const TwxPrintOut& po = m_PrintoutCache.Get(NULL);
int w, h;
m_po->GetPageSizePixels(&w, &h);
po.GetPageSizePixels(&w, &h);
rct.left = rct.top = 0;
rct.right = w;
rct.bottom = h;
@ -692,7 +627,7 @@ BOOLEAN xvt_print_is_valid(PRINT_RCD* precp)
ok = OsWin32_CheckPrinterInfo(rcd->m_data, rcd->m_size);
#else
wxPrintData data;
rcd->GetData(data);
RCD2data(rcd, data);
ok = data.Ok();
#endif
}
@ -701,7 +636,7 @@ BOOLEAN xvt_print_is_valid(PRINT_RCD* precp)
int xvt_print_get_name(PRINT_RCD* precp, char* name, int sz_s)
{
if (precp == NULL)
if (!xvt_print_is_valid(precp))
return 0;
#ifdef WIN32
@ -725,7 +660,7 @@ int xvt_print_get_name(PRINT_RCD* precp, char* name, int sz_s)
TPRINT_RCD* rcd = (TPRINT_RCD*)precp;
wxPrintData data;
rcd->GetData(data);
RCD2data(rcd, data);
wxString n = data.GetPrinterName();
#endif
if (name != NULL && sz_s > 0)
@ -738,7 +673,7 @@ int xvt_print_get_name(PRINT_RCD* precp, char* name, int sz_s)
BOOLEAN xvt_print_open(void)
{
return m_po == NULL;
return m_PrintoutCache.Ok();
}
///////////////////////////////////////////////////////////
@ -746,7 +681,8 @@ BOOLEAN xvt_print_open(void)
void CreateAbortWindow()
{
wxFrame* parent = (wxFrame*)TASK_WIN;
wxPrintAbortDialog* win = new wxPrintAbortDialog(parent, "Stampa" , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
wxPrintAbortDialog* win = new wxPrintAbortDialog(parent, _GetAppTitle() , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
wxBoxSizer *button_sizer = new wxBoxSizer( wxVERTICAL );
button_sizer->Add( new wxStaticText( win, -1, "Stampa in corso..."), 0, wxALL, 10 );
@ -781,17 +717,22 @@ BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
const wxString strDir = ::wxGetCwd(); // Memorizzo la directory corrente che Acrobat cambia!
wxBeginBusyCursor();
m_po = new TwxPrintOut;
m_PrintoutCache.Reset(); // Forza nuovo contesto di stampa
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
m_PrintoutCache.Lock();
wxEndBusyCursor();
CreateAbortWindow();
const BOOLEAN aborted = print_fcn(data);
DestroyAbortWindow();
m_po->OnEndDocument();
m_po->OnEndPrinting();
po.OnEndDocument();
po.OnEndPrinting();
delete m_po; m_po = NULL;
m_PrintoutCache.Unlock();
m_PrintoutCache.Reset();
::wxSetWorkingDirectory(strDir); // Ripristino la directory corrente
@ -800,14 +741,15 @@ BOOLEAN xvt_print_start_thread(BOOLEAN(*print_fcn)(long), long data)
BOOLEAN xvt_print_open_page(PRINT_RCD* precp)
{
BOOLEAN ok = m_po != NULL;
BOOLEAN ok = m_PrintoutCache.Printing();
if (ok)
{
if (wxPrinterBase::sm_abortIt)
ok = FALSE;
else
{
m_po->GetDC()->StartPage();
TwxPrintOut& po = m_PrintoutCache.Get(NULL);
po.GetDC()->StartPage();
TPrintDC::SetPageStart(); // Flag per azzeramento dati DC
}
}
@ -1080,7 +1022,7 @@ const char* xvt_fsys_get_campo_ini()
{
char msg[256];
sprintf(msg, "Impossibile aprire '%s'", (const char *)path);
xvt_dm_post_fatal_exit(msg);
xvt_dm_post_fatal_exit(msg);
}
prawin = xvt_str_duplicate(path);
}