]>
Commit | Line | Data |
---|---|---|
6adaedf0 | 1 | ///////////////////////////////////////////////////////////////////////////// |
f415cab9 | 2 | // Name: samples/printing.h |
be5a51fb | 3 | // Purpose: Printing demo for wxWidgets |
6adaedf0 JS |
4 | // Author: Julian Smart |
5 | // Modified by: | |
6 | // Created: 1995 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
c801d85f | 11 | |
c801d85f KB |
12 | // Define a new application |
13 | class MyApp: public wxApp | |
14 | { | |
48ed4a89 FM |
15 | public: |
16 | MyApp() {} | |
17 | ||
18 | virtual bool OnInit(); | |
19 | virtual int OnExit(); | |
20 | ||
21 | void Draw(wxDC& dc); | |
34da0970 | 22 | |
48ed4a89 FM |
23 | void IncrementAngle() |
24 | { m_angle += 5; } | |
25 | void DecrementAngle() | |
26 | { m_angle -= 5; } | |
27 | ||
28 | wxFont& GetTestFont() | |
29 | { return m_testFont; } | |
30 | ||
31 | private: | |
32 | int m_angle; | |
33 | wxBitmap m_bitmap; | |
34 | wxFont m_testFont; | |
c801d85f KB |
35 | }; |
36 | ||
34da0970 | 37 | DECLARE_APP(MyApp) |
c801d85f KB |
38 | class MyCanvas; |
39 | ||
40 | // Define a new canvas and frame | |
41 | class MyFrame: public wxFrame | |
42 | { | |
48ed4a89 | 43 | public: |
c801d85f KB |
44 | MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size); |
45 | ||
cac7ac30 RR |
46 | void OnAngleUp(wxCommandEvent& event); |
47 | void OnAngleDown(wxCommandEvent& event); | |
c801d85f | 48 | |
c801d85f KB |
49 | void OnPrint(wxCommandEvent& event); |
50 | void OnPrintPreview(wxCommandEvent& event); | |
c801d85f | 51 | void OnPageSetup(wxCommandEvent& event); |
dfad0599 | 52 | #if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW |
c801d85f KB |
53 | void OnPrintPS(wxCommandEvent& event); |
54 | void OnPrintPreviewPS(wxCommandEvent& event); | |
c801d85f | 55 | void OnPageSetupPS(wxCommandEvent& event); |
dfad0599 | 56 | #endif |
f415cab9 JS |
57 | #ifdef __WXMAC__ |
58 | void OnPageMargins(wxCommandEvent& event); | |
59 | #endif | |
dfad0599 | 60 | |
c801d85f KB |
61 | void OnExit(wxCommandEvent& event); |
62 | void OnPrintAbout(wxCommandEvent& event); | |
48ed4a89 FM |
63 | |
64 | private: | |
65 | MyCanvas* m_canvas; | |
66 | ||
67 | DECLARE_EVENT_TABLE() | |
c801d85f KB |
68 | }; |
69 | ||
48ed4a89 | 70 | // Define a new white canvas |
c801d85f KB |
71 | class MyCanvas: public wxScrolledWindow |
72 | { | |
48ed4a89 | 73 | public: |
c801d85f | 74 | MyCanvas(wxFrame *frame, const wxPoint& pos, const wxSize& size, long style = wxRETAINED); |
c801d85f | 75 | |
48ed4a89 | 76 | //void OnPaint(wxPaintEvent& evt); |
c801d85f | 77 | virtual void OnDraw(wxDC& dc); |
c801d85f | 78 | |
48ed4a89 FM |
79 | private: |
80 | DECLARE_EVENT_TABLE() | |
c801d85f KB |
81 | }; |
82 | ||
48ed4a89 | 83 | // Defines a new printout class to print our document |
c801d85f KB |
84 | class MyPrintout: public wxPrintout |
85 | { | |
48ed4a89 | 86 | public: |
9a83f860 | 87 | MyPrintout(MyFrame* frame, const wxString &title = wxT("My printout")) |
48ed4a89 FM |
88 | : wxPrintout(title) { m_frame=frame; } |
89 | ||
ca8b470a VZ |
90 | virtual bool OnPrintPage(int page); |
91 | virtual bool HasPage(int page); | |
92 | virtual bool OnBeginDocument(int startPage, int endPage); | |
93 | virtual void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); | |
c801d85f | 94 | |
48ed4a89 FM |
95 | void DrawPageOne(); |
96 | void DrawPageTwo(); | |
f415cab9 | 97 | |
48ed4a89 FM |
98 | // Writes a header on a page. Margin units are in millimetres. |
99 | bool WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString& text, float mmToLogical); | |
f415cab9 | 100 | |
48ed4a89 FM |
101 | private: |
102 | MyFrame *m_frame; | |
c801d85f KB |
103 | }; |
104 | ||
48ed4a89 FM |
105 | |
106 | // constants: | |
107 | ||
c801d85f | 108 | #define WXPRINT_PAGE_SETUP 103 |
c801d85f KB |
109 | |
110 | #define WXPRINT_PRINT_PS 105 | |
c801d85f KB |
111 | #define WXPRINT_PAGE_SETUP_PS 107 |
112 | #define WXPRINT_PREVIEW_PS 108 | |
113 | ||
cac7ac30 RR |
114 | #define WXPRINT_ANGLEUP 110 |
115 | #define WXPRINT_ANGLEDOWN 111 | |
f415cab9 JS |
116 | |
117 | #ifdef __WXMAC__ | |
118 | #define WXPRINT_PAGE_MARGINS 112 | |
119 | #endif |