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