]> git.saurik.com Git - wxWidgets.git/blame - include/wx/prntbase.h
Add FindLength()
[wxWidgets.git] / include / wx / prntbase.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: prntbase.h
3// Purpose: Base classes for printing framework
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
371a5b4e 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_PRNTBASEH__
13#define _WX_PRNTBASEH__
c801d85f 14
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
KB
25
26class WXDLLEXPORT wxDC;
27class WXDLLEXPORT wxButton;
28class WXDLLEXPORT wxChoice;
29class WXDLLEXPORT wxPrintout;
30class WXDLLEXPORT wxPrinterBase;
c061373d 31class WXDLLEXPORT wxPrintDialogBase;
08680429
RR
32class WXDLLEXPORT wxPrintDialog;
33class WXDLLEXPORT wxPageSetupDialogBase;
34class WXDLLEXPORT wxPageSetupDialog;
c801d85f
KB
35class WXDLLEXPORT wxPrintPreviewBase;
36class WXDLLEXPORT wxPreviewCanvas;
37class WXDLLEXPORT wxPreviewControlBar;
38class WXDLLEXPORT wxPreviewFrame;
e81e3883 39class WXDLLEXPORT wxPrintFactory;
8850cbd3 40class WXDLLEXPORT 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; }
264 void SetPageSizePixels(int w, int h) { m_pageWidthPixels = w; m_pageHeightPixels = h; }
265 void GetPageSizePixels(int *w, int *h) const { *w = m_pageWidthPixels; *h = m_pageHeightPixels; }
266 void SetPageSizeMM(int w, int h) { m_pageWidthMM = w; m_pageHeightMM = h; }
267 void GetPageSizeMM(int *w, int *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; }
34da0970 268
d6b9496a
VZ
269 void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; }
270 void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; }
271 void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; }
272 void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; }
34da0970 273
d6b9496a 274 virtual bool IsPreview() const { return m_isPreview; }
34da0970 275
d6b9496a 276 virtual void SetIsPreview(bool p) { m_isPreview = p; }
34da0970
JS
277
278private:
d6b9496a
VZ
279 wxString m_printoutTitle;
280 wxDC* m_printoutDC;
c801d85f 281
d6b9496a
VZ
282 int m_pageWidthPixels;
283 int m_pageHeightPixels;
c801d85f 284
d6b9496a
VZ
285 int m_pageWidthMM;
286 int m_pageHeightMM;
c801d85f 287
d6b9496a
VZ
288 int m_PPIScreenX;
289 int m_PPIScreenY;
290 int m_PPIPrinterX;
291 int m_PPIPrinterY;
c801d85f 292
d6b9496a 293 bool m_isPreview;
2b5f62a0
VZ
294
295private:
296 DECLARE_ABSTRACT_CLASS(wxPrintout)
22f3361e 297 DECLARE_NO_COPY_CLASS(wxPrintout)
c801d85f
KB
298};
299
300/*
301 * wxPreviewCanvas
302 * Canvas upon which a preview is drawn.
303 */
d6b9496a 304
c801d85f
KB
305class WXDLLEXPORT wxPreviewCanvas: public wxScrolledWindow
306{
34da0970 307public:
d6b9496a
VZ
308 wxPreviewCanvas(wxPrintPreviewBase *preview,
309 wxWindow *parent,
310 const wxPoint& pos = wxDefaultPosition,
311 const wxSize& size = wxDefaultSize,
312 long style = 0,
2b5f62a0 313 const wxString& name = wxT("canvas"));
d3c7fc99 314 virtual ~wxPreviewCanvas();
c801d85f 315
d6b9496a 316 void OnPaint(wxPaintEvent& event);
d2b354f9 317 void OnChar(wxKeyEvent &event);
d6b9496a
VZ
318 // Responds to colour changes
319 void OnSysColourChanged(wxSysColourChangedEvent& event);
c801d85f 320
34da0970 321private:
fb6efdf2
VZ
322#if wxUSE_MOUSEWHEEL
323 void OnMouseWheel(wxMouseEvent& event);
324#endif // wxUSE_MOUSEWHEEL
325
d6b9496a 326 wxPrintPreviewBase* m_printPreview;
34da0970 327
2b5f62a0 328 DECLARE_CLASS(wxPreviewCanvas)
d6b9496a 329 DECLARE_EVENT_TABLE()
22f3361e 330 DECLARE_NO_COPY_CLASS(wxPreviewCanvas)
c801d85f
KB
331};
332
333/*
334 * wxPreviewFrame
335 * Default frame for showing preview.
336 */
337
338class WXDLLEXPORT wxPreviewFrame: public wxFrame
339{
34da0970 340public:
d6b9496a 341 wxPreviewFrame(wxPrintPreviewBase *preview,
a5ae8241 342 wxWindow *parent,
2b5f62a0 343 const wxString& title = wxT("Print Preview"),
d6b9496a
VZ
344 const wxPoint& pos = wxDefaultPosition,
345 const wxSize& size = wxDefaultSize,
e9cafd42 346 long style = wxDEFAULT_FRAME_STYLE,
2b5f62a0 347 const wxString& name = wxT("frame"));
d3c7fc99 348 virtual ~wxPreviewFrame();
d6b9496a
VZ
349
350 void OnCloseWindow(wxCloseEvent& event);
351 virtual void Initialize();
352 virtual void CreateCanvas();
353 virtual void CreateControlBar();
d2b354f9
JS
354
355 inline wxPreviewControlBar* GetControlBar() const { return m_controlBar; }
356
34da0970 357protected:
d2b354f9 358 wxPreviewCanvas* m_previewCanvas;
d6b9496a
VZ
359 wxPreviewControlBar* m_controlBar;
360 wxPrintPreviewBase* m_printPreview;
7c995553 361 wxWindowDisabler* m_windowDisabler;
e3065973 362
d6b9496a 363private:
2b5f62a0 364 DECLARE_CLASS(wxPreviewFrame)
d6b9496a 365 DECLARE_EVENT_TABLE()
22f3361e 366 DECLARE_NO_COPY_CLASS(wxPreviewFrame)
c801d85f
KB
367};
368
369/*
370 * wxPreviewControlBar
371 * A panel with buttons for controlling a print preview.
372 * The programmer may wish to use other means for controlling
373 * the print preview.
374 */
375
376#define wxPREVIEW_PRINT 1
377#define wxPREVIEW_PREVIOUS 2
378#define wxPREVIEW_NEXT 4
379#define wxPREVIEW_ZOOM 8
bf89b538
JS
380#define wxPREVIEW_FIRST 16
381#define wxPREVIEW_LAST 32
382#define wxPREVIEW_GOTO 64
c801d85f 383
d0ee33f5
WS
384#define wxPREVIEW_DEFAULT (wxPREVIEW_PREVIOUS|wxPREVIEW_NEXT|wxPREVIEW_ZOOM\
385 |wxPREVIEW_FIRST|wxPREVIEW_GOTO|wxPREVIEW_LAST)
c801d85f
KB
386
387// Ids for controls
388#define wxID_PREVIEW_CLOSE 1
389#define wxID_PREVIEW_NEXT 2
390#define wxID_PREVIEW_PREVIOUS 3
391#define wxID_PREVIEW_PRINT 4
392#define wxID_PREVIEW_ZOOM 5
bf89b538
JS
393#define wxID_PREVIEW_FIRST 6
394#define wxID_PREVIEW_LAST 7
395#define wxID_PREVIEW_GOTO 8
c801d85f
KB
396
397class WXDLLEXPORT wxPreviewControlBar: public wxPanel
398{
d6b9496a 399 DECLARE_CLASS(wxPreviewControlBar)
c801d85f 400
34da0970 401public:
d6b9496a
VZ
402 wxPreviewControlBar(wxPrintPreviewBase *preview,
403 long buttons,
404 wxWindow *parent,
405 const wxPoint& pos = wxDefaultPosition,
406 const wxSize& size = wxDefaultSize,
d2b354f9 407 long style = wxTAB_TRAVERSAL,
2b5f62a0 408 const wxString& name = wxT("panel"));
d3c7fc99 409 virtual ~wxPreviewControlBar();
d6b9496a
VZ
410
411 virtual void CreateButtons();
412 virtual void SetZoomControl(int zoom);
413 virtual int GetZoomControl();
414 virtual wxPrintPreviewBase *GetPrintPreview() const
415 { return m_printPreview; }
416
d6b9496a 417 void OnWindowClose(wxCommandEvent& event);
0f90ec93
KB
418 void OnNext();
419 void OnPrevious();
bf89b538
JS
420 void OnFirst();
421 void OnLast();
422 void OnGoto();
b38b0d22 423 void OnPrint();
90b6b974 424 void OnPrintButton(wxCommandEvent& WXUNUSED(event)) { OnPrint(); }
014b0d06
VZ
425 void OnNextButton(wxCommandEvent & WXUNUSED(event)) { OnNext(); }
426 void OnPreviousButton(wxCommandEvent & WXUNUSED(event)) { OnPrevious(); }
bf89b538
JS
427 void OnFirstButton(wxCommandEvent & WXUNUSED(event)) { OnFirst(); }
428 void OnLastButton(wxCommandEvent & WXUNUSED(event)) { OnLast(); }
429 void OnGotoButton(wxCommandEvent & WXUNUSED(event)) { OnGoto(); }
d6b9496a
VZ
430 void OnZoom(wxCommandEvent& event);
431 void OnPaint(wxPaintEvent& event);
c801d85f 432
34da0970 433protected:
d6b9496a
VZ
434 wxPrintPreviewBase* m_printPreview;
435 wxButton* m_closeButton;
436 wxButton* m_nextPageButton;
437 wxButton* m_previousPageButton;
438 wxButton* m_printButton;
439 wxChoice* m_zoomControl;
bf89b538
JS
440 wxButton* m_firstPageButton;
441 wxButton* m_lastPageButton;
442 wxButton* m_gotoPageButton;
d6b9496a
VZ
443 long m_buttonFlags;
444
445private:
446 DECLARE_EVENT_TABLE()
22f3361e 447 DECLARE_NO_COPY_CLASS(wxPreviewControlBar)
c801d85f
KB
448};
449
e81e3883
RR
450//----------------------------------------------------------------------------
451// wxPrintPreviewBase
452//----------------------------------------------------------------------------
453
c801d85f 454/*
c801d85f
KB
455 * Programmer creates an object of this class to preview a wxPrintout.
456 */
d6b9496a 457
c801d85f
KB
458class WXDLLEXPORT wxPrintPreviewBase: public wxObject
459{
34da0970 460public:
d6b9496a
VZ
461 wxPrintPreviewBase(wxPrintout *printout,
462 wxPrintout *printoutForPrinting = (wxPrintout *) NULL,
463 wxPrintDialogData *data = (wxPrintDialogData *) NULL);
464 wxPrintPreviewBase(wxPrintout *printout,
465 wxPrintout *printoutForPrinting,
466 wxPrintData *data);
467 virtual ~wxPrintPreviewBase();
c801d85f 468
d6b9496a 469 virtual bool SetCurrentPage(int pageNum);
e81e3883 470 virtual int GetCurrentPage() const;
c801d85f 471
e81e3883
RR
472 virtual void SetPrintout(wxPrintout *printout);
473 virtual wxPrintout *GetPrintout() const;
474 virtual wxPrintout *GetPrintoutForPrinting() const;
c801d85f 475
e81e3883
RR
476 virtual void SetFrame(wxFrame *frame);
477 virtual void SetCanvas(wxPreviewCanvas *canvas);
c801d85f 478
e81e3883
RR
479 virtual wxFrame *GetFrame() const;
480 virtual wxPreviewCanvas *GetCanvas() const;
c801d85f 481
d6b9496a 482 // The preview canvas should call this from OnPaint
d2b354f9 483 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
c801d85f 484
d6b9496a 485 // This draws a blank page onto the preview canvas
d2b354f9
JS
486 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
487
488 // Adjusts the scrollbars for the current scale
489 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
c801d85f 490
d6b9496a
VZ
491 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
492 virtual bool RenderPage(int pageNum);
c801d85f 493
c801d85f 494
d6b9496a 495 virtual void SetZoom(int percent);
e81e3883 496 virtual int GetZoom() const;
34da0970 497
e81e3883 498 virtual wxPrintDialogData& GetPrintDialogData();
d0ee33f5 499
e81e3883
RR
500 virtual int GetMaxPage() const;
501 virtual int GetMinPage() const;
c801d85f 502
b7cacb43
VZ
503 virtual bool Ok() const { return IsOk(); }
504 virtual bool IsOk() const;
e81e3883 505 virtual void SetOk(bool ok);
c801d85f 506
d6b9496a
VZ
507 ///////////////////////////////////////////////////////////////////////////
508 // OVERRIDES
c801d85f 509
d6b9496a
VZ
510 // If we own a wxPrintout that can be used for printing, this
511 // will invoke the actual printing procedure. Called
512 // by the wxPreviewControlBar.
513 virtual bool Print(bool interactive) = 0;
c801d85f 514
d6b9496a
VZ
515 // Calculate scaling that needs to be done to get roughly
516 // the right scaling for the screen pretending to be
517 // the currently selected printer.
518 virtual void DetermineScaling() = 0;
34da0970
JS
519
520protected:
d6b9496a 521 wxPrintDialogData m_printDialogData;
d2b354f9 522 wxPreviewCanvas* m_previewCanvas;
d6b9496a
VZ
523 wxFrame* m_previewFrame;
524 wxBitmap* m_previewBitmap;
525 wxPrintout* m_previewPrintout;
526 wxPrintout* m_printPrintout;
527 int m_currentPage;
528 int m_currentZoom;
529 float m_previewScale;
530 int m_topMargin;
531 int m_leftMargin;
532 int m_pageWidth;
533 int m_pageHeight;
534 int m_minPage;
535 int m_maxPage;
536
537 bool m_isOk;
1044a386 538 bool m_printingPrepared; // Called OnPreparePrinting?
d6b9496a
VZ
539
540private:
541 void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
22f3361e
VZ
542
543 DECLARE_NO_COPY_CLASS(wxPrintPreviewBase)
e81e3883 544 DECLARE_CLASS(wxPrintPreviewBase)
c801d85f
KB
545};
546
e81e3883
RR
547//----------------------------------------------------------------------------
548// wxPrintPreview
549//----------------------------------------------------------------------------
550
551class WXDLLEXPORT wxPrintPreview: public wxPrintPreviewBase
552{
553public:
554 wxPrintPreview(wxPrintout *printout,
555 wxPrintout *printoutForPrinting = (wxPrintout *) NULL,
556 wxPrintDialogData *data = (wxPrintDialogData *) NULL);
557 wxPrintPreview(wxPrintout *printout,
558 wxPrintout *printoutForPrinting,
559 wxPrintData *data);
560 virtual ~wxPrintPreview();
561
562 virtual bool SetCurrentPage(int pageNum);
563 virtual int GetCurrentPage() const;
564 virtual void SetPrintout(wxPrintout *printout);
565 virtual wxPrintout *GetPrintout() const;
566 virtual wxPrintout *GetPrintoutForPrinting() const;
567 virtual void SetFrame(wxFrame *frame);
568 virtual void SetCanvas(wxPreviewCanvas *canvas);
569
570 virtual wxFrame *GetFrame() const;
571 virtual wxPreviewCanvas *GetCanvas() const;
572 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
573 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
574 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
575 virtual bool RenderPage(int pageNum);
576 virtual void SetZoom(int percent);
d8766675 577 virtual int GetZoom() const;
e81e3883
RR
578
579 virtual bool Print(bool interactive);
580 virtual void DetermineScaling();
d0ee33f5 581
e81e3883 582 virtual wxPrintDialogData& GetPrintDialogData();
d0ee33f5 583
e81e3883
RR
584 virtual int GetMaxPage() const;
585 virtual int GetMinPage() const;
586
b7cacb43
VZ
587 virtual bool Ok() const { return IsOk(); }
588 virtual bool IsOk() const;
e81e3883 589 virtual void SetOk(bool ok);
d0ee33f5 590
e81e3883
RR
591private:
592 wxPrintPreviewBase *m_pimpl;
593
594private:
595 DECLARE_CLASS(wxPrintPreview)
596 DECLARE_NO_COPY_CLASS(wxPrintPreview)
597};
598
599//----------------------------------------------------------------------------
600// wxPrintAbortDialog
601//----------------------------------------------------------------------------
c801d85f
KB
602
603class WXDLLEXPORT wxPrintAbortDialog: public wxDialog
604{
605public:
d6b9496a
VZ
606 wxPrintAbortDialog(wxWindow *parent,
607 const wxString& title,
608 const wxPoint& pos = wxDefaultPosition,
609 const wxSize& size = wxDefaultSize,
610 long style = 0,
2b5f62a0 611 const wxString& name = wxT("dialog"))
7e548f6b 612 : wxDialog(parent, wxID_ANY, title, pos, size, style, name)
d6b9496a
VZ
613 {
614 }
615
616 void OnCancel(wxCommandEvent& event);
34da0970 617
d6b9496a
VZ
618private:
619 DECLARE_EVENT_TABLE()
fc7a2a60 620 DECLARE_NO_COPY_CLASS(wxPrintAbortDialog)
c801d85f
KB
621};
622
d427503c
VZ
623#endif // wxUSE_PRINTING_ARCHITECTURE
624
c801d85f 625#endif
34138703 626 // _WX_PRNTBASEH__