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