Fixed MSW printing, tidied up member variable names
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@641 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -26,8 +26,6 @@ class WXDLLEXPORT wxWindowsPrinter: public wxPrinterBase
|
|||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxWindowsPrinter)
|
DECLARE_DYNAMIC_CLASS(wxWindowsPrinter)
|
||||||
|
|
||||||
private:
|
|
||||||
WXFARPROC lpAbortProc;
|
|
||||||
public:
|
public:
|
||||||
wxWindowsPrinter(wxPrintData *data = NULL);
|
wxWindowsPrinter(wxPrintData *data = NULL);
|
||||||
~wxWindowsPrinter(void);
|
~wxWindowsPrinter(void);
|
||||||
@@ -35,6 +33,9 @@ class WXDLLEXPORT wxWindowsPrinter: public wxPrinterBase
|
|||||||
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
|
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
|
||||||
virtual bool PrintDialog(wxWindow *parent);
|
virtual bool PrintDialog(wxWindow *parent);
|
||||||
virtual bool Setup(wxWindow *parent);
|
virtual bool Setup(wxWindow *parent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
WXFARPROC m_lpAbortProc;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -43,20 +43,14 @@ class WXDLLEXPORT wxPrinterBase: public wxObject
|
|||||||
{
|
{
|
||||||
DECLARE_CLASS(wxPrinterBase)
|
DECLARE_CLASS(wxPrinterBase)
|
||||||
|
|
||||||
protected:
|
|
||||||
wxPrintData printData;
|
|
||||||
wxPrintout *currentPrintout;
|
|
||||||
public:
|
public:
|
||||||
static wxWindow *abortWindow;
|
|
||||||
static bool abortIt;
|
|
||||||
|
|
||||||
wxPrinterBase(wxPrintData *data = (wxPrintData *) NULL);
|
wxPrinterBase(wxPrintData *data = (wxPrintData *) NULL);
|
||||||
~wxPrinterBase(void);
|
~wxPrinterBase();
|
||||||
|
|
||||||
virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout);
|
virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout);
|
||||||
virtual void ReportError(wxWindow *parent, wxPrintout *printout, char *message);
|
virtual void ReportError(wxWindow *parent, wxPrintout *printout, char *message);
|
||||||
inline wxPrintData& GetPrintData(void) { return printData; };
|
inline wxPrintData& GetPrintData() { return m_printData; };
|
||||||
inline bool GetAbort(void) { return abortIt; }
|
inline bool GetAbort() { return sm_abortIt; }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// OVERRIDES
|
// OVERRIDES
|
||||||
@@ -64,6 +58,14 @@ class WXDLLEXPORT wxPrinterBase: public wxObject
|
|||||||
virtual bool Setup(wxWindow *parent) = 0;
|
virtual bool Setup(wxWindow *parent) = 0;
|
||||||
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE) = 0;
|
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE) = 0;
|
||||||
virtual bool PrintDialog(wxWindow *parent) = 0;
|
virtual bool PrintDialog(wxWindow *parent) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxPrintData m_printData;
|
||||||
|
wxPrintout* m_currentPrintout;
|
||||||
|
public:
|
||||||
|
static wxWindow* sm_abortWindow;
|
||||||
|
static bool sm_abortIt;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -78,55 +80,56 @@ class WXDLLEXPORT wxPrintout: public wxObject
|
|||||||
{
|
{
|
||||||
DECLARE_ABSTRACT_CLASS(wxPrintout)
|
DECLARE_ABSTRACT_CLASS(wxPrintout)
|
||||||
|
|
||||||
private:
|
|
||||||
char *printoutTitle;
|
|
||||||
wxDC *printoutDC;
|
|
||||||
|
|
||||||
int pageWidthPixels;
|
|
||||||
int pageHeightPixels;
|
|
||||||
|
|
||||||
int pageWidthMM;
|
|
||||||
int pageHeightMM;
|
|
||||||
|
|
||||||
int PPIScreenX;
|
|
||||||
int PPIScreenY;
|
|
||||||
int PPIPrinterX;
|
|
||||||
int PPIPrinterY;
|
|
||||||
|
|
||||||
bool isPreview;
|
|
||||||
public:
|
public:
|
||||||
wxPrintout(const char *title = "Printout");
|
wxPrintout(const wxString& title = "Printout");
|
||||||
~wxPrintout(void);
|
~wxPrintout();
|
||||||
|
|
||||||
virtual bool OnBeginDocument(int startPage, int endPage);
|
virtual bool OnBeginDocument(int startPage, int endPage);
|
||||||
virtual void OnEndDocument(void);
|
virtual void OnEndDocument();
|
||||||
virtual void OnBeginPrinting(void);
|
virtual void OnBeginPrinting();
|
||||||
virtual void OnEndPrinting(void);
|
virtual void OnEndPrinting();
|
||||||
|
|
||||||
// Guaranteed to be before any other functions are called
|
// Guaranteed to be before any other functions are called
|
||||||
inline virtual void OnPreparePrinting(void) { }
|
inline virtual void OnPreparePrinting() { }
|
||||||
|
|
||||||
virtual bool HasPage(int page);
|
virtual bool HasPage(int page);
|
||||||
virtual bool OnPrintPage(int page) = 0;
|
virtual bool OnPrintPage(int page) = 0;
|
||||||
virtual void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo);
|
virtual void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo);
|
||||||
|
|
||||||
inline virtual char *GetTitle(void) { return printoutTitle; }
|
inline virtual wxString GetTitle() { return m_printoutTitle; }
|
||||||
|
|
||||||
inline wxDC *GetDC(void) { return printoutDC; }
|
inline wxDC *GetDC() { return m_printoutDC; }
|
||||||
inline void SetDC(wxDC *dc) { printoutDC = dc; }
|
inline void SetDC(wxDC *dc) { m_printoutDC = dc; }
|
||||||
inline void SetPageSizePixels(int w, int h) { pageWidthPixels = w; pageHeightPixels = h; }
|
inline void SetPageSizePixels(int w, int h) { m_pageWidthPixels = w; m_pageHeightPixels = h; }
|
||||||
inline void GetPageSizePixels(int *w, int *h) { *w = pageWidthPixels; *h = pageHeightPixels; }
|
inline void GetPageSizePixels(int *w, int *h) { *w = m_pageWidthPixels; *h = m_pageHeightPixels; }
|
||||||
inline void SetPageSizeMM(int w, int h) { pageWidthMM = w; pageHeightMM = h; }
|
inline void SetPageSizeMM(int w, int h) { m_pageWidthMM = w; m_pageHeightMM = h; }
|
||||||
inline void GetPageSizeMM(int *w, int *h) { *w = pageWidthMM; *h = pageHeightMM; }
|
inline void GetPageSizeMM(int *w, int *h) { *w = m_pageWidthMM; *h = m_pageHeightMM; }
|
||||||
|
|
||||||
inline void SetPPIScreen(int x, int y) { PPIScreenX = x; PPIScreenY = y; }
|
inline void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; }
|
||||||
inline void GetPPIScreen(int *x, int *y) { *x = PPIScreenX; *y = PPIScreenY; }
|
inline void GetPPIScreen(int *x, int *y) { *x = m_PPIScreenX; *y = m_PPIScreenY; }
|
||||||
inline void SetPPIPrinter(int x, int y) { PPIPrinterX = x; PPIPrinterY = y; }
|
inline void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; }
|
||||||
inline void GetPPIPrinter(int *x, int *y) { *x = PPIPrinterX; *y = PPIPrinterY; }
|
inline void GetPPIPrinter(int *x, int *y) { *x = m_PPIPrinterX; *y = m_PPIPrinterY; }
|
||||||
|
|
||||||
inline virtual bool IsPreview(void) { return isPreview; }
|
inline virtual bool IsPreview() { return m_isPreview; }
|
||||||
|
|
||||||
inline virtual void SetIsPreview(bool p) { isPreview = p; }
|
inline virtual void SetIsPreview(bool p) { m_isPreview = p; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_printoutTitle;
|
||||||
|
wxDC* m_printoutDC;
|
||||||
|
|
||||||
|
int m_pageWidthPixels;
|
||||||
|
int m_pageHeightPixels;
|
||||||
|
|
||||||
|
int m_pageWidthMM;
|
||||||
|
int m_pageHeightMM;
|
||||||
|
|
||||||
|
int m_PPIScreenX;
|
||||||
|
int m_PPIScreenY;
|
||||||
|
int m_PPIPrinterX;
|
||||||
|
int m_PPIPrinterY;
|
||||||
|
|
||||||
|
bool m_isPreview;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -138,19 +141,20 @@ class WXDLLEXPORT wxPreviewCanvas: public wxScrolledWindow
|
|||||||
{
|
{
|
||||||
DECLARE_CLASS(wxPreviewCanvas)
|
DECLARE_CLASS(wxPreviewCanvas)
|
||||||
|
|
||||||
private:
|
|
||||||
wxPrintPreviewBase *printPreview;
|
|
||||||
public:
|
public:
|
||||||
wxPreviewCanvas(wxPrintPreviewBase *preview, wxWindow *parent,
|
wxPreviewCanvas(wxPrintPreviewBase *preview, wxWindow *parent,
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
long style = 0, const wxString& name = "canvas");
|
long style = 0, const wxString& name = "canvas");
|
||||||
~wxPreviewCanvas(void);
|
~wxPreviewCanvas();
|
||||||
|
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
// Responds to colour changes
|
// Responds to colour changes
|
||||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxPrintPreviewBase* m_printPreview;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -163,20 +167,21 @@ class WXDLLEXPORT wxPreviewFrame: public wxFrame
|
|||||||
{
|
{
|
||||||
DECLARE_CLASS(wxPreviewFrame)
|
DECLARE_CLASS(wxPreviewFrame)
|
||||||
|
|
||||||
protected:
|
|
||||||
wxWindow *previewCanvas;
|
|
||||||
wxPreviewControlBar *controlBar;
|
|
||||||
wxPrintPreviewBase *printPreview;
|
|
||||||
public:
|
public:
|
||||||
wxPreviewFrame(wxPrintPreviewBase *preview, wxFrame *parent, const wxString& title = "Print Preview",
|
wxPreviewFrame(wxPrintPreviewBase *preview, wxFrame *parent, const wxString& title = "Print Preview",
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
long style = wxDEFAULT_FRAME, const wxString& name = "frame");
|
long style = wxDEFAULT_FRAME, const wxString& name = "frame");
|
||||||
~wxPreviewFrame(void);
|
~wxPreviewFrame();
|
||||||
|
|
||||||
bool OnClose(void);
|
bool OnClose();
|
||||||
virtual void Initialize(void);
|
virtual void Initialize();
|
||||||
virtual void CreateCanvas(void);
|
virtual void CreateCanvas();
|
||||||
virtual void CreateControlBar(void);
|
virtual void CreateControlBar();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxWindow* m_previewCanvas;
|
||||||
|
wxPreviewControlBar* m_controlBar;
|
||||||
|
wxPrintPreviewBase* m_printPreview;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -204,25 +209,16 @@ class WXDLLEXPORT wxPreviewControlBar: public wxPanel
|
|||||||
{
|
{
|
||||||
DECLARE_CLASS(wxPreviewControlBar)
|
DECLARE_CLASS(wxPreviewControlBar)
|
||||||
|
|
||||||
protected:
|
|
||||||
wxPrintPreviewBase *printPreview;
|
|
||||||
wxButton *closeButton;
|
|
||||||
wxButton *nextPageButton;
|
|
||||||
wxButton *previousPageButton;
|
|
||||||
wxButton *printButton;
|
|
||||||
wxChoice *zoomControl;
|
|
||||||
static wxFont *buttonFont;
|
|
||||||
long buttonFlags;
|
|
||||||
public:
|
public:
|
||||||
wxPreviewControlBar(wxPrintPreviewBase *preview, long buttons,
|
wxPreviewControlBar(wxPrintPreviewBase *preview, long buttons,
|
||||||
wxWindow *parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
wxWindow *parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
long style = 0, const wxString& name = "panel");
|
long style = 0, const wxString& name = "panel");
|
||||||
~wxPreviewControlBar(void);
|
~wxPreviewControlBar();
|
||||||
|
|
||||||
virtual void CreateButtons(void);
|
virtual void CreateButtons();
|
||||||
virtual void SetZoomControl(int zoom);
|
virtual void SetZoomControl(int zoom);
|
||||||
virtual int GetZoomControl(void);
|
virtual int GetZoomControl();
|
||||||
inline virtual wxPrintPreviewBase *GetPrintPreview(void) { return printPreview; }
|
inline virtual wxPrintPreviewBase *GetPrintPreview() const { return m_printPreview; }
|
||||||
|
|
||||||
void OnPrint(wxCommandEvent& event);
|
void OnPrint(wxCommandEvent& event);
|
||||||
void OnClose(wxCommandEvent& event);
|
void OnClose(wxCommandEvent& event);
|
||||||
@@ -231,6 +227,15 @@ class WXDLLEXPORT wxPreviewControlBar: public wxPanel
|
|||||||
void OnZoom(wxCommandEvent& event);
|
void OnZoom(wxCommandEvent& event);
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxPrintPreviewBase* m_printPreview;
|
||||||
|
wxButton* m_closeButton;
|
||||||
|
wxButton* m_nextPageButton;
|
||||||
|
wxButton* m_previousPageButton;
|
||||||
|
wxButton* m_printButton;
|
||||||
|
wxChoice* m_zoomControl;
|
||||||
|
long m_buttonFlags;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -243,40 +248,22 @@ class WXDLLEXPORT wxPrintPreviewBase: public wxObject
|
|||||||
{
|
{
|
||||||
DECLARE_CLASS(wxPrintPreviewBase)
|
DECLARE_CLASS(wxPrintPreviewBase)
|
||||||
|
|
||||||
protected:
|
|
||||||
wxPrintData printData;
|
|
||||||
wxWindow *previewCanvas;
|
|
||||||
wxFrame *previewFrame;
|
|
||||||
wxBitmap *previewBitmap;
|
|
||||||
wxPrintout *previewPrintout;
|
|
||||||
wxPrintout *printPrintout;
|
|
||||||
int currentPage;
|
|
||||||
int currentZoom;
|
|
||||||
float previewScale;
|
|
||||||
int topMargin;
|
|
||||||
int leftMargin;
|
|
||||||
int pageWidth;
|
|
||||||
int pageHeight;
|
|
||||||
int minPage;
|
|
||||||
int maxPage;
|
|
||||||
protected:
|
|
||||||
bool isOk;
|
|
||||||
public:
|
public:
|
||||||
wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting = (wxPrintout *) NULL, wxPrintData *data = (wxPrintData *) NULL);
|
wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting = (wxPrintout *) NULL, wxPrintData *data = (wxPrintData *) NULL);
|
||||||
~wxPrintPreviewBase(void);
|
~wxPrintPreviewBase();
|
||||||
|
|
||||||
virtual bool SetCurrentPage(int pageNum);
|
virtual bool SetCurrentPage(int pageNum);
|
||||||
inline int GetCurrentPage(void) { return currentPage; };
|
inline int GetCurrentPage() const { return m_currentPage; };
|
||||||
|
|
||||||
inline void SetPrintout(wxPrintout *printout) { previewPrintout = printout; };
|
inline void SetPrintout(wxPrintout *printout) { m_previewPrintout = printout; };
|
||||||
inline wxPrintout *GetPrintout(void) { return previewPrintout; };
|
inline wxPrintout *GetPrintout() const { return m_previewPrintout; };
|
||||||
inline wxPrintout *GetPrintoutForPrinting(void) { return printPrintout; };
|
inline wxPrintout *GetPrintoutForPrinting() const { return m_printPrintout; };
|
||||||
|
|
||||||
inline void SetFrame(wxFrame *frame) { previewFrame = frame; };
|
inline void SetFrame(wxFrame *frame) { m_previewFrame = frame; };
|
||||||
inline void SetCanvas(wxWindow *canvas) { previewCanvas = canvas; };
|
inline void SetCanvas(wxWindow *canvas) { m_previewCanvas = canvas; };
|
||||||
|
|
||||||
inline virtual wxFrame *GetFrame(void) { return previewFrame; }
|
inline virtual wxFrame *GetFrame() const { return m_previewFrame; }
|
||||||
inline virtual wxWindow *GetCanvas(void) { return previewCanvas; }
|
inline virtual wxWindow *GetCanvas() const { return m_previewCanvas; }
|
||||||
|
|
||||||
// The preview canvas should call this from OnPaint
|
// The preview canvas should call this from OnPaint
|
||||||
virtual bool PaintPage(wxWindow *canvas, wxDC& dc);
|
virtual bool PaintPage(wxWindow *canvas, wxDC& dc);
|
||||||
@@ -288,16 +275,16 @@ class WXDLLEXPORT wxPrintPreviewBase: public wxObject
|
|||||||
// a wxMemoryDC.
|
// a wxMemoryDC.
|
||||||
virtual bool RenderPage(int pageNum);
|
virtual bool RenderPage(int pageNum);
|
||||||
|
|
||||||
inline wxPrintData& GetPrintData(void) { return printData; }
|
inline wxPrintData& GetPrintData() { return m_printData; }
|
||||||
|
|
||||||
virtual void SetZoom(int percent);
|
virtual void SetZoom(int percent);
|
||||||
int GetZoom(void) { return currentZoom; };
|
inline int GetZoom() const { return m_currentZoom; };
|
||||||
|
|
||||||
inline int GetMaxPage(void) { return maxPage; }
|
inline int GetMaxPage() const { return m_maxPage; }
|
||||||
inline int GetMinPage(void) { return minPage; }
|
inline int GetMinPage() const { return m_minPage; }
|
||||||
|
|
||||||
inline bool Ok(void) { return isOk; }
|
inline bool Ok() const { return m_isOk; }
|
||||||
inline void SetOk(bool ok) { isOk = ok; }
|
inline void SetOk(bool ok) { m_isOk = ok; }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// OVERRIDES
|
// OVERRIDES
|
||||||
@@ -310,7 +297,26 @@ class WXDLLEXPORT wxPrintPreviewBase: public wxObject
|
|||||||
// Calculate scaling that needs to be done to get roughly
|
// Calculate scaling that needs to be done to get roughly
|
||||||
// the right scaling for the screen pretending to be
|
// the right scaling for the screen pretending to be
|
||||||
// the currently selected printer.
|
// the currently selected printer.
|
||||||
virtual void DetermineScaling(void) = 0;
|
virtual void DetermineScaling() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxPrintData m_printData;
|
||||||
|
wxWindow* m_previewCanvas;
|
||||||
|
wxFrame* m_previewFrame;
|
||||||
|
wxBitmap* m_previewBitmap;
|
||||||
|
wxPrintout* m_previewPrintout;
|
||||||
|
wxPrintout* m_printPrintout;
|
||||||
|
int m_currentPage;
|
||||||
|
int m_currentZoom;
|
||||||
|
float m_previewScale;
|
||||||
|
int m_topMargin;
|
||||||
|
int m_leftMargin;
|
||||||
|
int m_pageWidth;
|
||||||
|
int m_pageHeight;
|
||||||
|
int m_minPage;
|
||||||
|
int m_maxPage;
|
||||||
|
protected:
|
||||||
|
bool m_isOk;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -320,8 +326,6 @@ class WXDLLEXPORT wxPrintPreviewBase: public wxObject
|
|||||||
class WXDLLEXPORT wxPrintAbortDialog: public wxDialog
|
class WXDLLEXPORT wxPrintAbortDialog: public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void OnCancel(wxCommandEvent& event);
|
|
||||||
|
|
||||||
wxPrintAbortDialog(wxWindow *parent,
|
wxPrintAbortDialog(wxWindow *parent,
|
||||||
const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
long style = 0, const wxString& name = "dialog"):
|
long style = 0, const wxString& name = "dialog"):
|
||||||
@@ -329,6 +333,8 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnCancel(wxCommandEvent& event);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -45,13 +45,6 @@ int orientation = wxPORTRAIT;
|
|||||||
// Main proc
|
// Main proc
|
||||||
IMPLEMENT_APP(MyApp)
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
// Must initialise these in OnInit, not statically
|
|
||||||
wxPen *red_pen;
|
|
||||||
wxFont *labelFont;
|
|
||||||
wxFont *itemFont;
|
|
||||||
|
|
||||||
float zoom_factor = 1.0;
|
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
#include "folder.xpm"
|
#include "folder.xpm"
|
||||||
#endif
|
#endif
|
||||||
@@ -67,12 +60,7 @@ MyApp::MyApp()
|
|||||||
// main frame
|
// main frame
|
||||||
bool MyApp::OnInit(void)
|
bool MyApp::OnInit(void)
|
||||||
{
|
{
|
||||||
// Create a red pen
|
m_testFont = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
|
||||||
red_pen = new wxPen("RED", 3, wxSOLID);
|
|
||||||
|
|
||||||
// Create a small font
|
|
||||||
itemFont = new wxFont(11, wxROMAN, wxNORMAL, wxNORMAL);
|
|
||||||
labelFont = new wxFont(12, wxROMAN, wxITALIC, wxBOLD);
|
|
||||||
|
|
||||||
// Create the main frame window
|
// Create the main frame window
|
||||||
frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows Printing Demo", wxPoint(0, 0), wxSize(400, 400));
|
frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows Printing Demo", wxPoint(0, 0), wxSize(400, 400));
|
||||||
@@ -122,11 +110,6 @@ bool MyApp::OnInit(void)
|
|||||||
// Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
|
// Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
|
||||||
canvas->SetScrollbars(20, 20, 50, 50);
|
canvas->SetScrollbars(20, 20, 50, 50);
|
||||||
|
|
||||||
// This ensures that the fonts get created as _screen_
|
|
||||||
// fonts, not printer fonts.
|
|
||||||
canvas->SetFont(itemFont);
|
|
||||||
canvas->SetFont(labelFont);
|
|
||||||
|
|
||||||
frame->canvas = canvas;
|
frame->canvas = canvas;
|
||||||
|
|
||||||
frame->Centre(wxBOTH);
|
frame->Centre(wxBOTH);
|
||||||
@@ -303,20 +286,21 @@ void MyFrame::OnPrintAbout(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void MyFrame::Draw(wxDC& dc)
|
void MyFrame::Draw(wxDC& dc)
|
||||||
{
|
{
|
||||||
dc.SetFont(itemFont);
|
dc.SetFont(* wxGetApp().m_testFont);
|
||||||
|
|
||||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||||
|
|
||||||
dc.SetBrush(wxCYAN_BRUSH);
|
dc.SetBrush(* wxCYAN_BRUSH);
|
||||||
dc.SetPen(wxRED_PEN);
|
dc.SetPen(* wxRED_PEN);
|
||||||
|
|
||||||
dc.DrawRectangle(0, 30, 200, 100);
|
dc.DrawRectangle(0, 30, 200, 100);
|
||||||
dc.DrawText("Rectangle 200 by 100", 40, 40);
|
dc.DrawText("Rectangle 200 by 100", 40, 40);
|
||||||
|
|
||||||
dc.DrawEllipse(50, 140, 100, 50);
|
dc.DrawEllipse(50, 140, 100, 50);
|
||||||
|
|
||||||
dc.DrawText("Test message: this is in 11 point text", 10, 180);
|
dc.DrawText("Test message: this is in 10 point text", 10, 180);
|
||||||
|
|
||||||
dc.SetPen(wxBLACK_PEN);
|
dc.SetPen(* wxBLACK_PEN);
|
||||||
dc.DrawLine(0, 0, 200, 200);
|
dc.DrawLine(0, 0, 200, 200);
|
||||||
dc.DrawLine(200, 0, 0, 200);
|
dc.DrawLine(200, 0, 0, 200);
|
||||||
|
|
||||||
@@ -360,11 +344,10 @@ void MyCanvas::OnEvent(wxMouseEvent& WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define the behaviour for the frame closing
|
|
||||||
// - must delete all frames except for the main one.
|
|
||||||
bool MyFrame::OnClose(void)
|
bool MyFrame::OnClose(void)
|
||||||
{
|
{
|
||||||
Show(FALSE);
|
Show(FALSE);
|
||||||
|
delete wxGetApp().m_testFont;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -495,11 +478,11 @@ void MyPrintout::DrawPageTwo(wxDC *dc)
|
|||||||
// Draw 50 mm by 50 mm L shape
|
// Draw 50 mm by 50 mm L shape
|
||||||
float logUnitsFactor = (float)(ppiPrinterX/(scale*25.1));
|
float logUnitsFactor = (float)(ppiPrinterX/(scale*25.1));
|
||||||
float logUnits = (float)(50*logUnitsFactor);
|
float logUnits = (float)(50*logUnitsFactor);
|
||||||
dc->SetPen(wxBLACK_PEN);
|
dc->SetPen(* wxBLACK_PEN);
|
||||||
dc->DrawLine(50, 50, (long)(50.0 + logUnits), 50);
|
dc->DrawLine(50, 50, (long)(50.0 + logUnits), 50);
|
||||||
dc->DrawLine(50, 50, 50, (long)(50.0 + logUnits));
|
dc->DrawLine(50, 50, 50, (long)(50.0 + logUnits));
|
||||||
|
|
||||||
dc->SetFont(itemFont);
|
dc->SetFont(* wxGetApp().m_testFont);
|
||||||
dc->SetBackgroundMode(wxTRANSPARENT);
|
dc->SetBackgroundMode(wxTRANSPARENT);
|
||||||
|
|
||||||
dc->DrawText("Some test text", 200, 200 );
|
dc->DrawText("Some test text", 200, 200 );
|
||||||
@@ -555,7 +538,7 @@ bool WritePageHeader(wxPrintout *printout, wxDC *dc, char *text, float mmToLogic
|
|||||||
float xPos = (float)(((((pageWidthMM - leftMargin - rightMargin)/2.0)+leftMargin)*mmToLogical) - (xExtent/2.0));
|
float xPos = (float)(((((pageWidthMM - leftMargin - rightMargin)/2.0)+leftMargin)*mmToLogical) - (xExtent/2.0));
|
||||||
dc->DrawText(text, (long)xPos, (long)topMarginLogical);
|
dc->DrawText(text, (long)xPos, (long)topMarginLogical);
|
||||||
|
|
||||||
dc->SetPen(wxBLACK_PEN);
|
dc->SetPen(* wxBLACK_PEN);
|
||||||
dc->DrawLine( (long)leftMarginLogical, (long)(topMarginLogical+yExtent),
|
dc->DrawLine( (long)leftMarginLogical, (long)(topMarginLogical+yExtent),
|
||||||
(long)rightMarginLogical, (long)topMarginLogical+yExtent );
|
(long)rightMarginLogical, (long)topMarginLogical+yExtent );
|
||||||
|
|
||||||
|
@@ -19,8 +19,12 @@ class MyApp: public wxApp
|
|||||||
public:
|
public:
|
||||||
MyApp(void) ;
|
MyApp(void) ;
|
||||||
bool OnInit(void);
|
bool OnInit(void);
|
||||||
|
|
||||||
|
wxFont* m_testFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DECLARE_APP(MyApp)
|
||||||
|
|
||||||
class MyCanvas;
|
class MyCanvas;
|
||||||
|
|
||||||
// Define a new canvas and frame
|
// Define a new canvas and frame
|
||||||
|
@@ -60,22 +60,6 @@
|
|||||||
#include <print.h>
|
#include <print.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
|
|
||||||
#define APIENTRY FAR PASCAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
#define _EXPORT /**/
|
|
||||||
#else
|
|
||||||
#define _EXPORT _export
|
|
||||||
typedef signed short int SHORT ;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__WIN32__) // 3.x uses FARPROC for dialogs
|
|
||||||
#define DLGPROC FARPROC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LONG APIENTRY _EXPORT wxAbortProc(HDC hPr, int Code);
|
|
||||||
#endif
|
#endif
|
||||||
// End __WXMSW__
|
// End __WXMSW__
|
||||||
|
|
||||||
@@ -103,31 +87,31 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
wxPrinterBase::wxPrinterBase(wxPrintData *data)
|
wxPrinterBase::wxPrinterBase(wxPrintData *data)
|
||||||
{
|
{
|
||||||
currentPrintout = (wxPrintout *) NULL;
|
m_currentPrintout = (wxPrintout *) NULL;
|
||||||
abortWindow = (wxWindow *) NULL;
|
sm_abortWindow = (wxWindow *) NULL;
|
||||||
abortIt = FALSE;
|
sm_abortIt = FALSE;
|
||||||
if (data)
|
if (data)
|
||||||
printData = (*data);
|
m_printData = (*data);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow *wxPrinterBase::abortWindow = (wxWindow *) NULL;
|
wxWindow *wxPrinterBase::sm_abortWindow = (wxWindow *) NULL;
|
||||||
bool wxPrinterBase::abortIt = FALSE;
|
bool wxPrinterBase::sm_abortIt = FALSE;
|
||||||
|
|
||||||
wxPrinterBase::~wxPrinterBase(void)
|
wxPrinterBase::~wxPrinterBase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxPrinterBase::abortIt = TRUE;
|
wxPrinterBase::sm_abortIt = TRUE;
|
||||||
wxPrinterBase::abortWindow->Show(FALSE);
|
wxPrinterBase::sm_abortWindow->Show(FALSE);
|
||||||
wxPrinterBase::abortWindow->Close(TRUE);
|
wxPrinterBase::sm_abortWindow->Close(TRUE);
|
||||||
wxPrinterBase::abortWindow = (wxWindow *) NULL;
|
wxPrinterBase::sm_abortWindow = (wxWindow *) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow *wxPrinterBase::CreateAbortWindow(wxWindow *parent, wxPrintout *WXUNUSED(printout))
|
wxWindow *wxPrinterBase::CreateAbortWindow(wxWindow *parent, wxPrintout *WXUNUSED(printout))
|
||||||
{
|
{
|
||||||
wxPrintAbortDialog *dialog = new wxPrintAbortDialog(parent, _("Printing"), wxPoint(0, 0), wxSize(400, 400));
|
wxPrintAbortDialog *dialog = new wxPrintAbortDialog(parent, _("Printing"), wxPoint(0, 0), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE);
|
||||||
(void) new wxStaticText(dialog, -1, _("Please wait..."), wxPoint(5, 5));
|
(void) new wxStaticText(dialog, -1, _("Please wait..."), wxPoint(5, 5));
|
||||||
|
|
||||||
wxButton *button = new wxButton(dialog, wxID_CANCEL, _("Cancel"), wxPoint(5, 30));
|
wxButton *button = new wxButton(dialog, wxID_CANCEL, _("Cancel"), wxPoint(5, 30));
|
||||||
@@ -148,25 +132,23 @@ void wxPrinterBase::ReportError(wxWindow *parent, wxPrintout *WXUNUSED(printout)
|
|||||||
* Printout class
|
* Printout class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wxPrintout::wxPrintout(const char *title)
|
wxPrintout::wxPrintout(const wxString& title)
|
||||||
{
|
{
|
||||||
printoutTitle = title ? copystring(title) : (char *) NULL;
|
m_printoutTitle = title ;
|
||||||
printoutDC = (wxDC *) NULL;
|
m_printoutDC = (wxDC *) NULL;
|
||||||
pageWidthMM = 0;
|
m_pageWidthMM = 0;
|
||||||
pageHeightMM = 0;
|
m_pageHeightMM = 0;
|
||||||
pageWidthPixels = 0;
|
m_pageWidthPixels = 0;
|
||||||
pageHeightPixels = 0;
|
m_pageHeightPixels = 0;
|
||||||
PPIScreenX = 0;
|
m_PPIScreenX = 0;
|
||||||
PPIScreenY = 0;
|
m_PPIScreenY = 0;
|
||||||
PPIPrinterX = 0;
|
m_PPIPrinterX = 0;
|
||||||
PPIPrinterY = 0;
|
m_PPIPrinterY = 0;
|
||||||
isPreview = FALSE;
|
m_isPreview = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintout::~wxPrintout(void)
|
wxPrintout::~wxPrintout()
|
||||||
{
|
{
|
||||||
if (printoutTitle)
|
|
||||||
delete[] printoutTitle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPrintout::OnBeginDocument(int WXUNUSED(startPage), int WXUNUSED(endPage))
|
bool wxPrintout::OnBeginDocument(int WXUNUSED(startPage), int WXUNUSED(endPage))
|
||||||
@@ -174,16 +156,16 @@ bool wxPrintout::OnBeginDocument(int WXUNUSED(startPage), int WXUNUSED(endPage))
|
|||||||
return GetDC()->StartDoc(_("Printing"));
|
return GetDC()->StartDoc(_("Printing"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrintout::OnEndDocument(void)
|
void wxPrintout::OnEndDocument()
|
||||||
{
|
{
|
||||||
GetDC()->EndDoc();
|
GetDC()->EndDoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrintout::OnBeginPrinting(void)
|
void wxPrintout::OnBeginPrinting()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPrintout::OnEndPrinting(void)
|
void wxPrintout::OnEndPrinting()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,13 +190,13 @@ wxPreviewCanvas::wxPreviewCanvas(wxPrintPreviewBase *preview, wxWindow *parent,
|
|||||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
|
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
|
||||||
wxScrolledWindow(parent, -1, pos, size, style, name)
|
wxScrolledWindow(parent, -1, pos, size, style, name)
|
||||||
{
|
{
|
||||||
printPreview = preview;
|
m_printPreview = preview;
|
||||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
|
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
|
||||||
|
|
||||||
SetScrollbars(40, 40, 100, 100);
|
SetScrollbars(40, 40, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPreviewCanvas::~wxPreviewCanvas(void)
|
wxPreviewCanvas::~wxPreviewCanvas()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,9 +204,9 @@ void wxPreviewCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
if (printPreview)
|
if (m_printPreview)
|
||||||
{
|
{
|
||||||
printPreview->PaintPage(this, dc);
|
m_printPreview->PaintPage(this, dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,18 +238,16 @@ wxPreviewControlBar::wxPreviewControlBar(wxPrintPreviewBase *preview, long butto
|
|||||||
long style, const wxString& name):
|
long style, const wxString& name):
|
||||||
wxPanel(parent, -1, pos, size, style, name)
|
wxPanel(parent, -1, pos, size, style, name)
|
||||||
{
|
{
|
||||||
printPreview = preview;
|
m_printPreview = preview;
|
||||||
closeButton = (wxButton *) NULL;
|
m_closeButton = (wxButton *) NULL;
|
||||||
nextPageButton = (wxButton *) NULL;
|
m_nextPageButton = (wxButton *) NULL;
|
||||||
previousPageButton = (wxButton *) NULL;
|
m_previousPageButton = (wxButton *) NULL;
|
||||||
printButton = (wxButton *) NULL;
|
m_printButton = (wxButton *) NULL;
|
||||||
zoomControl = (wxChoice *) NULL;
|
m_zoomControl = (wxChoice *) NULL;
|
||||||
buttonFlags = buttons;
|
m_buttonFlags = buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont *wxPreviewControlBar::buttonFont = (wxFont *) NULL;
|
wxPreviewControlBar::~wxPreviewControlBar()
|
||||||
|
|
||||||
wxPreviewControlBar::~wxPreviewControlBar(void)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +311,7 @@ void wxPreviewControlBar::OnZoom(wxCommandEvent& WXUNUSED(event))
|
|||||||
GetPrintPreview()->SetZoom(zoom);
|
GetPrintPreview()->SetZoom(zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPreviewControlBar::CreateButtons(void)
|
void wxPreviewControlBar::CreateButtons()
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
|
|
||||||
@@ -343,9 +323,8 @@ void wxPreviewControlBar::CreateButtons(void)
|
|||||||
int fontSize = 10;
|
int fontSize = 10;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!buttonFont)
|
wxFont buttonFont(fontSize, wxSWISS, wxNORMAL, wxBOLD);
|
||||||
buttonFont = wxTheFontList->FindOrCreateFont(fontSize, wxSWISS, wxNORMAL, wxBOLD);
|
SetButtonFont(buttonFont);
|
||||||
SetButtonFont(*buttonFont);
|
|
||||||
|
|
||||||
int buttonWidth = 65;
|
int buttonWidth = 65;
|
||||||
int buttonHeight = 24;
|
int buttonHeight = 24;
|
||||||
@@ -354,28 +333,28 @@ void wxPreviewControlBar::CreateButtons(void)
|
|||||||
int y = 5;
|
int y = 5;
|
||||||
int gap = 5;
|
int gap = 5;
|
||||||
|
|
||||||
closeButton = new wxButton(this, wxID_PREVIEW_CLOSE, _("Close"),
|
m_closeButton = new wxButton(this, wxID_PREVIEW_CLOSE, _("Close"),
|
||||||
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
|
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
|
||||||
|
|
||||||
x += gap + buttonWidth;
|
x += gap + buttonWidth;
|
||||||
|
|
||||||
if (buttonFlags & wxPREVIEW_PRINT)
|
if (m_buttonFlags & wxPREVIEW_PRINT)
|
||||||
{
|
{
|
||||||
printButton = new wxButton(this, wxID_PREVIEW_PRINT, _("Print..."), wxPoint(x, y),
|
m_printButton = new wxButton(this, wxID_PREVIEW_PRINT, _("Print..."), wxPoint(x, y),
|
||||||
wxSize(buttonWidth, buttonHeight));
|
wxSize(buttonWidth, buttonHeight));
|
||||||
x += gap + buttonWidth;
|
x += gap + buttonWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttonFlags & wxPREVIEW_PREVIOUS)
|
if (m_buttonFlags & wxPREVIEW_PREVIOUS)
|
||||||
{
|
{
|
||||||
previousPageButton = new wxButton(this, wxID_PREVIEW_PREVIOUS, "<<", wxPoint(x, y),
|
m_previousPageButton = new wxButton(this, wxID_PREVIEW_PREVIOUS, "<<", wxPoint(x, y),
|
||||||
wxSize(buttonWidth, buttonHeight));
|
wxSize(buttonWidth, buttonHeight));
|
||||||
x += gap + buttonWidth;
|
x += gap + buttonWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttonFlags & wxPREVIEW_NEXT)
|
if (m_buttonFlags & wxPREVIEW_NEXT)
|
||||||
{
|
{
|
||||||
nextPageButton = new wxButton(this, wxID_PREVIEW_NEXT, ">>",
|
m_nextPageButton = new wxButton(this, wxID_PREVIEW_NEXT, ">>",
|
||||||
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
|
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
|
||||||
x += gap + buttonWidth;
|
x += gap + buttonWidth;
|
||||||
}
|
}
|
||||||
@@ -383,14 +362,14 @@ void wxPreviewControlBar::CreateButtons(void)
|
|||||||
static wxString choices[] = { "10%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", "55%", "60%",
|
static wxString choices[] = { "10%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", "55%", "60%",
|
||||||
"65%", "70%", "75%", "80%", "85%", "90%", "95%", "100%", "110%", "120%", "150%", "200%" };
|
"65%", "70%", "75%", "80%", "85%", "90%", "95%", "100%", "110%", "120%", "150%", "200%" };
|
||||||
int n = 22;
|
int n = 22;
|
||||||
if (buttonFlags & wxPREVIEW_ZOOM)
|
if (m_buttonFlags & wxPREVIEW_ZOOM)
|
||||||
{
|
{
|
||||||
zoomControl = new wxChoice(this, wxID_PREVIEW_ZOOM, wxPoint(x, y),
|
m_zoomControl = new wxChoice(this, wxID_PREVIEW_ZOOM, wxPoint(x, y),
|
||||||
wxSize(100, -1), n, (wxString *)choices);
|
wxSize(100, -1), n, (wxString *)choices);
|
||||||
SetZoomControl(printPreview->GetZoom());
|
SetZoomControl(m_printPreview->GetZoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
closeButton->SetDefault();
|
m_closeButton->SetDefault();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -400,18 +379,18 @@ void wxPreviewControlBar::SetZoomControl(int zoom)
|
|||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
char buf[20];
|
char buf[20];
|
||||||
sprintf(buf, "%d%%", zoom);
|
sprintf(buf, "%d%%", zoom);
|
||||||
if (zoomControl)
|
if (m_zoomControl)
|
||||||
zoomControl->SetStringSelection(buf);
|
m_zoomControl->SetStringSelection(buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxPreviewControlBar::GetZoomControl(void)
|
int wxPreviewControlBar::GetZoomControl()
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
char buf[20];
|
char buf[20];
|
||||||
if (zoomControl && zoomControl->GetStringSelection())
|
if (m_zoomControl && m_zoomControl->GetStringSelection())
|
||||||
{
|
{
|
||||||
strcpy(buf, zoomControl->GetStringSelection());
|
strcpy(buf, m_zoomControl->GetStringSelection());
|
||||||
buf[strlen(buf) - 1] = 0;
|
buf[strlen(buf) - 1] = 0;
|
||||||
return (int)atoi(buf);
|
return (int)atoi(buf);
|
||||||
}
|
}
|
||||||
@@ -431,40 +410,39 @@ wxPreviewFrame::wxPreviewFrame(wxPrintPreviewBase *preview, wxFrame *parent, con
|
|||||||
wxFrame(parent, -1, title, pos, size, style, name)
|
wxFrame(parent, -1, title, pos, size, style, name)
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
|
m_printPreview = preview;
|
||||||
printPreview = preview;
|
m_controlBar = NULL;
|
||||||
controlBar = NULL;
|
m_previewCanvas = NULL;
|
||||||
previewCanvas = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPreviewFrame::~wxPreviewFrame(void)
|
wxPreviewFrame::~wxPreviewFrame()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPreviewFrame::OnClose(void)
|
bool wxPreviewFrame::OnClose()
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
|
|
||||||
MakeModal(FALSE);
|
MakeModal(FALSE);
|
||||||
|
|
||||||
// Need to delete the printout and the print preview
|
// Need to delete the printout and the print preview
|
||||||
wxPrintout *printout = printPreview->GetPrintout();
|
wxPrintout *printout = m_printPreview->GetPrintout();
|
||||||
if (printout)
|
if (printout)
|
||||||
{
|
{
|
||||||
delete printout;
|
delete printout;
|
||||||
printPreview->SetPrintout(NULL);
|
m_printPreview->SetPrintout(NULL);
|
||||||
printPreview->SetCanvas(NULL);
|
m_printPreview->SetCanvas(NULL);
|
||||||
printPreview->SetFrame(NULL);
|
m_printPreview->SetFrame(NULL);
|
||||||
}
|
}
|
||||||
delete printPreview;
|
delete m_printPreview;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else
|
#else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPreviewFrame::Initialize(void)
|
void wxPreviewFrame::Initialize()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
@@ -474,15 +452,15 @@ void wxPreviewFrame::Initialize(void)
|
|||||||
CreateCanvas();
|
CreateCanvas();
|
||||||
CreateControlBar();
|
CreateControlBar();
|
||||||
|
|
||||||
printPreview->SetCanvas(previewCanvas);
|
m_printPreview->SetCanvas(m_previewCanvas);
|
||||||
printPreview->SetFrame(this);
|
m_printPreview->SetFrame(this);
|
||||||
|
|
||||||
// Set layout constraints here
|
// Set layout constraints here
|
||||||
|
|
||||||
// Control bar constraints
|
// Control bar constraints
|
||||||
wxLayoutConstraints *c1 = new wxLayoutConstraints;
|
wxLayoutConstraints *c1 = new wxLayoutConstraints;
|
||||||
// int w, h;
|
// int w, h;
|
||||||
// controlBar->GetSize(&w, &h);
|
// m_controlBar->GetSize(&w, &h);
|
||||||
int h;
|
int h;
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
h = 40;
|
h = 40;
|
||||||
@@ -495,17 +473,17 @@ void wxPreviewFrame::Initialize(void)
|
|||||||
c1->right.SameAs (this, wxRight);
|
c1->right.SameAs (this, wxRight);
|
||||||
c1->height.Absolute (h);
|
c1->height.Absolute (h);
|
||||||
|
|
||||||
controlBar->SetConstraints(c1);
|
m_controlBar->SetConstraints(c1);
|
||||||
|
|
||||||
// Canvas constraints
|
// Canvas constraints
|
||||||
wxLayoutConstraints *c2 = new wxLayoutConstraints;
|
wxLayoutConstraints *c2 = new wxLayoutConstraints;
|
||||||
|
|
||||||
c2->left.SameAs (this, wxLeft);
|
c2->left.SameAs (this, wxLeft);
|
||||||
c2->top.Below (controlBar);
|
c2->top.Below (m_controlBar);
|
||||||
c2->right.SameAs (this, wxRight);
|
c2->right.SameAs (this, wxRight);
|
||||||
c2->bottom.SameAs (this, wxBottom);
|
c2->bottom.SameAs (this, wxBottom);
|
||||||
|
|
||||||
previewCanvas->SetConstraints(c2);
|
m_previewCanvas->SetConstraints(c2);
|
||||||
|
|
||||||
SetAutoLayout(TRUE);
|
SetAutoLayout(TRUE);
|
||||||
|
|
||||||
@@ -516,25 +494,25 @@ void wxPreviewFrame::Initialize(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPreviewFrame::CreateCanvas(void)
|
void wxPreviewFrame::CreateCanvas()
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
|
|
||||||
previewCanvas = new wxPreviewCanvas(printPreview, this);
|
m_previewCanvas = new wxPreviewCanvas(m_printPreview, this);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPreviewFrame::CreateControlBar(void)
|
void wxPreviewFrame::CreateControlBar()
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
|
|
||||||
long buttons = wxPREVIEW_DEFAULT;
|
long buttons = wxPREVIEW_DEFAULT;
|
||||||
if (printPreview->GetPrintoutForPrinting())
|
if (m_printPreview->GetPrintoutForPrinting())
|
||||||
buttons |= wxPREVIEW_PRINT;
|
buttons |= wxPREVIEW_PRINT;
|
||||||
|
|
||||||
controlBar = new wxPreviewControlBar(printPreview, buttons, this, wxPoint(0, 0), wxSize(400, 40));
|
m_controlBar = new wxPreviewControlBar(m_printPreview, buttons, this, wxPoint(0, 0), wxSize(400, 40));
|
||||||
controlBar->CreateButtons();
|
m_controlBar->CreateButtons();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,44 +525,44 @@ wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printou
|
|||||||
|
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
|
|
||||||
isOk = TRUE;
|
m_isOk = TRUE;
|
||||||
previewPrintout = printout;
|
m_previewPrintout = printout;
|
||||||
if (previewPrintout)
|
if (m_previewPrintout)
|
||||||
previewPrintout->SetIsPreview(TRUE);
|
m_previewPrintout->SetIsPreview(TRUE);
|
||||||
|
|
||||||
printPrintout = printoutForPrinting;
|
m_printPrintout = printoutForPrinting;
|
||||||
if (data)
|
if (data)
|
||||||
printData = (*data);
|
m_printData = (*data);
|
||||||
|
|
||||||
previewCanvas = NULL;
|
m_previewCanvas = NULL;
|
||||||
previewFrame = NULL;
|
m_previewFrame = NULL;
|
||||||
previewBitmap = NULL;
|
m_previewBitmap = NULL;
|
||||||
currentPage = 1;
|
m_currentPage = 1;
|
||||||
currentZoom = 30;
|
m_currentZoom = 30;
|
||||||
topMargin = 40;
|
m_topMargin = 40;
|
||||||
leftMargin = 40;
|
m_leftMargin = 40;
|
||||||
pageWidth = 0;
|
m_pageWidth = 0;
|
||||||
pageHeight = 0;
|
m_pageHeight = 0;
|
||||||
|
|
||||||
printout->OnPreparePrinting();
|
printout->OnPreparePrinting();
|
||||||
|
|
||||||
// Get some parameters from the printout, if defined
|
// Get some parameters from the printout, if defined
|
||||||
int selFrom, selTo;
|
int selFrom, selTo;
|
||||||
printout->GetPageInfo(&minPage, &maxPage, &selFrom, &selTo);
|
printout->GetPageInfo(&m_minPage, &m_maxPage, &selFrom, &selTo);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintPreviewBase::~wxPrintPreviewBase(void)
|
wxPrintPreviewBase::~wxPrintPreviewBase()
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
|
|
||||||
if (previewPrintout)
|
if (m_previewPrintout)
|
||||||
delete previewPrintout;
|
delete m_previewPrintout;
|
||||||
if (previewBitmap)
|
if (m_previewBitmap)
|
||||||
delete previewBitmap;
|
delete m_previewBitmap;
|
||||||
if (printPrintout)
|
if (m_printPrintout)
|
||||||
delete printPrintout;
|
delete m_printPrintout;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -592,20 +570,20 @@ wxPrintPreviewBase::~wxPrintPreviewBase(void)
|
|||||||
bool wxPrintPreviewBase::SetCurrentPage(int pageNum)
|
bool wxPrintPreviewBase::SetCurrentPage(int pageNum)
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
if (currentPage == pageNum)
|
if (m_currentPage == pageNum)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
currentPage = pageNum;
|
m_currentPage = pageNum;
|
||||||
if (previewBitmap)
|
if (m_previewBitmap)
|
||||||
{
|
{
|
||||||
delete previewBitmap;
|
delete m_previewBitmap;
|
||||||
previewBitmap = NULL;
|
m_previewBitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previewCanvas)
|
if (m_previewCanvas)
|
||||||
{
|
{
|
||||||
RenderPage(pageNum);
|
RenderPage(pageNum);
|
||||||
previewCanvas->Refresh();
|
m_previewCanvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -619,10 +597,10 @@ bool wxPrintPreviewBase::PaintPage(wxWindow *canvas, wxDC& dc)
|
|||||||
|
|
||||||
DrawBlankPage(canvas, dc);
|
DrawBlankPage(canvas, dc);
|
||||||
|
|
||||||
if (!previewBitmap)
|
if (!m_previewBitmap)
|
||||||
RenderPage(currentPage);
|
RenderPage(m_currentPage);
|
||||||
|
|
||||||
if (!previewBitmap)
|
if (!m_previewBitmap)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!canvas)
|
if (!canvas)
|
||||||
@@ -631,19 +609,19 @@ bool wxPrintPreviewBase::PaintPage(wxWindow *canvas, wxDC& dc)
|
|||||||
int canvasWidth, canvasHeight;
|
int canvasWidth, canvasHeight;
|
||||||
canvas->GetSize(&canvasWidth, &canvasHeight);
|
canvas->GetSize(&canvasWidth, &canvasHeight);
|
||||||
|
|
||||||
float zoomScale = (float)((float)currentZoom/(float)100);
|
double zoomScale = ((float)m_currentZoom/(float)100);
|
||||||
float actualWidth = (float)(zoomScale*pageWidth*previewScale);
|
double actualWidth = (zoomScale*m_pageWidth*m_previewScale);
|
||||||
// float actualHeight = (float)(zoomScale*pageHeight*previewScale);
|
// float actualHeight = (float)(zoomScale*m_pageHeight*m_previewScale);
|
||||||
|
|
||||||
float x = (float)((canvasWidth - actualWidth)/2.0);
|
int x = ((canvasWidth - actualWidth)/2.0);
|
||||||
if (x < leftMargin)
|
if (x < m_leftMargin)
|
||||||
x = (float)leftMargin;
|
x = m_leftMargin;
|
||||||
float y = (float)topMargin;
|
int y = m_topMargin;
|
||||||
|
|
||||||
wxMemoryDC temp_dc;
|
wxMemoryDC temp_dc;
|
||||||
temp_dc.SelectObject(*previewBitmap);
|
temp_dc.SelectObject(*m_previewBitmap);
|
||||||
|
|
||||||
dc.Blit((float)x, (float)y, (float)previewBitmap->GetWidth(), (float)previewBitmap->GetHeight(), &temp_dc, (float)0, (float)0);
|
dc.Blit(x, y, m_previewBitmap->GetWidth(), m_previewBitmap->GetHeight(), &temp_dc, 0, 0);
|
||||||
|
|
||||||
temp_dc.SelectObject(wxNullBitmap);
|
temp_dc.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
@@ -658,74 +636,74 @@ bool wxPrintPreviewBase::RenderPage(int pageNum)
|
|||||||
|
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
|
|
||||||
if (!previewCanvas)
|
if (!m_previewCanvas)
|
||||||
{
|
{
|
||||||
wxMessageBox(_("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!"),
|
wxMessageBox(_("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!"),
|
||||||
_("Print Preview Failure"), wxOK);
|
_("Print Preview Failure"), wxOK);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
previewCanvas->GetSize(&canvasWidth, &canvasHeight);
|
m_previewCanvas->GetSize(&canvasWidth, &canvasHeight);
|
||||||
|
|
||||||
float zoomScale = (float)((float)currentZoom/(float)100);
|
double zoomScale = (m_currentZoom/100.0);
|
||||||
float actualWidth = (float)(zoomScale*pageWidth*previewScale);
|
int actualWidth = (int)(zoomScale*m_pageWidth*m_previewScale);
|
||||||
float actualHeight = (float)(zoomScale*pageHeight*previewScale);
|
int actualHeight = (int)(zoomScale*m_pageHeight*m_previewScale);
|
||||||
|
|
||||||
float x = (float)((canvasWidth - actualWidth)/2.0);
|
int x = (int)((canvasWidth - actualWidth)/2.0);
|
||||||
if (x < leftMargin)
|
if (x < m_leftMargin)
|
||||||
x = (float)leftMargin;
|
x = m_leftMargin;
|
||||||
// float y = topMargin;
|
// int y = m_topMargin;
|
||||||
|
|
||||||
|
|
||||||
if (!previewBitmap)
|
if (!m_previewBitmap)
|
||||||
{
|
{
|
||||||
previewBitmap = new wxBitmap((int)actualWidth, (int)actualHeight);
|
m_previewBitmap = new wxBitmap((int)actualWidth, (int)actualHeight);
|
||||||
if (!previewBitmap || !previewBitmap->Ok())
|
if (!m_previewBitmap || !m_previewBitmap->Ok())
|
||||||
{
|
{
|
||||||
if (previewBitmap)
|
if (m_previewBitmap)
|
||||||
delete previewBitmap;
|
delete m_previewBitmap;
|
||||||
wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK);
|
wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMemoryDC memoryDC;
|
wxMemoryDC memoryDC;
|
||||||
memoryDC.SelectObject(*previewBitmap);
|
memoryDC.SelectObject(*m_previewBitmap);
|
||||||
|
|
||||||
memoryDC.Clear();
|
memoryDC.Clear();
|
||||||
|
|
||||||
previewPrintout->SetDC(&memoryDC);
|
m_previewPrintout->SetDC(&memoryDC);
|
||||||
previewPrintout->SetPageSizePixels(pageWidth, pageHeight);
|
m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight);
|
||||||
|
|
||||||
previewPrintout->OnBeginPrinting();
|
m_previewPrintout->OnBeginPrinting();
|
||||||
|
|
||||||
|
|
||||||
if (!previewPrintout->OnBeginDocument(printData.GetFromPage(), printData.GetToPage()))
|
if (!m_previewPrintout->OnBeginDocument(m_printData.GetFromPage(), m_printData.GetToPage()))
|
||||||
{
|
{
|
||||||
wxMessageBox(_("Could not start document preview."), _("Print Preview Failure"), wxOK);
|
wxMessageBox(_("Could not start document preview."), _("Print Preview Failure"), wxOK);
|
||||||
|
|
||||||
memoryDC.SelectObject(wxNullBitmap);
|
memoryDC.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
delete previewBitmap;
|
delete m_previewBitmap;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
previewPrintout->OnPrintPage(pageNum);
|
m_previewPrintout->OnPrintPage(pageNum);
|
||||||
previewPrintout->OnEndDocument();
|
m_previewPrintout->OnEndDocument();
|
||||||
previewPrintout->OnEndPrinting();
|
m_previewPrintout->OnEndPrinting();
|
||||||
|
|
||||||
previewPrintout->SetDC(NULL);
|
m_previewPrintout->SetDC(NULL);
|
||||||
|
|
||||||
memoryDC.SelectObject(wxNullBitmap);
|
memoryDC.SelectObject(wxNullBitmap);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char buf[200];
|
char buf[200];
|
||||||
if (maxPage != 0)
|
if (m_maxPage != 0)
|
||||||
sprintf(buf, _("Page %d of %d"), pageNum, maxPage);
|
sprintf(buf, _("Page %d of %d"), pageNum, m_maxPage);
|
||||||
else
|
else
|
||||||
sprintf(buf, _("Page %d"), pageNum);
|
sprintf(buf, _("Page %d"), pageNum);
|
||||||
|
|
||||||
if (previewFrame)
|
if (m_previewFrame)
|
||||||
previewFrame->SetStatusText(buf);
|
m_previewFrame->SetStatusText(buf);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -739,14 +717,14 @@ bool wxPrintPreviewBase::DrawBlankPage(wxWindow *canvas, wxDC& dc)
|
|||||||
int canvasWidth, canvasHeight;
|
int canvasWidth, canvasHeight;
|
||||||
canvas->GetSize(&canvasWidth, &canvasHeight);
|
canvas->GetSize(&canvasWidth, &canvasHeight);
|
||||||
|
|
||||||
float zoomScale = (float)((float)currentZoom/(float)100);
|
float zoomScale = (float)((float)m_currentZoom/(float)100);
|
||||||
float actualWidth = zoomScale*pageWidth*previewScale;
|
float actualWidth = zoomScale*m_pageWidth*m_previewScale;
|
||||||
float actualHeight = zoomScale*pageHeight*previewScale;
|
float actualHeight = zoomScale*m_pageHeight*m_previewScale;
|
||||||
|
|
||||||
float x = (float)((canvasWidth - actualWidth)/2.0);
|
float x = (float)((canvasWidth - actualWidth)/2.0);
|
||||||
if (x < leftMargin)
|
if (x < m_leftMargin)
|
||||||
x = (float)leftMargin;
|
x = (float)m_leftMargin;
|
||||||
float y = (float)topMargin;
|
float y = (float)m_topMargin;
|
||||||
|
|
||||||
// Draw shadow, allowing for 1-pixel border AROUND the actual page
|
// Draw shadow, allowing for 1-pixel border AROUND the actual page
|
||||||
int shadowOffset = 4;
|
int shadowOffset = 4;
|
||||||
@@ -769,21 +747,21 @@ bool wxPrintPreviewBase::DrawBlankPage(wxWindow *canvas, wxDC& dc)
|
|||||||
void wxPrintPreviewBase::SetZoom(int percent)
|
void wxPrintPreviewBase::SetZoom(int percent)
|
||||||
{
|
{
|
||||||
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
#ifdef __GOOD_COMPILER__ // Robert Roebling
|
||||||
if (currentZoom == percent)
|
if (m_currentZoom == percent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentZoom = percent;
|
m_currentZoom = percent;
|
||||||
if (previewBitmap)
|
if (m_previewBitmap)
|
||||||
{
|
{
|
||||||
delete previewBitmap;
|
delete m_previewBitmap;
|
||||||
previewBitmap = NULL;
|
m_previewBitmap = NULL;
|
||||||
}
|
}
|
||||||
RenderPage(currentPage);
|
RenderPage(m_currentPage);
|
||||||
|
|
||||||
if (previewCanvas)
|
if (m_previewCanvas)
|
||||||
{
|
{
|
||||||
previewCanvas->Clear();
|
m_previewCanvas->Clear();
|
||||||
previewCanvas->Refresh();
|
m_previewCanvas->Refresh();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -57,8 +57,8 @@ wxPostScriptPrinter::~wxPostScriptPrinter(void)
|
|||||||
|
|
||||||
bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
||||||
{
|
{
|
||||||
abortIt = FALSE;
|
sm_abortIt = FALSE;
|
||||||
abortWindow = (wxWindow *) NULL;
|
sm_abortWindow = (wxWindow *) NULL;
|
||||||
|
|
||||||
if (!printout)
|
if (!printout)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -74,37 +74,37 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
|
|||||||
if (maxPage == 0)
|
if (maxPage == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
printData.SetMinPage(minPage);
|
m_printData.SetMinPage(minPage);
|
||||||
printData.SetMaxPage(maxPage);
|
m_printData.SetMaxPage(maxPage);
|
||||||
if (fromPage != 0)
|
if (fromPage != 0)
|
||||||
printData.SetFromPage(fromPage);
|
m_printData.SetFromPage(fromPage);
|
||||||
if (toPage != 0)
|
if (toPage != 0)
|
||||||
printData.SetToPage(toPage);
|
m_printData.SetToPage(toPage);
|
||||||
|
|
||||||
if (minPage != 0)
|
if (minPage != 0)
|
||||||
{
|
{
|
||||||
printData.EnablePageNumbers(TRUE);
|
m_printData.EnablePageNumbers(TRUE);
|
||||||
if (printData.GetFromPage() < printData.GetMinPage())
|
if (m_printData.GetFromPage() < m_printData.GetMinPage())
|
||||||
printData.SetFromPage(printData.GetMinPage());
|
m_printData.SetFromPage(m_printData.GetMinPage());
|
||||||
else if (printData.GetFromPage() > printData.GetMaxPage())
|
else if (m_printData.GetFromPage() > m_printData.GetMaxPage())
|
||||||
printData.SetFromPage(printData.GetMaxPage());
|
m_printData.SetFromPage(m_printData.GetMaxPage());
|
||||||
if (printData.GetToPage() > printData.GetMaxPage())
|
if (m_printData.GetToPage() > m_printData.GetMaxPage())
|
||||||
printData.SetToPage(printData.GetMaxPage());
|
m_printData.SetToPage(m_printData.GetMaxPage());
|
||||||
else if (printData.GetToPage() < printData.GetMinPage())
|
else if (m_printData.GetToPage() < m_printData.GetMinPage())
|
||||||
printData.SetToPage(printData.GetMinPage());
|
m_printData.SetToPage(m_printData.GetMinPage());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printData.EnablePageNumbers(FALSE);
|
m_printData.EnablePageNumbers(FALSE);
|
||||||
|
|
||||||
// Create a suitable device context
|
// Create a suitable device context
|
||||||
wxDC *dc = (wxDC *) NULL;
|
wxDC *dc = (wxDC *) NULL;
|
||||||
if (prompt)
|
if (prompt)
|
||||||
{
|
{
|
||||||
wxGenericPrintDialog dialog(parent, & printData);
|
wxGenericPrintDialog dialog(parent, & m_printData);
|
||||||
if (dialog.ShowModal() == wxID_OK)
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
dc = dialog.GetPrintDC();
|
dc = dialog.GetPrintDC();
|
||||||
printData = dialog.GetPrintData();
|
m_printData = dialog.GetPrintData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -151,22 +151,22 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
|
|||||||
bool keepGoing = TRUE;
|
bool keepGoing = TRUE;
|
||||||
|
|
||||||
int copyCount;
|
int copyCount;
|
||||||
for (copyCount = 1; copyCount <= printData.GetNoCopies(); copyCount ++)
|
for (copyCount = 1; copyCount <= m_printData.GetNoCopies(); copyCount ++)
|
||||||
{
|
{
|
||||||
if (!printout->OnBeginDocument(printData.GetFromPage(), printData.GetToPage()))
|
if (!printout->OnBeginDocument(m_printData.GetFromPage(), m_printData.GetToPage()))
|
||||||
{
|
{
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
wxMessageBox(_("Could not start printing."), _("Print Error"), wxOK, parent);
|
wxMessageBox(_("Could not start printing."), _("Print Error"), wxOK, parent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (abortIt)
|
if (sm_abortIt)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int pn;
|
int pn;
|
||||||
for (pn = printData.GetFromPage(); keepGoing && (pn <= printData.GetToPage()) && printout->HasPage(pn);
|
for (pn = m_printData.GetFromPage(); keepGoing && (pn <= m_printData.GetToPage()) && printout->HasPage(pn);
|
||||||
pn++)
|
pn++)
|
||||||
{
|
{
|
||||||
if (abortIt)
|
if (sm_abortIt)
|
||||||
{
|
{
|
||||||
keepGoing = FALSE;
|
keepGoing = FALSE;
|
||||||
break;
|
break;
|
||||||
@@ -192,13 +192,13 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
|
|||||||
|
|
||||||
bool wxPostScriptPrinter::PrintDialog(wxWindow *parent)
|
bool wxPostScriptPrinter::PrintDialog(wxWindow *parent)
|
||||||
{
|
{
|
||||||
wxGenericPrintDialog dialog(parent, & printData);
|
wxGenericPrintDialog dialog(parent, & m_printData);
|
||||||
return (dialog.ShowModal() == wxID_OK);
|
return (dialog.ShowModal() == wxID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPostScriptPrinter::Setup(wxWindow *parent)
|
bool wxPostScriptPrinter::Setup(wxWindow *parent)
|
||||||
{
|
{
|
||||||
wxGenericPrintDialog dialog(parent, & printData);
|
wxGenericPrintDialog dialog(parent, & m_printData);
|
||||||
dialog.GetPrintData().SetSetupDialog(TRUE);
|
dialog.GetPrintData().SetSetupDialog(TRUE);
|
||||||
return (dialog.ShowModal() == wxID_OK);
|
return (dialog.ShowModal() == wxID_OK);
|
||||||
}
|
}
|
||||||
@@ -220,10 +220,10 @@ wxPostScriptPrintPreview::~wxPostScriptPrintPreview(void)
|
|||||||
|
|
||||||
bool wxPostScriptPrintPreview::Print(bool interactive)
|
bool wxPostScriptPrintPreview::Print(bool interactive)
|
||||||
{
|
{
|
||||||
if (!printPrintout)
|
if (!m_printPrintout)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wxPostScriptPrinter printer(&printData);
|
wxPostScriptPrinter printer(&m_printData);
|
||||||
return printer.Print(previewFrame, printPrintout, interactive);
|
return printer.Print(m_previewFrame, m_printPrintout, interactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPostScriptPrintPreview::DetermineScaling(void)
|
void wxPostScriptPrintPreview::DetermineScaling(void)
|
||||||
@@ -237,29 +237,29 @@ void wxPostScriptPrintPreview::DetermineScaling(void)
|
|||||||
paper = wxThePrintPaperDatabase->FindPaperType(_("A4 210 x 297 mm"));
|
paper = wxThePrintPaperDatabase->FindPaperType(_("A4 210 x 297 mm"));
|
||||||
if (paper)
|
if (paper)
|
||||||
{
|
{
|
||||||
previewPrintout->SetPPIScreen(100, 100);
|
m_previewPrintout->SetPPIScreen(100, 100);
|
||||||
previewPrintout->SetPPIPrinter(100, 100);
|
m_previewPrintout->SetPPIPrinter(100, 100);
|
||||||
|
|
||||||
// If in landscape mode, we need to swap the width and height.
|
// If in landscape mode, we need to swap the width and height.
|
||||||
if ( printData.GetOrientation() == wxLANDSCAPE )
|
if ( m_printData.GetOrientation() == wxLANDSCAPE )
|
||||||
{
|
{
|
||||||
pageWidth = paper->heightPixels;
|
m_pageWidth = paper->heightPixels;
|
||||||
pageHeight = paper->widthPixels;
|
m_pageHeight = paper->widthPixels;
|
||||||
previewPrintout->SetPageSizeMM(paper->heightMM, paper->widthMM);
|
m_previewPrintout->SetPageSizeMM(paper->heightMM, paper->widthMM);
|
||||||
previewPrintout->SetPageSizePixels(paper->heightPixels, paper->widthPixels);
|
m_previewPrintout->SetPageSizePixels(paper->heightPixels, paper->widthPixels);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pageWidth = paper->widthPixels;
|
m_pageWidth = paper->widthPixels;
|
||||||
pageHeight = paper->heightPixels;
|
m_pageHeight = paper->heightPixels;
|
||||||
previewPrintout->SetPageSizeMM(paper->widthMM, paper->heightMM);
|
m_previewPrintout->SetPageSizeMM(paper->widthMM, paper->heightMM);
|
||||||
previewPrintout->SetPageSizePixels(paper->widthPixels, paper->heightPixels);
|
m_previewPrintout->SetPageSizePixels(paper->widthPixels, paper->heightPixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
// At 100%, the page should look about page-size on the screen.
|
// At 100%, the page should look about page-size on the screen.
|
||||||
previewScale = (float)0.8;
|
m_previewScale = (float)0.8;
|
||||||
// previewScale = (float)((float)screenWidth/(float)printerWidth);
|
// m_previewScale = (float)((float)screenWidth/(float)printerWidth);
|
||||||
// previewScale = previewScale * (float)((float)screenXRes/(float)printerYRes);
|
// m_previewScale = previewScale * (float)((float)screenXRes/(float)printerYRes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -648,6 +648,10 @@ void wxDC::SetFont(const wxFont& the_font)
|
|||||||
wxDebugMsg("wxDC::SetFont: Selecting HFONT %X\n", m_font.GetResourceHandle());
|
wxDebugMsg("wxDC::SetFont: Selecting HFONT %X\n", m_font.GetResourceHandle());
|
||||||
#endif
|
#endif
|
||||||
HFONT f = (HFONT) ::SelectObject((HDC) m_hDC, (HFONT) m_font.GetResourceHandle());
|
HFONT f = (HFONT) ::SelectObject((HDC) m_hDC, (HFONT) m_font.GetResourceHandle());
|
||||||
|
if (f == NULL)
|
||||||
|
{
|
||||||
|
wxDebugMsg("::SelectObject failed in wxDC::SetFont.");
|
||||||
|
}
|
||||||
if (!m_oldFont)
|
if (!m_oldFont)
|
||||||
m_oldFont = (WXHFONT) f;
|
m_oldFont = (WXHFONT) f;
|
||||||
}
|
}
|
||||||
@@ -716,6 +720,8 @@ void wxDC::SetBrush(const wxBrush& brush)
|
|||||||
|
|
||||||
void wxDC::DrawText(const wxString& text, long x, long y, bool use16bit)
|
void wxDC::DrawText(const wxString& text, long x, long y, bool use16bit)
|
||||||
{
|
{
|
||||||
|
// Should be unnecessary: SetFont should have done this already.
|
||||||
|
#if 0
|
||||||
if (m_font.Ok() && m_font.GetResourceHandle())
|
if (m_font.Ok() && m_font.GetResourceHandle())
|
||||||
{
|
{
|
||||||
#if WXDEBUG > 1
|
#if WXDEBUG > 1
|
||||||
@@ -725,6 +731,7 @@ void wxDC::DrawText(const wxString& text, long x, long y, bool use16bit)
|
|||||||
if (!m_oldFont)
|
if (!m_oldFont)
|
||||||
m_oldFont = (WXHFONT) f;
|
m_oldFont = (WXHFONT) f;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_textForegroundColour.Ok())
|
if (m_textForegroundColour.Ok())
|
||||||
SetTextColor((HDC) m_hDC, m_textForegroundColour.GetPixel() ) ;
|
SetTextColor((HDC) m_hDC, m_textForegroundColour.GetPixel() ) ;
|
||||||
@@ -838,31 +845,40 @@ bool wxDC::StartDoc(const wxString& message)
|
|||||||
if (!this->IsKindOf(CLASSINFO(wxPrinterDC)))
|
if (!this->IsKindOf(CLASSINFO(wxPrinterDC)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
bool flag = FALSE;
|
|
||||||
|
|
||||||
DOCINFO docinfo;
|
DOCINFO docinfo;
|
||||||
docinfo.cbSize = sizeof(DOCINFO);
|
docinfo.cbSize = sizeof(DOCINFO);
|
||||||
docinfo.lpszDocName = (const char *)message;
|
docinfo.lpszDocName = (const char *)message;
|
||||||
|
|
||||||
|
if (m_filename.IsEmpty())
|
||||||
|
docinfo.lpszOutput = NULL;
|
||||||
|
else
|
||||||
docinfo.lpszOutput = (const char *)m_filename;
|
docinfo.lpszOutput = (const char *)m_filename;
|
||||||
|
|
||||||
#if defined(__WIN95__)
|
#if defined(__WIN95__)
|
||||||
docinfo.lpszDatatype = NULL;
|
docinfo.lpszDatatype = NULL;
|
||||||
docinfo.fwType = 0;
|
docinfo.fwType = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_hDC) flag = (SP_ERROR !=
|
if (!m_hDC)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
int ret =
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
::StartDoc((HDC) m_hDC, &docinfo));
|
::StartDoc((HDC) m_hDC, &docinfo);
|
||||||
#else
|
#else
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
::StartDocW((HDC) m_hDC, &docinfo));
|
::StartDocW((HDC) m_hDC, &docinfo);
|
||||||
#else
|
#else
|
||||||
::StartDocA((HDC) m_hDC, &docinfo));
|
::StartDocA((HDC) m_hDC, &docinfo);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else flag = FALSE;
|
if (ret <= 0)
|
||||||
|
{
|
||||||
return flag;
|
DWORD lastError = GetLastError();
|
||||||
|
wxDebugMsg("wxDC::StartDoc failed with error: %d\n", lastError);
|
||||||
|
}
|
||||||
|
return (ret > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::EndDoc(void)
|
void wxDC::EndDoc(void)
|
||||||
|
@@ -158,13 +158,9 @@ bool wxFont::RealizeResource(void)
|
|||||||
else if (M_FONTDATA->m_weight == wxBOLD)
|
else if (M_FONTDATA->m_weight == wxBOLD)
|
||||||
ff_weight = FW_BOLD;
|
ff_weight = FW_BOLD;
|
||||||
|
|
||||||
#if defined(__X__) || (defined(__WXMSW__) && USE_PORTABLE_FONTS_IN_MSW)
|
const char* pzFace = (const char*) ff_face;
|
||||||
ff_face = wxTheFontNameDirectory.GetScreenName(M_FONTDATA->m_family, M_FONTDATA->m_weight, M_FONTDATA->m_style);
|
if (!M_FONTDATA->m_faceName.IsNull())
|
||||||
#else
|
pzFace = (const char*) M_FONTDATA->m_faceName ;
|
||||||
ff_face = M_FONTDATA->m_faceName;
|
|
||||||
if ( ff_face.IsNull() )
|
|
||||||
ff_face = "";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Always calculate fonts using the screen DC (is this the best strategy?)
|
/* Always calculate fonts using the screen DC (is this the best strategy?)
|
||||||
* There may be confusion if a font is selected into a printer
|
* There may be confusion if a font is selected into a printer
|
||||||
@@ -208,7 +204,7 @@ bool wxFont::RealizeResource(void)
|
|||||||
|
|
||||||
M_FONTDATA->m_hFont = (WXHFONT) CreateFont(nHeight, 0, 0, 0,ff_weight,ff_italic,(BYTE)ff_underline,
|
M_FONTDATA->m_hFont = (WXHFONT) CreateFont(nHeight, 0, 0, 0,ff_weight,ff_italic,(BYTE)ff_underline,
|
||||||
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||||
PROOF_QUALITY, DEFAULT_PITCH | ff_family, (ff_face == "" ? NULL : (const char *)ff_face));
|
PROOF_QUALITY, DEFAULT_PITCH | ff_family, pzFace);
|
||||||
#ifdef WXDEBUG_CREATE
|
#ifdef WXDEBUG_CREATE
|
||||||
if (m_hFont==NULL) wxError("Cannot create font","Internal Error") ;
|
if (m_hFont==NULL) wxError("Cannot create font","Internal Error") ;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -63,18 +63,18 @@ IMPLEMENT_CLASS(wxWindowsPrintPreview, wxPrintPreviewBase)
|
|||||||
wxWindowsPrinter::wxWindowsPrinter(wxPrintData *data):
|
wxWindowsPrinter::wxWindowsPrinter(wxPrintData *data):
|
||||||
wxPrinterBase(data)
|
wxPrinterBase(data)
|
||||||
{
|
{
|
||||||
lpAbortProc = (WXFARPROC) MakeProcInstance((FARPROC) wxAbortProc, wxGetInstance());
|
m_lpAbortProc = (WXFARPROC) MakeProcInstance((FARPROC) wxAbortProc, wxGetInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindowsPrinter::~wxWindowsPrinter(void)
|
wxWindowsPrinter::~wxWindowsPrinter(void)
|
||||||
{
|
{
|
||||||
FreeProcInstance((FARPROC) lpAbortProc);
|
FreeProcInstance((FARPROC) m_lpAbortProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
||||||
{
|
{
|
||||||
abortIt = FALSE;
|
sm_abortIt = FALSE;
|
||||||
abortWindow = NULL;
|
sm_abortWindow = NULL;
|
||||||
|
|
||||||
if (!printout)
|
if (!printout)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -90,42 +90,42 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
if (maxPage == 0)
|
if (maxPage == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
printData.SetMinPage(minPage);
|
m_printData.SetMinPage(minPage);
|
||||||
printData.SetMaxPage(maxPage);
|
m_printData.SetMaxPage(maxPage);
|
||||||
if (fromPage != 0)
|
if (fromPage != 0)
|
||||||
printData.SetFromPage(fromPage);
|
m_printData.SetFromPage(fromPage);
|
||||||
if (toPage != 0)
|
if (toPage != 0)
|
||||||
printData.SetToPage(toPage);
|
m_printData.SetToPage(toPage);
|
||||||
|
|
||||||
if (minPage != 0)
|
if (minPage != 0)
|
||||||
{
|
{
|
||||||
printData.EnablePageNumbers(TRUE);
|
m_printData.EnablePageNumbers(TRUE);
|
||||||
if (printData.GetFromPage() < printData.GetMinPage())
|
if (m_printData.GetFromPage() < m_printData.GetMinPage())
|
||||||
printData.SetFromPage(printData.GetMinPage());
|
m_printData.SetFromPage(m_printData.GetMinPage());
|
||||||
else if (printData.GetFromPage() > printData.GetMaxPage())
|
else if (m_printData.GetFromPage() > m_printData.GetMaxPage())
|
||||||
printData.SetFromPage(printData.GetMaxPage());
|
m_printData.SetFromPage(m_printData.GetMaxPage());
|
||||||
if (printData.GetToPage() > printData.GetMaxPage())
|
if (m_printData.GetToPage() > m_printData.GetMaxPage())
|
||||||
printData.SetToPage(printData.GetMaxPage());
|
m_printData.SetToPage(m_printData.GetMaxPage());
|
||||||
else if (printData.GetToPage() < printData.GetMinPage())
|
else if (m_printData.GetToPage() < m_printData.GetMinPage())
|
||||||
printData.SetToPage(printData.GetMinPage());
|
m_printData.SetToPage(m_printData.GetMinPage());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printData.EnablePageNumbers(FALSE);
|
m_printData.EnablePageNumbers(FALSE);
|
||||||
|
|
||||||
// Create a suitable device context
|
// Create a suitable device context
|
||||||
wxDC *dc = NULL;
|
wxDC *dc = NULL;
|
||||||
if (prompt)
|
if (prompt)
|
||||||
{
|
{
|
||||||
wxPrintDialog dialog(parent, & printData);
|
wxPrintDialog dialog(parent, & m_printData);
|
||||||
if (dialog.ShowModal() == wxID_OK)
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
dc = dialog.GetPrintDC();
|
dc = dialog.GetPrintDC();
|
||||||
printData = dialog.GetPrintData();
|
m_printData = dialog.GetPrintData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dc = new wxPrinterDC("", "", "", FALSE, printData.GetOrientation());
|
dc = new wxPrinterDC("", "", "", FALSE, m_printData.GetOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
// May have pressed cancel.
|
// May have pressed cancel.
|
||||||
@@ -173,7 +173,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
wxYield();
|
wxYield();
|
||||||
|
|
||||||
#if defined(__BORLANDC__) || defined(__GNUWIN32__) || !defined(__WIN32__)
|
#if defined(__BORLANDC__) || defined(__GNUWIN32__) || !defined(__WIN32__)
|
||||||
::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) lpAbortProc);
|
::SetAbortProc((HDC) dc->GetHDC(), (FARPROC) m_lpAbortProc);
|
||||||
#else
|
#else
|
||||||
::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *)
|
::SetAbortProc((HDC) dc->GetHDC(), (int (_stdcall *)
|
||||||
// cast it to right type only if required
|
// cast it to right type only if required
|
||||||
@@ -184,7 +184,7 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
#else
|
#else
|
||||||
()
|
()
|
||||||
#endif
|
#endif
|
||||||
)lpAbortProc);
|
)m_lpAbortProc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!win)
|
if (!win)
|
||||||
@@ -193,8 +193,8 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent);
|
wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent);
|
||||||
delete dc;
|
delete dc;
|
||||||
}
|
}
|
||||||
abortWindow = win;
|
sm_abortWindow = win;
|
||||||
abortWindow->Show(TRUE);
|
sm_abortWindow->Show(TRUE);
|
||||||
wxYield();
|
wxYield();
|
||||||
|
|
||||||
printout->OnBeginPrinting();
|
printout->OnBeginPrinting();
|
||||||
@@ -202,22 +202,22 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
bool keepGoing = TRUE;
|
bool keepGoing = TRUE;
|
||||||
|
|
||||||
int copyCount;
|
int copyCount;
|
||||||
for (copyCount = 1; copyCount <= printData.GetNoCopies(); copyCount ++)
|
for (copyCount = 1; copyCount <= m_printData.GetNoCopies(); copyCount ++)
|
||||||
{
|
{
|
||||||
if (!printout->OnBeginDocument(printData.GetFromPage(), printData.GetToPage()))
|
if (!printout->OnBeginDocument(m_printData.GetFromPage(), m_printData.GetToPage()))
|
||||||
{
|
{
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
wxMessageBox("Could not start printing.", "Print Error", wxOK, parent);
|
wxMessageBox("Could not start printing.", "Print Error", wxOK, parent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (abortIt)
|
if (sm_abortIt)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int pn;
|
int pn;
|
||||||
for (pn = printData.GetFromPage(); keepGoing && (pn <= printData.GetToPage()) && printout->HasPage(pn);
|
for (pn = m_printData.GetFromPage(); keepGoing && (pn <= m_printData.GetToPage()) && printout->HasPage(pn);
|
||||||
pn++)
|
pn++)
|
||||||
{
|
{
|
||||||
if (abortIt)
|
if (sm_abortIt)
|
||||||
{
|
{
|
||||||
keepGoing = FALSE;
|
keepGoing = FALSE;
|
||||||
break;
|
break;
|
||||||
@@ -236,11 +236,11 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
|
|
||||||
printout->OnEndPrinting();
|
printout->OnEndPrinting();
|
||||||
|
|
||||||
if (abortWindow)
|
if (sm_abortWindow)
|
||||||
{
|
{
|
||||||
abortWindow->Show(FALSE);
|
sm_abortWindow->Show(FALSE);
|
||||||
delete abortWindow;
|
delete sm_abortWindow;
|
||||||
abortWindow = NULL;
|
sm_abortWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
@@ -252,13 +252,13 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
|
|||||||
|
|
||||||
bool wxWindowsPrinter::PrintDialog(wxWindow *parent)
|
bool wxWindowsPrinter::PrintDialog(wxWindow *parent)
|
||||||
{
|
{
|
||||||
wxPrintDialog dialog(parent, & printData);
|
wxPrintDialog dialog(parent, & m_printData);
|
||||||
return (dialog.ShowModal() == wxID_OK);
|
return (dialog.ShowModal() == wxID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowsPrinter::Setup(wxWindow *parent)
|
bool wxWindowsPrinter::Setup(wxWindow *parent)
|
||||||
{
|
{
|
||||||
wxPrintDialog dialog(parent, & printData);
|
wxPrintDialog dialog(parent, & m_printData);
|
||||||
dialog.GetPrintData().SetSetupDialog(TRUE);
|
dialog.GetPrintData().SetSetupDialog(TRUE);
|
||||||
return (dialog.ShowModal() == wxID_OK);
|
return (dialog.ShowModal() == wxID_OK);
|
||||||
}
|
}
|
||||||
@@ -279,10 +279,10 @@ wxWindowsPrintPreview::~wxWindowsPrintPreview(void)
|
|||||||
|
|
||||||
bool wxWindowsPrintPreview::Print(bool interactive)
|
bool wxWindowsPrintPreview::Print(bool interactive)
|
||||||
{
|
{
|
||||||
if (!printPrintout)
|
if (!m_printPrintout)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wxWindowsPrinter printer(&printData);
|
wxWindowsPrinter printer(&m_printData);
|
||||||
return printer.Print(previewFrame, printPrintout, interactive);
|
return printer.Print(m_previewFrame, m_printPrintout, interactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowsPrintPreview::DetermineScaling(void)
|
void wxWindowsPrintPreview::DetermineScaling(void)
|
||||||
@@ -294,12 +294,12 @@ void wxWindowsPrintPreview::DetermineScaling(void)
|
|||||||
// int screenYRes = ::GetDeviceCaps(dc, VERTRES);
|
// int screenYRes = ::GetDeviceCaps(dc, VERTRES);
|
||||||
int logPPIScreenX = ::GetDeviceCaps(dc, LOGPIXELSX);
|
int logPPIScreenX = ::GetDeviceCaps(dc, LOGPIXELSX);
|
||||||
int logPPIScreenY = ::GetDeviceCaps(dc, LOGPIXELSY);
|
int logPPIScreenY = ::GetDeviceCaps(dc, LOGPIXELSY);
|
||||||
previewPrintout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
|
m_previewPrintout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
|
||||||
|
|
||||||
::ReleaseDC(NULL, dc);
|
::ReleaseDC(NULL, dc);
|
||||||
|
|
||||||
// Get a device context for the currently selected printer
|
// Get a device context for the currently selected printer
|
||||||
wxPrinterDC printerDC("", "", "", FALSE, printData.GetOrientation());
|
wxPrinterDC printerDC("", "", "", FALSE, m_printData.GetOrientation());
|
||||||
|
|
||||||
int printerWidth = 150;
|
int printerWidth = 150;
|
||||||
int printerHeight = 250;
|
int printerHeight = 250;
|
||||||
@@ -316,21 +316,21 @@ void wxWindowsPrintPreview::DetermineScaling(void)
|
|||||||
int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX);
|
int logPPIPrinterX = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSX);
|
||||||
int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY);
|
int logPPIPrinterY = ::GetDeviceCaps((HDC) printerDC.GetHDC(), LOGPIXELSY);
|
||||||
|
|
||||||
previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
|
m_previewPrintout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
|
||||||
previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
|
m_previewPrintout->SetPageSizeMM(printerWidth, printerHeight);
|
||||||
|
|
||||||
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
|
if (logPPIPrinterX == 0 || logPPIPrinterY == 0 || printerWidth == 0 || printerHeight == 0)
|
||||||
isOk = FALSE;
|
m_isOk = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
isOk = FALSE;
|
m_isOk = FALSE;
|
||||||
|
|
||||||
pageWidth = printerXRes;
|
m_pageWidth = printerXRes;
|
||||||
pageHeight = printerYRes;
|
m_pageHeight = printerYRes;
|
||||||
|
|
||||||
// At 100%, the page should look about page-size on the screen.
|
// At 100%, the page should look about page-size on the screen.
|
||||||
previewScale = (float)((float)screenWidth/(float)printerWidth);
|
m_previewScale = (float)((float)screenWidth/(float)printerWidth);
|
||||||
previewScale = previewScale * (float)((float)screenXRes/(float)printerYRes);
|
m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerYRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -345,19 +345,19 @@ LONG APIENTRY _EXPORT wxAbortProc(HDC WXUNUSED(hPr), int WXUNUSED(Code))
|
|||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
if (!wxPrinterBase::abortWindow) /* If the abort dialog isn't up yet */
|
if (!wxPrinterBase::sm_abortWindow) /* If the abort dialog isn't up yet */
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
|
||||||
/* Process messages intended for the abort dialog box */
|
/* Process messages intended for the abort dialog box */
|
||||||
|
|
||||||
while (!wxPrinterBase::abortIt && PeekMessage(&msg, 0, 0, 0, TRUE))
|
while (!wxPrinterBase::sm_abortIt && PeekMessage(&msg, 0, 0, 0, TRUE))
|
||||||
if (!IsDialogMessage((HWND) wxPrinterBase::abortWindow->GetHWND(), &msg)) {
|
if (!IsDialogMessage((HWND) wxPrinterBase::sm_abortWindow->GetHWND(), &msg)) {
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bAbort is TRUE (return is FALSE) if the user has aborted */
|
/* bAbort is TRUE (return is FALSE) if the user has aborted */
|
||||||
|
|
||||||
return (!wxPrinterBase::abortIt);
|
return (!wxPrinterBase::sm_abortIt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user