1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples/printing.h
3 // Purpose: Printing demo for wxWidgets
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // Define a new application
12 class MyApp
: public wxApp
17 virtual bool OnInit();
28 { return m_testFont
; }
39 // Define a new canvas and frame
40 class MyFrame
: public wxFrame
43 MyFrame(wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
45 void OnAngleUp(wxCommandEvent
& event
);
46 void OnAngleDown(wxCommandEvent
& event
);
48 void OnPrint(wxCommandEvent
& event
);
49 void OnPrintPreview(wxCommandEvent
& event
);
50 void OnPageSetup(wxCommandEvent
& event
);
52 void OnPrintPS(wxCommandEvent
& event
);
53 void OnPrintPreviewPS(wxCommandEvent
& event
);
54 void OnPageSetupPS(wxCommandEvent
& event
);
57 void OnPageMargins(wxCommandEvent
& event
);
60 void OnPreviewFrameModalityKind(wxCommandEvent
& event
);
62 void OnExit(wxCommandEvent
& event
);
63 void OnPrintAbout(wxCommandEvent
& event
);
67 wxPreviewFrameModalityKind m_previewModality
;
72 // Define a new white canvas
73 class MyCanvas
: public wxScrolledWindow
76 MyCanvas(wxFrame
*frame
, const wxPoint
& pos
, const wxSize
& size
, long style
= wxRETAINED
);
78 //void OnPaint(wxPaintEvent& evt);
79 virtual void OnDraw(wxDC
& dc
);
85 // Defines a new printout class to print our document
86 class MyPrintout
: public wxPrintout
89 MyPrintout(MyFrame
* frame
, const wxString
&title
= wxT("My printout"))
90 : wxPrintout(title
) { m_frame
=frame
; }
92 virtual bool OnPrintPage(int page
);
93 virtual bool HasPage(int page
);
94 virtual bool OnBeginDocument(int startPage
, int endPage
);
95 virtual void GetPageInfo(int *minPage
, int *maxPage
, int *selPageFrom
, int *selPageTo
);
100 // Writes a header on a page. Margin units are in millimetres.
101 bool WritePageHeader(wxPrintout
*printout
, wxDC
*dc
, const wxString
& text
, float mmToLogical
);
111 WXPRINT_PAGE_SETUP
= 103,
114 WXPRINT_PAGE_SETUP_PS
,
121 WXPRINT_PAGE_MARGINS
,
124 WXPRINT_FRAME_MODAL_APP
,
125 WXPRINT_FRAME_MODAL_WIN
,
126 WXPRINT_FRAME_MODAL_NON