1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Base classes for printing framework
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PRNTBASEH__
13 #define _WX_PRNTBASEH__
17 #if wxUSE_PRINTING_ARCHITECTURE
20 #include "wx/cmndata.h"
22 #include "wx/scrolwin.h"
23 #include "wx/dialog.h"
27 class WXDLLIMPEXP_FWD_CORE wxDC
;
28 class WXDLLIMPEXP_FWD_CORE wxButton
;
29 class WXDLLIMPEXP_FWD_CORE wxChoice
;
30 class WXDLLIMPEXP_FWD_CORE wxPrintout
;
31 class WXDLLIMPEXP_FWD_CORE wxPrinterBase
;
32 class WXDLLIMPEXP_FWD_CORE wxPrintDialogBase
;
33 class WXDLLIMPEXP_FWD_CORE wxPrintDialog
;
34 class WXDLLIMPEXP_FWD_CORE wxPageSetupDialogBase
;
35 class WXDLLIMPEXP_FWD_CORE wxPageSetupDialog
;
36 class WXDLLIMPEXP_FWD_CORE wxPrintPreviewBase
;
37 class WXDLLIMPEXP_FWD_CORE wxPreviewCanvas
;
38 class WXDLLIMPEXP_FWD_CORE wxPreviewControlBar
;
39 class WXDLLIMPEXP_FWD_CORE wxPreviewFrame
;
40 class WXDLLIMPEXP_FWD_CORE wxPrintFactory
;
41 class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase
;
42 class WXDLLIMPEXP_FWD_CORE wxPrintPreview
;
43 class WXDLLIMPEXP_FWD_CORE wxPrintAbortDialog
;
44 class WXDLLIMPEXP_FWD_CORE wxStaticText
;
45 class wxPrintPageMaxCtrl
;
46 class wxPrintPageTextCtrl
;
48 //----------------------------------------------------------------------------
50 //----------------------------------------------------------------------------
54 wxPRINTER_NO_ERROR
= 0,
59 // Preview frame modality kind used with wxPreviewFrame::Initialize()
60 enum wxPreviewFrameModalityKind
62 // Disable all the other top level windows while the preview is shown.
63 wxPreviewFrame_AppModal
,
65 // Disable only the parent window while the preview is shown.
66 wxPreviewFrame_WindowModal
,
68 // Don't disable any windows.
69 wxPreviewFrame_NonModal
72 //----------------------------------------------------------------------------
74 //----------------------------------------------------------------------------
76 class WXDLLIMPEXP_CORE wxPrintFactory
80 virtual ~wxPrintFactory() {}
82 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
* data
) = 0;
84 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
85 wxPrintout
*printout
= NULL
,
86 wxPrintDialogData
*data
= NULL
) = 0;
87 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
89 wxPrintData
*data
) = 0;
91 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
92 wxPrintDialogData
*data
= NULL
) = 0;
93 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
94 wxPrintData
*data
) = 0;
96 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
97 wxPageSetupDialogData
* data
= NULL
) = 0;
99 virtual wxDCImpl
* CreatePrinterDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
) = 0;
101 // What to do and what to show in the wxPrintDialog
102 // a) Use the generic print setup dialog or a native one?
103 virtual bool HasPrintSetupDialog() = 0;
104 virtual wxDialog
*CreatePrintSetupDialog( wxWindow
*parent
, wxPrintData
*data
) = 0;
105 // b) Provide the "print to file" option ourselves or via print setup?
106 virtual bool HasOwnPrintToFile() = 0;
107 // c) Show current printer
108 virtual bool HasPrinterLine() = 0;
109 virtual wxString
CreatePrinterLine() = 0;
110 // d) Show Status line for current printer?
111 virtual bool HasStatusLine() = 0;
112 virtual wxString
CreateStatusLine() = 0;
115 virtual wxPrintNativeDataBase
*CreatePrintNativeData() = 0;
117 static void SetPrintFactory( wxPrintFactory
*factory
);
118 static wxPrintFactory
*GetFactory();
120 static wxPrintFactory
*m_factory
;
123 class WXDLLIMPEXP_CORE wxNativePrintFactory
: public wxPrintFactory
126 virtual wxPrinterBase
*CreatePrinter( wxPrintDialogData
*data
);
128 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
129 wxPrintout
*printout
= NULL
,
130 wxPrintDialogData
*data
= NULL
);
131 virtual wxPrintPreviewBase
*CreatePrintPreview( wxPrintout
*preview
,
132 wxPrintout
*printout
,
135 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
136 wxPrintDialogData
*data
= NULL
);
137 virtual wxPrintDialogBase
*CreatePrintDialog( wxWindow
*parent
,
140 virtual wxPageSetupDialogBase
*CreatePageSetupDialog( wxWindow
*parent
,
141 wxPageSetupDialogData
* data
= NULL
);
143 virtual wxDCImpl
* CreatePrinterDCImpl( wxPrinterDC
*owner
, const wxPrintData
& data
);
145 virtual bool HasPrintSetupDialog();
146 virtual wxDialog
*CreatePrintSetupDialog( wxWindow
*parent
, wxPrintData
*data
);
147 virtual bool HasOwnPrintToFile();
148 virtual bool HasPrinterLine();
149 virtual wxString
CreatePrinterLine();
150 virtual bool HasStatusLine();
151 virtual wxString
CreateStatusLine();
153 virtual wxPrintNativeDataBase
*CreatePrintNativeData();
156 //----------------------------------------------------------------------------
157 // wxPrintNativeDataBase
158 //----------------------------------------------------------------------------
160 class WXDLLIMPEXP_CORE wxPrintNativeDataBase
: public wxObject
163 wxPrintNativeDataBase();
164 virtual ~wxPrintNativeDataBase() {}
166 virtual bool TransferTo( wxPrintData
&data
) = 0;
167 virtual bool TransferFrom( const wxPrintData
&data
) = 0;
169 virtual bool Ok() const { return IsOk(); }
170 virtual bool IsOk() const = 0;
175 DECLARE_CLASS(wxPrintNativeDataBase
)
176 wxDECLARE_NO_COPY_CLASS(wxPrintNativeDataBase
);
179 //----------------------------------------------------------------------------
181 //----------------------------------------------------------------------------
184 * Represents the printer: manages printing a wxPrintout object
187 class WXDLLIMPEXP_CORE wxPrinterBase
: public wxObject
190 wxPrinterBase(wxPrintDialogData
*data
= NULL
);
191 virtual ~wxPrinterBase();
193 virtual wxPrintAbortDialog
*CreateAbortWindow(wxWindow
*parent
, wxPrintout
*printout
);
194 virtual void ReportError(wxWindow
*parent
, wxPrintout
*printout
, const wxString
& message
);
196 virtual wxPrintDialogData
& GetPrintDialogData() const;
197 bool GetAbort() const { return sm_abortIt
; }
199 static wxPrinterError
GetLastError() { return sm_lastError
; }
201 ///////////////////////////////////////////////////////////////////////////
204 virtual bool Setup(wxWindow
*parent
) = 0;
205 virtual bool Print(wxWindow
*parent
, wxPrintout
*printout
, bool prompt
= true) = 0;
206 virtual wxDC
* PrintDialog(wxWindow
*parent
) = 0;
209 wxPrintDialogData m_printDialogData
;
210 wxPrintout
* m_currentPrintout
;
212 static wxPrinterError sm_lastError
;
215 static wxWindow
* sm_abortWindow
;
216 static bool sm_abortIt
;
219 DECLARE_CLASS(wxPrinterBase
)
220 wxDECLARE_NO_COPY_CLASS(wxPrinterBase
);
223 //----------------------------------------------------------------------------
225 //----------------------------------------------------------------------------
227 class WXDLLIMPEXP_CORE wxPrinter
: public wxPrinterBase
230 wxPrinter(wxPrintDialogData
*data
= NULL
);
231 virtual ~wxPrinter();
233 virtual wxPrintAbortDialog
*CreateAbortWindow(wxWindow
*parent
, wxPrintout
*printout
);
234 virtual void ReportError(wxWindow
*parent
, wxPrintout
*printout
, const wxString
& message
);
236 virtual bool Setup(wxWindow
*parent
);
237 virtual bool Print(wxWindow
*parent
, wxPrintout
*printout
, bool prompt
= true);
238 virtual wxDC
* PrintDialog(wxWindow
*parent
);
240 virtual wxPrintDialogData
& GetPrintDialogData() const;
243 wxPrinterBase
*m_pimpl
;
246 DECLARE_CLASS(wxPrinter
)
247 wxDECLARE_NO_COPY_CLASS(wxPrinter
);
250 //----------------------------------------------------------------------------
252 //----------------------------------------------------------------------------
255 * Represents an object via which a document may be printed.
256 * The programmer derives from this, overrides (at least) OnPrintPage,
257 * and passes it to a wxPrinter object for printing, or a wxPrintPreview
258 * object for previewing.
261 class WXDLLIMPEXP_CORE wxPrintout
: public wxObject
264 wxPrintout(const wxString
& title
= _("Printout"));
265 virtual ~wxPrintout();
267 virtual bool OnBeginDocument(int startPage
, int endPage
);
268 virtual void OnEndDocument();
269 virtual void OnBeginPrinting();
270 virtual void OnEndPrinting();
272 // Guaranteed to be before any other functions are called
273 virtual void OnPreparePrinting() { }
275 virtual bool HasPage(int page
);
276 virtual bool OnPrintPage(int page
) = 0;
277 virtual void GetPageInfo(int *minPage
, int *maxPage
, int *pageFrom
, int *pageTo
);
279 virtual wxString
GetTitle() const { return m_printoutTitle
; }
281 wxDC
*GetDC() const { return m_printoutDC
; }
282 void SetDC(wxDC
*dc
) { m_printoutDC
= dc
; }
284 void FitThisSizeToPaper(const wxSize
& imageSize
);
285 void FitThisSizeToPage(const wxSize
& imageSize
);
286 void FitThisSizeToPageMargins(const wxSize
& imageSize
, const wxPageSetupDialogData
& pageSetupData
);
287 void MapScreenSizeToPaper();
288 void MapScreenSizeToPage();
289 void MapScreenSizeToPageMargins(const wxPageSetupDialogData
& pageSetupData
);
290 void MapScreenSizeToDevice();
292 wxRect
GetLogicalPaperRect() const;
293 wxRect
GetLogicalPageRect() const;
294 wxRect
GetLogicalPageMarginsRect(const wxPageSetupDialogData
& pageSetupData
) const;
296 void SetLogicalOrigin(wxCoord x
, wxCoord y
);
297 void OffsetLogicalOrigin(wxCoord xoff
, wxCoord yoff
);
299 void SetPageSizePixels(int w
, int h
) { m_pageWidthPixels
= w
; m_pageHeightPixels
= h
; }
300 void GetPageSizePixels(int *w
, int *h
) const { *w
= m_pageWidthPixels
; *h
= m_pageHeightPixels
; }
301 void SetPageSizeMM(int w
, int h
) { m_pageWidthMM
= w
; m_pageHeightMM
= h
; }
302 void GetPageSizeMM(int *w
, int *h
) const { *w
= m_pageWidthMM
; *h
= m_pageHeightMM
; }
304 void SetPPIScreen(int x
, int y
) { m_PPIScreenX
= x
; m_PPIScreenY
= y
; }
305 void SetPPIScreen(const wxSize
& ppi
) { SetPPIScreen(ppi
.x
, ppi
.y
); }
306 void GetPPIScreen(int *x
, int *y
) const { *x
= m_PPIScreenX
; *y
= m_PPIScreenY
; }
307 void SetPPIPrinter(int x
, int y
) { m_PPIPrinterX
= x
; m_PPIPrinterY
= y
; }
308 void SetPPIPrinter(const wxSize
& ppi
) { SetPPIPrinter(ppi
.x
, ppi
.y
); }
309 void GetPPIPrinter(int *x
, int *y
) const { *x
= m_PPIPrinterX
; *y
= m_PPIPrinterY
; }
311 void SetPaperRectPixels(const wxRect
& paperRectPixels
) { m_paperRectPixels
= paperRectPixels
; }
312 wxRect
GetPaperRectPixels() const { return m_paperRectPixels
; }
314 // This must be called by wxPrintPreview to associate itself with the
316 virtual void SetPreview(wxPrintPreview
*preview
) { m_preview
= preview
; }
318 wxPrintPreview
*GetPreview() const { return m_preview
; }
319 virtual bool IsPreview() const { return GetPreview() != NULL
; }
322 wxString m_printoutTitle
;
324 wxPrintPreview
*m_preview
;
326 int m_pageWidthPixels
;
327 int m_pageHeightPixels
;
337 wxRect m_paperRectPixels
;
340 DECLARE_ABSTRACT_CLASS(wxPrintout
)
341 wxDECLARE_NO_COPY_CLASS(wxPrintout
);
344 //----------------------------------------------------------------------------
346 //----------------------------------------------------------------------------
349 * Canvas upon which a preview is drawn.
352 class WXDLLIMPEXP_CORE wxPreviewCanvas
: public wxScrolledWindow
355 wxPreviewCanvas(wxPrintPreviewBase
*preview
,
357 const wxPoint
& pos
= wxDefaultPosition
,
358 const wxSize
& size
= wxDefaultSize
,
360 const wxString
& name
= wxT("canvas"));
361 virtual ~wxPreviewCanvas();
363 void SetPreview(wxPrintPreviewBase
*preview
) { m_printPreview
= preview
; }
365 void OnPaint(wxPaintEvent
& event
);
366 void OnChar(wxKeyEvent
&event
);
367 // Responds to colour changes
368 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
372 void OnMouseWheel(wxMouseEvent
& event
);
373 #endif // wxUSE_MOUSEWHEEL
374 void OnIdle(wxIdleEvent
& event
);
376 wxPrintPreviewBase
* m_printPreview
;
378 DECLARE_CLASS(wxPreviewCanvas
)
379 DECLARE_EVENT_TABLE()
380 wxDECLARE_NO_COPY_CLASS(wxPreviewCanvas
);
383 //----------------------------------------------------------------------------
385 //----------------------------------------------------------------------------
388 * Default frame for showing preview.
391 class WXDLLIMPEXP_CORE wxPreviewFrame
: public wxFrame
394 wxPreviewFrame(wxPrintPreviewBase
*preview
,
396 const wxString
& title
= _("Print Preview"),
397 const wxPoint
& pos
= wxDefaultPosition
,
398 const wxSize
& size
= wxDefaultSize
,
399 long style
= wxDEFAULT_FRAME_STYLE
| wxFRAME_FLOAT_ON_PARENT
,
400 const wxString
& name
= wxFrameNameStr
);
401 virtual ~wxPreviewFrame();
403 // Either Initialize() or InitializeWithModality() must be called before
404 // showing the preview frame, the former being just a particular case of
405 // the latter initializing the frame for being showing app-modally.
407 // Notice that we must keep Initialize() with its existing signature to
408 // avoid breaking the old code that overrides it and we can't reuse the
409 // same name for the other functions to avoid virtual function hiding
410 // problem and the associated warnings given by some compilers (e.g. from
411 // g++ with -Woverloaded-virtual).
412 virtual void Initialize()
414 InitializeWithModality(wxPreviewFrame_AppModal
);
417 // Also note that this method is not virtual as it doesn't need to be
418 // overridden: it's never called by wxWidgets (of course, the same is true
419 // for Initialize() but, again, it must remain virtual for compatibility).
420 void InitializeWithModality(wxPreviewFrameModalityKind kind
);
422 void OnCloseWindow(wxCloseEvent
& event
);
423 virtual void CreateCanvas();
424 virtual void CreateControlBar();
426 inline wxPreviewControlBar
* GetControlBar() const { return m_controlBar
; }
429 wxPreviewCanvas
* m_previewCanvas
;
430 wxPreviewControlBar
* m_controlBar
;
431 wxPrintPreviewBase
* m_printPreview
;
432 wxWindowDisabler
* m_windowDisabler
;
434 wxPreviewFrameModalityKind m_modalityKind
;
438 void OnChar(wxKeyEvent
& event
);
440 DECLARE_EVENT_TABLE()
441 DECLARE_CLASS(wxPreviewFrame
)
442 wxDECLARE_NO_COPY_CLASS(wxPreviewFrame
);
445 //----------------------------------------------------------------------------
446 // wxPreviewControlBar
447 //----------------------------------------------------------------------------
450 * A panel with buttons for controlling a print preview.
451 * The programmer may wish to use other means for controlling
455 #define wxPREVIEW_PRINT 1
456 #define wxPREVIEW_PREVIOUS 2
457 #define wxPREVIEW_NEXT 4
458 #define wxPREVIEW_ZOOM 8
459 #define wxPREVIEW_FIRST 16
460 #define wxPREVIEW_LAST 32
461 #define wxPREVIEW_GOTO 64
463 #define wxPREVIEW_DEFAULT (wxPREVIEW_PREVIOUS|wxPREVIEW_NEXT|wxPREVIEW_ZOOM\
464 |wxPREVIEW_FIRST|wxPREVIEW_GOTO|wxPREVIEW_LAST)
467 #define wxID_PREVIEW_CLOSE 1
468 #define wxID_PREVIEW_NEXT 2
469 #define wxID_PREVIEW_PREVIOUS 3
470 #define wxID_PREVIEW_PRINT 4
471 #define wxID_PREVIEW_ZOOM 5
472 #define wxID_PREVIEW_FIRST 6
473 #define wxID_PREVIEW_LAST 7
474 #define wxID_PREVIEW_GOTO 8
475 #define wxID_PREVIEW_ZOOM_IN 9
476 #define wxID_PREVIEW_ZOOM_OUT 10
478 class WXDLLIMPEXP_CORE wxPreviewControlBar
: public wxPanel
480 DECLARE_CLASS(wxPreviewControlBar
)
483 wxPreviewControlBar(wxPrintPreviewBase
*preview
,
486 const wxPoint
& pos
= wxDefaultPosition
,
487 const wxSize
& size
= wxDefaultSize
,
488 long style
= wxTAB_TRAVERSAL
,
489 const wxString
& name
= wxT("panel"));
490 virtual ~wxPreviewControlBar();
492 virtual void CreateButtons();
493 virtual void SetPageInfo(int minPage
, int maxPage
);
494 virtual void SetZoomControl(int zoom
);
495 virtual int GetZoomControl();
496 virtual wxPrintPreviewBase
*GetPrintPreview() const
497 { return m_printPreview
; }
500 // Implementation only from now on.
501 void OnWindowClose(wxCommandEvent
& event
);
509 void OnPrintButton(wxCommandEvent
& WXUNUSED(event
)) { OnPrint(); }
510 void OnNextButton(wxCommandEvent
& WXUNUSED(event
)) { OnNext(); }
511 void OnPreviousButton(wxCommandEvent
& WXUNUSED(event
)) { OnPrevious(); }
512 void OnFirstButton(wxCommandEvent
& WXUNUSED(event
)) { OnFirst(); }
513 void OnLastButton(wxCommandEvent
& WXUNUSED(event
)) { OnLast(); }
514 void OnPaint(wxPaintEvent
& event
);
516 void OnUpdateNextButton(wxUpdateUIEvent
& event
)
517 { event
.Enable(IsNextEnabled()); }
518 void OnUpdatePreviousButton(wxUpdateUIEvent
& event
)
519 { event
.Enable(IsPreviousEnabled()); }
520 void OnUpdateFirstButton(wxUpdateUIEvent
& event
)
521 { event
.Enable(IsFirstEnabled()); }
522 void OnUpdateLastButton(wxUpdateUIEvent
& event
)
523 { event
.Enable(IsLastEnabled()); }
524 void OnUpdateZoomInButton(wxUpdateUIEvent
& event
)
525 { event
.Enable(IsZoomInEnabled()); }
526 void OnUpdateZoomOutButton(wxUpdateUIEvent
& event
)
527 { event
.Enable(IsZoomOutEnabled()); }
529 // These methods are not private because they are called by wxPreviewCanvas.
534 wxPrintPreviewBase
* m_printPreview
;
535 wxButton
* m_closeButton
;
536 wxChoice
* m_zoomControl
;
537 wxPrintPageTextCtrl
* m_currentPageText
;
538 wxPrintPageMaxCtrl
* m_maxPageText
;
543 void DoGotoPage(int page
);
547 bool IsNextEnabled() const;
548 bool IsPreviousEnabled() const;
549 bool IsFirstEnabled() const;
550 bool IsLastEnabled() const;
551 bool IsZoomInEnabled() const;
552 bool IsZoomOutEnabled() const;
554 void OnZoomInButton(wxCommandEvent
& WXUNUSED(event
)) { DoZoomIn(); }
555 void OnZoomOutButton(wxCommandEvent
& WXUNUSED(event
)) { DoZoomOut(); }
556 void OnZoomChoice(wxCommandEvent
& WXUNUSED(event
)) { DoZoom(); }
558 DECLARE_EVENT_TABLE()
559 wxDECLARE_NO_COPY_CLASS(wxPreviewControlBar
);
562 //----------------------------------------------------------------------------
563 // wxPrintPreviewBase
564 //----------------------------------------------------------------------------
567 * Programmer creates an object of this class to preview a wxPrintout.
570 class WXDLLIMPEXP_CORE wxPrintPreviewBase
: public wxObject
573 wxPrintPreviewBase(wxPrintout
*printout
,
574 wxPrintout
*printoutForPrinting
= NULL
,
575 wxPrintDialogData
*data
= NULL
);
576 wxPrintPreviewBase(wxPrintout
*printout
,
577 wxPrintout
*printoutForPrinting
,
579 virtual ~wxPrintPreviewBase();
581 virtual bool SetCurrentPage(int pageNum
);
582 virtual int GetCurrentPage() const;
584 virtual void SetPrintout(wxPrintout
*printout
);
585 virtual wxPrintout
*GetPrintout() const;
586 virtual wxPrintout
*GetPrintoutForPrinting() const;
588 virtual void SetFrame(wxFrame
*frame
);
589 virtual void SetCanvas(wxPreviewCanvas
*canvas
);
591 virtual wxFrame
*GetFrame() const;
592 virtual wxPreviewCanvas
*GetCanvas() const;
594 // This is a helper routine, used by the next 4 routines.
596 virtual void CalcRects(wxPreviewCanvas
*canvas
, wxRect
& printableAreaRect
, wxRect
& paperRect
);
598 // The preview canvas should call this from OnPaint
599 virtual bool PaintPage(wxPreviewCanvas
*canvas
, wxDC
& dc
);
601 // Updates rendered page by calling RenderPage() if needed, returns true
602 // if there was some change. Preview canvas should call it at idle time
603 virtual bool UpdatePageRendering();
605 // This draws a blank page onto the preview canvas
606 virtual bool DrawBlankPage(wxPreviewCanvas
*canvas
, wxDC
& dc
);
608 // Adjusts the scrollbars for the current scale
609 virtual void AdjustScrollbars(wxPreviewCanvas
*canvas
);
611 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
612 virtual bool RenderPage(int pageNum
);
615 virtual void SetZoom(int percent
);
616 virtual int GetZoom() const;
618 virtual wxPrintDialogData
& GetPrintDialogData();
620 virtual int GetMaxPage() const;
621 virtual int GetMinPage() const;
623 virtual bool Ok() const { return IsOk(); }
624 virtual bool IsOk() const;
625 virtual void SetOk(bool ok
);
627 ///////////////////////////////////////////////////////////////////////////
630 // If we own a wxPrintout that can be used for printing, this
631 // will invoke the actual printing procedure. Called
632 // by the wxPreviewControlBar.
633 virtual bool Print(bool interactive
) = 0;
635 // Calculate scaling that needs to be done to get roughly
636 // the right scaling for the screen pretending to be
637 // the currently selected printer.
638 virtual void DetermineScaling() = 0;
641 // helpers for RenderPage():
642 virtual bool RenderPageIntoDC(wxDC
& dc
, int pageNum
);
643 // renders preview into m_previewBitmap
644 virtual bool RenderPageIntoBitmap(wxBitmap
& bmp
, int pageNum
);
646 void InvalidatePreviewBitmap();
649 wxPrintDialogData m_printDialogData
;
650 wxPreviewCanvas
* m_previewCanvas
;
651 wxFrame
* m_previewFrame
;
652 wxBitmap
* m_previewBitmap
;
653 bool m_previewFailed
;
654 wxPrintout
* m_previewPrintout
;
655 wxPrintout
* m_printPrintout
;
658 float m_previewScaleX
;
659 float m_previewScaleY
;
668 bool m_printingPrepared
; // Called OnPreparePrinting?
671 void Init(wxPrintout
*printout
, wxPrintout
*printoutForPrinting
);
673 wxDECLARE_NO_COPY_CLASS(wxPrintPreviewBase
);
674 DECLARE_CLASS(wxPrintPreviewBase
)
677 //----------------------------------------------------------------------------
679 //----------------------------------------------------------------------------
681 class WXDLLIMPEXP_CORE wxPrintPreview
: public wxPrintPreviewBase
684 wxPrintPreview(wxPrintout
*printout
,
685 wxPrintout
*printoutForPrinting
= NULL
,
686 wxPrintDialogData
*data
= NULL
);
687 wxPrintPreview(wxPrintout
*printout
,
688 wxPrintout
*printoutForPrinting
,
690 virtual ~wxPrintPreview();
692 virtual bool SetCurrentPage(int pageNum
);
693 virtual int GetCurrentPage() const;
694 virtual void SetPrintout(wxPrintout
*printout
);
695 virtual wxPrintout
*GetPrintout() const;
696 virtual wxPrintout
*GetPrintoutForPrinting() const;
697 virtual void SetFrame(wxFrame
*frame
);
698 virtual void SetCanvas(wxPreviewCanvas
*canvas
);
700 virtual wxFrame
*GetFrame() const;
701 virtual wxPreviewCanvas
*GetCanvas() const;
702 virtual bool PaintPage(wxPreviewCanvas
*canvas
, wxDC
& dc
);
703 virtual bool UpdatePageRendering();
704 virtual bool DrawBlankPage(wxPreviewCanvas
*canvas
, wxDC
& dc
);
705 virtual void AdjustScrollbars(wxPreviewCanvas
*canvas
);
706 virtual bool RenderPage(int pageNum
);
707 virtual void SetZoom(int percent
);
708 virtual int GetZoom() const;
710 virtual bool Print(bool interactive
);
711 virtual void DetermineScaling();
713 virtual wxPrintDialogData
& GetPrintDialogData();
715 virtual int GetMaxPage() const;
716 virtual int GetMinPage() const;
718 virtual bool Ok() const { return IsOk(); }
719 virtual bool IsOk() const;
720 virtual void SetOk(bool ok
);
723 wxPrintPreviewBase
*m_pimpl
;
726 DECLARE_CLASS(wxPrintPreview
)
727 wxDECLARE_NO_COPY_CLASS(wxPrintPreview
);
730 //----------------------------------------------------------------------------
731 // wxPrintAbortDialog
732 //----------------------------------------------------------------------------
734 class WXDLLIMPEXP_CORE wxPrintAbortDialog
: public wxDialog
737 wxPrintAbortDialog(wxWindow
*parent
,
738 const wxString
& documentTitle
,
739 const wxPoint
& pos
= wxDefaultPosition
,
740 const wxSize
& size
= wxDefaultSize
,
741 long style
= wxDEFAULT_DIALOG_STYLE
,
742 const wxString
& name
= wxT("dialog"));
744 void SetProgress(int currentPage
, int totalPages
,
745 int currentCopy
, int totalCopies
);
747 void OnCancel(wxCommandEvent
& event
);
750 wxStaticText
*m_progress
;
752 DECLARE_EVENT_TABLE()
753 wxDECLARE_NO_COPY_CLASS(wxPrintAbortDialog
);
756 #endif // wxUSE_PRINTING_ARCHITECTURE