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