]> git.saurik.com Git - wxWidgets.git/blame - include/wx/prntbase.h
Fix wrong tab order in wxAuiNotebook after dragging.
[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;
446659ca 43class WXDLLIMPEXP_FWD_CORE wxPrintAbortDialog;
e7aa9bb7 44class WXDLLIMPEXP_FWD_CORE wxStaticText;
d7cfeeb4 45class wxPrintPageMaxCtrl;
82579461 46class wxPrintPageTextCtrl;
c801d85f 47
e81e3883
RR
48//----------------------------------------------------------------------------
49// error consts
50//----------------------------------------------------------------------------
f6bcfd97
BP
51
52enum wxPrinterError
53{
54 wxPRINTER_NO_ERROR = 0,
55 wxPRINTER_CANCELLED,
56 wxPRINTER_ERROR
57};
58
6aacfc73
VZ
59// Preview frame modality kind used with wxPreviewFrame::Initialize()
60enum wxPreviewFrameModalityKind
61{
62 // Disable all the other top level windows while the preview is shown.
63 wxPreviewFrame_AppModal,
64
65 // Disable only the parent window while the preview is shown.
66 wxPreviewFrame_WindowModal,
67
68 // Don't disable any windows.
69 wxPreviewFrame_NonModal
70};
71
e81e3883
RR
72//----------------------------------------------------------------------------
73// wxPrintFactory
74//----------------------------------------------------------------------------
75
53a2db12 76class WXDLLIMPEXP_CORE wxPrintFactory
e81e3883
RR
77{
78public:
79 wxPrintFactory() {}
80 virtual ~wxPrintFactory() {}
d0ee33f5 81
e81e3883 82 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData* data ) = 0;
d0ee33f5
WS
83
84 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
85 wxPrintout *printout = NULL,
e81e3883 86 wxPrintDialogData *data = NULL ) = 0;
d0ee33f5
WS
87 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
88 wxPrintout *printout,
e81e3883 89 wxPrintData *data ) = 0;
c061373d 90
d0ee33f5 91 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
c061373d 92 wxPrintDialogData *data = NULL ) = 0;
d0ee33f5 93 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
c061373d 94 wxPrintData *data ) = 0;
d0ee33f5 95
08680429
RR
96 virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
97 wxPageSetupDialogData * data = NULL ) = 0;
d0ee33f5 98
888dde65 99 virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data ) = 0;
147bf263 100
6038ec8e
RR
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;
113
d0ee33f5 114
8850cbd3 115 virtual wxPrintNativeDataBase *CreatePrintNativeData() = 0;
d0ee33f5 116
e81e3883
RR
117 static void SetPrintFactory( wxPrintFactory *factory );
118 static wxPrintFactory *GetFactory();
33d094d1 119private:
e81e3883
RR
120 static wxPrintFactory *m_factory;
121};
122
53a2db12 123class WXDLLIMPEXP_CORE wxNativePrintFactory: public wxPrintFactory
e81e3883
RR
124{
125public:
e81e3883 126 virtual wxPrinterBase *CreatePrinter( wxPrintDialogData *data );
d0ee33f5
WS
127
128 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
129 wxPrintout *printout = NULL,
e81e3883 130 wxPrintDialogData *data = NULL );
d0ee33f5 131 virtual wxPrintPreviewBase *CreatePrintPreview( wxPrintout *preview,
e81e3883
RR
132 wxPrintout *printout,
133 wxPrintData *data );
d0ee33f5
WS
134
135 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
c061373d 136 wxPrintDialogData *data = NULL );
d0ee33f5 137 virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent,
c061373d 138 wxPrintData *data );
d0ee33f5 139
08680429
RR
140 virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
141 wxPageSetupDialogData * data = NULL );
d0ee33f5 142
888dde65 143 virtual wxDCImpl* CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data );
147bf263 144
6038ec8e
RR
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();
d0ee33f5 152
8850cbd3
RR
153 virtual wxPrintNativeDataBase *CreatePrintNativeData();
154};
155
156//----------------------------------------------------------------------------
157// wxPrintNativeDataBase
158//----------------------------------------------------------------------------
159
53a2db12 160class WXDLLIMPEXP_CORE wxPrintNativeDataBase: public wxObject
8850cbd3
RR
161{
162public:
163 wxPrintNativeDataBase();
164 virtual ~wxPrintNativeDataBase() {}
d0ee33f5 165
fd64de59 166 virtual bool TransferTo( wxPrintData &data ) = 0;
d0ee33f5
WS
167 virtual bool TransferFrom( const wxPrintData &data ) = 0;
168
b7cacb43
VZ
169 virtual bool Ok() const { return IsOk(); }
170 virtual bool IsOk() const = 0;
d0ee33f5 171
8850cbd3 172 int m_ref;
d0ee33f5 173
8850cbd3
RR
174private:
175 DECLARE_CLASS(wxPrintNativeDataBase)
c0c133e1 176 wxDECLARE_NO_COPY_CLASS(wxPrintNativeDataBase);
e81e3883
RR
177};
178
179//----------------------------------------------------------------------------
180// wxPrinterBase
181//----------------------------------------------------------------------------
f6bcfd97 182
c801d85f
KB
183/*
184 * Represents the printer: manages printing a wxPrintout object
185 */
d6b9496a 186
53a2db12 187class WXDLLIMPEXP_CORE wxPrinterBase: public wxObject
c801d85f 188{
34da0970 189public:
d3b9f782 190 wxPrinterBase(wxPrintDialogData *data = NULL);
d6b9496a
VZ
191 virtual ~wxPrinterBase();
192
446659ca 193 virtual wxPrintAbortDialog *CreateAbortWindow(wxWindow *parent, wxPrintout *printout);
161f4f73 194 virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message);
c801d85f 195
c061373d 196 virtual wxPrintDialogData& GetPrintDialogData() const;
d6b9496a 197 bool GetAbort() const { return sm_abortIt; }
7e548f6b 198
f6bcfd97 199 static wxPrinterError GetLastError() { return sm_lastError; }
c801d85f 200
d6b9496a
VZ
201 ///////////////////////////////////////////////////////////////////////////
202 // OVERRIDES
c801d85f 203
d6b9496a 204 virtual bool Setup(wxWindow *parent) = 0;
7e548f6b 205 virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true) = 0;
d6b9496a 206 virtual wxDC* PrintDialog(wxWindow *parent) = 0;
34da0970
JS
207
208protected:
d6b9496a
VZ
209 wxPrintDialogData m_printDialogData;
210 wxPrintout* m_currentPrintout;
7e548f6b 211
f6bcfd97 212 static wxPrinterError sm_lastError;
7e548f6b 213
34da0970 214public:
d6b9496a
VZ
215 static wxWindow* sm_abortWindow;
216 static bool sm_abortIt;
34da0970 217
2b5f62a0
VZ
218private:
219 DECLARE_CLASS(wxPrinterBase)
c0c133e1 220 wxDECLARE_NO_COPY_CLASS(wxPrinterBase);
c801d85f
KB
221};
222
e81e3883
RR
223//----------------------------------------------------------------------------
224// wxPrinter
225//----------------------------------------------------------------------------
226
53a2db12 227class WXDLLIMPEXP_CORE wxPrinter: public wxPrinterBase
e81e3883
RR
228{
229public:
d3b9f782 230 wxPrinter(wxPrintDialogData *data = NULL);
e81e3883
RR
231 virtual ~wxPrinter();
232
446659ca 233 virtual wxPrintAbortDialog *CreateAbortWindow(wxWindow *parent, wxPrintout *printout);
e81e3883
RR
234 virtual void ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message);
235
236 virtual bool Setup(wxWindow *parent);
237 virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = true);
238 virtual wxDC* PrintDialog(wxWindow *parent);
d0ee33f5 239
c061373d 240 virtual wxPrintDialogData& GetPrintDialogData() const;
e81e3883
RR
241
242protected:
243 wxPrinterBase *m_pimpl;
d0ee33f5 244
e81e3883
RR
245private:
246 DECLARE_CLASS(wxPrinter)
c0c133e1 247 wxDECLARE_NO_COPY_CLASS(wxPrinter);
e81e3883
RR
248};
249
250//----------------------------------------------------------------------------
251// wxPrintout
252//----------------------------------------------------------------------------
253
c801d85f 254/*
c801d85f
KB
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.
259 */
d6b9496a 260
53a2db12 261class WXDLLIMPEXP_CORE wxPrintout: public wxObject
c801d85f 262{
34da0970 263public:
6c4da6d6 264 wxPrintout(const wxString& title = _("Printout"));
d6b9496a 265 virtual ~wxPrintout();
c801d85f 266
d6b9496a
VZ
267 virtual bool OnBeginDocument(int startPage, int endPage);
268 virtual void OnEndDocument();
269 virtual void OnBeginPrinting();
270 virtual void OnEndPrinting();
c801d85f 271
d6b9496a
VZ
272 // Guaranteed to be before any other functions are called
273 virtual void OnPreparePrinting() { }
c801d85f 274
d6b9496a
VZ
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);
c801d85f 278
d6b9496a 279 virtual wxString GetTitle() const { return m_printoutTitle; }
34da0970 280
d6b9496a
VZ
281 wxDC *GetDC() const { return m_printoutDC; }
282 void SetDC(wxDC *dc) { m_printoutDC = dc; }
f415cab9
JS
283
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();
291
292 wxRect GetLogicalPaperRect() const;
293 wxRect GetLogicalPageRect() const;
294 wxRect GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSetupData) const;
295
296 void SetLogicalOrigin(wxCoord x, wxCoord y);
297 void OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff);
298
d6b9496a
VZ
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; }
34da0970 303
d6b9496a 304 void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; }
40fcf546 305 void SetPPIScreen(const wxSize& ppi) { SetPPIScreen(ppi.x, ppi.y); }
d6b9496a
VZ
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; }
40fcf546 308 void SetPPIPrinter(const wxSize& ppi) { SetPPIPrinter(ppi.x, ppi.y); }
d6b9496a 309 void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; }
34da0970 310
f415cab9
JS
311 void SetPaperRectPixels(const wxRect& paperRectPixels) { m_paperRectPixels = paperRectPixels; }
312 wxRect GetPaperRectPixels() const { return m_paperRectPixels; }
313
1bd122dd
VZ
314 // This must be called by wxPrintPreview to associate itself with the
315 // printout it uses.
316 virtual void SetPreview(wxPrintPreview *preview) { m_preview = preview; }
34da0970 317
1bd122dd
VZ
318 wxPrintPreview *GetPreview() const { return m_preview; }
319 virtual bool IsPreview() const { return GetPreview() != NULL; }
34da0970
JS
320
321private:
d6b9496a
VZ
322 wxString m_printoutTitle;
323 wxDC* m_printoutDC;
1bd122dd 324 wxPrintPreview *m_preview;
c801d85f 325
d6b9496a
VZ
326 int m_pageWidthPixels;
327 int m_pageHeightPixels;
c801d85f 328
d6b9496a
VZ
329 int m_pageWidthMM;
330 int m_pageHeightMM;
c801d85f 331
d6b9496a
VZ
332 int m_PPIScreenX;
333 int m_PPIScreenY;
334 int m_PPIPrinterX;
335 int m_PPIPrinterY;
c801d85f 336
f415cab9
JS
337 wxRect m_paperRectPixels;
338
2b5f62a0
VZ
339private:
340 DECLARE_ABSTRACT_CLASS(wxPrintout)
c0c133e1 341 wxDECLARE_NO_COPY_CLASS(wxPrintout);
c801d85f
KB
342};
343
f415cab9
JS
344//----------------------------------------------------------------------------
345// wxPreviewCanvas
346//----------------------------------------------------------------------------
347
c801d85f 348/*
c801d85f
KB
349 * Canvas upon which a preview is drawn.
350 */
d6b9496a 351
53a2db12 352class WXDLLIMPEXP_CORE wxPreviewCanvas: public wxScrolledWindow
c801d85f 353{
34da0970 354public:
d6b9496a
VZ
355 wxPreviewCanvas(wxPrintPreviewBase *preview,
356 wxWindow *parent,
357 const wxPoint& pos = wxDefaultPosition,
358 const wxSize& size = wxDefaultSize,
359 long style = 0,
2b5f62a0 360 const wxString& name = wxT("canvas"));
d3c7fc99 361 virtual ~wxPreviewCanvas();
c801d85f 362
b88bf073
VS
363 void SetPreview(wxPrintPreviewBase *preview) { m_printPreview = preview; }
364
d6b9496a 365 void OnPaint(wxPaintEvent& event);
d2b354f9 366 void OnChar(wxKeyEvent &event);
d6b9496a
VZ
367 // Responds to colour changes
368 void OnSysColourChanged(wxSysColourChangedEvent& event);
c801d85f 369
34da0970 370private:
fb6efdf2
VZ
371#if wxUSE_MOUSEWHEEL
372 void OnMouseWheel(wxMouseEvent& event);
373#endif // wxUSE_MOUSEWHEEL
b88bf073 374 void OnIdle(wxIdleEvent& event);
fb6efdf2 375
d6b9496a 376 wxPrintPreviewBase* m_printPreview;
34da0970 377
2b5f62a0 378 DECLARE_CLASS(wxPreviewCanvas)
d6b9496a 379 DECLARE_EVENT_TABLE()
c0c133e1 380 wxDECLARE_NO_COPY_CLASS(wxPreviewCanvas);
c801d85f
KB
381};
382
f415cab9
JS
383//----------------------------------------------------------------------------
384// wxPreviewFrame
385//----------------------------------------------------------------------------
386
c801d85f 387/*
c801d85f
KB
388 * Default frame for showing preview.
389 */
390
53a2db12 391class WXDLLIMPEXP_CORE wxPreviewFrame: public wxFrame
c801d85f 392{
34da0970 393public:
d6b9496a 394 wxPreviewFrame(wxPrintPreviewBase *preview,
a5ae8241 395 wxWindow *parent,
6c4da6d6 396 const wxString& title = _("Print Preview"),
d6b9496a
VZ
397 const wxPoint& pos = wxDefaultPosition,
398 const wxSize& size = wxDefaultSize,
ca44dbde 399 long style = wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT,
3366d55c 400 const wxString& name = wxFrameNameStr);
d3c7fc99 401 virtual ~wxPreviewFrame();
d6b9496a 402
1e5ad6e1
VZ
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.
406
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()
413 {
414 InitializeWithModality(wxPreviewFrame_AppModal);
415 }
416
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);
421
d6b9496a 422 void OnCloseWindow(wxCloseEvent& event);
d6b9496a
VZ
423 virtual void CreateCanvas();
424 virtual void CreateControlBar();
d2b354f9
JS
425
426 inline wxPreviewControlBar* GetControlBar() const { return m_controlBar; }
427
34da0970 428protected:
d2b354f9 429 wxPreviewCanvas* m_previewCanvas;
d6b9496a
VZ
430 wxPreviewControlBar* m_controlBar;
431 wxPrintPreviewBase* m_printPreview;
7c995553 432 wxWindowDisabler* m_windowDisabler;
e3065973 433
6aacfc73
VZ
434 wxPreviewFrameModalityKind m_modalityKind;
435
436
d6b9496a 437private:
043c6705
VZ
438 void OnChar(wxKeyEvent& event);
439
d6b9496a 440 DECLARE_EVENT_TABLE()
043c6705 441 DECLARE_CLASS(wxPreviewFrame)
c0c133e1 442 wxDECLARE_NO_COPY_CLASS(wxPreviewFrame);
c801d85f
KB
443};
444
f415cab9
JS
445//----------------------------------------------------------------------------
446// wxPreviewControlBar
447//----------------------------------------------------------------------------
448
c801d85f 449/*
c801d85f
KB
450 * A panel with buttons for controlling a print preview.
451 * The programmer may wish to use other means for controlling
452 * the print preview.
453 */
454
455#define wxPREVIEW_PRINT 1
456#define wxPREVIEW_PREVIOUS 2
457#define wxPREVIEW_NEXT 4
458#define wxPREVIEW_ZOOM 8
bf89b538
JS
459#define wxPREVIEW_FIRST 16
460#define wxPREVIEW_LAST 32
461#define wxPREVIEW_GOTO 64
c801d85f 462
d0ee33f5
WS
463#define wxPREVIEW_DEFAULT (wxPREVIEW_PREVIOUS|wxPREVIEW_NEXT|wxPREVIEW_ZOOM\
464 |wxPREVIEW_FIRST|wxPREVIEW_GOTO|wxPREVIEW_LAST)
c801d85f
KB
465
466// Ids for controls
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
bf89b538
JS
472#define wxID_PREVIEW_FIRST 6
473#define wxID_PREVIEW_LAST 7
474#define wxID_PREVIEW_GOTO 8
82579461
VZ
475#define wxID_PREVIEW_ZOOM_IN 9
476#define wxID_PREVIEW_ZOOM_OUT 10
c801d85f 477
53a2db12 478class WXDLLIMPEXP_CORE wxPreviewControlBar: public wxPanel
c801d85f 479{
d6b9496a 480 DECLARE_CLASS(wxPreviewControlBar)
c801d85f 481
34da0970 482public:
d6b9496a
VZ
483 wxPreviewControlBar(wxPrintPreviewBase *preview,
484 long buttons,
485 wxWindow *parent,
486 const wxPoint& pos = wxDefaultPosition,
487 const wxSize& size = wxDefaultSize,
d2b354f9 488 long style = wxTAB_TRAVERSAL,
2b5f62a0 489 const wxString& name = wxT("panel"));
d3c7fc99 490 virtual ~wxPreviewControlBar();
d6b9496a
VZ
491
492 virtual void CreateButtons();
d7cfeeb4 493 virtual void SetPageInfo(int minPage, int maxPage);
d6b9496a
VZ
494 virtual void SetZoomControl(int zoom);
495 virtual int GetZoomControl();
496 virtual wxPrintPreviewBase *GetPrintPreview() const
497 { return m_printPreview; }
498
82579461
VZ
499
500 // Implementation only from now on.
d6b9496a 501 void OnWindowClose(wxCommandEvent& event);
0f90ec93
KB
502 void OnNext();
503 void OnPrevious();
bf89b538
JS
504 void OnFirst();
505 void OnLast();
82579461 506 void OnGotoPage();
b38b0d22 507 void OnPrint();
82579461 508
90b6b974 509 void OnPrintButton(wxCommandEvent& WXUNUSED(event)) { OnPrint(); }
014b0d06
VZ
510 void OnNextButton(wxCommandEvent & WXUNUSED(event)) { OnNext(); }
511 void OnPreviousButton(wxCommandEvent & WXUNUSED(event)) { OnPrevious(); }
bf89b538
JS
512 void OnFirstButton(wxCommandEvent & WXUNUSED(event)) { OnFirst(); }
513 void OnLastButton(wxCommandEvent & WXUNUSED(event)) { OnLast(); }
d6b9496a 514 void OnPaint(wxPaintEvent& event);
c801d85f 515
82579461
VZ
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()); }
528
529 // These methods are not private because they are called by wxPreviewCanvas.
530 void DoZoomIn();
531 void DoZoomOut();
532
34da0970 533protected:
d6b9496a
VZ
534 wxPrintPreviewBase* m_printPreview;
535 wxButton* m_closeButton;
d6b9496a 536 wxChoice* m_zoomControl;
d7cfeeb4
VZ
537 wxPrintPageTextCtrl* m_currentPageText;
538 wxPrintPageMaxCtrl* m_maxPageText;
82579461 539
d6b9496a
VZ
540 long m_buttonFlags;
541
542private:
82579461
VZ
543 void DoGotoPage(int page);
544
545 void DoZoom();
546
547 bool IsNextEnabled() const;
548 bool IsPreviousEnabled() const;
549 bool IsFirstEnabled() const;
550 bool IsLastEnabled() const;
551 bool IsZoomInEnabled() const;
552 bool IsZoomOutEnabled() const;
553
554 void OnZoomInButton(wxCommandEvent & WXUNUSED(event)) { DoZoomIn(); }
555 void OnZoomOutButton(wxCommandEvent & WXUNUSED(event)) { DoZoomOut(); }
556 void OnZoomChoice(wxCommandEvent& WXUNUSED(event)) { DoZoom(); }
557
d6b9496a 558 DECLARE_EVENT_TABLE()
c0c133e1 559 wxDECLARE_NO_COPY_CLASS(wxPreviewControlBar);
c801d85f
KB
560};
561
e81e3883
RR
562//----------------------------------------------------------------------------
563// wxPrintPreviewBase
564//----------------------------------------------------------------------------
565
c801d85f 566/*
c801d85f
KB
567 * Programmer creates an object of this class to preview a wxPrintout.
568 */
d6b9496a 569
53a2db12 570class WXDLLIMPEXP_CORE wxPrintPreviewBase: public wxObject
c801d85f 571{
34da0970 572public:
d6b9496a 573 wxPrintPreviewBase(wxPrintout *printout,
d3b9f782
VZ
574 wxPrintout *printoutForPrinting = NULL,
575 wxPrintDialogData *data = NULL);
d6b9496a
VZ
576 wxPrintPreviewBase(wxPrintout *printout,
577 wxPrintout *printoutForPrinting,
578 wxPrintData *data);
579 virtual ~wxPrintPreviewBase();
c801d85f 580
d6b9496a 581 virtual bool SetCurrentPage(int pageNum);
e81e3883 582 virtual int GetCurrentPage() const;
c801d85f 583
e81e3883
RR
584 virtual void SetPrintout(wxPrintout *printout);
585 virtual wxPrintout *GetPrintout() const;
586 virtual wxPrintout *GetPrintoutForPrinting() const;
c801d85f 587
e81e3883
RR
588 virtual void SetFrame(wxFrame *frame);
589 virtual void SetCanvas(wxPreviewCanvas *canvas);
c801d85f 590
e81e3883
RR
591 virtual wxFrame *GetFrame() const;
592 virtual wxPreviewCanvas *GetCanvas() const;
c801d85f 593
f415cab9
JS
594 // This is a helper routine, used by the next 4 routines.
595
596 virtual void CalcRects(wxPreviewCanvas *canvas, wxRect& printableAreaRect, wxRect& paperRect);
597
d6b9496a 598 // The preview canvas should call this from OnPaint
d2b354f9 599 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
c801d85f 600
b88bf073
VS
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();
604
d6b9496a 605 // This draws a blank page onto the preview canvas
d2b354f9
JS
606 virtual bool DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc);
607
608 // Adjusts the scrollbars for the current scale
609 virtual void AdjustScrollbars(wxPreviewCanvas *canvas);
c801d85f 610
d6b9496a
VZ
611 // This is called by wxPrintPreview to render a page into a wxMemoryDC.
612 virtual bool RenderPage(int pageNum);
c801d85f 613
c801d85f 614
d6b9496a 615 virtual void SetZoom(int percent);
e81e3883 616 virtual int GetZoom() const;
34da0970 617
e81e3883 618 virtual wxPrintDialogData& GetPrintDialogData();
d0ee33f5 619
e81e3883
RR
620 virtual int GetMaxPage() const;
621 virtual int GetMinPage() const;
c801d85f 622
b7cacb43
VZ
623 virtual bool Ok() const { return IsOk(); }
624 virtual bool IsOk() const;
e81e3883 625 virtual void SetOk(bool ok);
c801d85f 626
d6b9496a
VZ
627 ///////////////////////////////////////////////////////////////////////////
628 // OVERRIDES
c801d85f 629
d6b9496a
VZ
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;
c801d85f 634
d6b9496a
VZ
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;
34da0970 639
88b98787 640protected:
25a3fca2
VS
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);
645
88b98787
VS
646 void InvalidatePreviewBitmap();
647
34da0970 648protected:
d6b9496a 649 wxPrintDialogData m_printDialogData;
d2b354f9 650 wxPreviewCanvas* m_previewCanvas;
d6b9496a
VZ
651 wxFrame* m_previewFrame;
652 wxBitmap* m_previewBitmap;
88b98787 653 bool m_previewFailed;
d6b9496a
VZ
654 wxPrintout* m_previewPrintout;
655 wxPrintout* m_printPrintout;
656 int m_currentPage;
657 int m_currentZoom;
f415cab9
JS
658 float m_previewScaleX;
659 float m_previewScaleY;
d6b9496a
VZ
660 int m_topMargin;
661 int m_leftMargin;
662 int m_pageWidth;
663 int m_pageHeight;
664 int m_minPage;
665 int m_maxPage;
666
667 bool m_isOk;
1044a386 668 bool m_printingPrepared; // Called OnPreparePrinting?
d6b9496a
VZ
669
670private:
671 void Init(wxPrintout *printout, wxPrintout *printoutForPrinting);
22f3361e 672
c0c133e1 673 wxDECLARE_NO_COPY_CLASS(wxPrintPreviewBase);
e81e3883 674 DECLARE_CLASS(wxPrintPreviewBase)
c801d85f
KB
675};
676
e81e3883
RR
677//----------------------------------------------------------------------------
678// wxPrintPreview
679//----------------------------------------------------------------------------
680
53a2db12 681class WXDLLIMPEXP_CORE wxPrintPreview: public wxPrintPreviewBase
e81e3883
RR
682{
683public:
684 wxPrintPreview(wxPrintout *printout,
d3b9f782
VZ
685 wxPrintout *printoutForPrinting = NULL,
686 wxPrintDialogData *data = NULL);
e81e3883
RR
687 wxPrintPreview(wxPrintout *printout,
688 wxPrintout *printoutForPrinting,
689 wxPrintData *data);
690 virtual ~wxPrintPreview();
691
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);
699
700 virtual wxFrame *GetFrame() const;
701 virtual wxPreviewCanvas *GetCanvas() const;
702 virtual bool PaintPage(wxPreviewCanvas *canvas, wxDC& dc);
b88bf073 703 virtual bool UpdatePageRendering();
e81e3883
RR
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);
d8766675 708 virtual int GetZoom() const;
e81e3883
RR
709
710 virtual bool Print(bool interactive);
711 virtual void DetermineScaling();
d0ee33f5 712
e81e3883 713 virtual wxPrintDialogData& GetPrintDialogData();
d0ee33f5 714
e81e3883
RR
715 virtual int GetMaxPage() const;
716 virtual int GetMinPage() const;
717
b7cacb43
VZ
718 virtual bool Ok() const { return IsOk(); }
719 virtual bool IsOk() const;
e81e3883 720 virtual void SetOk(bool ok);
d0ee33f5 721
e81e3883
RR
722private:
723 wxPrintPreviewBase *m_pimpl;
724
725private:
726 DECLARE_CLASS(wxPrintPreview)
c0c133e1 727 wxDECLARE_NO_COPY_CLASS(wxPrintPreview);
e81e3883
RR
728};
729
730//----------------------------------------------------------------------------
731// wxPrintAbortDialog
732//----------------------------------------------------------------------------
c801d85f 733
53a2db12 734class WXDLLIMPEXP_CORE wxPrintAbortDialog: public wxDialog
c801d85f
KB
735{
736public:
d6b9496a 737 wxPrintAbortDialog(wxWindow *parent,
1a19b321 738 const wxString& documentTitle,
d6b9496a
VZ
739 const wxPoint& pos = wxDefaultPosition,
740 const wxSize& size = wxDefaultSize,
1a19b321
VS
741 long style = wxDEFAULT_DIALOG_STYLE,
742 const wxString& name = wxT("dialog"));
d6b9496a 743
e7aa9bb7
VS
744 void SetProgress(int currentPage, int totalPages,
745 int currentCopy, int totalCopies);
746
d6b9496a 747 void OnCancel(wxCommandEvent& event);
34da0970 748
d6b9496a 749private:
e7aa9bb7
VS
750 wxStaticText *m_progress;
751
d6b9496a 752 DECLARE_EVENT_TABLE()
c0c133e1 753 wxDECLARE_NO_COPY_CLASS(wxPrintAbortDialog);
c801d85f
KB
754};
755
d427503c
VZ
756#endif // wxUSE_PRINTING_ARCHITECTURE
757
c801d85f 758#endif
34138703 759 // _WX_PRNTBASEH__