]> git.saurik.com Git - wxWidgets.git/blame - include/wx/prntbase.h
Applied [ 1708971 ] Make a virtual function to enable/disable docking
[wxWidgets.git] / include / wx / prntbase.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
ce7208d4 2// Name: wx/prntbase.h
c801d85f
KB
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
c801d85f 15#include "wx/defs.h"
d427503c
VZ
16
17#if wxUSE_PRINTING_ARCHITECTURE
18
c801d85f
KB
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"
34138703 24#include "wx/frame.h"
c801d85f 25
b5dbe15d
VS
26class WXDLLIMPEXP_FWD_CORE wxDC;
27class WXDLLIMPEXP_FWD_CORE wxButton;
28class WXDLLIMPEXP_FWD_CORE wxChoice;
29class WXDLLIMPEXP_FWD_CORE wxPrintout;
30class WXDLLIMPEXP_FWD_CORE wxPrinterBase;
31class WXDLLIMPEXP_FWD_CORE wxPrintDialogBase;
32class WXDLLIMPEXP_FWD_CORE wxPrintDialog;
33class WXDLLIMPEXP_FWD_CORE wxPageSetupDialogBase;
34class WXDLLIMPEXP_FWD_CORE wxPageSetupDialog;
35class WXDLLIMPEXP_FWD_CORE wxPrintPreviewBase;
36class WXDLLIMPEXP_FWD_CORE wxPreviewCanvas;
37class WXDLLIMPEXP_FWD_CORE wxPreviewControlBar;
38class WXDLLIMPEXP_FWD_CORE wxPreviewFrame;
39class WXDLLIMPEXP_FWD_CORE wxPrintFactory;
40class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
c801d85f 41
e81e3883
RR
42//----------------------------------------------------------------------------
43// error consts
44//----------------------------------------------------------------------------
f6bcfd97
BP
45
46enum wxPrinterError
47{
48 wxPRINTER_NO_ERROR = 0,
49 wxPRINTER_CANCELLED,
50 wxPRINTER_ERROR
51};
52
e81e3883
RR
53//----------------------------------------------------------------------------
54// wxPrintFactory
55//----------------------------------------------------------------------------
56
57class WXDLLEXPORT wxPrintFactory
58{
59public:
60 wxPrintFactory() {}
61 virtual ~wxPrintFactory() {}
d0ee33f5 62
e81e3883 63 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData* data ) = 0;
d0ee33f5
WS
64
65 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
66 wxPrintout *printout = NULL,
e81e3883 67 wxPrintDialogData *data = NULL ) = 0;
d0ee33f5
WS
68 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
69 wxPrintout *printout,
e81e3883 70 wxPrintData *data ) = 0;
c061373d 71
d0ee33f5 72 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
c061373d 73 wxPrintDialogData *data = NULL ) = 0;
d0ee33f5 74 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
c061373d 75 wxPrintData *data ) = 0;
d0ee33f5 76
08680429
RR
77 virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
78 wxPageSetupDialogData * data = NULL ) = 0;
d0ee33f5 79
147bf263
JS
80 virtual wxDC* CreatePrinterDC( const wxPrintData& data ) = 0;
81
6038ec8e
RR
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
d0ee33f5 95
8850cbd3 96 virtual wxPrintNativeDataBase *CreatePrintNativeData() = 0;
d0ee33f5 97
e81e3883
RR
98 static void SetPrintFactory( wxPrintFactory *factory );
99 static wxPrintFactory *GetFactory();
33d094d1 100private:
e81e3883
RR
101 static wxPrintFactory *m_factory;
102};
103
104class WXDLLEXPORT wxNativePrintFactory: public wxPrintFactory
105{
106public:
e81e3883 107 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
d0ee33f5
WS
108
109 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
110 wxPrintout *printout = NULL,
e81e3883 111 wxPrintDialogData *data = NULL );
d0ee33f5 112 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
e81e3883
RR
113 wxPrintout *printout,
114 wxPrintData *data );
d0ee33f5
WS
115
116 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
c061373d 117 wxPrintDialogData *data = NULL );
d0ee33f5 118 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
c061373d 119 wxPrintData *data );
d0ee33f5 120
08680429
RR
121 virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
122 wxPageSetupDialogData * data = NULL );
d0ee33f5 123
147bf263
JS
124 virtual wxDC* CreatePrinterDC( const wxPrintData& data );
125
6038ec8e
RR
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();
d0ee33f5 133
8850cbd3
RR
134 virtual wxPrintNativeDataBase *CreatePrintNativeData();
135};
136
137//----------------------------------------------------------------------------
138// wxPrintNativeDataBase
139//----------------------------------------------------------------------------
140
141class WXDLLEXPORT wxPrintNativeDataBase: public wxObject
142{
143public:
144 wxPrintNativeDataBase();
145 virtual ~wxPrintNativeDataBase() {}
d0ee33f5 146
fd64de59 147 virtual bool TransferTo( wxPrintData &data ) = 0;
d0ee33f5
WS
148 virtual bool TransferFrom( const wxPrintData &data ) = 0;
149
b7cacb43
VZ
150 virtual bool Ok() const { return IsOk(); }
151 virtual bool IsOk() const = 0;
d0ee33f5 152
8850cbd3 153 int m_ref;
d0ee33f5 154
8850cbd3
RR
155private:
156 DECLARE_CLASS(wxPrintNativeDataBase)
157 DECLARE_NO_COPY_CLASS(wxPrintNativeDataBase)
e81e3883
RR
158};
159
160//----------------------------------------------------------------------------
161// wxPrinterBase
162//----------------------------------------------------------------------------
f6bcfd97 163
c801d85f
KB
164/*
165 * Represents the printer: manages printing a wxPrintout object
166 */
d6b9496a 167
c801d85f
KB
168class WXDLLEXPORT wxPrinterBase: public wxObject
169{
34da0970 170public:
d6b9496a
VZ
171 wxPrinterBase(wxPrintDialogData *data = (wxPrintDialogData *) NULL);
172 virtual ~wxPrinterBase();
173
174 virtual wxWindow *CreateAbortWindow(wxWindow *parent, wxPrintout *printout);
161f4f73 175 virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message);
c801d85f 176
c061373d 177 virtual wxPrintDialogData& GetPrintDialogData() const;
d6b9496a 178 bool GetAbort() const { return sm_abortIt; }
7e548f6b 179
f6bcfd97 180 static wxPrinterError GetLastError() { return sm_lastError; }
c801d85f 181
d6b9496a
VZ
182 ///////////////////////////////////////////////////////////////////////////
183 // OVERRIDES
c801d85f 184
d6b9496a 185 virtual bool Setup(wxWindow *parent) = 0;
7e548f6b 186 virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true) = 0;
d6b9496a 187 virtual wxDC* PrintDialog(wxWindow *parent) = 0;
34da0970
JS
188
189protected:
d6b9496a
VZ
190 wxPrintDialogData m_printDialogData;
191 wxPrintout* m_currentPrintout;
7e548f6b 192
f6bcfd97 193 static wxPrinterError sm_lastError;
7e548f6b 194
34da0970 195public:
d6b9496a
VZ
196 static wxWindow* sm_abortWindow;
197 static bool sm_abortIt;
34da0970 198
2b5f62a0
VZ
199private:
200 DECLARE_CLASS(wxPrinterBase)
22f3361e 201 DECLARE_NO_COPY_CLASS(wxPrinterBase)
c801d85f
KB
202};
203
e81e3883
RR
204//----------------------------------------------------------------------------
205// wxPrinter
206//----------------------------------------------------------------------------
207
208class WXDLLEXPORT wxPrinter: public wxPrinterBase
209{
210public:
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);
d0ee33f5 220
c061373d 221 virtual wxPrintDialogData& GetPrintDialogData() const;
e81e3883
RR
222
223protected:
224 wxPrinterBase *m_pimpl;
d0ee33f5 225
e81e3883
RR
226private:
227 DECLARE_CLASS(wxPrinter)
228 DECLARE_NO_COPY_CLASS(wxPrinter)
229};
230
231//----------------------------------------------------------------------------
232// wxPrintout
233//----------------------------------------------------------------------------
234
c801d85f 235/*
c801d85f
KB
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 */
d6b9496a 241
c801d85f
KB
242class WXDLLEXPORT wxPrintout: public wxObject
243{
34da0970 244public:
2b5f62a0 245 wxPrintout(const wxString& title = wxT("Printout"));
d6b9496a 246 virtual ~wxPrintout();
c801d85f 247
d6b9496a
VZ
248 virtual bool OnBeginDocument(int startPage, int endPage);
249 virtual void OnEndDocument();
250 virtual void OnBeginPrinting();
251 virtual void OnEndPrinting();
c801d85f 252
d6b9496a
VZ
253 // Guaranteed to be before any other functions are called
254 virtual void OnPreparePrinting() { }
c801d85f 255
d6b9496a
VZ
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);
c801d85f 259
d6b9496a 260 virtual wxString GetTitle() const { return m_printoutTitle; }
34da0970 261
d6b9496a
VZ
262 wxDC *GetDC() const { return m_printoutDC; }
263 void SetDC(wxDC *dc) { m_printoutDC = dc; }
f415cab9
JS
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
d6b9496a
VZ
280 void SetPageSizePixels(int w, int h) { m_pageWidthPixels = w; m_pageHeightPixels = h; }
281 void GetPageSizePixels(int *w, int *h) const { *w = m_pageWidthPixels; *h = m_pageHeightPixels; }
282 void SetPageSizeMM(int w, int h) { m_pageWidthMM = w; m_pageHeightMM = h; }
283 void GetPageSizeMM(int *w, int *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; }
34da0970 284
d6b9496a
VZ
285 void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; }
286 void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; }
287 void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; }
288 void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; }
34da0970 289
f415cab9
JS
290 void SetPaperRectPixels(const wxRect& paperRectPixels) { m_paperRectPixels = paperRectPixels; }
291 wxRect GetPaperRectPixels() const { return m_paperRectPixels; }
292
d6b9496a 293 virtual bool IsPreview() const { return m_isPreview; }
34da0970 294
d6b9496a 295 virtual void SetIsPreview(bool p) { m_isPreview = p; }
34da0970
JS
296
297private:
d6b9496a
VZ
298 wxString m_printoutTitle;
299 wxDC* m_printoutDC;
c801d85f 300
d6b9496a
VZ
301 int m_pageWidthPixels;
302 int m_pageHeightPixels;
c801d85f 303
d6b9496a
VZ
304 int m_pageWidthMM;
305 int m_pageHeightMM;
c801d85f 306
d6b9496a
VZ
307 int m_PPIScreenX;
308 int m_PPIScreenY;
309 int m_PPIPrinterX;
310 int m_PPIPrinterY;
c801d85f 311
f415cab9
JS
312 wxRect m_paperRectPixels;
313
d6b9496a 314 bool m_isPreview;
2b5f62a0
VZ
315
316private:
317 DECLARE_ABSTRACT_CLASS(wxPrintout)
22f3361e 318 DECLARE_NO_COPY_CLASS(wxPrintout)
c801d85f
KB
319};
320
f415cab9
JS
321//----------------------------------------------------------------------------
322// wxPreviewCanvas
323//----------------------------------------------------------------------------
324
c801d85f 325/*
c801d85f
KB
326 * Canvas upon which a preview is drawn.
327 */
d6b9496a 328
c801d85f
KB
329class WXDLLEXPORT wxPreviewCanvas: public wxScrolledWindow
330{
34da0970 331public:
d6b9496a
VZ
332 wxPreviewCanvas(wxPrintPreviewBase *preview,
333 wxWindow *parent,
334 const wxPoint& pos = wxDefaultPosition,
335 const wxSize& size = wxDefaultSize,
336 long style = 0,
2b5f62a0 337 const wxString& name = wxT("canvas"));
d3c7fc99 338 virtual ~wxPreviewCanvas();
c801d85f 339
d6b9496a 340 void OnPaint(wxPaintEvent& event);
d2b354f9 341 void OnChar(wxKeyEvent &event);
d6b9496a
VZ
342 // Responds to colour changes
343 void OnSysColourChanged(wxSysColourChangedEvent& event);
c801d85f 344
34da0970 345private:
fb6efdf2
VZ
346#if wxUSE_MOUSEWHEEL
347 void OnMouseWheel(wxMouseEvent& event);
348#endif // wxUSE_MOUSEWHEEL
349
d6b9496a 350 wxPrintPreviewBase* m_printPreview;
34da0970 351
2b5f62a0 352 DECLARE_CLASS(wxPreviewCanvas)
d6b9496a 353 DECLARE_EVENT_TABLE()
22f3361e 354 DECLARE_NO_COPY_CLASS(wxPreviewCanvas)
c801d85f
KB
355};
356
f415cab9
JS
357//----------------------------------------------------------------------------
358// wxPreviewFrame
359//----------------------------------------------------------------------------
360
c801d85f 361/*
c801d85f
KB
362 * Default frame for showing preview.
363 */
364
365class WXDLLEXPORT wxPreviewFrame: public wxFrame
366{
34da0970 367public:
d6b9496a 368 wxPreviewFrame(wxPrintPreviewBase *preview,
a5ae8241 369 wxWindow *parent,
2b5f62a0 370 const wxString& title = wxT("Print Preview"),
d6b9496a
VZ
371 const wxPoint& pos = wxDefaultPosition,
372 const wxSize& size = wxDefaultSize,
e9cafd42 373 long style = wxDEFAULT_FRAME_STYLE,
2b5f62a0 374 const wxString& name = wxT("frame"));
d3c7fc99 375 virtual ~wxPreviewFrame();
d6b9496a
VZ
376
377 void OnCloseWindow(wxCloseEvent& event);
378 virtual void Initialize();
379 virtual void CreateCanvas();
380 virtual void CreateControlBar();
d2b354f9
JS
381
382 inline wxPreviewControlBar* GetControlBar() const { return m_controlBar; }
383
34da0970 384protected:
d2b354f9 385 wxPreviewCanvas* m_previewCanvas;
d6b9496a
VZ
386 wxPreviewControlBar* m_controlBar;
387 wxPrintPreviewBase* m_printPreview;
7c995553 388 wxWindowDisabler* m_windowDisabler;
e3065973 389
d6b9496a 390private:
2b5f62a0 391 DECLARE_CLASS(wxPreviewFrame)
d6b9496a 392 DECLARE_EVENT_TABLE()
22f3361e 393 DECLARE_NO_COPY_CLASS(wxPreviewFrame)
c801d85f
KB
394};
395
f415cab9
JS
396//----------------------------------------------------------------------------
397// wxPreviewControlBar
398//----------------------------------------------------------------------------
399
c801d85f 400/*
c801d85f
KB
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
bf89b538
JS
410#define wxPREVIEW_FIRST 16
411#define wxPREVIEW_LAST 32
412#define wxPREVIEW_GOTO 64
c801d85f 413
d0ee33f5
WS
414#define wxPREVIEW_DEFAULT (wxPREVIEW_PREVIOUS|wxPREVIEW_NEXT|wxPREVIEW_ZOOM\
415 |wxPREVIEW_FIRST|wxPREVIEW_GOTO|wxPREVIEW_LAST)
c801d85f
KB
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
bf89b538
JS
423#define wxID_PREVIEW_FIRST 6
424#define wxID_PREVIEW_LAST 7
425#define wxID_PREVIEW_GOTO 8
c801d85f
KB
426
427class WXDLLEXPORT wxPreviewControlBar: public wxPanel
428{
d6b9496a 429 DECLARE_CLASS(wxPreviewControlBar)
c801d85f 430
34da0970 431public:
d6b9496a
VZ
432 wxPreviewControlBar(wxPrintPreviewBase *preview,
433 long buttons,
434 wxWindow *parent,
435 const wxPoint& pos = wxDefaultPosition,
436 const wxSize& size = wxDefaultSize,
d2b354f9 437 long style = wxTAB_TRAVERSAL,
2b5f62a0 438 const wxString& name = wxT("panel"));
d3c7fc99 439 virtual ~wxPreviewControlBar();
d6b9496a
VZ
440
441 virtual void CreateButtons();
442 virtual void SetZoomControl(int zoom);
443 virtual int GetZoomControl();
444 virtual wxPrintPreviewBase *GetPrintPreview() const
445 { return m_printPreview; }
446
d6b9496a 447 void OnWindowClose(wxCommandEvent& event);
0f90ec93
KB
448 void OnNext();
449 void OnPrevious();
bf89b538
JS
450 void OnFirst();
451 void OnLast();
452 void OnGoto();
b38b0d22 453 void OnPrint();
90b6b974 454 void OnPrintButton(wxCommandEvent& WXUNUSED(event)) { OnPrint(); }
014b0d06
VZ
455 void OnNextButton(wxCommandEvent & WXUNUSED(event)) { OnNext(); }
456 void OnPreviousButton(wxCommandEvent & WXUNUSED(event)) { OnPrevious(); }
bf89b538
JS
457 void OnFirstButton(wxCommandEvent & WXUNUSED(event)) { OnFirst(); }
458 void OnLastButton(wxCommandEvent & WXUNUSED(event)) { OnLast(); }
459 void OnGotoButton(wxCommandEvent & WXUNUSED(event)) { OnGoto(); }
d6b9496a
VZ
460 void OnZoom(wxCommandEvent& event);
461 void OnPaint(wxPaintEvent& event);
c801d85f 462
34da0970 463protected:
d6b9496a
VZ
464 wxPrintPreviewBase* m_printPreview;
465 wxButton* m_closeButton;
466 wxButton* m_nextPageButton;
467 wxButton* m_previousPageButton;
468 wxButton* m_printButton;
469 wxChoice* m_zoomControl;
bf89b538
JS
470 wxButton* m_firstPageButton;
471 wxButton* m_lastPageButton;
472 wxButton* m_gotoPageButton;
d6b9496a
VZ
473 long m_buttonFlags;
474
475private:
476 DECLARE_EVENT_TABLE()
22f3361e 477 DECLARE_NO_COPY_CLASS(wxPreviewControlBar)
c801d85f
KB
478};
479
e81e3883
RR
480//----------------------------------------------------------------------------
481// wxPrintPreviewBase
482//----------------------------------------------------------------------------
483
c801d85f 484/*
c801d85f
KB
485 * Programmer creates an object of this class to preview a wxPrintout.
486 */
d6b9496a 487
c801d85f
KB
488class WXDLLEXPORT wxPrintPreviewBase: public wxObject
489{
34da0970 490public:
d6b9496a
VZ
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();
c801d85f 498
d6b9496a 499 virtual bool SetCurrentPage(int pageNum);
e81e3883 500 virtual int GetCurrentPage() const;
c801d85f 501
e81e3883
RR
502 virtual void SetPrintout(wxPrintout *printout);
503 virtual wxPrintout *GetPrintout() const;
504 virtual wxPrintout *GetPrintoutForPrinting() const;
c801d85f 505
e81e3883
RR
506 virtual void SetFrame(wxFrame *frame);
507 virtual void SetCanvas(wxPreviewCanvas *canvas);
c801d85f 508
e81e3883
RR
509 virtual wxFrame *GetFrame() const;
510 virtual wxPreviewCanvas *GetCanvas() const;
c801d85f 511
f415cab9
JS
512 // This is a helper routine, used by the next 4 routines.
513
514 virtual void CalcRects(wxPreviewCanvas *canvas, wxRect& printableAreaRect, wxRect& paperRect);
515
d6b9496a 516 // The preview canvas should call this from OnPaint
d2b354f9 517 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
c801d85f 518
d6b9496a 519 // This draws a blank page onto the preview canvas
d2b354f9
JS
520 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
521
522 // Adjusts the scrollbars for the current scale
523 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
c801d85f 524
d6b9496a
VZ
525 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
526 virtual bool RenderPage(int pageNum);
c801d85f 527
c801d85f 528
d6b9496a 529 virtual void SetZoom(int percent);
e81e3883 530 virtual int GetZoom() const;
34da0970 531
e81e3883 532 virtual wxPrintDialogData& GetPrintDialogData();
d0ee33f5 533
e81e3883
RR
534 virtual int GetMaxPage() const;
535 virtual int GetMinPage() const;
c801d85f 536
b7cacb43
VZ
537 virtual bool Ok() const { return IsOk(); }
538 virtual bool IsOk() const;
e81e3883 539 virtual void SetOk(bool ok);
c801d85f 540
d6b9496a
VZ
541 ///////////////////////////////////////////////////////////////////////////
542 // OVERRIDES
c801d85f 543
d6b9496a
VZ
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;
c801d85f 548
d6b9496a
VZ
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;
34da0970
JS
553
554protected:
d6b9496a 555 wxPrintDialogData m_printDialogData;
d2b354f9 556 wxPreviewCanvas* m_previewCanvas;
d6b9496a
VZ
557 wxFrame* m_previewFrame;
558 wxBitmap* m_previewBitmap;
559 wxPrintout* m_previewPrintout;
560 wxPrintout* m_printPrintout;
561 int m_currentPage;
562 int m_currentZoom;
f415cab9
JS
563 float m_previewScaleX;
564 float m_previewScaleY;
d6b9496a
VZ
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;
1044a386 573 bool m_printingPrepared; // Called OnPreparePrinting?
d6b9496a
VZ
574
575private:
576 void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
22f3361e
VZ
577
578 DECLARE_NO_COPY_CLASS(wxPrintPreviewBase)
e81e3883 579 DECLARE_CLASS(wxPrintPreviewBase)
c801d85f
KB
580};
581
e81e3883
RR
582//----------------------------------------------------------------------------
583// wxPrintPreview
584//----------------------------------------------------------------------------
585
586class WXDLLEXPORT wxPrintPreview: public wxPrintPreviewBase
587{
588public:
589 wxPrintPreview(wxPrintout *printout,
590 wxPrintout *printoutForPrinting = (wxPrintout *) NULL,
591 wxPrintDialogData *data = (wxPrintDialogData *) NULL);
592 wxPrintPreview(wxPrintout *printout,
593 wxPrintout *printoutForPrinting,
594 wxPrintData *data);
595 virtual ~wxPrintPreview();
596
597 virtual bool SetCurrentPage(int pageNum);
598 virtual int GetCurrentPage() const;
599 virtual void SetPrintout(wxPrintout *printout);
600 virtual wxPrintout *GetPrintout() const;
601 virtual wxPrintout *GetPrintoutForPrinting() const;
602 virtual void SetFrame(wxFrame *frame);
603 virtual void SetCanvas(wxPreviewCanvas *canvas);
604
605 virtual wxFrame *GetFrame() const;
606 virtual wxPreviewCanvas *GetCanvas() const;
607 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
608 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
609 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
610 virtual bool RenderPage(int pageNum);
611 virtual void SetZoom(int percent);
d8766675 612 virtual int GetZoom() const;
e81e3883
RR
613
614 virtual bool Print(bool interactive);
615 virtual void DetermineScaling();
d0ee33f5 616
e81e3883 617 virtual wxPrintDialogData& GetPrintDialogData();
d0ee33f5 618
e81e3883
RR
619 virtual int GetMaxPage() const;
620 virtual int GetMinPage() const;
621
b7cacb43
VZ
622 virtual bool Ok() const { return IsOk(); }
623 virtual bool IsOk() const;
e81e3883 624 virtual void SetOk(bool ok);
d0ee33f5 625
e81e3883
RR
626private:
627 wxPrintPreviewBase *m_pimpl;
628
629private:
630 DECLARE_CLASS(wxPrintPreview)
631 DECLARE_NO_COPY_CLASS(wxPrintPreview)
632};
633
634//----------------------------------------------------------------------------
635// wxPrintAbortDialog
636//----------------------------------------------------------------------------
c801d85f
KB
637
638class WXDLLEXPORT wxPrintAbortDialog: public wxDialog
639{
640public:
d6b9496a
VZ
641 wxPrintAbortDialog(wxWindow *parent,
642 const wxString& title,
643 const wxPoint& pos = wxDefaultPosition,
644 const wxSize& size = wxDefaultSize,
645 long style = 0,
2b5f62a0 646 const wxString& name = wxT("dialog"))
7e548f6b 647 : wxDialog(parent, wxID_ANY, title, pos, size, style, name)
d6b9496a
VZ
648 {
649 }
650
651 void OnCancel(wxCommandEvent& event);
34da0970 652
d6b9496a
VZ
653private:
654 DECLARE_EVENT_TABLE()
fc7a2a60 655 DECLARE_NO_COPY_CLASS(wxPrintAbortDialog)
c801d85f
KB
656};
657
d427503c
VZ
658#endif // wxUSE_PRINTING_ARCHITECTURE
659
c801d85f 660#endif
34138703 661 // _WX_PRNTBASEH__