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