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