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