1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/printing.h
3 // Purpose: Printing demo for wxWidgets
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // Define a new application
13 class MyApp
: public wxApp
18 virtual bool OnInit();
29 { return m_testFont
; }
40 // Define a new canvas and frame
41 class MyFrame
: public wxFrame
44 MyFrame(wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
46 void OnAngleUp(wxCommandEvent
& event
);
47 void OnAngleDown(wxCommandEvent
& event
);
49 void OnPrint(wxCommandEvent
& event
);
50 void OnPrintPreview(wxCommandEvent
& event
);
51 void OnPageSetup(wxCommandEvent
& event
);
52 #if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
53 void OnPrintPS(wxCommandEvent
& event
);
54 void OnPrintPreviewPS(wxCommandEvent
& event
);
55 void OnPageSetupPS(wxCommandEvent
& event
);
58 void OnPageMargins(wxCommandEvent
& event
);
61 void OnPreviewFrameModalityKind(wxCommandEvent
& event
);
63 void OnExit(wxCommandEvent
& event
);
64 void OnPrintAbout(wxCommandEvent
& event
);
68 wxPreviewFrameModalityKind m_previewModality
;
73 // Define a new white canvas
74 class MyCanvas
: public wxScrolledWindow
77 MyCanvas(wxFrame
*frame
, const wxPoint
& pos
, const wxSize
& size
, long style
= wxRETAINED
);
79 //void OnPaint(wxPaintEvent& evt);
80 virtual void OnDraw(wxDC
& dc
);
86 // Defines a new printout class to print our document
87 class MyPrintout
: public wxPrintout
90 MyPrintout(MyFrame
* frame
, const wxString
&title
= wxT("My printout"))
91 : wxPrintout(title
) { m_frame
=frame
; }
93 virtual bool OnPrintPage(int page
);
94 virtual bool HasPage(int page
);
95 virtual bool OnBeginDocument(int startPage
, int endPage
);
96 virtual void GetPageInfo(int *minPage
, int *maxPage
, int *selPageFrom
, int *selPageTo
);
101 // Writes a header on a page. Margin units are in millimetres.
102 bool WritePageHeader(wxPrintout
*printout
, wxDC
*dc
, const wxString
& text
, float mmToLogical
);
112 WXPRINT_PAGE_SETUP
= 103,
115 WXPRINT_PAGE_SETUP_PS
,
122 WXPRINT_PAGE_MARGINS
,
125 WXPRINT_FRAME_MODAL_APP
,
126 WXPRINT_FRAME_MODAL_WIN
,
127 WXPRINT_FRAME_MODAL_NON