1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Base classes for printing framework
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_PRNTBASEH__
12 #define _WX_PRNTBASEH__
16 #if wxUSE_PRINTING_ARCHITECTURE
19 #include "wx/cmndata.h"
21 #include "wx/scrolwin.h"
22 #include "wx/dialog.h"
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 class WXDLLIMPEXP_FWD_CORE wxPrintPreview
;
42 class WXDLLIMPEXP_FWD_CORE wxPrintAbortDialog
;
43 class WXDLLIMPEXP_FWD_CORE wxStaticText
;
44 class wxPrintPageMaxCtrl
;
45 class wxPrintPageTextCtrl
;
47 //----------------------------------------------------------------------------
49 //----------------------------------------------------------------------------
53 wxPRINTER_NO_ERROR
= 0,
58 // Preview frame modality kind used with wxPreviewFrame::Initialize()
59 enum wxPreviewFrameModalityKind
61 // Disable all the other top level windows while the preview is shown.
62 wxPreviewFrame_AppModal
,
64 // Disable only the parent window while the preview is shown.
65 wxPreviewFrame_WindowModal
,
67 // Don't disable any windows.
68 wxPreviewFrame_NonModal
71 //----------------------------------------------------------------------------
73 //----------------------------------------------------------------------------
75 class WXDLLIMPEXP_CORE wxPrintFactory
79 virtual ~wxPrintFactory() {}
81 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
* data
) = 0;
83 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
84 wxPrintout
*printout
= NULL
,
85 wxPrintDialogData
*data
= NULL
) = 0;
86 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
88 wxPrintData
*data
) = 0;
90 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
91 wxPrintDialogData
*data
= NULL
) = 0;
92 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
93 wxPrintData
*data
) = 0;
95 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
96 wxPageSetupDialogData
* data
= NULL
) = 0;
98 virtual wxDCImpl
* CreatePrinterDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
) = 0;
100 // What to do and what to show in the wxPrintDialog
101 // a) Use the generic print setup dialog or a native one?
102 virtual bool HasPrintSetupDialog() = 0;
103 virtual wxDialog
*CreatePrintSetupDialog( wxWindow
*parent
, wxPrintData
*data
) = 0;
104 // b) Provide the "print to file" option ourselves or via print setup?
105 virtual bool HasOwnPrintToFile() = 0;
106 // c) Show current printer
107 virtual bool HasPrinterLine() = 0;
108 virtual wxString
CreatePrinterLine() = 0;
109 // d) Show Status line for current printer?
110 virtual bool HasStatusLine() = 0;
111 virtual wxString
CreateStatusLine() = 0;
114 virtual wxPrintNativeDataBase
*CreatePrintNativeData() = 0;
116 static void SetPrintFactory( wxPrintFactory
*factory
);
117 static wxPrintFactory
*GetFactory();
119 static wxPrintFactory
*m_factory
;
122 class WXDLLIMPEXP_CORE wxNativePrintFactory
: public wxPrintFactory
125 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
*data
);
127 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
128 wxPrintout
*printout
= NULL
,
129 wxPrintDialogData
*data
= NULL
);
130 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
131 wxPrintout
*printout
,
134 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
135 wxPrintDialogData
*data
= NULL
);
136 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
139 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
140 wxPageSetupDialogData
* data
= NULL
);
142 virtual wxDCImpl
* CreatePrinterDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
);
144 virtual bool HasPrintSetupDialog();
145 virtual wxDialog
*CreatePrintSetupDialog( wxWindow
*parent
, wxPrintData
*data
);
146 virtual bool HasOwnPrintToFile();
147 virtual bool HasPrinterLine();
148 virtual wxString
CreatePrinterLine();
149 virtual bool HasStatusLine();
150 virtual wxString
CreateStatusLine();
152 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
155 //----------------------------------------------------------------------------
156 // wxPrintNativeDataBase
157 //----------------------------------------------------------------------------
159 class WXDLLIMPEXP_CORE wxPrintNativeDataBase
: public wxObject
162 wxPrintNativeDataBase();
163 virtual ~wxPrintNativeDataBase() {}
165 virtual bool TransferTo( wxPrintData
&data
) = 0;
166 virtual bool TransferFrom( const wxPrintData
&data
) = 0;
168 virtual bool Ok() const { return IsOk(); }
169 virtual bool IsOk() const = 0;
174 DECLARE_CLASS(wxPrintNativeDataBase
)
175 wxDECLARE_NO_COPY_CLASS(wxPrintNativeDataBase
);
178 //----------------------------------------------------------------------------
180 //----------------------------------------------------------------------------
183 * Represents the printer: manages printing a wxPrintout object
186 class WXDLLIMPEXP_CORE wxPrinterBase
: public wxObject
189 wxPrinterBase(wxPrintDialogData
*data
= NULL
);
190 virtual ~wxPrinterBase();
192 virtual wxPrintAbortDialog
*CreateAbortWindow(wxWindow
*parent
, wxPrintout
*printout
);
193 virtual void ReportError(wxWindow
*parent
, wxPrintout
*printout
, const wxString
& message
);
195 virtual wxPrintDialogData
& GetPrintDialogData() const;
196 bool GetAbort() const { return sm_abortIt
; }
198 static wxPrinterError
GetLastError() { return sm_lastError
; }
200 ///////////////////////////////////////////////////////////////////////////
203 virtual bool Setup(wxWindow
*parent
) = 0;
204 virtual bool Print(wxWindow
*parent
, wxPrintout
*printout
, bool prompt
= true) = 0;
205 virtual wxDC
* PrintDialog(wxWindow
*parent
) = 0;
208 wxPrintDialogData m_printDialogData
;
209 wxPrintout
* m_currentPrintout
;
211 static wxPrinterError sm_lastError
;
214 static wxWindow
* sm_abortWindow
;
215 static bool sm_abortIt
;
218 DECLARE_CLASS(wxPrinterBase
)
219 wxDECLARE_NO_COPY_CLASS(wxPrinterBase
);
222 //----------------------------------------------------------------------------
224 //----------------------------------------------------------------------------
226 class WXDLLIMPEXP_CORE wxPrinter
: public wxPrinterBase
229 wxPrinter(wxPrintDialogData
*data
= NULL
);
230 virtual ~wxPrinter();
232 virtual wxPrintAbortDialog
*CreateAbortWindow(wxWindow
*parent
, wxPrintout
*printout
);
233 virtual void ReportError(wxWindow
*parent
, wxPrintout
*printout
, const wxString
& message
);
235 virtual bool Setup(wxWindow
*parent
);
236 virtual bool Print(wxWindow
*parent
, wxPrintout
*printout
, bool prompt
= true);
237 virtual wxDC
* PrintDialog(wxWindow
*parent
);
239 virtual wxPrintDialogData
& GetPrintDialogData() const;
242 wxPrinterBase
*m_pimpl
;
245 DECLARE_CLASS(wxPrinter
)
246 wxDECLARE_NO_COPY_CLASS(wxPrinter
);
249 //----------------------------------------------------------------------------
251 //----------------------------------------------------------------------------
254 * Represents an object via which a document may be printed.
255 * The programmer derives from this, overrides (at least) OnPrintPage,
256 * and passes it to a wxPrinter object for printing, or a wxPrintPreview
257 * object for previewing.
260 class WXDLLIMPEXP_CORE wxPrintout
: public wxObject
263 wxPrintout(const wxString
& title
= _("Printout"));
264 virtual ~wxPrintout();
266 virtual bool OnBeginDocument(int startPage
, int endPage
);
267 virtual void OnEndDocument();
268 virtual void OnBeginPrinting();
269 virtual void OnEndPrinting();
271 // Guaranteed to be before any other functions are called
272 virtual void OnPreparePrinting() { }
274 virtual bool HasPage(int page
);
275 virtual bool OnPrintPage(int page
) = 0;
276 virtual void GetPageInfo(int *minPage
, int *maxPage
, int *pageFrom
, int *pageTo
);
278 virtual wxString
GetTitle() const { return m_printoutTitle
; }
280 wxDC
*GetDC() const { return m_printoutDC
; }
281 void SetDC(wxDC
*dc
) { m_printoutDC
= dc
; }
283 void FitThisSizeToPaper(const wxSize
& imageSize
);
284 void FitThisSizeToPage(const wxSize
& imageSize
);
285 void FitThisSizeToPageMargins(const wxSize
& imageSize
, const wxPageSetupDialogData
& pageSetupData
);
286 void MapScreenSizeToPaper();
287 void MapScreenSizeToPage();
288 void MapScreenSizeToPageMargins(const wxPageSetupDialogData
& pageSetupData
);
289 void MapScreenSizeToDevice();
291 wxRect
GetLogicalPaperRect() const;
292 wxRect
GetLogicalPageRect() const;
293 wxRect
GetLogicalPageMarginsRect(const wxPageSetupDialogData
& pageSetupData
) const;
295 void SetLogicalOrigin(wxCoord x
, wxCoord y
);
296 void OffsetLogicalOrigin(wxCoord xoff
, wxCoord yoff
);
298 void SetPageSizePixels(int w
, int h
) { m_pageWidthPixels
= w
; m_pageHeightPixels
= h
; }
299 void GetPageSizePixels(int *w
, int *h
) const { *w
= m_pageWidthPixels
; *h
= m_pageHeightPixels
; }
300 void SetPageSizeMM(int w
, int h
) { m_pageWidthMM
= w
; m_pageHeightMM
= h
; }
301 void GetPageSizeMM(int *w
, int *h
) const { *w
= m_pageWidthMM
; *h
= m_pageHeightMM
; }
303 void SetPPIScreen(int x
, int y
) { m_PPIScreenX
= x
; m_PPIScreenY
= y
; }
304 void SetPPIScreen(const wxSize
& ppi
) { SetPPIScreen(ppi
.x
, ppi
.y
); }
305 void GetPPIScreen(int *x
, int *y
) const { *x
= m_PPIScreenX
; *y
= m_PPIScreenY
; }
306 void SetPPIPrinter(int x
, int y
) { m_PPIPrinterX
= x
; m_PPIPrinterY
= y
; }
307 void SetPPIPrinter(const wxSize
& ppi
) { SetPPIPrinter(ppi
.x
, ppi
.y
); }
308 void GetPPIPrinter(int *x
, int *y
) const { *x
= m_PPIPrinterX
; *y
= m_PPIPrinterY
; }
310 void SetPaperRectPixels(const wxRect
& paperRectPixels
) { m_paperRectPixels
= paperRectPixels
; }
311 wxRect
GetPaperRectPixels() const { return m_paperRectPixels
; }
313 // This must be called by wxPrintPreview to associate itself with the
315 virtual void SetPreview(wxPrintPreview
*preview
) { m_preview
= preview
; }
317 wxPrintPreview
*GetPreview() const { return m_preview
; }
318 virtual bool IsPreview() const { return GetPreview() != NULL
; }
321 wxString m_printoutTitle
;
323 wxPrintPreview
*m_preview
;
325 int m_pageWidthPixels
;
326 int m_pageHeightPixels
;
336 wxRect m_paperRectPixels
;
339 DECLARE_ABSTRACT_CLASS(wxPrintout
)
340 wxDECLARE_NO_COPY_CLASS(wxPrintout
);
343 //----------------------------------------------------------------------------
345 //----------------------------------------------------------------------------
348 * Canvas upon which a preview is drawn.
351 class WXDLLIMPEXP_CORE wxPreviewCanvas
: public wxScrolledWindow
354 wxPreviewCanvas(wxPrintPreviewBase
*preview
,
356 const wxPoint
& pos
= wxDefaultPosition
,
357 const wxSize
& size
= wxDefaultSize
,
359 const wxString
& name
= wxT("canvas"));
360 virtual ~wxPreviewCanvas();
362 void SetPreview(wxPrintPreviewBase
*preview
) { m_printPreview
= preview
; }
364 void OnPaint(wxPaintEvent
& event
);
365 void OnChar(wxKeyEvent
&event
);
366 // Responds to colour changes
367 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
371 void OnMouseWheel(wxMouseEvent
& event
);
372 #endif // wxUSE_MOUSEWHEEL
373 void OnIdle(wxIdleEvent
& event
);
375 wxPrintPreviewBase
* m_printPreview
;
377 DECLARE_CLASS(wxPreviewCanvas
)
378 DECLARE_EVENT_TABLE()
379 wxDECLARE_NO_COPY_CLASS(wxPreviewCanvas
);
382 //----------------------------------------------------------------------------
384 //----------------------------------------------------------------------------
387 * Default frame for showing preview.
390 class WXDLLIMPEXP_CORE wxPreviewFrame
: public wxFrame
393 wxPreviewFrame(wxPrintPreviewBase
*preview
,
395 const wxString
& title
= _("Print Preview"),
396 const wxPoint
& pos
= wxDefaultPosition
,
397 const wxSize
& size
= wxDefaultSize
,
398 long style
= wxDEFAULT_FRAME_STYLE
| wxFRAME_FLOAT_ON_PARENT
,
399 const wxString
& name
= wxFrameNameStr
);
400 virtual ~wxPreviewFrame();
402 // Either Initialize() or InitializeWithModality() must be called before
403 // showing the preview frame, the former being just a particular case of
404 // the latter initializing the frame for being showing app-modally.
406 // Notice that we must keep Initialize() with its existing signature to
407 // avoid breaking the old code that overrides it and we can't reuse the
408 // same name for the other functions to avoid virtual function hiding
409 // problem and the associated warnings given by some compilers (e.g. from
410 // g++ with -Woverloaded-virtual).
411 virtual void Initialize()
413 InitializeWithModality(wxPreviewFrame_AppModal
);
416 // Also note that this method is not virtual as it doesn't need to be
417 // overridden: it's never called by wxWidgets (of course, the same is true
418 // for Initialize() but, again, it must remain virtual for compatibility).
419 void InitializeWithModality(wxPreviewFrameModalityKind kind
);
421 void OnCloseWindow(wxCloseEvent
& event
);
422 virtual void CreateCanvas();
423 virtual void CreateControlBar();
425 inline wxPreviewControlBar
* GetControlBar() const { return m_controlBar
; }
428 wxPreviewCanvas
* m_previewCanvas
;
429 wxPreviewControlBar
* m_controlBar
;
430 wxPrintPreviewBase
* m_printPreview
;
431 wxWindowDisabler
* m_windowDisabler
;
433 wxPreviewFrameModalityKind m_modalityKind
;
437 void OnChar(wxKeyEvent
& event
);
439 DECLARE_EVENT_TABLE()
440 DECLARE_CLASS(wxPreviewFrame
)
441 wxDECLARE_NO_COPY_CLASS(wxPreviewFrame
);
444 //----------------------------------------------------------------------------
445 // wxPreviewControlBar
446 //----------------------------------------------------------------------------
449 * A panel with buttons for controlling a print preview.
450 * The programmer may wish to use other means for controlling
454 #define wxPREVIEW_PRINT 1
455 #define wxPREVIEW_PREVIOUS 2
456 #define wxPREVIEW_NEXT 4
457 #define wxPREVIEW_ZOOM 8
458 #define wxPREVIEW_FIRST 16
459 #define wxPREVIEW_LAST 32
460 #define wxPREVIEW_GOTO 64
462 #define wxPREVIEW_DEFAULT (wxPREVIEW_PREVIOUS|wxPREVIEW_NEXT|wxPREVIEW_ZOOM\
463 |wxPREVIEW_FIRST|wxPREVIEW_GOTO|wxPREVIEW_LAST)
466 #define wxID_PREVIEW_CLOSE 1
467 #define wxID_PREVIEW_NEXT 2
468 #define wxID_PREVIEW_PREVIOUS 3
469 #define wxID_PREVIEW_PRINT 4
470 #define wxID_PREVIEW_ZOOM 5
471 #define wxID_PREVIEW_FIRST 6
472 #define wxID_PREVIEW_LAST 7
473 #define wxID_PREVIEW_GOTO 8
474 #define wxID_PREVIEW_ZOOM_IN 9
475 #define wxID_PREVIEW_ZOOM_OUT 10
477 class WXDLLIMPEXP_CORE wxPreviewControlBar
: public wxPanel
479 DECLARE_CLASS(wxPreviewControlBar
)
482 wxPreviewControlBar(wxPrintPreviewBase
*preview
,
485 const wxPoint
& pos
= wxDefaultPosition
,
486 const wxSize
& size
= wxDefaultSize
,
487 long style
= wxTAB_TRAVERSAL
,
488 const wxString
& name
= wxT("panel"));
489 virtual ~wxPreviewControlBar();
491 virtual void CreateButtons();
492 virtual void SetPageInfo(int minPage
, int maxPage
);
493 virtual void SetZoomControl(int zoom
);
494 virtual int GetZoomControl();
495 virtual wxPrintPreviewBase
*GetPrintPreview() const
496 { return m_printPreview
; }
499 // Implementation only from now on.
500 void OnWindowClose(wxCommandEvent
& event
);
508 void OnPrintButton(wxCommandEvent
& WXUNUSED(event
)) { OnPrint(); }
509 void OnNextButton(wxCommandEvent
& WXUNUSED(event
)) { OnNext(); }
510 void OnPreviousButton(wxCommandEvent
& WXUNUSED(event
)) { OnPrevious(); }
511 void OnFirstButton(wxCommandEvent
& WXUNUSED(event
)) { OnFirst(); }
512 void OnLastButton(wxCommandEvent
& WXUNUSED(event
)) { OnLast(); }
513 void OnPaint(wxPaintEvent
& event
);
515 void OnUpdateNextButton(wxUpdateUIEvent
& event
)
516 { event
.Enable(IsNextEnabled()); }
517 void OnUpdatePreviousButton(wxUpdateUIEvent
& event
)
518 { event
.Enable(IsPreviousEnabled()); }
519 void OnUpdateFirstButton(wxUpdateUIEvent
& event
)
520 { event
.Enable(IsFirstEnabled()); }
521 void OnUpdateLastButton(wxUpdateUIEvent
& event
)
522 { event
.Enable(IsLastEnabled()); }
523 void OnUpdateZoomInButton(wxUpdateUIEvent
& event
)
524 { event
.Enable(IsZoomInEnabled()); }
525 void OnUpdateZoomOutButton(wxUpdateUIEvent
& event
)
526 { event
.Enable(IsZoomOutEnabled()); }
528 // These methods are not private because they are called by wxPreviewCanvas.
533 wxPrintPreviewBase
* m_printPreview
;
534 wxButton
* m_closeButton
;
535 wxChoice
* m_zoomControl
;
536 wxPrintPageTextCtrl
* m_currentPageText
;
537 wxPrintPageMaxCtrl
* m_maxPageText
;
542 void DoGotoPage(int page
);
546 bool IsNextEnabled() const;
547 bool IsPreviousEnabled() const;
548 bool IsFirstEnabled() const;
549 bool IsLastEnabled() const;
550 bool IsZoomInEnabled() const;
551 bool IsZoomOutEnabled() const;
553 void OnZoomInButton(wxCommandEvent
& WXUNUSED(event
)) { DoZoomIn(); }
554 void OnZoomOutButton(wxCommandEvent
& WXUNUSED(event
)) { DoZoomOut(); }
555 void OnZoomChoice(wxCommandEvent
& WXUNUSED(event
)) { DoZoom(); }
557 DECLARE_EVENT_TABLE()
558 wxDECLARE_NO_COPY_CLASS(wxPreviewControlBar
);
561 //----------------------------------------------------------------------------
562 // wxPrintPreviewBase
563 //----------------------------------------------------------------------------
566 * Programmer creates an object of this class to preview a wxPrintout.
569 class WXDLLIMPEXP_CORE wxPrintPreviewBase
: public wxObject
572 wxPrintPreviewBase(wxPrintout
*printout
,
573 wxPrintout
*printoutForPrinting
= NULL
,
574 wxPrintDialogData
*data
= NULL
);
575 wxPrintPreviewBase(wxPrintout
*printout
,
576 wxPrintout
*printoutForPrinting
,
578 virtual ~wxPrintPreviewBase();
580 virtual bool SetCurrentPage(int pageNum
);
581 virtual int GetCurrentPage() const;
583 virtual void SetPrintout(wxPrintout
*printout
);
584 virtual wxPrintout
*GetPrintout() const;
585 virtual wxPrintout
*GetPrintoutForPrinting() const;
587 virtual void SetFrame(wxFrame
*frame
);
588 virtual void SetCanvas(wxPreviewCanvas
*canvas
);
590 virtual wxFrame
*GetFrame() const;
591 virtual wxPreviewCanvas
*GetCanvas() const;
593 // This is a helper routine, used by the next 4 routines.
595 virtual void CalcRects(wxPreviewCanvas
*canvas
, wxRect
& printableAreaRect
, wxRect
& paperRect
);
597 // The preview canvas should call this from OnPaint
598 virtual bool PaintPage(wxPreviewCanvas
*canvas
, wxDC
& dc
);
600 // Updates rendered page by calling RenderPage() if needed, returns true
601 // if there was some change. Preview canvas should call it at idle time
602 virtual bool UpdatePageRendering();
604 // This draws a blank page onto the preview canvas
605 virtual bool DrawBlankPage(wxPreviewCanvas
*canvas
, wxDC
& dc
);
607 // Adjusts the scrollbars for the current scale
608 virtual void AdjustScrollbars(wxPreviewCanvas
*canvas
);
610 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
611 virtual bool RenderPage(int pageNum
);
614 virtual void SetZoom(int percent
);
615 virtual int GetZoom() const;
617 virtual wxPrintDialogData
& GetPrintDialogData();
619 virtual int GetMaxPage() const;
620 virtual int GetMinPage() const;
622 virtual bool Ok() const { return IsOk(); }
623 virtual bool IsOk() const;
624 virtual void SetOk(bool ok
);
626 ///////////////////////////////////////////////////////////////////////////
629 // If we own a wxPrintout that can be used for printing, this
630 // will invoke the actual printing procedure. Called
631 // by the wxPreviewControlBar.
632 virtual bool Print(bool interactive
) = 0;
634 // Calculate scaling that needs to be done to get roughly
635 // the right scaling for the screen pretending to be
636 // the currently selected printer.
637 virtual void DetermineScaling() = 0;
640 // helpers for RenderPage():
641 virtual bool RenderPageIntoDC(wxDC
& dc
, int pageNum
);
642 // renders preview into m_previewBitmap
643 virtual bool RenderPageIntoBitmap(wxBitmap
& bmp
, int pageNum
);
645 void InvalidatePreviewBitmap();
648 wxPrintDialogData m_printDialogData
;
649 wxPreviewCanvas
* m_previewCanvas
;
650 wxFrame
* m_previewFrame
;
651 wxBitmap
* m_previewBitmap
;
652 bool m_previewFailed
;
653 wxPrintout
* m_previewPrintout
;
654 wxPrintout
* m_printPrintout
;
657 float m_previewScaleX
;
658 float m_previewScaleY
;
667 bool m_printingPrepared
; // Called OnPreparePrinting?
670 void Init(wxPrintout
*printout
, wxPrintout
*printoutForPrinting
);
672 wxDECLARE_NO_COPY_CLASS(wxPrintPreviewBase
);
673 DECLARE_CLASS(wxPrintPreviewBase
)
676 //----------------------------------------------------------------------------
678 //----------------------------------------------------------------------------
680 class WXDLLIMPEXP_CORE wxPrintPreview
: public wxPrintPreviewBase
683 wxPrintPreview(wxPrintout
*printout
,
684 wxPrintout
*printoutForPrinting
= NULL
,
685 wxPrintDialogData
*data
= NULL
);
686 wxPrintPreview(wxPrintout
*printout
,
687 wxPrintout
*printoutForPrinting
,
689 virtual ~wxPrintPreview();
691 virtual bool SetCurrentPage(int pageNum
);
692 virtual int GetCurrentPage() const;
693 virtual void SetPrintout(wxPrintout
*printout
);
694 virtual wxPrintout
*GetPrintout() const;
695 virtual wxPrintout
*GetPrintoutForPrinting() const;
696 virtual void SetFrame(wxFrame
*frame
);
697 virtual void SetCanvas(wxPreviewCanvas
*canvas
);
699 virtual wxFrame
*GetFrame() const;
700 virtual wxPreviewCanvas
*GetCanvas() const;
701 virtual bool PaintPage(wxPreviewCanvas
*canvas
, wxDC
& dc
);
702 virtual bool UpdatePageRendering();
703 virtual bool DrawBlankPage(wxPreviewCanvas
*canvas
, wxDC
& dc
);
704 virtual void AdjustScrollbars(wxPreviewCanvas
*canvas
);
705 virtual bool RenderPage(int pageNum
);
706 virtual void SetZoom(int percent
);
707 virtual int GetZoom() const;
709 virtual bool Print(bool interactive
);
710 virtual void DetermineScaling();
712 virtual wxPrintDialogData
& GetPrintDialogData();
714 virtual int GetMaxPage() const;
715 virtual int GetMinPage() const;
717 virtual bool Ok() const { return IsOk(); }
718 virtual bool IsOk() const;
719 virtual void SetOk(bool ok
);
722 wxPrintPreviewBase
*m_pimpl
;
725 DECLARE_CLASS(wxPrintPreview
)
726 wxDECLARE_NO_COPY_CLASS(wxPrintPreview
);
729 //----------------------------------------------------------------------------
730 // wxPrintAbortDialog
731 //----------------------------------------------------------------------------
733 class WXDLLIMPEXP_CORE wxPrintAbortDialog
: public wxDialog
736 wxPrintAbortDialog(wxWindow
*parent
,
737 const wxString
& documentTitle
,
738 const wxPoint
& pos
= wxDefaultPosition
,
739 const wxSize
& size
= wxDefaultSize
,
740 long style
= wxDEFAULT_DIALOG_STYLE
,
741 const wxString
& name
= wxT("dialog"));
743 void SetProgress(int currentPage
, int totalPages
,
744 int currentCopy
, int totalCopies
);
746 void OnCancel(wxCommandEvent
& event
);
749 wxStaticText
*m_progress
;
751 DECLARE_EVENT_TABLE()
752 wxDECLARE_NO_COPY_CLASS(wxPrintAbortDialog
);
755 #endif // wxUSE_PRINTING_ARCHITECTURE