]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: prntbase.h | |
3 | // Purpose: Base classes for printing framework | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
371a5b4e | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_PRNTBASEH__ |
13 | #define _WX_PRNTBASEH__ | |
c801d85f | 14 | |
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
d6b9496a | 16 | #pragma interface "prntbase.h" |
c801d85f KB |
17 | #endif |
18 | ||
19 | #include "wx/defs.h" | |
d427503c VZ |
20 | |
21 | #if wxUSE_PRINTING_ARCHITECTURE | |
22 | ||
c801d85f KB |
23 | #include "wx/event.h" |
24 | #include "wx/cmndata.h" | |
25 | #include "wx/panel.h" | |
26 | #include "wx/scrolwin.h" | |
27 | #include "wx/dialog.h" | |
34138703 | 28 | #include "wx/frame.h" |
c801d85f KB |
29 | |
30 | class WXDLLEXPORT wxDC; | |
31 | class WXDLLEXPORT wxButton; | |
32 | class WXDLLEXPORT wxChoice; | |
33 | class WXDLLEXPORT wxPrintout; | |
34 | class WXDLLEXPORT wxPrinterBase; | |
35 | class WXDLLEXPORT wxPrintDialog; | |
c061373d | 36 | class WXDLLEXPORT wxPrintDialogBase; |
c801d85f KB |
37 | class WXDLLEXPORT wxPrintPreviewBase; |
38 | class WXDLLEXPORT wxPreviewCanvas; | |
39 | class WXDLLEXPORT wxPreviewControlBar; | |
40 | class WXDLLEXPORT wxPreviewFrame; | |
e81e3883 | 41 | class WXDLLEXPORT wxPrintFactory; |
8850cbd3 | 42 | class WXDLLEXPORT wxPrintNativeDataBase; |
c801d85f | 43 | |
e81e3883 RR |
44 | //---------------------------------------------------------------------------- |
45 | // error consts | |
46 | //---------------------------------------------------------------------------- | |
f6bcfd97 BP |
47 | |
48 | enum wxPrinterError | |
49 | { | |
50 | wxPRINTER_NO_ERROR = 0, | |
51 | wxPRINTER_CANCELLED, | |
52 | wxPRINTER_ERROR | |
53 | }; | |
54 | ||
e81e3883 RR |
55 | //---------------------------------------------------------------------------- |
56 | // wxPrintFactory | |
57 | //---------------------------------------------------------------------------- | |
58 | ||
59 | class WXDLLEXPORT wxPrintFactory | |
60 | { | |
61 | public: | |
62 | wxPrintFactory() {} | |
63 | virtual ~wxPrintFactory() {} | |
64 | ||
e81e3883 | 65 | virtual wxPrinterBase *CreatePrinter( wxPrintDialogData* data ) = 0; |
c061373d | 66 | |
e81e3883 RR |
67 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, |
68 | wxPrintout *printout = NULL, | |
69 | wxPrintDialogData *data = NULL ) = 0; | |
70 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, | |
71 | wxPrintout *printout, | |
72 | wxPrintData *data ) = 0; | |
c061373d RR |
73 | |
74 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
75 | wxPrintDialogData *data = NULL ) = 0; | |
76 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
77 | wxPrintData *data ) = 0; | |
8850cbd3 | 78 | |
6038ec8e RR |
79 | // What to do and what to show in the wxPrintDialog |
80 | // a) Use the generic print setup dialog or a native one? | |
81 | virtual bool HasPrintSetupDialog() = 0; | |
82 | virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ) = 0; | |
83 | // b) Provide the "print to file" option ourselves or via print setup? | |
84 | virtual bool HasOwnPrintToFile() = 0; | |
85 | // c) Show current printer | |
86 | virtual bool HasPrinterLine() = 0; | |
87 | virtual wxString CreatePrinterLine() = 0; | |
88 | // d) Show Status line for current printer? | |
89 | virtual bool HasStatusLine() = 0; | |
90 | virtual wxString CreateStatusLine() = 0; | |
91 | ||
92 | ||
8850cbd3 | 93 | virtual wxPrintNativeDataBase *CreatePrintNativeData() = 0; |
e81e3883 RR |
94 | |
95 | static void SetPrintFactory( wxPrintFactory *factory ); | |
96 | static wxPrintFactory *GetFactory(); | |
97 | static wxPrintFactory *m_factory; | |
98 | }; | |
99 | ||
100 | class WXDLLEXPORT wxNativePrintFactory: public wxPrintFactory | |
101 | { | |
102 | public: | |
e81e3883 | 103 | virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data ); |
c061373d | 104 | |
e81e3883 RR |
105 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, |
106 | wxPrintout *printout = NULL, | |
107 | wxPrintDialogData *data = NULL ); | |
108 | virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview, | |
109 | wxPrintout *printout, | |
110 | wxPrintData *data ); | |
c061373d RR |
111 | |
112 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
113 | wxPrintDialogData *data = NULL ); | |
114 | virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, | |
115 | wxPrintData *data ); | |
8850cbd3 | 116 | |
6038ec8e RR |
117 | virtual bool HasPrintSetupDialog(); |
118 | virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); | |
119 | virtual bool HasOwnPrintToFile(); | |
120 | virtual bool HasPrinterLine(); | |
121 | virtual wxString CreatePrinterLine(); | |
122 | virtual bool HasStatusLine(); | |
123 | virtual wxString CreateStatusLine(); | |
124 | ||
8850cbd3 RR |
125 | virtual wxPrintNativeDataBase *CreatePrintNativeData(); |
126 | }; | |
127 | ||
128 | //---------------------------------------------------------------------------- | |
129 | // wxPrintNativeDataBase | |
130 | //---------------------------------------------------------------------------- | |
131 | ||
132 | class WXDLLEXPORT wxPrintNativeDataBase: public wxObject | |
133 | { | |
134 | public: | |
135 | wxPrintNativeDataBase(); | |
136 | virtual ~wxPrintNativeDataBase() {} | |
137 | ||
fd64de59 RR |
138 | virtual bool TransferTo( wxPrintData &data ) = 0; |
139 | virtual bool TransferFrom( const wxPrintData &data ) = 0; | |
8850cbd3 RR |
140 | |
141 | virtual bool Ok() const = 0; | |
142 | ||
143 | int m_ref; | |
144 | ||
145 | private: | |
146 | DECLARE_CLASS(wxPrintNativeDataBase) | |
147 | DECLARE_NO_COPY_CLASS(wxPrintNativeDataBase) | |
e81e3883 RR |
148 | }; |
149 | ||
150 | //---------------------------------------------------------------------------- | |
151 | // wxPrinterBase | |
152 | //---------------------------------------------------------------------------- | |
f6bcfd97 | 153 | |
c801d85f KB |
154 | /* |
155 | * Represents the printer: manages printing a wxPrintout object | |
156 | */ | |
d6b9496a | 157 | |
c801d85f KB |
158 | class WXDLLEXPORT wxPrinterBase: public wxObject |
159 | { | |
34da0970 | 160 | public: |
d6b9496a VZ |
161 | wxPrinterBase(wxPrintDialogData *data = (wxPrintDialogData *) NULL); |
162 | virtual ~wxPrinterBase(); | |
163 | ||
164 | virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout); | |
161f4f73 | 165 | virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message); |
c801d85f | 166 | |
c061373d | 167 | virtual wxPrintDialogData& GetPrintDialogData() const; |
d6b9496a | 168 | bool GetAbort() const { return sm_abortIt; } |
7e548f6b | 169 | |
f6bcfd97 | 170 | static wxPrinterError GetLastError() { return sm_lastError; } |
c801d85f | 171 | |
d6b9496a VZ |
172 | /////////////////////////////////////////////////////////////////////////// |
173 | // OVERRIDES | |
c801d85f | 174 | |
d6b9496a | 175 | virtual bool Setup(wxWindow *parent) = 0; |
7e548f6b | 176 | virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true) = 0; |
d6b9496a | 177 | virtual wxDC* PrintDialog(wxWindow *parent) = 0; |
34da0970 JS |
178 | |
179 | protected: | |
d6b9496a VZ |
180 | wxPrintDialogData m_printDialogData; |
181 | wxPrintout* m_currentPrintout; | |
7e548f6b | 182 | |
f6bcfd97 | 183 | static wxPrinterError sm_lastError; |
7e548f6b | 184 | |
34da0970 | 185 | public: |
d6b9496a VZ |
186 | static wxWindow* sm_abortWindow; |
187 | static bool sm_abortIt; | |
34da0970 | 188 | |
2b5f62a0 VZ |
189 | private: |
190 | DECLARE_CLASS(wxPrinterBase) | |
22f3361e | 191 | DECLARE_NO_COPY_CLASS(wxPrinterBase) |
c801d85f KB |
192 | }; |
193 | ||
e81e3883 RR |
194 | //---------------------------------------------------------------------------- |
195 | // wxPrinter | |
196 | //---------------------------------------------------------------------------- | |
197 | ||
198 | class WXDLLEXPORT wxPrinter: public wxPrinterBase | |
199 | { | |
200 | public: | |
201 | wxPrinter(wxPrintDialogData *data = (wxPrintDialogData *) NULL); | |
202 | virtual ~wxPrinter(); | |
203 | ||
204 | virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout); | |
205 | virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message); | |
206 | ||
207 | virtual bool Setup(wxWindow *parent); | |
208 | virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true); | |
209 | virtual wxDC* PrintDialog(wxWindow *parent); | |
c061373d RR |
210 | |
211 | virtual wxPrintDialogData& GetPrintDialogData() const; | |
e81e3883 RR |
212 | |
213 | protected: | |
214 | wxPrinterBase *m_pimpl; | |
215 | ||
216 | private: | |
217 | DECLARE_CLASS(wxPrinter) | |
218 | DECLARE_NO_COPY_CLASS(wxPrinter) | |
219 | }; | |
220 | ||
221 | //---------------------------------------------------------------------------- | |
222 | // wxPrintout | |
223 | //---------------------------------------------------------------------------- | |
224 | ||
c801d85f | 225 | /* |
c801d85f KB |
226 | * Represents an object via which a document may be printed. |
227 | * The programmer derives from this, overrides (at least) OnPrintPage, | |
228 | * and passes it to a wxPrinter object for printing, or a wxPrintPreview | |
229 | * object for previewing. | |
230 | */ | |
d6b9496a | 231 | |
c801d85f KB |
232 | class WXDLLEXPORT wxPrintout: public wxObject |
233 | { | |
34da0970 | 234 | public: |
2b5f62a0 | 235 | wxPrintout(const wxString& title = wxT("Printout")); |
d6b9496a | 236 | virtual ~wxPrintout(); |
c801d85f | 237 | |
d6b9496a VZ |
238 | virtual bool OnBeginDocument(int startPage, int endPage); |
239 | virtual void OnEndDocument(); | |
240 | virtual void OnBeginPrinting(); | |
241 | virtual void OnEndPrinting(); | |
c801d85f | 242 | |
d6b9496a VZ |
243 | // Guaranteed to be before any other functions are called |
244 | virtual void OnPreparePrinting() { } | |
c801d85f | 245 | |
d6b9496a VZ |
246 | virtual bool HasPage(int page); |
247 | virtual bool OnPrintPage(int page) = 0; | |
248 | virtual void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo); | |
c801d85f | 249 | |
d6b9496a | 250 | virtual wxString GetTitle() const { return m_printoutTitle; } |
34da0970 | 251 | |
d6b9496a VZ |
252 | wxDC *GetDC() const { return m_printoutDC; } |
253 | void SetDC(wxDC *dc) { m_printoutDC = dc; } | |
254 | void SetPageSizePixels(int w, int h) { m_pageWidthPixels = w; m_pageHeightPixels = h; } | |
255 | void GetPageSizePixels(int *w, int *h) const { *w = m_pageWidthPixels; *h = m_pageHeightPixels; } | |
256 | void SetPageSizeMM(int w, int h) { m_pageWidthMM = w; m_pageHeightMM = h; } | |
257 | void GetPageSizeMM(int *w, int *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; } | |
34da0970 | 258 | |
d6b9496a VZ |
259 | void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; } |
260 | void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; } | |
261 | void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; } | |
262 | void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; } | |
34da0970 | 263 | |
d6b9496a | 264 | virtual bool IsPreview() const { return m_isPreview; } |
34da0970 | 265 | |
d6b9496a | 266 | virtual void SetIsPreview(bool p) { m_isPreview = p; } |
34da0970 JS |
267 | |
268 | private: | |
d6b9496a VZ |
269 | wxString m_printoutTitle; |
270 | wxDC* m_printoutDC; | |
c801d85f | 271 | |
d6b9496a VZ |
272 | int m_pageWidthPixels; |
273 | int m_pageHeightPixels; | |
c801d85f | 274 | |
d6b9496a VZ |
275 | int m_pageWidthMM; |
276 | int m_pageHeightMM; | |
c801d85f | 277 | |
d6b9496a VZ |
278 | int m_PPIScreenX; |
279 | int m_PPIScreenY; | |
280 | int m_PPIPrinterX; | |
281 | int m_PPIPrinterY; | |
c801d85f | 282 | |
d6b9496a | 283 | bool m_isPreview; |
2b5f62a0 VZ |
284 | |
285 | private: | |
286 | DECLARE_ABSTRACT_CLASS(wxPrintout) | |
22f3361e | 287 | DECLARE_NO_COPY_CLASS(wxPrintout) |
c801d85f KB |
288 | }; |
289 | ||
290 | /* | |
291 | * wxPreviewCanvas | |
292 | * Canvas upon which a preview is drawn. | |
293 | */ | |
d6b9496a | 294 | |
c801d85f KB |
295 | class WXDLLEXPORT wxPreviewCanvas: public wxScrolledWindow |
296 | { | |
34da0970 | 297 | public: |
d6b9496a VZ |
298 | wxPreviewCanvas(wxPrintPreviewBase *preview, |
299 | wxWindow *parent, | |
300 | const wxPoint& pos = wxDefaultPosition, | |
301 | const wxSize& size = wxDefaultSize, | |
302 | long style = 0, | |
2b5f62a0 | 303 | const wxString& name = wxT("canvas")); |
d6b9496a | 304 | ~wxPreviewCanvas(); |
c801d85f | 305 | |
d6b9496a | 306 | void OnPaint(wxPaintEvent& event); |
d2b354f9 | 307 | void OnChar(wxKeyEvent &event); |
c801d85f | 308 | |
d6b9496a VZ |
309 | // Responds to colour changes |
310 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
c801d85f | 311 | |
34da0970 | 312 | private: |
d6b9496a | 313 | wxPrintPreviewBase* m_printPreview; |
34da0970 | 314 | |
2b5f62a0 | 315 | DECLARE_CLASS(wxPreviewCanvas) |
d6b9496a | 316 | DECLARE_EVENT_TABLE() |
22f3361e | 317 | DECLARE_NO_COPY_CLASS(wxPreviewCanvas) |
c801d85f KB |
318 | }; |
319 | ||
320 | /* | |
321 | * wxPreviewFrame | |
322 | * Default frame for showing preview. | |
323 | */ | |
324 | ||
325 | class WXDLLEXPORT wxPreviewFrame: public wxFrame | |
326 | { | |
34da0970 | 327 | public: |
d6b9496a | 328 | wxPreviewFrame(wxPrintPreviewBase *preview, |
a5ae8241 | 329 | wxWindow *parent, |
2b5f62a0 | 330 | const wxString& title = wxT("Print Preview"), |
d6b9496a VZ |
331 | const wxPoint& pos = wxDefaultPosition, |
332 | const wxSize& size = wxDefaultSize, | |
e9cafd42 | 333 | long style = wxDEFAULT_FRAME_STYLE, |
2b5f62a0 | 334 | const wxString& name = wxT("frame")); |
d6b9496a VZ |
335 | ~wxPreviewFrame(); |
336 | ||
337 | void OnCloseWindow(wxCloseEvent& event); | |
338 | virtual void Initialize(); | |
339 | virtual void CreateCanvas(); | |
340 | virtual void CreateControlBar(); | |
d2b354f9 JS |
341 | |
342 | inline wxPreviewControlBar* GetControlBar() const { return m_controlBar; } | |
343 | ||
34da0970 | 344 | protected: |
d2b354f9 | 345 | wxPreviewCanvas* m_previewCanvas; |
d6b9496a VZ |
346 | wxPreviewControlBar* m_controlBar; |
347 | wxPrintPreviewBase* m_printPreview; | |
7c995553 | 348 | wxWindowDisabler* m_windowDisabler; |
e3065973 | 349 | |
d6b9496a | 350 | private: |
2b5f62a0 | 351 | DECLARE_CLASS(wxPreviewFrame) |
d6b9496a | 352 | DECLARE_EVENT_TABLE() |
22f3361e | 353 | DECLARE_NO_COPY_CLASS(wxPreviewFrame) |
c801d85f KB |
354 | }; |
355 | ||
356 | /* | |
357 | * wxPreviewControlBar | |
358 | * A panel with buttons for controlling a print preview. | |
359 | * The programmer may wish to use other means for controlling | |
360 | * the print preview. | |
361 | */ | |
362 | ||
363 | #define wxPREVIEW_PRINT 1 | |
364 | #define wxPREVIEW_PREVIOUS 2 | |
365 | #define wxPREVIEW_NEXT 4 | |
366 | #define wxPREVIEW_ZOOM 8 | |
bf89b538 JS |
367 | #define wxPREVIEW_FIRST 16 |
368 | #define wxPREVIEW_LAST 32 | |
369 | #define wxPREVIEW_GOTO 64 | |
c801d85f | 370 | |
bf89b538 JS |
371 | #define wxPREVIEW_DEFAULT wxPREVIEW_PREVIOUS|wxPREVIEW_NEXT|wxPREVIEW_ZOOM\ |
372 | |wxPREVIEW_FIRST|wxPREVIEW_GOTO|wxPREVIEW_LAST | |
c801d85f KB |
373 | |
374 | // Ids for controls | |
375 | #define wxID_PREVIEW_CLOSE 1 | |
376 | #define wxID_PREVIEW_NEXT 2 | |
377 | #define wxID_PREVIEW_PREVIOUS 3 | |
378 | #define wxID_PREVIEW_PRINT 4 | |
379 | #define wxID_PREVIEW_ZOOM 5 | |
bf89b538 JS |
380 | #define wxID_PREVIEW_FIRST 6 |
381 | #define wxID_PREVIEW_LAST 7 | |
382 | #define wxID_PREVIEW_GOTO 8 | |
c801d85f KB |
383 | |
384 | class WXDLLEXPORT wxPreviewControlBar: public wxPanel | |
385 | { | |
d6b9496a | 386 | DECLARE_CLASS(wxPreviewControlBar) |
c801d85f | 387 | |
34da0970 | 388 | public: |
d6b9496a VZ |
389 | wxPreviewControlBar(wxPrintPreviewBase *preview, |
390 | long buttons, | |
391 | wxWindow *parent, | |
392 | const wxPoint& pos = wxDefaultPosition, | |
393 | const wxSize& size = wxDefaultSize, | |
d2b354f9 | 394 | long style = wxTAB_TRAVERSAL, |
2b5f62a0 | 395 | const wxString& name = wxT("panel")); |
d6b9496a VZ |
396 | ~wxPreviewControlBar(); |
397 | ||
398 | virtual void CreateButtons(); | |
399 | virtual void SetZoomControl(int zoom); | |
400 | virtual int GetZoomControl(); | |
401 | virtual wxPrintPreviewBase *GetPrintPreview() const | |
402 | { return m_printPreview; } | |
403 | ||
d6b9496a | 404 | void OnWindowClose(wxCommandEvent& event); |
0f90ec93 KB |
405 | void OnNext(); |
406 | void OnPrevious(); | |
bf89b538 JS |
407 | void OnFirst(); |
408 | void OnLast(); | |
409 | void OnGoto(); | |
b38b0d22 | 410 | void OnPrint(); |
90b6b974 | 411 | void OnPrintButton(wxCommandEvent& WXUNUSED(event)) { OnPrint(); } |
014b0d06 VZ |
412 | void OnNextButton(wxCommandEvent & WXUNUSED(event)) { OnNext(); } |
413 | void OnPreviousButton(wxCommandEvent & WXUNUSED(event)) { OnPrevious(); } | |
bf89b538 JS |
414 | void OnFirstButton(wxCommandEvent & WXUNUSED(event)) { OnFirst(); } |
415 | void OnLastButton(wxCommandEvent & WXUNUSED(event)) { OnLast(); } | |
416 | void OnGotoButton(wxCommandEvent & WXUNUSED(event)) { OnGoto(); } | |
d6b9496a VZ |
417 | void OnZoom(wxCommandEvent& event); |
418 | void OnPaint(wxPaintEvent& event); | |
c801d85f | 419 | |
34da0970 | 420 | protected: |
d6b9496a VZ |
421 | wxPrintPreviewBase* m_printPreview; |
422 | wxButton* m_closeButton; | |
423 | wxButton* m_nextPageButton; | |
424 | wxButton* m_previousPageButton; | |
425 | wxButton* m_printButton; | |
426 | wxChoice* m_zoomControl; | |
bf89b538 JS |
427 | wxButton* m_firstPageButton; |
428 | wxButton* m_lastPageButton; | |
429 | wxButton* m_gotoPageButton; | |
d6b9496a VZ |
430 | long m_buttonFlags; |
431 | ||
432 | private: | |
433 | DECLARE_EVENT_TABLE() | |
22f3361e | 434 | DECLARE_NO_COPY_CLASS(wxPreviewControlBar) |
c801d85f KB |
435 | }; |
436 | ||
e81e3883 RR |
437 | //---------------------------------------------------------------------------- |
438 | // wxPrintPreviewBase | |
439 | //---------------------------------------------------------------------------- | |
440 | ||
c801d85f | 441 | /* |
c801d85f KB |
442 | * Programmer creates an object of this class to preview a wxPrintout. |
443 | */ | |
d6b9496a | 444 | |
c801d85f KB |
445 | class WXDLLEXPORT wxPrintPreviewBase: public wxObject |
446 | { | |
34da0970 | 447 | public: |
d6b9496a VZ |
448 | wxPrintPreviewBase(wxPrintout *printout, |
449 | wxPrintout *printoutForPrinting = (wxPrintout *) NULL, | |
450 | wxPrintDialogData *data = (wxPrintDialogData *) NULL); | |
451 | wxPrintPreviewBase(wxPrintout *printout, | |
452 | wxPrintout *printoutForPrinting, | |
453 | wxPrintData *data); | |
454 | virtual ~wxPrintPreviewBase(); | |
c801d85f | 455 | |
d6b9496a | 456 | virtual bool SetCurrentPage(int pageNum); |
e81e3883 | 457 | virtual int GetCurrentPage() const; |
c801d85f | 458 | |
e81e3883 RR |
459 | virtual void SetPrintout(wxPrintout *printout); |
460 | virtual wxPrintout *GetPrintout() const; | |
461 | virtual wxPrintout *GetPrintoutForPrinting() const; | |
c801d85f | 462 | |
e81e3883 RR |
463 | virtual void SetFrame(wxFrame *frame); |
464 | virtual void SetCanvas(wxPreviewCanvas *canvas); | |
c801d85f | 465 | |
e81e3883 RR |
466 | virtual wxFrame *GetFrame() const; |
467 | virtual wxPreviewCanvas *GetCanvas() const; | |
c801d85f | 468 | |
d6b9496a | 469 | // The preview canvas should call this from OnPaint |
d2b354f9 | 470 | virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc); |
c801d85f | 471 | |
d6b9496a | 472 | // This draws a blank page onto the preview canvas |
d2b354f9 JS |
473 | virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc); |
474 | ||
475 | // Adjusts the scrollbars for the current scale | |
476 | virtual void AdjustScrollbars(wxPreviewCanvas *canvas); | |
c801d85f | 477 | |
d6b9496a VZ |
478 | // This is called by wxPrintPreview to render a page into a wxMemoryDC. |
479 | virtual bool RenderPage(int pageNum); | |
c801d85f | 480 | |
c801d85f | 481 | |
d6b9496a | 482 | virtual void SetZoom(int percent); |
e81e3883 | 483 | virtual int GetZoom() const; |
34da0970 | 484 | |
e81e3883 RR |
485 | virtual wxPrintDialogData& GetPrintDialogData(); |
486 | ||
487 | virtual int GetMaxPage() const; | |
488 | virtual int GetMinPage() const; | |
c801d85f | 489 | |
e81e3883 RR |
490 | virtual bool Ok() const; |
491 | virtual void SetOk(bool ok); | |
c801d85f | 492 | |
d6b9496a VZ |
493 | /////////////////////////////////////////////////////////////////////////// |
494 | // OVERRIDES | |
c801d85f | 495 | |
d6b9496a VZ |
496 | // If we own a wxPrintout that can be used for printing, this |
497 | // will invoke the actual printing procedure. Called | |
498 | // by the wxPreviewControlBar. | |
499 | virtual bool Print(bool interactive) = 0; | |
c801d85f | 500 | |
d6b9496a VZ |
501 | // Calculate scaling that needs to be done to get roughly |
502 | // the right scaling for the screen pretending to be | |
503 | // the currently selected printer. | |
504 | virtual void DetermineScaling() = 0; | |
34da0970 JS |
505 | |
506 | protected: | |
d6b9496a | 507 | wxPrintDialogData m_printDialogData; |
d2b354f9 | 508 | wxPreviewCanvas* m_previewCanvas; |
d6b9496a VZ |
509 | wxFrame* m_previewFrame; |
510 | wxBitmap* m_previewBitmap; | |
511 | wxPrintout* m_previewPrintout; | |
512 | wxPrintout* m_printPrintout; | |
513 | int m_currentPage; | |
514 | int m_currentZoom; | |
515 | float m_previewScale; | |
516 | int m_topMargin; | |
517 | int m_leftMargin; | |
518 | int m_pageWidth; | |
519 | int m_pageHeight; | |
520 | int m_minPage; | |
521 | int m_maxPage; | |
522 | ||
523 | bool m_isOk; | |
1044a386 | 524 | bool m_printingPrepared; // Called OnPreparePrinting? |
d6b9496a VZ |
525 | |
526 | private: | |
527 | void Init(wxPrintout *printout, wxPrintout *printoutForPrinting); | |
22f3361e VZ |
528 | |
529 | DECLARE_NO_COPY_CLASS(wxPrintPreviewBase) | |
e81e3883 | 530 | DECLARE_CLASS(wxPrintPreviewBase) |
c801d85f KB |
531 | }; |
532 | ||
e81e3883 RR |
533 | //---------------------------------------------------------------------------- |
534 | // wxPrintPreview | |
535 | //---------------------------------------------------------------------------- | |
536 | ||
537 | class WXDLLEXPORT wxPrintPreview: public wxPrintPreviewBase | |
538 | { | |
539 | public: | |
540 | wxPrintPreview(wxPrintout *printout, | |
541 | wxPrintout *printoutForPrinting = (wxPrintout *) NULL, | |
542 | wxPrintDialogData *data = (wxPrintDialogData *) NULL); | |
543 | wxPrintPreview(wxPrintout *printout, | |
544 | wxPrintout *printoutForPrinting, | |
545 | wxPrintData *data); | |
546 | virtual ~wxPrintPreview(); | |
547 | ||
548 | virtual bool SetCurrentPage(int pageNum); | |
549 | virtual int GetCurrentPage() const; | |
550 | virtual void SetPrintout(wxPrintout *printout); | |
551 | virtual wxPrintout *GetPrintout() const; | |
552 | virtual wxPrintout *GetPrintoutForPrinting() const; | |
553 | virtual void SetFrame(wxFrame *frame); | |
554 | virtual void SetCanvas(wxPreviewCanvas *canvas); | |
555 | ||
556 | virtual wxFrame *GetFrame() const; | |
557 | virtual wxPreviewCanvas *GetCanvas() const; | |
558 | virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc); | |
559 | virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc); | |
560 | virtual void AdjustScrollbars(wxPreviewCanvas *canvas); | |
561 | virtual bool RenderPage(int pageNum); | |
562 | virtual void SetZoom(int percent); | |
563 | ||
564 | virtual bool Print(bool interactive); | |
565 | virtual void DetermineScaling(); | |
566 | ||
567 | virtual wxPrintDialogData& GetPrintDialogData(); | |
568 | ||
569 | virtual int GetMaxPage() const; | |
570 | virtual int GetMinPage() const; | |
571 | ||
572 | virtual bool Ok() const; | |
573 | virtual void SetOk(bool ok); | |
574 | ||
575 | private: | |
576 | wxPrintPreviewBase *m_pimpl; | |
577 | ||
578 | private: | |
579 | DECLARE_CLASS(wxPrintPreview) | |
580 | DECLARE_NO_COPY_CLASS(wxPrintPreview) | |
581 | }; | |
582 | ||
583 | //---------------------------------------------------------------------------- | |
584 | // wxPrintAbortDialog | |
585 | //---------------------------------------------------------------------------- | |
c801d85f KB |
586 | |
587 | class WXDLLEXPORT wxPrintAbortDialog: public wxDialog | |
588 | { | |
589 | public: | |
d6b9496a VZ |
590 | wxPrintAbortDialog(wxWindow *parent, |
591 | const wxString& title, | |
592 | const wxPoint& pos = wxDefaultPosition, | |
593 | const wxSize& size = wxDefaultSize, | |
594 | long style = 0, | |
2b5f62a0 | 595 | const wxString& name = wxT("dialog")) |
7e548f6b | 596 | : wxDialog(parent, wxID_ANY, title, pos, size, style, name) |
d6b9496a VZ |
597 | { |
598 | } | |
599 | ||
600 | void OnCancel(wxCommandEvent& event); | |
34da0970 | 601 | |
d6b9496a VZ |
602 | private: |
603 | DECLARE_EVENT_TABLE() | |
fc7a2a60 | 604 | DECLARE_NO_COPY_CLASS(wxPrintAbortDialog) |
c801d85f KB |
605 | }; |
606 | ||
d427503c VZ |
607 | #endif // wxUSE_PRINTING_ARCHITECTURE |
608 | ||
c801d85f | 609 | #endif |
34138703 | 610 | // _WX_PRNTBASEH__ |