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