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