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