]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: prntbase.cpp | |
3 | // Purpose: Printing framework base class implementation | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
55d99c7a | 8 | // Copyright: (c) Julian Smart |
65571936 | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
14f355c2 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
523fd221 RR |
13 | #pragma implementation "prntbase.h" |
14 | #pragma implementation "printdlg.h" | |
c801d85f KB |
15 | #endif |
16 | ||
17 | // For compilers that support precompilation, includes "wx.h". | |
18 | #include "wx/wxprec.h" | |
19 | ||
20 | #ifdef __BORLANDC__ | |
21 | #pragma hdrstop | |
22 | #endif | |
23 | ||
c801d85f KB |
24 | #include "wx/defs.h" |
25 | ||
d427503c VZ |
26 | #if wxUSE_PRINTING_ARCHITECTURE |
27 | ||
c801d85f KB |
28 | #ifndef WX_PRECOMP |
29 | #include "wx/utils.h" | |
30 | #include "wx/dc.h" | |
31 | #include "wx/app.h" | |
32 | #include "wx/msgdlg.h" | |
33 | #include "wx/layout.h" | |
34 | #include "wx/choice.h" | |
35 | #include "wx/button.h" | |
36 | #include "wx/settings.h" | |
37 | #include "wx/dcmemory.h" | |
38 | #include "wx/stattext.h" | |
39 | #include "wx/intl.h" | |
384a1303 | 40 | #include "wx/textdlg.h" |
2b5f62a0 VZ |
41 | #include "wx/sizer.h" |
42 | #endif // !WX_PRECOMP | |
c801d85f KB |
43 | |
44 | #include "wx/prntbase.h" | |
45 | #include "wx/dcprint.h" | |
46 | #include "wx/printdlg.h" | |
e81e3883 | 47 | #include "wx/print.h" |
2a47d3c1 | 48 | #include "wx/module.h" |
c801d85f KB |
49 | |
50 | #include <stdlib.h> | |
51 | #include <string.h> | |
52 | ||
891daf8c RR |
53 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) |
54 | #include "wx/msw/printdlg.h" | |
55 | #elif defined(__WXMAC__) | |
56 | #include "wx/mac/printdlg.h" | |
dc7ccb9c | 57 | #include "wx/mac/private/print.h" |
891daf8c RR |
58 | #else |
59 | #include "wx/generic/prntdlgg.h" | |
60 | #endif | |
61 | ||
2049ba38 | 62 | #ifdef __WXMSW__ |
660296aa | 63 | #include "wx/msw/wrapcdlg.h" |
d427503c VZ |
64 | #ifndef __WIN32__ |
65 | #include <print.h> | |
66 | #endif | |
67 | #endif // __WXMSW__ | |
c801d85f | 68 | |
e81e3883 RR |
69 | //---------------------------------------------------------------------------- |
70 | // wxPrintFactory | |
71 | //---------------------------------------------------------------------------- | |
72 | ||
73 | wxPrintFactory *wxPrintFactory::m_factory = NULL; | |
383f6abd | 74 | |
e81e3883 | 75 | void wxPrintFactory::SetPrintFactory( wxPrintFactory *factory ) |
383f6abd WS |
76 | { |
77 | if (wxPrintFactory::m_factory) | |
e81e3883 | 78 | delete wxPrintFactory::m_factory; |
383f6abd WS |
79 | |
80 | wxPrintFactory::m_factory = factory; | |
e81e3883 | 81 | } |
c801d85f | 82 | |
e81e3883 RR |
83 | wxPrintFactory *wxPrintFactory::GetFactory() |
84 | { | |
85 | if (!wxPrintFactory::m_factory) | |
383f6abd | 86 | wxPrintFactory::m_factory = new wxNativePrintFactory; |
c801d85f | 87 | |
e81e3883 RR |
88 | return wxPrintFactory::m_factory; |
89 | } | |
90 | ||
91 | //---------------------------------------------------------------------------- | |
92 | // wxNativePrintFactory | |
93 | //---------------------------------------------------------------------------- | |
94 | ||
95 | wxPrinterBase *wxNativePrintFactory::CreatePrinter( wxPrintDialogData *data ) | |
383f6abd WS |
96 | { |
97 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) | |
e81e3883 RR |
98 | return new wxWindowsPrinter( data ); |
99 | #elif defined(__WXMAC__) | |
100 | return new wxMacPrinter( data ); | |
21708c73 SN |
101 | #elif defined(__WXPM__) |
102 | return new wxOS2Printer( data ); | |
e81e3883 RR |
103 | #else |
104 | return new wxPostScriptPrinter( data ); | |
105 | #endif | |
106 | }; | |
107 | ||
383f6abd | 108 | wxPrintPreviewBase *wxNativePrintFactory::CreatePrintPreview( wxPrintout *preview, |
e81e3883 RR |
109 | wxPrintout *printout, wxPrintDialogData *data ) |
110 | { | |
383f6abd | 111 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) |
e81e3883 RR |
112 | return new wxWindowsPrintPreview( preview, printout, data ); |
113 | #elif defined(__WXMAC__) | |
114 | return new wxMacPrintPreview( preview, printout, data ); | |
21708c73 SN |
115 | #elif defined(__WXPM__) |
116 | return new wxOS2PrintPreview( preview, printout, data ); | |
e81e3883 RR |
117 | #else |
118 | return new wxPostScriptPrintPreview( preview, printout, data ); | |
119 | #endif | |
120 | } | |
121 | ||
383f6abd | 122 | wxPrintPreviewBase *wxNativePrintFactory::CreatePrintPreview( wxPrintout *preview, |
e81e3883 RR |
123 | wxPrintout *printout, wxPrintData *data ) |
124 | { | |
383f6abd | 125 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) |
e81e3883 RR |
126 | return new wxWindowsPrintPreview( preview, printout, data ); |
127 | #elif defined(__WXMAC__) | |
128 | return new wxMacPrintPreview( preview, printout, data ); | |
21708c73 SN |
129 | #elif defined(__WXPM__) |
130 | return new wxOS2PrintPreview( preview, printout, data ); | |
e81e3883 RR |
131 | #else |
132 | return new wxPostScriptPrintPreview( preview, printout, data ); | |
133 | #endif | |
134 | } | |
135 | ||
2997ca30 | 136 | wxPrintDialogBase *wxNativePrintFactory::CreatePrintDialog( wxWindow *parent, |
c061373d RR |
137 | wxPrintDialogData *data ) |
138 | { | |
139 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) | |
140 | return new wxWindowsPrintDialog( parent, data ); | |
141 | #elif defined(__WXMAC__) | |
142 | return new wxMacPrintDialog( parent, data ); | |
143 | #else | |
144 | return new wxGenericPrintDialog( parent, data ); | |
145 | #endif | |
146 | } | |
147 | ||
2997ca30 | 148 | wxPrintDialogBase *wxNativePrintFactory::CreatePrintDialog( wxWindow *parent, |
c061373d RR |
149 | wxPrintData *data ) |
150 | { | |
151 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) | |
152 | return new wxWindowsPrintDialog( parent, data ); | |
153 | #elif defined(__WXMAC__) | |
154 | return new wxMacPrintDialog( parent, data ); | |
155 | #else | |
156 | return new wxGenericPrintDialog( parent, data ); | |
157 | #endif | |
158 | } | |
159 | ||
2997ca30 | 160 | wxPageSetupDialogBase *wxNativePrintFactory::CreatePageSetupDialog( wxWindow *parent, |
891daf8c RR |
161 | wxPageSetupDialogData *data ) |
162 | { | |
163 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) | |
164 | return new wxWindowsPageSetupDialog( parent, data ); | |
165 | #elif defined(__WXMAC__) | |
166 | return new wxMacPageSetupDialog( parent, data ); | |
167 | #else | |
168 | return new wxGenericPageSetupDialog( parent, data ); | |
169 | #endif | |
170 | } | |
171 | ||
6038ec8e RR |
172 | bool wxNativePrintFactory::HasPrintSetupDialog() |
173 | { | |
174 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) | |
175 | return false; | |
176 | #elif defined(__WXMAC__) | |
177 | return false; | |
178 | #else | |
179 | // Only here do we need to provide the print setup | |
180 | // dialog ourselves, the other platforms either have | |
181 | // none, don't make it accessible or let you configure | |
182 | // the printer from the wxPrintDialog anyway. | |
183 | return true; | |
184 | #endif | |
2997ca30 | 185 | |
6038ec8e RR |
186 | } |
187 | ||
2997ca30 | 188 | wxDialog *wxNativePrintFactory::CreatePrintSetupDialog( wxWindow *parent, |
891daf8c | 189 | wxPrintData *data ) |
6038ec8e RR |
190 | { |
191 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) | |
ce403057 WS |
192 | wxUnusedVar(parent); |
193 | wxUnusedVar(data); | |
6038ec8e RR |
194 | return NULL; |
195 | #elif defined(__WXMAC__) | |
ce403057 WS |
196 | wxUnusedVar(parent); |
197 | wxUnusedVar(data); | |
6038ec8e RR |
198 | return NULL; |
199 | #else | |
200 | // Only here do we need to provide the print setup | |
201 | // dialog ourselves, the other platforms either have | |
202 | // none, don't make it accessible or let you configure | |
203 | // the printer from the wxPrintDialog anyway. | |
204 | return new wxGenericPrintSetupDialog( parent, data ); | |
205 | #endif | |
206 | } | |
207 | ||
208 | bool wxNativePrintFactory::HasOwnPrintToFile() | |
209 | { | |
210 | // Only relevant for PostScript and here the | |
2997ca30 | 211 | // setup dialog provides no "print to file" |
6038ec8e RR |
212 | // option. In the GNOME setup dialog, the |
213 | // setup dialog has its own print to file. | |
214 | return false; | |
215 | } | |
216 | ||
217 | bool wxNativePrintFactory::HasPrinterLine() | |
218 | { | |
219 | // Only relevant for PostScript for now | |
220 | return true; | |
221 | } | |
222 | ||
223 | wxString wxNativePrintFactory::CreatePrinterLine() | |
224 | { | |
225 | // Only relevant for PostScript for now | |
2997ca30 | 226 | |
6038ec8e RR |
227 | // We should query "lpstat -d" here |
228 | return _("Generic PostScript"); | |
229 | } | |
230 | ||
231 | bool wxNativePrintFactory::HasStatusLine() | |
232 | { | |
233 | // Only relevant for PostScript for now | |
2997ca30 | 234 | return true; |
6038ec8e RR |
235 | } |
236 | ||
237 | wxString wxNativePrintFactory::CreateStatusLine() | |
238 | { | |
239 | // Only relevant for PostScript for now | |
2997ca30 | 240 | |
6038ec8e RR |
241 | // We should query "lpstat -r" or "lpstat -p" here |
242 | return _("Ready"); | |
243 | } | |
244 | ||
8850cbd3 RR |
245 | wxPrintNativeDataBase *wxNativePrintFactory::CreatePrintNativeData() |
246 | { | |
247 | #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) | |
248 | return new wxWindowsPrintNativeData; | |
249 | #elif defined(__WXMAC__) | |
dc7ccb9c | 250 | return new wxMacCarbonPrintData; |
8850cbd3 RR |
251 | #else |
252 | return new wxPostScriptPrintNativeData; | |
253 | #endif | |
254 | } | |
255 | ||
256 | //---------------------------------------------------------------------------- | |
257 | // wxPrintNativeDataBase | |
258 | //---------------------------------------------------------------------------- | |
259 | ||
260 | IMPLEMENT_ABSTRACT_CLASS(wxPrintNativeDataBase, wxObject) | |
261 | ||
262 | wxPrintNativeDataBase::wxPrintNativeDataBase() | |
2997ca30 WS |
263 | { |
264 | m_ref = 1; | |
8850cbd3 RR |
265 | } |
266 | ||
0ab2de15 RR |
267 | //---------------------------------------------------------------------------- |
268 | // wxPrintFactoryModule | |
269 | //---------------------------------------------------------------------------- | |
270 | ||
271 | class wxPrintFactoryModule: public wxModule | |
272 | { | |
273 | public: | |
274 | wxPrintFactoryModule() {} | |
275 | bool OnInit() { return true; } | |
276 | void OnExit() { wxPrintFactory::SetPrintFactory( NULL ); } | |
2997ca30 | 277 | |
0ab2de15 RR |
278 | private: |
279 | DECLARE_DYNAMIC_CLASS(wxPrintFactoryModule) | |
280 | }; | |
281 | ||
282 | IMPLEMENT_DYNAMIC_CLASS(wxPrintFactoryModule, wxModule) | |
283 | ||
e81e3883 RR |
284 | //---------------------------------------------------------------------------- |
285 | // wxPrinterBase | |
286 | //---------------------------------------------------------------------------- | |
287 | ||
288 | IMPLEMENT_CLASS(wxPrinterBase, wxObject) | |
7bcb11d3 JS |
289 | |
290 | wxPrinterBase::wxPrinterBase(wxPrintDialogData *data) | |
c801d85f | 291 | { |
7bcb11d3 JS |
292 | m_currentPrintout = (wxPrintout *) NULL; |
293 | sm_abortWindow = (wxWindow *) NULL; | |
7e548f6b | 294 | sm_abortIt = false; |
7bcb11d3 JS |
295 | if (data) |
296 | m_printDialogData = (*data); | |
f6bcfd97 | 297 | sm_lastError = wxPRINTER_NO_ERROR; |
c801d85f KB |
298 | } |
299 | ||
34da0970 | 300 | wxWindow *wxPrinterBase::sm_abortWindow = (wxWindow *) NULL; |
7e548f6b | 301 | bool wxPrinterBase::sm_abortIt = false; |
f6bcfd97 | 302 | wxPrinterError wxPrinterBase::sm_lastError = wxPRINTER_NO_ERROR; |
c801d85f | 303 | |
34da0970 | 304 | wxPrinterBase::~wxPrinterBase() |
c801d85f KB |
305 | { |
306 | } | |
307 | ||
fc799548 | 308 | wxWindow *wxPrinterBase::CreateAbortWindow(wxWindow *parent, wxPrintout * printout) |
c801d85f | 309 | { |
fc799548 | 310 | wxPrintAbortDialog *dialog = new wxPrintAbortDialog(parent, _("Printing ") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE); |
8826f46f | 311 | |
fc799548 | 312 | wxBoxSizer *button_sizer = new wxBoxSizer( wxVERTICAL ); |
7e548f6b | 313 | button_sizer->Add( new wxStaticText(dialog, wxID_ANY, _("Please wait while printing\n") + printout->GetTitle() ), 0, wxALL, 10 ); |
fc799548 | 314 | button_sizer->Add( new wxButton( dialog, wxID_CANCEL, wxT("Cancel") ), 0, wxALL | wxALIGN_CENTER, 10 ); |
8826f46f | 315 | |
7e548f6b | 316 | dialog->SetAutoLayout( true ); |
fc799548 JS |
317 | dialog->SetSizer( button_sizer ); |
318 | ||
319 | button_sizer->Fit(dialog); | |
320 | button_sizer->SetSizeHints (dialog) ; | |
8826f46f | 321 | |
7bcb11d3 | 322 | return dialog; |
c801d85f KB |
323 | } |
324 | ||
161f4f73 | 325 | void wxPrinterBase::ReportError(wxWindow *parent, wxPrintout *WXUNUSED(printout), const wxString& message) |
c801d85f | 326 | { |
7bcb11d3 | 327 | wxMessageBox(message, _("Printing Error"), wxOK, parent); |
c801d85f KB |
328 | } |
329 | ||
c061373d RR |
330 | wxPrintDialogData& wxPrinterBase::GetPrintDialogData() const |
331 | { | |
332 | return (wxPrintDialogData&) m_printDialogData; | |
333 | } | |
334 | ||
e81e3883 RR |
335 | //---------------------------------------------------------------------------- |
336 | // wxPrinter | |
337 | //---------------------------------------------------------------------------- | |
338 | ||
339 | IMPLEMENT_CLASS(wxPrinter, wxPrinterBase) | |
340 | ||
341 | wxPrinter::wxPrinter(wxPrintDialogData *data) | |
342 | { | |
343 | m_pimpl = wxPrintFactory::GetFactory()->CreatePrinter( data ); | |
344 | } | |
345 | ||
346 | wxPrinter::~wxPrinter() | |
347 | { | |
348 | delete m_pimpl; | |
349 | } | |
350 | ||
351 | wxWindow *wxPrinter::CreateAbortWindow(wxWindow *parent, wxPrintout *printout) | |
352 | { | |
353 | return m_pimpl->CreateAbortWindow( parent, printout ); | |
354 | } | |
355 | ||
356 | void wxPrinter::ReportError(wxWindow *parent, wxPrintout *printout, const wxString& message) | |
357 | { | |
358 | m_pimpl->ReportError( parent, printout, message ); | |
359 | } | |
360 | ||
361 | bool wxPrinter::Setup(wxWindow *parent) | |
362 | { | |
363 | return m_pimpl->Setup( parent ); | |
364 | } | |
365 | ||
366 | bool wxPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) | |
367 | { | |
368 | return m_pimpl->Print( parent, printout, prompt ); | |
369 | } | |
370 | ||
371 | wxDC* wxPrinter::PrintDialog(wxWindow *parent) | |
372 | { | |
373 | return m_pimpl->PrintDialog( parent ); | |
374 | } | |
375 | ||
c061373d RR |
376 | wxPrintDialogData& wxPrinter::GetPrintDialogData() const |
377 | { | |
378 | return m_pimpl->GetPrintDialogData(); | |
379 | } | |
380 | ||
381 | // --------------------------------------------------------------------------- | |
891daf8c | 382 | // wxPrintDialogBase: the dialog for printing. |
c061373d RR |
383 | // --------------------------------------------------------------------------- |
384 | ||
891daf8c | 385 | IMPLEMENT_ABSTRACT_CLASS(wxPrintDialogBase, wxDialog) |
c061373d | 386 | |
6ce8c562 | 387 | wxPrintDialogBase::wxPrintDialogBase(wxWindow *parent, |
2997ca30 | 388 | wxWindowID id, |
6ce8c562 VZ |
389 | const wxString &title, |
390 | const wxPoint &pos, | |
391 | const wxSize &size, | |
392 | long style) | |
891daf8c RR |
393 | : wxDialog( parent, id, title.empty() ? wxString(_("Print")) : title, |
394 | pos, size, style ) | |
c061373d RR |
395 | { |
396 | } | |
397 | ||
398 | // --------------------------------------------------------------------------- | |
891daf8c | 399 | // wxPrintDialog: the dialog for printing |
c061373d RR |
400 | // --------------------------------------------------------------------------- |
401 | ||
402 | IMPLEMENT_CLASS(wxPrintDialog, wxObject) | |
403 | ||
404 | wxPrintDialog::wxPrintDialog(wxWindow *parent, wxPrintDialogData* data) | |
405 | { | |
406 | m_pimpl = wxPrintFactory::GetFactory()->CreatePrintDialog( parent, data ); | |
407 | } | |
408 | ||
409 | wxPrintDialog::wxPrintDialog(wxWindow *parent, wxPrintData* data) | |
410 | { | |
411 | m_pimpl = wxPrintFactory::GetFactory()->CreatePrintDialog( parent, data ); | |
412 | } | |
413 | ||
414 | wxPrintDialog::~wxPrintDialog() | |
415 | { | |
416 | delete m_pimpl; | |
417 | } | |
418 | ||
419 | int wxPrintDialog::ShowModal() | |
420 | { | |
421 | return m_pimpl->ShowModal(); | |
422 | } | |
423 | ||
424 | wxPrintDialogData& wxPrintDialog::GetPrintDialogData() | |
425 | { | |
426 | return m_pimpl->GetPrintDialogData(); | |
427 | } | |
428 | ||
429 | wxPrintData& wxPrintDialog::GetPrintData() | |
430 | { | |
431 | return m_pimpl->GetPrintData(); | |
432 | } | |
891daf8c | 433 | |
c061373d RR |
434 | wxDC *wxPrintDialog::GetPrintDC() |
435 | { | |
436 | return m_pimpl->GetPrintDC(); | |
437 | } | |
438 | ||
891daf8c RR |
439 | // --------------------------------------------------------------------------- |
440 | // wxPageSetupDialogBase: the page setup dialog | |
441 | // --------------------------------------------------------------------------- | |
442 | ||
443 | IMPLEMENT_ABSTRACT_CLASS(wxPageSetupDialogBase, wxDialog) | |
444 | ||
445 | wxPageSetupDialogBase::wxPageSetupDialogBase(wxWindow *parent, | |
2997ca30 | 446 | wxWindowID id, |
891daf8c RR |
447 | const wxString &title, |
448 | const wxPoint &pos, | |
449 | const wxSize &size, | |
450 | long style) | |
451 | : wxDialog( parent, id, title.empty() ? wxString(_("Page setup")) : title, | |
452 | pos, size, style ) | |
453 | { | |
454 | } | |
455 | ||
456 | // --------------------------------------------------------------------------- | |
457 | // wxPageSetupDialog: the page setup dialog | |
458 | // --------------------------------------------------------------------------- | |
459 | ||
460 | IMPLEMENT_CLASS(wxPageSetupDialog, wxObject) | |
461 | ||
462 | wxPageSetupDialog::wxPageSetupDialog(wxWindow *parent, wxPageSetupDialogData *data ) | |
463 | { | |
464 | m_pimpl = wxPrintFactory::GetFactory()->CreatePageSetupDialog( parent, data ); | |
465 | } | |
466 | ||
467 | wxPageSetupDialog::~wxPageSetupDialog() | |
468 | { | |
469 | delete m_pimpl; | |
470 | } | |
471 | ||
472 | int wxPageSetupDialog::ShowModal() | |
473 | { | |
474 | return m_pimpl->ShowModal(); | |
475 | } | |
476 | ||
477 | wxPageSetupDialogData& wxPageSetupDialog::GetPageSetupDialogData() | |
478 | { | |
479 | return m_pimpl->GetPageSetupDialogData(); | |
480 | } | |
481 | ||
482 | // old name | |
483 | wxPageSetupDialogData& wxPageSetupDialog::GetPageSetupData() | |
484 | { | |
485 | return m_pimpl->GetPageSetupDialogData(); | |
486 | } | |
487 | ||
e81e3883 RR |
488 | //---------------------------------------------------------------------------- |
489 | // wxPrintAbortDialog | |
490 | //---------------------------------------------------------------------------- | |
491 | ||
492 | BEGIN_EVENT_TABLE(wxPrintAbortDialog, wxDialog) | |
493 | EVT_BUTTON(wxID_CANCEL, wxPrintAbortDialog::OnCancel) | |
494 | END_EVENT_TABLE() | |
495 | ||
496 | void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) | |
497 | { | |
498 | wxPrinterBase::sm_abortIt = true; | |
499 | wxPrinterBase::sm_abortWindow->Show(false); | |
500 | wxPrinterBase::sm_abortWindow->Close(true); | |
501 | wxPrinterBase::sm_abortWindow = (wxWindow *) NULL; | |
502 | } | |
503 | ||
504 | //---------------------------------------------------------------------------- | |
505 | // wxPrintout | |
506 | //---------------------------------------------------------------------------- | |
507 | ||
508 | IMPLEMENT_ABSTRACT_CLASS(wxPrintout, wxObject) | |
7bcb11d3 | 509 | |
34da0970 | 510 | wxPrintout::wxPrintout(const wxString& title) |
c801d85f | 511 | { |
7bcb11d3 JS |
512 | m_printoutTitle = title ; |
513 | m_printoutDC = (wxDC *) NULL; | |
514 | m_pageWidthMM = 0; | |
515 | m_pageHeightMM = 0; | |
516 | m_pageWidthPixels = 0; | |
517 | m_pageHeightPixels = 0; | |
518 | m_PPIScreenX = 0; | |
519 | m_PPIScreenY = 0; | |
520 | m_PPIPrinterX = 0; | |
521 | m_PPIPrinterY = 0; | |
7e548f6b | 522 | m_isPreview = false; |
c801d85f KB |
523 | } |
524 | ||
34da0970 | 525 | wxPrintout::~wxPrintout() |
c801d85f | 526 | { |
c801d85f KB |
527 | } |
528 | ||
529 | bool wxPrintout::OnBeginDocument(int WXUNUSED(startPage), int WXUNUSED(endPage)) | |
530 | { | |
fc799548 | 531 | return GetDC()->StartDoc(_("Printing ") + m_printoutTitle); |
c801d85f KB |
532 | } |
533 | ||
34da0970 | 534 | void wxPrintout::OnEndDocument() |
c801d85f | 535 | { |
7bcb11d3 | 536 | GetDC()->EndDoc(); |
c801d85f KB |
537 | } |
538 | ||
34da0970 | 539 | void wxPrintout::OnBeginPrinting() |
c801d85f KB |
540 | { |
541 | } | |
542 | ||
34da0970 | 543 | void wxPrintout::OnEndPrinting() |
c801d85f KB |
544 | { |
545 | } | |
546 | ||
547 | bool wxPrintout::HasPage(int page) | |
548 | { | |
7bcb11d3 | 549 | return (page == 1); |
c801d85f KB |
550 | } |
551 | ||
552 | void wxPrintout::GetPageInfo(int *minPage, int *maxPage, int *fromPage, int *toPage) | |
553 | { | |
7bcb11d3 JS |
554 | *minPage = 1; |
555 | *maxPage = 32000; | |
556 | *fromPage = 1; | |
557 | *toPage = 1; | |
c801d85f KB |
558 | } |
559 | ||
e81e3883 RR |
560 | //---------------------------------------------------------------------------- |
561 | // wxPreviewCanvas | |
562 | //---------------------------------------------------------------------------- | |
563 | ||
564 | IMPLEMENT_CLASS(wxPreviewCanvas, wxWindow) | |
565 | ||
566 | BEGIN_EVENT_TABLE(wxPreviewCanvas, wxScrolledWindow) | |
567 | EVT_PAINT(wxPreviewCanvas::OnPaint) | |
568 | EVT_CHAR(wxPreviewCanvas::OnChar) | |
569 | EVT_SYS_COLOUR_CHANGED(wxPreviewCanvas::OnSysColourChanged) | |
570 | END_EVENT_TABLE() | |
7bcb11d3 | 571 | |
e9cafd42 VZ |
572 | // VZ: the current code doesn't refresh properly without |
573 | // wxFULL_REPAINT_ON_RESIZE, this must be fixed as otherwise we have | |
574 | // really horrible flicker when resizing the preview frame, but without | |
575 | // this style it simply doesn't work correctly at all... | |
c801d85f | 576 | wxPreviewCanvas::wxPreviewCanvas(wxPrintPreviewBase *preview, wxWindow *parent, |
7bcb11d3 | 577 | const wxPoint& pos, const wxSize& size, long style, const wxString& name): |
7e548f6b | 578 | wxScrolledWindow(parent, wxID_ANY, pos, size, style | wxFULL_REPAINT_ON_RESIZE, name) |
c801d85f | 579 | { |
7bcb11d3 | 580 | m_printPreview = preview; |
46b24ef9 JS |
581 | #ifdef __WXMAC__ |
582 | // The app workspace colour is always white, but we should have | |
583 | // a contrast with the page. | |
ca5020c2 | 584 | wxSystemColour colourIndex = wxSYS_COLOUR_3DDKSHADOW; |
46b24ef9 JS |
585 | #else |
586 | wxSystemColour colourIndex = wxSYS_COLOUR_APPWORKSPACE; | |
e71fd398 | 587 | #endif |
46b24ef9 | 588 | SetBackgroundColour(wxSystemSettings::GetColour(colourIndex)); |
8826f46f | 589 | |
d2b354f9 | 590 | SetScrollbars(10, 10, 100, 100); |
c801d85f KB |
591 | } |
592 | ||
34da0970 | 593 | wxPreviewCanvas::~wxPreviewCanvas() |
c801d85f KB |
594 | { |
595 | } | |
596 | ||
597 | void wxPreviewCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
598 | { | |
7bcb11d3 JS |
599 | wxPaintDC dc(this); |
600 | PrepareDC( dc ); | |
8826f46f | 601 | |
a56fcaaf | 602 | /* |
809934d2 RR |
603 | #ifdef __WXGTK__ |
604 | if (!GetUpdateRegion().IsEmpty()) | |
605 | dc.SetClippingRegion( GetUpdateRegion() ); | |
606 | #endif | |
a56fcaaf | 607 | */ |
809934d2 | 608 | |
7bcb11d3 JS |
609 | if (m_printPreview) |
610 | { | |
611 | m_printPreview->PaintPage(this, dc); | |
612 | } | |
c801d85f KB |
613 | } |
614 | ||
615 | // Responds to colour changes, and passes event on to children. | |
616 | void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent& event) | |
617 | { | |
46b24ef9 JS |
618 | #ifdef __WXMAC__ |
619 | // The app workspace colour is always white, but we should have | |
620 | // a contrast with the page. | |
ca5020c2 | 621 | wxSystemColour colourIndex = wxSYS_COLOUR_3DDKSHADOW; |
46b24ef9 JS |
622 | #else |
623 | wxSystemColour colourIndex = wxSYS_COLOUR_APPWORKSPACE; | |
e71fd398 | 624 | #endif |
46b24ef9 | 625 | SetBackgroundColour(wxSystemSettings::GetColour(colourIndex)); |
7bcb11d3 | 626 | Refresh(); |
8826f46f | 627 | |
7bcb11d3 JS |
628 | // Propagate the event to the non-top-level children |
629 | wxWindow::OnSysColourChanged(event); | |
c801d85f KB |
630 | } |
631 | ||
d2b354f9 JS |
632 | void wxPreviewCanvas::OnChar(wxKeyEvent &event) |
633 | { | |
b38b0d22 | 634 | wxPreviewControlBar* controlBar = ((wxPreviewFrame*) GetParent())->GetControlBar(); |
d2b354f9 JS |
635 | if (event.GetKeyCode() == WXK_ESCAPE) |
636 | { | |
7e548f6b | 637 | ((wxPreviewFrame*) GetParent())->Close(true); |
d2b354f9 | 638 | return; |
e71fd398 | 639 | } |
b38b0d22 JS |
640 | else if (event.GetKeyCode() == WXK_TAB) |
641 | { | |
642 | controlBar->OnGoto(); | |
643 | return; | |
d2b354f9 | 644 | } |
b38b0d22 JS |
645 | else if (event.GetKeyCode() == WXK_RETURN) |
646 | { | |
647 | controlBar->OnPrint(); | |
648 | return; | |
649 | } | |
650 | ||
d2b354f9 JS |
651 | if (!event.ControlDown()) |
652 | { | |
653 | event.Skip(); | |
654 | return; | |
655 | } | |
e71fd398 | 656 | |
b38b0d22 JS |
657 | switch(event.GetKeyCode()) |
658 | { | |
659 | case WXK_NEXT: | |
660 | controlBar->OnNext(); break; | |
661 | case WXK_PRIOR: | |
662 | controlBar->OnPrevious(); break; | |
663 | case WXK_HOME: | |
664 | controlBar->OnFirst(); break; | |
665 | case WXK_END: | |
666 | controlBar->OnLast(); break; | |
667 | default: | |
668 | event.Skip(); | |
669 | } | |
d2b354f9 JS |
670 | } |
671 | ||
e81e3883 RR |
672 | //---------------------------------------------------------------------------- |
673 | // wxPreviewControlBar | |
674 | //---------------------------------------------------------------------------- | |
675 | ||
676 | IMPLEMENT_CLASS(wxPreviewControlBar, wxWindow) | |
c801d85f KB |
677 | |
678 | BEGIN_EVENT_TABLE(wxPreviewControlBar, wxPanel) | |
8826f46f | 679 | EVT_BUTTON(wxID_PREVIEW_CLOSE, wxPreviewControlBar::OnWindowClose) |
90b6b974 | 680 | EVT_BUTTON(wxID_PREVIEW_PRINT, wxPreviewControlBar::OnPrintButton) |
0f90ec93 KB |
681 | EVT_BUTTON(wxID_PREVIEW_PREVIOUS, wxPreviewControlBar::OnPreviousButton) |
682 | EVT_BUTTON(wxID_PREVIEW_NEXT, wxPreviewControlBar::OnNextButton) | |
bf89b538 JS |
683 | EVT_BUTTON(wxID_PREVIEW_FIRST, wxPreviewControlBar::OnFirstButton) |
684 | EVT_BUTTON(wxID_PREVIEW_LAST, wxPreviewControlBar::OnLastButton) | |
685 | EVT_BUTTON(wxID_PREVIEW_GOTO, wxPreviewControlBar::OnGotoButton) | |
8826f46f VZ |
686 | EVT_CHOICE(wxID_PREVIEW_ZOOM, wxPreviewControlBar::OnZoom) |
687 | EVT_PAINT(wxPreviewControlBar::OnPaint) | |
c801d85f | 688 | END_EVENT_TABLE() |
7bcb11d3 | 689 | |
c801d85f | 690 | wxPreviewControlBar::wxPreviewControlBar(wxPrintPreviewBase *preview, long buttons, |
7bcb11d3 JS |
691 | wxWindow *parent, const wxPoint& pos, const wxSize& size, |
692 | long style, const wxString& name): | |
7e548f6b | 693 | wxPanel(parent, wxID_ANY, pos, size, style, name) |
c801d85f | 694 | { |
7bcb11d3 JS |
695 | m_printPreview = preview; |
696 | m_closeButton = (wxButton *) NULL; | |
697 | m_nextPageButton = (wxButton *) NULL; | |
698 | m_previousPageButton = (wxButton *) NULL; | |
699 | m_printButton = (wxButton *) NULL; | |
700 | m_zoomControl = (wxChoice *) NULL; | |
701 | m_buttonFlags = buttons; | |
c801d85f KB |
702 | } |
703 | ||
34da0970 | 704 | wxPreviewControlBar::~wxPreviewControlBar() |
c801d85f KB |
705 | { |
706 | } | |
707 | ||
708 | void wxPreviewControlBar::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
709 | { | |
7bcb11d3 | 710 | wxPaintDC dc(this); |
8826f46f | 711 | |
7bcb11d3 JS |
712 | int w, h; |
713 | GetSize(&w, &h); | |
714 | dc.SetPen(*wxBLACK_PEN); | |
715 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | |
716 | dc.DrawLine( 0, h-1, w, h-1 ); | |
c801d85f KB |
717 | } |
718 | ||
c330a2cf | 719 | void wxPreviewControlBar::OnWindowClose(wxCommandEvent& WXUNUSED(event)) |
c801d85f | 720 | { |
7bcb11d3 | 721 | wxPreviewFrame *frame = (wxPreviewFrame *)GetParent(); |
7e548f6b | 722 | frame->Close(true); |
c801d85f KB |
723 | } |
724 | ||
b38b0d22 | 725 | void wxPreviewControlBar::OnPrint(void) |
c801d85f | 726 | { |
7bcb11d3 | 727 | wxPrintPreviewBase *preview = GetPrintPreview(); |
7e548f6b | 728 | preview->Print(true); |
c801d85f KB |
729 | } |
730 | ||
0f90ec93 | 731 | void wxPreviewControlBar::OnNext(void) |
c801d85f | 732 | { |
7bcb11d3 JS |
733 | wxPrintPreviewBase *preview = GetPrintPreview(); |
734 | if (preview) | |
c801d85f | 735 | { |
7bcb11d3 JS |
736 | int currentPage = preview->GetCurrentPage(); |
737 | if ((preview->GetMaxPage() > 0) && | |
738 | (currentPage < preview->GetMaxPage()) && | |
739 | preview->GetPrintout()->HasPage(currentPage + 1)) | |
740 | { | |
741 | preview->SetCurrentPage(currentPage + 1); | |
742 | } | |
c801d85f | 743 | } |
c801d85f KB |
744 | } |
745 | ||
0f90ec93 | 746 | void wxPreviewControlBar::OnPrevious(void) |
c801d85f | 747 | { |
7bcb11d3 JS |
748 | wxPrintPreviewBase *preview = GetPrintPreview(); |
749 | if (preview) | |
c801d85f | 750 | { |
7bcb11d3 JS |
751 | int currentPage = preview->GetCurrentPage(); |
752 | if ((preview->GetMinPage() > 0) && | |
753 | (currentPage > preview->GetMinPage()) && | |
754 | preview->GetPrintout()->HasPage(currentPage - 1)) | |
755 | { | |
756 | preview->SetCurrentPage(currentPage - 1); | |
757 | } | |
c801d85f | 758 | } |
c801d85f KB |
759 | } |
760 | ||
bf89b538 JS |
761 | void wxPreviewControlBar::OnFirst(void) |
762 | { | |
763 | wxPrintPreviewBase *preview = GetPrintPreview(); | |
764 | if (preview) | |
765 | { | |
766 | int currentPage = preview->GetMinPage(); | |
767 | if (preview->GetPrintout()->HasPage(currentPage)) | |
768 | { | |
769 | preview->SetCurrentPage(currentPage); | |
770 | } | |
771 | } | |
772 | } | |
773 | ||
774 | void wxPreviewControlBar::OnLast(void) | |
775 | { | |
776 | wxPrintPreviewBase *preview = GetPrintPreview(); | |
777 | if (preview) | |
778 | { | |
779 | int currentPage = preview->GetMaxPage(); | |
780 | if (preview->GetPrintout()->HasPage(currentPage)) | |
781 | { | |
782 | preview->SetCurrentPage(currentPage); | |
783 | } | |
784 | } | |
785 | } | |
786 | ||
787 | void wxPreviewControlBar::OnGoto(void) | |
788 | { | |
789 | wxPrintPreviewBase *preview = GetPrintPreview(); | |
790 | if (preview) | |
791 | { | |
792 | long currentPage; | |
793 | ||
794 | if (preview->GetMinPage() > 0) | |
795 | { | |
796 | wxString strPrompt; | |
797 | wxString strPage; | |
798 | ||
d2b354f9 | 799 | strPrompt.Printf( _("Enter a page number between %d and %d:"), |
bf89b538 | 800 | preview->GetMinPage(), preview->GetMaxPage()); |
7e99eddf | 801 | strPage.Printf( wxT("%d"), preview->GetCurrentPage() ); |
bf89b538 JS |
802 | |
803 | strPage = | |
d2b354f9 | 804 | wxGetTextFromUser( strPrompt, _("Goto Page"), strPage, GetParent()); |
bf89b538 JS |
805 | |
806 | if ( strPage.ToLong( ¤tPage ) ) | |
807 | if (preview->GetPrintout()->HasPage(currentPage)) | |
808 | { | |
809 | preview->SetCurrentPage(currentPage); | |
810 | } | |
811 | } | |
812 | } | |
813 | } | |
814 | ||
c801d85f KB |
815 | void wxPreviewControlBar::OnZoom(wxCommandEvent& WXUNUSED(event)) |
816 | { | |
7bcb11d3 JS |
817 | int zoom = GetZoomControl(); |
818 | if (GetPrintPreview()) | |
819 | GetPrintPreview()->SetZoom(zoom); | |
c801d85f KB |
820 | } |
821 | ||
34da0970 | 822 | void wxPreviewControlBar::CreateButtons() |
c801d85f | 823 | { |
7bcb11d3 | 824 | SetSize(0, 0, 400, 40); |
8826f46f | 825 | |
9dff8515 | 826 | wxBoxSizer *item0 = new wxBoxSizer( wxHORIZONTAL ); |
e71fd398 | 827 | |
9dff8515 JS |
828 | m_closeButton = new wxButton( this, wxID_PREVIEW_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 ); |
829 | item0->Add( m_closeButton, 0, wxALIGN_CENTRE|wxALL, 5 ); | |
e71fd398 | 830 | |
7bcb11d3 JS |
831 | if (m_buttonFlags & wxPREVIEW_PRINT) |
832 | { | |
9dff8515 JS |
833 | m_printButton = new wxButton( this, wxID_PREVIEW_PRINT, _("&Print..."), wxDefaultPosition, wxDefaultSize, 0 ); |
834 | item0->Add( m_printButton, 0, wxALIGN_CENTRE|wxALL, 5 ); | |
7bcb11d3 | 835 | } |
e71fd398 | 836 | |
bf89b538 JS |
837 | if (m_buttonFlags & wxPREVIEW_FIRST) |
838 | { | |
681aeb18 | 839 | m_firstPageButton = new wxButton( this, wxID_PREVIEW_FIRST, _("|<<"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); |
9dff8515 | 840 | item0->Add( m_firstPageButton, 0, wxALIGN_CENTRE|wxALL, 5 ); |
bf89b538 | 841 | } |
e71fd398 | 842 | |
7bcb11d3 JS |
843 | if (m_buttonFlags & wxPREVIEW_PREVIOUS) |
844 | { | |
681aeb18 | 845 | m_previousPageButton = new wxButton( this, wxID_PREVIEW_PREVIOUS, _("<<"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); |
9dff8515 | 846 | item0->Add( m_previousPageButton, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 ); |
7bcb11d3 | 847 | } |
e71fd398 | 848 | |
7bcb11d3 JS |
849 | if (m_buttonFlags & wxPREVIEW_NEXT) |
850 | { | |
681aeb18 | 851 | m_nextPageButton = new wxButton( this, wxID_PREVIEW_NEXT, _(">>"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); |
9dff8515 | 852 | item0->Add( m_nextPageButton, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 ); |
bf89b538 | 853 | } |
e71fd398 | 854 | |
bf89b538 JS |
855 | if (m_buttonFlags & wxPREVIEW_LAST) |
856 | { | |
681aeb18 | 857 | m_lastPageButton = new wxButton( this, wxID_PREVIEW_LAST, _(">>|"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); |
9dff8515 | 858 | item0->Add( m_lastPageButton, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 ); |
bf89b538 | 859 | } |
e71fd398 | 860 | |
bf89b538 JS |
861 | if (m_buttonFlags & wxPREVIEW_GOTO) |
862 | { | |
9dff8515 JS |
863 | m_gotoPageButton = new wxButton( this, wxID_PREVIEW_GOTO, _("&Goto..."), wxDefaultPosition, wxDefaultSize, 0 ); |
864 | item0->Add( m_gotoPageButton, 0, wxALIGN_CENTRE|wxALL, 5 ); | |
7bcb11d3 | 865 | } |
e71fd398 | 866 | |
7bcb11d3 JS |
867 | if (m_buttonFlags & wxPREVIEW_ZOOM) |
868 | { | |
e71fd398 | 869 | wxString choices[] = |
c25ccf85 | 870 | { |
2b5f62a0 | 871 | wxT("10%"), wxT("15%"), wxT("20%"), wxT("25%"), wxT("30%"), wxT("35%"), wxT("40%"), wxT("45%"), wxT("50%"), wxT("55%"), |
9dff8515 JS |
872 | wxT("60%"), wxT("65%"), wxT("70%"), wxT("75%"), wxT("80%"), wxT("85%"), wxT("90%"), wxT("95%"), wxT("100%"), wxT("110%"), |
873 | wxT("120%"), wxT("150%"), wxT("200%") | |
c25ccf85 | 874 | }; |
c25ccf85 | 875 | int n = WXSIZEOF(choices); |
e71fd398 | 876 | |
7e548f6b | 877 | m_zoomControl = new wxChoice( this, wxID_PREVIEW_ZOOM, wxDefaultPosition, wxSize(70,wxDefaultCoord), n, choices, 0 ); |
9dff8515 | 878 | item0->Add( m_zoomControl, 0, wxALIGN_CENTRE|wxALL, 5 ); |
7bcb11d3 JS |
879 | SetZoomControl(m_printPreview->GetZoom()); |
880 | } | |
8826f46f | 881 | |
9dff8515 JS |
882 | SetSizer(item0); |
883 | item0->Fit(this); | |
c801d85f KB |
884 | } |
885 | ||
886 | void wxPreviewControlBar::SetZoomControl(int zoom) | |
887 | { | |
7bcb11d3 | 888 | if (m_zoomControl) |
963907fa RR |
889 | { |
890 | int n, count = m_zoomControl->GetCount(); | |
891 | long val; | |
892 | for (n=0; n<count; n++) | |
893 | { | |
894 | if (m_zoomControl->GetString(n).BeforeFirst(wxT('%')).ToLong(&val) && | |
895 | (val >= long(zoom))) | |
896 | { | |
897 | m_zoomControl->SetSelection(n); | |
898 | return; | |
899 | } | |
900 | } | |
7e548f6b | 901 | |
963907fa RR |
902 | m_zoomControl->SetSelection(count-1); |
903 | } | |
c801d85f KB |
904 | } |
905 | ||
34da0970 | 906 | int wxPreviewControlBar::GetZoomControl() |
c801d85f | 907 | { |
963907fa | 908 | if (m_zoomControl && (m_zoomControl->GetStringSelection() != wxEmptyString)) |
7bcb11d3 | 909 | { |
963907fa RR |
910 | long val; |
911 | if (m_zoomControl->GetStringSelection().BeforeFirst(wxT('%')).ToLong(&val)) | |
912 | return int(val); | |
7bcb11d3 | 913 | } |
7e548f6b | 914 | |
963907fa | 915 | return 0; |
c801d85f KB |
916 | } |
917 | ||
918 | ||
919 | /* | |
7bcb11d3 JS |
920 | * Preview frame |
921 | */ | |
c801d85f | 922 | |
e81e3883 RR |
923 | IMPLEMENT_CLASS(wxPreviewFrame, wxFrame) |
924 | ||
e3065973 | 925 | BEGIN_EVENT_TABLE(wxPreviewFrame, wxFrame) |
0f90ec93 | 926 | EVT_CLOSE(wxPreviewFrame::OnCloseWindow) |
e3065973 JS |
927 | END_EVENT_TABLE() |
928 | ||
a5ae8241 | 929 | wxPreviewFrame::wxPreviewFrame(wxPrintPreviewBase *preview, wxWindow *parent, const wxString& title, |
7bcb11d3 | 930 | const wxPoint& pos, const wxSize& size, long style, const wxString& name): |
7e548f6b | 931 | wxFrame(parent, wxID_ANY, title, pos, size, style, name) |
c801d85f | 932 | { |
7bcb11d3 JS |
933 | m_printPreview = preview; |
934 | m_controlBar = NULL; | |
935 | m_previewCanvas = NULL; | |
7c995553 | 936 | m_windowDisabler = NULL; |
46b24ef9 | 937 | |
a5ae8241 | 938 | // Give the application icon |
46b24ef9 JS |
939 | #ifdef __WXMSW__ |
940 | wxFrame* topFrame = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame); | |
941 | if (topFrame) | |
942 | SetIcon(topFrame->GetIcon()); | |
e71fd398 | 943 | #endif |
c801d85f KB |
944 | } |
945 | ||
34da0970 | 946 | wxPreviewFrame::~wxPreviewFrame() |
c801d85f KB |
947 | { |
948 | } | |
949 | ||
74e3313b | 950 | void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) |
c801d85f | 951 | { |
7c995553 VZ |
952 | if (m_windowDisabler) |
953 | delete m_windowDisabler; | |
8826f46f | 954 | |
7bcb11d3 JS |
955 | // Need to delete the printout and the print preview |
956 | wxPrintout *printout = m_printPreview->GetPrintout(); | |
957 | if (printout) | |
958 | { | |
959 | delete printout; | |
960 | m_printPreview->SetPrintout(NULL); | |
961 | m_printPreview->SetCanvas(NULL); | |
962 | m_printPreview->SetFrame(NULL); | |
963 | } | |
964 | delete m_printPreview; | |
8826f46f | 965 | |
7bcb11d3 | 966 | Destroy(); |
c801d85f KB |
967 | } |
968 | ||
34da0970 | 969 | void wxPreviewFrame::Initialize() |
c801d85f | 970 | { |
3080bf59 | 971 | #if wxUSE_STATUSBAR |
7bcb11d3 | 972 | CreateStatusBar(); |
3080bf59 | 973 | #endif |
7bcb11d3 JS |
974 | CreateCanvas(); |
975 | CreateControlBar(); | |
8826f46f | 976 | |
7bcb11d3 JS |
977 | m_printPreview->SetCanvas(m_previewCanvas); |
978 | m_printPreview->SetFrame(this); | |
8826f46f | 979 | |
9dff8515 | 980 | wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); |
8826f46f | 981 | |
9dff8515 JS |
982 | item0->Add( m_controlBar, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 ); |
983 | item0->Add( m_previewCanvas, 1, wxGROW|wxALIGN_CENTER_VERTICAL, 5 ); | |
8826f46f | 984 | |
7e548f6b | 985 | SetAutoLayout( true ); |
9dff8515 | 986 | SetSizer( item0 ); |
8826f46f | 987 | |
7c995553 | 988 | m_windowDisabler = new wxWindowDisabler(this); |
8826f46f | 989 | |
7bcb11d3 | 990 | Layout(); |
e71fd398 | 991 | |
d2b354f9 JS |
992 | m_printPreview->AdjustScrollbars(m_previewCanvas); |
993 | m_previewCanvas->SetFocus(); | |
994 | m_controlBar->SetFocus(); | |
c801d85f KB |
995 | } |
996 | ||
34da0970 | 997 | void wxPreviewFrame::CreateCanvas() |
c801d85f | 998 | { |
7bcb11d3 | 999 | m_previewCanvas = new wxPreviewCanvas(m_printPreview, this); |
c801d85f KB |
1000 | } |
1001 | ||
34da0970 | 1002 | void wxPreviewFrame::CreateControlBar() |
c801d85f | 1003 | { |
7bcb11d3 JS |
1004 | long buttons = wxPREVIEW_DEFAULT; |
1005 | if (m_printPreview->GetPrintoutForPrinting()) | |
1006 | buttons |= wxPREVIEW_PRINT; | |
8826f46f | 1007 | |
c47addef | 1008 | m_controlBar = new wxPreviewControlBar(m_printPreview, buttons, this, wxPoint(0,0), wxSize(400, 40)); |
7bcb11d3 | 1009 | m_controlBar->CreateButtons(); |
c801d85f | 1010 | } |
7bcb11d3 | 1011 | |
c801d85f | 1012 | /* |
7bcb11d3 JS |
1013 | * Print preview |
1014 | */ | |
c801d85f | 1015 | |
891daf8c RR |
1016 | IMPLEMENT_CLASS(wxPrintPreviewBase, wxObject) |
1017 | ||
8826f46f VZ |
1018 | wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout, |
1019 | wxPrintout *printoutForPrinting, | |
1020 | wxPrintData *data) | |
1021 | { | |
1022 | if (data) | |
1023 | m_printDialogData = (*data); | |
1024 | ||
1025 | Init(printout, printoutForPrinting); | |
1026 | } | |
1027 | ||
1028 | wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout, | |
1029 | wxPrintout *printoutForPrinting, | |
1030 | wxPrintDialogData *data) | |
1031 | { | |
1032 | if (data) | |
1033 | m_printDialogData = (*data); | |
1034 | ||
1035 | Init(printout, printoutForPrinting); | |
1036 | } | |
1037 | ||
1038 | void wxPrintPreviewBase::Init(wxPrintout *printout, | |
1039 | wxPrintout *printoutForPrinting) | |
c801d85f | 1040 | { |
7e548f6b | 1041 | m_isOk = true; |
7bcb11d3 JS |
1042 | m_previewPrintout = printout; |
1043 | if (m_previewPrintout) | |
7e548f6b | 1044 | m_previewPrintout->SetIsPreview(true); |
8826f46f | 1045 | |
7bcb11d3 | 1046 | m_printPrintout = printoutForPrinting; |
8826f46f | 1047 | |
7bcb11d3 JS |
1048 | m_previewCanvas = NULL; |
1049 | m_previewFrame = NULL; | |
1050 | m_previewBitmap = NULL; | |
1051 | m_currentPage = 1; | |
c25ccf85 | 1052 | m_currentZoom = 70; |
7bcb11d3 JS |
1053 | m_topMargin = 40; |
1054 | m_leftMargin = 40; | |
1055 | m_pageWidth = 0; | |
1056 | m_pageHeight = 0; | |
7e548f6b | 1057 | m_printingPrepared = false; |
d2b354f9 JS |
1058 | m_minPage = 1; |
1059 | m_maxPage = 1; | |
c801d85f KB |
1060 | } |
1061 | ||
34da0970 | 1062 | wxPrintPreviewBase::~wxPrintPreviewBase() |
c801d85f | 1063 | { |
7bcb11d3 JS |
1064 | if (m_previewPrintout) |
1065 | delete m_previewPrintout; | |
1066 | if (m_previewBitmap) | |
1067 | delete m_previewBitmap; | |
1068 | if (m_printPrintout) | |
1069 | delete m_printPrintout; | |
c801d85f KB |
1070 | } |
1071 | ||
1072 | bool wxPrintPreviewBase::SetCurrentPage(int pageNum) | |
1073 | { | |
7bcb11d3 | 1074 | if (m_currentPage == pageNum) |
7e548f6b | 1075 | return true; |
8826f46f | 1076 | |
7bcb11d3 JS |
1077 | m_currentPage = pageNum; |
1078 | if (m_previewBitmap) | |
1079 | { | |
1080 | delete m_previewBitmap; | |
1081 | m_previewBitmap = NULL; | |
1082 | } | |
e71fd398 | 1083 | |
7bcb11d3 JS |
1084 | if (m_previewCanvas) |
1085 | { | |
d2b354f9 | 1086 | AdjustScrollbars(m_previewCanvas); |
e71fd398 | 1087 | |
9eee81a4 | 1088 | if (!RenderPage(pageNum)) |
7e548f6b | 1089 | return false; |
7bcb11d3 | 1090 | m_previewCanvas->Refresh(); |
d2b354f9 | 1091 | m_previewCanvas->SetFocus(); |
7bcb11d3 | 1092 | } |
7e548f6b | 1093 | return true; |
c801d85f KB |
1094 | } |
1095 | ||
383f6abd | 1096 | int wxPrintPreviewBase::GetCurrentPage() const |
e81e3883 | 1097 | { return m_currentPage; }; |
383f6abd | 1098 | void wxPrintPreviewBase::SetPrintout(wxPrintout *printout) |
e81e3883 | 1099 | { m_previewPrintout = printout; }; |
383f6abd | 1100 | wxPrintout *wxPrintPreviewBase::GetPrintout() const |
e81e3883 | 1101 | { return m_previewPrintout; }; |
383f6abd | 1102 | wxPrintout *wxPrintPreviewBase::GetPrintoutForPrinting() const |
e81e3883 | 1103 | { return m_printPrintout; }; |
383f6abd | 1104 | void wxPrintPreviewBase::SetFrame(wxFrame *frame) |
e81e3883 | 1105 | { m_previewFrame = frame; }; |
383f6abd | 1106 | void wxPrintPreviewBase::SetCanvas(wxPreviewCanvas *canvas) |
e81e3883 | 1107 | { m_previewCanvas = canvas; }; |
383f6abd | 1108 | wxFrame *wxPrintPreviewBase::GetFrame() const |
e81e3883 | 1109 | { return m_previewFrame; } |
383f6abd | 1110 | wxPreviewCanvas *wxPrintPreviewBase::GetCanvas() const |
e81e3883 RR |
1111 | { return m_previewCanvas; } |
1112 | ||
d2b354f9 | 1113 | bool wxPrintPreviewBase::PaintPage(wxPreviewCanvas *canvas, wxDC& dc) |
c801d85f | 1114 | { |
7bcb11d3 | 1115 | DrawBlankPage(canvas, dc); |
8826f46f | 1116 | |
7bcb11d3 | 1117 | if (!m_previewBitmap) |
9eee81a4 | 1118 | if (!RenderPage(m_currentPage)) |
7e548f6b | 1119 | return false; |
8826f46f | 1120 | |
7bcb11d3 | 1121 | if (!m_previewBitmap) |
7e548f6b | 1122 | return false; |
8826f46f | 1123 | |
7bcb11d3 | 1124 | if (!canvas) |
7e548f6b | 1125 | return false; |
8826f46f | 1126 | |
7bcb11d3 JS |
1127 | int canvasWidth, canvasHeight; |
1128 | canvas->GetSize(&canvasWidth, &canvasHeight); | |
8826f46f | 1129 | |
7bcb11d3 JS |
1130 | double zoomScale = ((float)m_currentZoom/(float)100); |
1131 | double actualWidth = (zoomScale*m_pageWidth*m_previewScale); | |
1132 | // float actualHeight = (float)(zoomScale*m_pageHeight*m_previewScale); | |
8826f46f | 1133 | |
7bcb11d3 JS |
1134 | int x = (int) ((canvasWidth - actualWidth)/2.0); |
1135 | if (x < m_leftMargin) | |
1136 | x = m_leftMargin; | |
1137 | int y = m_topMargin; | |
8826f46f | 1138 | |
7bcb11d3 JS |
1139 | wxMemoryDC temp_dc; |
1140 | temp_dc.SelectObject(*m_previewBitmap); | |
8826f46f | 1141 | |
7bcb11d3 | 1142 | dc.Blit(x, y, m_previewBitmap->GetWidth(), m_previewBitmap->GetHeight(), &temp_dc, 0, 0); |
8826f46f | 1143 | |
7bcb11d3 | 1144 | temp_dc.SelectObject(wxNullBitmap); |
8826f46f | 1145 | |
7e548f6b | 1146 | return true; |
c801d85f KB |
1147 | } |
1148 | ||
d2b354f9 JS |
1149 | // Adjusts the scrollbars for the current scale |
1150 | void wxPrintPreviewBase::AdjustScrollbars(wxPreviewCanvas *canvas) | |
1151 | { | |
1152 | if (!canvas) | |
1153 | return ; | |
1154 | ||
1155 | int canvasWidth, canvasHeight; | |
1156 | canvas->GetSize(&canvasWidth, &canvasHeight); | |
1157 | ||
1158 | double zoomScale = ((float)m_currentZoom/(float)100); | |
1159 | double actualWidth = (zoomScale*m_pageWidth*m_previewScale); | |
1160 | double actualHeight = (zoomScale*m_pageHeight*m_previewScale); | |
1161 | ||
1162 | // Set the scrollbars appropriately | |
8b58d2df VZ |
1163 | int totalWidth = (int)(actualWidth + 2*m_leftMargin); |
1164 | int totalHeight = (int)(actualHeight + 2*m_topMargin); | |
d2b354f9 JS |
1165 | int scrollUnitsX = totalWidth/10; |
1166 | int scrollUnitsY = totalHeight/10; | |
1167 | wxSize virtualSize = canvas->GetVirtualSize(); | |
1168 | if (virtualSize.GetWidth() != totalWidth || virtualSize.GetHeight() != totalHeight) | |
7e548f6b | 1169 | canvas->SetScrollbars(10, 10, scrollUnitsX, scrollUnitsY, 0, 0, true); |
d2b354f9 JS |
1170 | } |
1171 | ||
c801d85f KB |
1172 | bool wxPrintPreviewBase::RenderPage(int pageNum) |
1173 | { | |
f6bcfd97 BP |
1174 | wxBusyCursor busy; |
1175 | ||
7bcb11d3 | 1176 | int canvasWidth, canvasHeight; |
8826f46f | 1177 | |
7bcb11d3 | 1178 | if (!m_previewCanvas) |
c801d85f | 1179 | { |
f6bcfd97 | 1180 | wxFAIL_MSG(_T("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!")); |
771779ed | 1181 | |
7e548f6b | 1182 | return false; |
c801d85f | 1183 | } |
7bcb11d3 | 1184 | m_previewCanvas->GetSize(&canvasWidth, &canvasHeight); |
8826f46f | 1185 | |
7bcb11d3 JS |
1186 | double zoomScale = (m_currentZoom/100.0); |
1187 | int actualWidth = (int)(zoomScale*m_pageWidth*m_previewScale); | |
1188 | int actualHeight = (int)(zoomScale*m_pageHeight*m_previewScale); | |
8826f46f | 1189 | |
7bcb11d3 JS |
1190 | if (!m_previewBitmap) |
1191 | { | |
1192 | m_previewBitmap = new wxBitmap((int)actualWidth, (int)actualHeight); | |
1193 | if (!m_previewBitmap || !m_previewBitmap->Ok()) | |
1194 | { | |
9eee81a4 | 1195 | if (m_previewBitmap) { |
7bcb11d3 | 1196 | delete m_previewBitmap; |
9eee81a4 GD |
1197 | m_previewBitmap = NULL; |
1198 | } | |
7bcb11d3 | 1199 | wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK); |
7e548f6b | 1200 | return false; |
7bcb11d3 JS |
1201 | } |
1202 | } | |
8826f46f | 1203 | |
7bcb11d3 JS |
1204 | wxMemoryDC memoryDC; |
1205 | memoryDC.SelectObject(*m_previewBitmap); | |
8826f46f | 1206 | |
7bcb11d3 | 1207 | memoryDC.Clear(); |
8826f46f | 1208 | |
7bcb11d3 JS |
1209 | m_previewPrintout->SetDC(&memoryDC); |
1210 | m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight); | |
8826f46f | 1211 | |
1044a386 JS |
1212 | // Need to delay OnPreparePrinting until here, so we have enough information. |
1213 | if (!m_printingPrepared) | |
1214 | { | |
1215 | m_previewPrintout->OnPreparePrinting(); | |
d2b354f9 JS |
1216 | int selFrom, selTo; |
1217 | m_previewPrintout->GetPageInfo(&m_minPage, &m_maxPage, &selFrom, &selTo); | |
7e548f6b | 1218 | m_printingPrepared = true; |
1044a386 JS |
1219 | } |
1220 | ||
7bcb11d3 | 1221 | m_previewPrintout->OnBeginPrinting(); |
c801d85f | 1222 | |
7bcb11d3 JS |
1223 | if (!m_previewPrintout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) |
1224 | { | |
1225 | wxMessageBox(_("Could not start document preview."), _("Print Preview Failure"), wxOK); | |
8826f46f | 1226 | |
7bcb11d3 | 1227 | memoryDC.SelectObject(wxNullBitmap); |
8826f46f | 1228 | |
7bcb11d3 | 1229 | delete m_previewBitmap; |
9eee81a4 | 1230 | m_previewBitmap = NULL; |
7e548f6b | 1231 | return false; |
7bcb11d3 | 1232 | } |
8826f46f | 1233 | |
7bcb11d3 JS |
1234 | m_previewPrintout->OnPrintPage(pageNum); |
1235 | m_previewPrintout->OnEndDocument(); | |
1236 | m_previewPrintout->OnEndPrinting(); | |
8826f46f | 1237 | |
7bcb11d3 | 1238 | m_previewPrintout->SetDC(NULL); |
8826f46f | 1239 | |
c801d85f | 1240 | memoryDC.SelectObject(wxNullBitmap); |
8826f46f | 1241 | |
3080bf59 VZ |
1242 | #if wxUSE_STATUSBAR |
1243 | wxString status; | |
7bcb11d3 | 1244 | if (m_maxPage != 0) |
7e548f6b | 1245 | status = wxString::Format(_("Page %d of %d"), pageNum, m_maxPage); |
7bcb11d3 | 1246 | else |
7e548f6b | 1247 | status = wxString::Format(_("Page %d"), pageNum); |
8826f46f | 1248 | |
7bcb11d3 | 1249 | if (m_previewFrame) |
3080bf59 VZ |
1250 | m_previewFrame->SetStatusText(status); |
1251 | #endif | |
8826f46f | 1252 | |
7e548f6b | 1253 | return true; |
c801d85f KB |
1254 | } |
1255 | ||
1256 | ||
d2b354f9 | 1257 | bool wxPrintPreviewBase::DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc) |
c801d85f | 1258 | { |
7bcb11d3 JS |
1259 | int canvasWidth, canvasHeight; |
1260 | canvas->GetSize(&canvasWidth, &canvasHeight); | |
8826f46f | 1261 | |
7bcb11d3 JS |
1262 | float zoomScale = (float)((float)m_currentZoom/(float)100); |
1263 | float actualWidth = zoomScale*m_pageWidth*m_previewScale; | |
1264 | float actualHeight = zoomScale*m_pageHeight*m_previewScale; | |
8826f46f | 1265 | |
7bcb11d3 JS |
1266 | float x = (float)((canvasWidth - actualWidth)/2.0); |
1267 | if (x < m_leftMargin) | |
1268 | x = (float)m_leftMargin; | |
1269 | float y = (float)m_topMargin; | |
8826f46f | 1270 | |
7bcb11d3 JS |
1271 | // Draw shadow, allowing for 1-pixel border AROUND the actual page |
1272 | int shadowOffset = 4; | |
1273 | dc.SetPen(*wxBLACK_PEN); | |
1274 | dc.SetBrush(*wxBLACK_BRUSH); | |
1275 | /* | |
1276 | dc.DrawRectangle((int)(x-1 + shadowOffset), (int)(y-1 + shadowOffset), (int)(actualWidth+2), (int)(actualHeight+2)); | |
1277 | */ | |
1278 | dc.DrawRectangle((int)(x + shadowOffset), (int)(y + actualHeight+1), (int)(actualWidth), shadowOffset); | |
1279 | dc.DrawRectangle((int)(x + actualWidth), (int)(y + shadowOffset), shadowOffset, (int)(actualHeight)); | |
8826f46f | 1280 | |
7bcb11d3 JS |
1281 | // Draw blank page allowing for 1-pixel border AROUND the actual page |
1282 | dc.SetPen(*wxBLACK_PEN); | |
1283 | dc.SetBrush(*wxWHITE_BRUSH); | |
8826f46f | 1284 | |
7bcb11d3 JS |
1285 | /* |
1286 | wxRegion update_region = canvas->GetUpdateRegion(); | |
1287 | wxRect r = update_region.GetBox(); | |
8826f46f | 1288 | |
7bcb11d3 JS |
1289 | printf( "x: %d y: %d w: %d h: %d.\n", (int)r.x, (int)r.y, (int)r.width, (int)r.height ); |
1290 | */ | |
8826f46f | 1291 | |
7bcb11d3 | 1292 | dc.DrawRectangle((int)(x-2), (int)(y-1), (int)(actualWidth+3), (int)(actualHeight+2)); |
8826f46f | 1293 | |
7e548f6b | 1294 | return true; |
2a47d3c1 JS |
1295 | } |
1296 | ||
7bcb11d3 | 1297 | void wxPrintPreviewBase::SetZoom(int percent) |
2a47d3c1 | 1298 | { |
7bcb11d3 JS |
1299 | if (m_currentZoom == percent) |
1300 | return; | |
8826f46f | 1301 | |
7bcb11d3 JS |
1302 | m_currentZoom = percent; |
1303 | if (m_previewBitmap) | |
1304 | { | |
1305 | delete m_previewBitmap; | |
1306 | m_previewBitmap = NULL; | |
1307 | } | |
aff37a19 | 1308 | |
7bcb11d3 JS |
1309 | if (m_previewCanvas) |
1310 | { | |
d2b354f9 | 1311 | AdjustScrollbars(m_previewCanvas); |
aff37a19 | 1312 | RenderPage(m_currentPage); |
95724b1a | 1313 | ((wxScrolledWindow *) m_previewCanvas)->Scroll(0, 0); |
e71fd398 | 1314 | m_previewCanvas->ClearBackground(); |
7bcb11d3 | 1315 | m_previewCanvas->Refresh(); |
d2b354f9 | 1316 | m_previewCanvas->SetFocus(); |
7bcb11d3 | 1317 | } |
2a47d3c1 JS |
1318 | } |
1319 | ||
383f6abd WS |
1320 | wxPrintDialogData& wxPrintPreviewBase::GetPrintDialogData() |
1321 | { | |
e81e3883 RR |
1322 | return m_printDialogData; |
1323 | } | |
1324 | ||
383f6abd | 1325 | int wxPrintPreviewBase::GetZoom() const |
e81e3883 | 1326 | { return m_currentZoom; } |
383f6abd | 1327 | int wxPrintPreviewBase::GetMaxPage() const |
e81e3883 | 1328 | { return m_maxPage; } |
383f6abd | 1329 | int wxPrintPreviewBase::GetMinPage() const |
e81e3883 | 1330 | { return m_minPage; } |
383f6abd | 1331 | bool wxPrintPreviewBase::Ok() const |
e81e3883 | 1332 | { return m_isOk; } |
383f6abd | 1333 | void wxPrintPreviewBase::SetOk(bool ok) |
e81e3883 RR |
1334 | { m_isOk = ok; } |
1335 | //---------------------------------------------------------------------------- | |
1336 | // wxPrintPreview | |
1337 | //---------------------------------------------------------------------------- | |
1338 | ||
1339 | IMPLEMENT_CLASS(wxPrintPreview, wxPrintPreviewBase) | |
1340 | ||
1341 | wxPrintPreview::wxPrintPreview(wxPrintout *printout, | |
1342 | wxPrintout *printoutForPrinting, | |
1343 | wxPrintDialogData *data) : | |
1344 | wxPrintPreviewBase( printout, printoutForPrinting, data ) | |
1345 | { | |
1346 | m_pimpl = wxPrintFactory::GetFactory()-> | |
1347 | CreatePrintPreview( printout, printoutForPrinting, data ); | |
1348 | } | |
1349 | ||
1350 | wxPrintPreview::wxPrintPreview(wxPrintout *printout, | |
1351 | wxPrintout *printoutForPrinting, | |
1352 | wxPrintData *data ) : | |
1353 | wxPrintPreviewBase( printout, printoutForPrinting, data ) | |
1354 | { | |
1355 | m_pimpl = wxPrintFactory::GetFactory()-> | |
1356 | CreatePrintPreview( printout, printoutForPrinting, data ); | |
1357 | } | |
1358 | ||
1359 | wxPrintPreview::~wxPrintPreview() | |
1360 | { | |
1361 | delete m_pimpl; | |
383f6abd | 1362 | |
e81e3883 RR |
1363 | // don't delete twice |
1364 | m_printPrintout = NULL; | |
1365 | m_previewPrintout = NULL; | |
1366 | m_previewBitmap = NULL; | |
1367 | } | |
1368 | ||
1369 | bool wxPrintPreview::SetCurrentPage(int pageNum) | |
1370 | { | |
1371 | return m_pimpl->SetCurrentPage( pageNum ); | |
1372 | } | |
1373 | ||
383f6abd WS |
1374 | int wxPrintPreview::GetCurrentPage() const |
1375 | { | |
e81e3883 RR |
1376 | return m_pimpl->GetCurrentPage(); |
1377 | } | |
1378 | ||
383f6abd WS |
1379 | void wxPrintPreview::SetPrintout(wxPrintout *printout) |
1380 | { | |
e81e3883 RR |
1381 | m_pimpl->SetPrintout( printout ); |
1382 | } | |
1383 | ||
383f6abd WS |
1384 | wxPrintout *wxPrintPreview::GetPrintout() const |
1385 | { | |
e81e3883 RR |
1386 | return m_pimpl->GetPrintout(); |
1387 | } | |
1388 | ||
383f6abd WS |
1389 | wxPrintout *wxPrintPreview::GetPrintoutForPrinting() const |
1390 | { | |
e81e3883 RR |
1391 | return m_pimpl->GetPrintoutForPrinting(); |
1392 | } | |
1393 | ||
383f6abd WS |
1394 | void wxPrintPreview::SetFrame(wxFrame *frame) |
1395 | { | |
e81e3883 RR |
1396 | m_pimpl->SetFrame( frame ); |
1397 | } | |
1398 | ||
383f6abd WS |
1399 | void wxPrintPreview::SetCanvas(wxPreviewCanvas *canvas) |
1400 | { | |
e81e3883 RR |
1401 | m_pimpl->SetCanvas( canvas ); |
1402 | } | |
1403 | ||
383f6abd | 1404 | wxFrame *wxPrintPreview::GetFrame() const |
e81e3883 RR |
1405 | { |
1406 | return m_pimpl->GetFrame(); | |
1407 | } | |
1408 | ||
383f6abd WS |
1409 | wxPreviewCanvas *wxPrintPreview::GetCanvas() const |
1410 | { | |
e81e3883 RR |
1411 | return m_pimpl->GetCanvas(); |
1412 | } | |
1413 | ||
1414 | bool wxPrintPreview::PaintPage(wxPreviewCanvas *canvas, wxDC& dc) | |
1415 | { | |
1416 | return m_pimpl->PaintPage( canvas, dc ); | |
1417 | } | |
1418 | ||
1419 | bool wxPrintPreview::DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc) | |
1420 | { | |
1421 | return m_pimpl->DrawBlankPage( canvas, dc ); | |
1422 | } | |
1423 | ||
1424 | void wxPrintPreview::AdjustScrollbars(wxPreviewCanvas *canvas) | |
1425 | { | |
1426 | m_pimpl->AdjustScrollbars( canvas ); | |
1427 | } | |
1428 | ||
1429 | bool wxPrintPreview::RenderPage(int pageNum) | |
1430 | { | |
1431 | return m_pimpl->RenderPage( pageNum ); | |
1432 | } | |
1433 | ||
1434 | void wxPrintPreview::SetZoom(int percent) | |
1435 | { | |
1436 | m_pimpl->SetZoom( percent ); | |
1437 | } | |
1438 | ||
1439 | wxPrintDialogData& wxPrintPreview::GetPrintDialogData() | |
1440 | { | |
1441 | return m_pimpl->GetPrintDialogData(); | |
1442 | } | |
1443 | ||
1444 | int wxPrintPreview::GetMaxPage() const | |
1445 | { | |
1446 | return m_pimpl->GetMaxPage(); | |
1447 | } | |
1448 | ||
1449 | int wxPrintPreview::GetMinPage() const | |
1450 | { | |
1451 | return m_pimpl->GetMinPage(); | |
1452 | } | |
1453 | ||
1454 | bool wxPrintPreview::Ok() const | |
1455 | { | |
1456 | return m_pimpl->Ok(); | |
1457 | } | |
1458 | ||
1459 | void wxPrintPreview::SetOk(bool ok) | |
1460 | { | |
1461 | m_pimpl->SetOk( ok ); | |
1462 | } | |
1463 | ||
1464 | bool wxPrintPreview::Print(bool interactive) | |
1465 | { | |
1466 | return m_pimpl->Print( interactive ); | |
1467 | } | |
1468 | ||
1469 | void wxPrintPreview::DetermineScaling() | |
1470 | { | |
1471 | m_pimpl->DetermineScaling(); | |
1472 | } | |
1473 | ||
1474 | ||
d427503c | 1475 | #endif // wxUSE_PRINTING_ARCHITECTURE |