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