]> git.saurik.com Git - wxWidgets.git/blame_incremental - samples/printing/printing.h
should have been part of r74664: Avoid calling gtk_window_get_position() from "config...
[wxWidgets.git] / samples / printing / printing.h
... / ...
CommitLineData
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
12class MyApp: public wxApp
13{
14public:
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
30private:
31 int m_angle;
32 wxBitmap m_bitmap;
33 wxFont m_testFont;
34};
35
36DECLARE_APP(MyApp)
37class MyCanvas;
38
39// Define a new canvas and frame
40class MyFrame: public wxFrame
41{
42public:
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
65private:
66 MyCanvas* m_canvas;
67 wxPreviewFrameModalityKind m_previewModality;
68
69 DECLARE_EVENT_TABLE()
70};
71
72// Define a new white canvas
73class MyCanvas: public wxScrolledWindow
74{
75public:
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
81private:
82 DECLARE_EVENT_TABLE()
83};
84
85// Defines a new printout class to print our document
86class MyPrintout: public wxPrintout
87{
88public:
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
103private:
104 MyFrame *m_frame;
105};
106
107
108// constants:
109enum
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};