]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/prntbase.cpp
Remaining Makefile.ins,
[wxWidgets.git] / src / common / prntbase.cpp
... / ...
CommitLineData
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 and Markus Holzem
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
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
23#include "wx/defs.h"
24
25#if wxUSE_PRINTING_ARCHITECTURE
26
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"
39#endif
40
41#include "wx/prntbase.h"
42#include "wx/dcprint.h"
43#include "wx/printdlg.h"
44#include "wx/module.h"
45
46#include <stdlib.h>
47#include <string.h>
48
49#ifdef __WXMSW__
50 #include "wx/msw/private.h"
51 #include <commdlg.h>
52
53 #ifndef __WIN32__
54 #include <print.h>
55 #endif
56#endif // __WXMSW__
57
58#if !USE_SHARED_LIBRARY
59IMPLEMENT_CLASS(wxPrinterBase, wxObject)
60IMPLEMENT_ABSTRACT_CLASS(wxPrintout, wxObject)
61IMPLEMENT_CLASS(wxPreviewCanvas, wxWindow)
62IMPLEMENT_CLASS(wxPreviewControlBar, wxWindow)
63IMPLEMENT_CLASS(wxPreviewFrame, wxFrame)
64IMPLEMENT_CLASS(wxPrintPreviewBase, wxObject)
65
66BEGIN_EVENT_TABLE(wxPrintAbortDialog, wxDialog)
67 EVT_BUTTON(wxID_CANCEL, wxPrintAbortDialog::OnCancel)
68END_EVENT_TABLE()
69
70BEGIN_EVENT_TABLE(wxPreviewCanvas, wxScrolledWindow)
71 EVT_PAINT(wxPreviewCanvas::OnPaint)
72 EVT_SYS_COLOUR_CHANGED(wxPreviewCanvas::OnSysColourChanged)
73END_EVENT_TABLE()
74#endif
75
76/*
77* Printer
78*/
79
80wxPrinterBase::wxPrinterBase(wxPrintDialogData *data)
81{
82 m_currentPrintout = (wxPrintout *) NULL;
83 sm_abortWindow = (wxWindow *) NULL;
84 sm_abortIt = FALSE;
85 if (data)
86 m_printDialogData = (*data);
87}
88
89wxWindow *wxPrinterBase::sm_abortWindow = (wxWindow *) NULL;
90bool wxPrinterBase::sm_abortIt = FALSE;
91
92wxPrinterBase::~wxPrinterBase()
93{
94}
95
96void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
97{
98 wxPrinterBase::sm_abortIt = TRUE;
99 wxPrinterBase::sm_abortWindow->Show(FALSE);
100 wxPrinterBase::sm_abortWindow->Close(TRUE);
101 wxPrinterBase::sm_abortWindow = (wxWindow *) NULL;
102}
103
104wxWindow *wxPrinterBase::CreateAbortWindow(wxWindow *parent, wxPrintout *WXUNUSED(printout))
105{
106 wxPrintAbortDialog *dialog = new wxPrintAbortDialog(parent, _("Printing"), wxPoint(0, 0), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE);
107 (void) new wxStaticText(dialog, -1, _("Please wait..."), wxPoint(5, 5));
108
109 wxButton *button = new wxButton(dialog, wxID_CANCEL, _("Cancel"), wxPoint(5, 30));
110
111 dialog->Fit();
112 button->Centre(wxHORIZONTAL);
113
114 dialog->Centre();
115 return dialog;
116}
117
118void wxPrinterBase::ReportError(wxWindow *parent, wxPrintout *WXUNUSED(printout), char *message)
119{
120 wxMessageBox(message, _("Printing Error"), wxOK, parent);
121}
122
123/*
124* Printout class
125*/
126
127wxPrintout::wxPrintout(const wxString& title)
128{
129 m_printoutTitle = title ;
130 m_printoutDC = (wxDC *) NULL;
131 m_pageWidthMM = 0;
132 m_pageHeightMM = 0;
133 m_pageWidthPixels = 0;
134 m_pageHeightPixels = 0;
135 m_PPIScreenX = 0;
136 m_PPIScreenY = 0;
137 m_PPIPrinterX = 0;
138 m_PPIPrinterY = 0;
139 m_isPreview = FALSE;
140}
141
142wxPrintout::~wxPrintout()
143{
144}
145
146bool wxPrintout::OnBeginDocument(int WXUNUSED(startPage), int WXUNUSED(endPage))
147{
148 return GetDC()->StartDoc(_("Printing"));
149}
150
151void wxPrintout::OnEndDocument()
152{
153 GetDC()->EndDoc();
154}
155
156void wxPrintout::OnBeginPrinting()
157{
158}
159
160void wxPrintout::OnEndPrinting()
161{
162}
163
164bool wxPrintout::HasPage(int page)
165{
166 return (page == 1);
167}
168
169void wxPrintout::GetPageInfo(int *minPage, int *maxPage, int *fromPage, int *toPage)
170{
171 *minPage = 1;
172 *maxPage = 32000;
173 *fromPage = 1;
174 *toPage = 1;
175}
176
177/*
178* Preview canvas
179*/
180
181wxPreviewCanvas::wxPreviewCanvas(wxPrintPreviewBase *preview, wxWindow *parent,
182 const wxPoint& pos, const wxSize& size, long style, const wxString& name):
183wxScrolledWindow(parent, -1, pos, size, style, name)
184{
185 m_printPreview = preview;
186 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
187
188 SetScrollbars(15, 18, 100, 100);
189}
190
191wxPreviewCanvas::~wxPreviewCanvas()
192{
193}
194
195void wxPreviewCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
196{
197 wxPaintDC dc(this);
198 PrepareDC( dc );
199
200 if (m_printPreview)
201 {
202 m_printPreview->PaintPage(this, dc);
203 }
204}
205
206// Responds to colour changes, and passes event on to children.
207void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent& event)
208{
209 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
210 Refresh();
211
212 // Propagate the event to the non-top-level children
213 wxWindow::OnSysColourChanged(event);
214}
215
216/*
217* Preview control bar
218*/
219
220BEGIN_EVENT_TABLE(wxPreviewControlBar, wxPanel)
221 EVT_BUTTON(wxID_PREVIEW_CLOSE, wxPreviewControlBar::OnWindowClose)
222 EVT_BUTTON(wxID_PREVIEW_PRINT, wxPreviewControlBar::OnPrint)
223 EVT_BUTTON(wxID_PREVIEW_PREVIOUS, wxPreviewControlBar::OnPrevious)
224 EVT_BUTTON(wxID_PREVIEW_NEXT, wxPreviewControlBar::OnNext)
225 EVT_CHOICE(wxID_PREVIEW_ZOOM, wxPreviewControlBar::OnZoom)
226 EVT_PAINT(wxPreviewControlBar::OnPaint)
227END_EVENT_TABLE()
228
229wxPreviewControlBar::wxPreviewControlBar(wxPrintPreviewBase *preview, long buttons,
230 wxWindow *parent, const wxPoint& pos, const wxSize& size,
231 long style, const wxString& name):
232wxPanel(parent, -1, pos, size, style, name)
233{
234 m_printPreview = preview;
235 m_closeButton = (wxButton *) NULL;
236 m_nextPageButton = (wxButton *) NULL;
237 m_previousPageButton = (wxButton *) NULL;
238 m_printButton = (wxButton *) NULL;
239 m_zoomControl = (wxChoice *) NULL;
240 m_buttonFlags = buttons;
241}
242
243wxPreviewControlBar::~wxPreviewControlBar()
244{
245}
246
247void wxPreviewControlBar::OnPaint(wxPaintEvent& WXUNUSED(event))
248{
249 wxPaintDC dc(this);
250
251 int w, h;
252 GetSize(&w, &h);
253 dc.SetPen(*wxBLACK_PEN);
254 dc.SetBrush(*wxTRANSPARENT_BRUSH);
255 dc.DrawLine( 0, h-1, w, h-1 );
256}
257
258void wxPreviewControlBar::OnWindowClose(wxCommandEvent& WXUNUSED(event))
259{
260 wxPreviewFrame *frame = (wxPreviewFrame *)GetParent();
261 frame->Close(TRUE);
262}
263
264void wxPreviewControlBar::OnPrint(wxCommandEvent& WXUNUSED(event))
265{
266 wxPrintPreviewBase *preview = GetPrintPreview();
267 preview->Print(TRUE);
268}
269
270void wxPreviewControlBar::OnNext(wxCommandEvent& WXUNUSED(event))
271{
272 wxPrintPreviewBase *preview = GetPrintPreview();
273 if (preview)
274 {
275 int currentPage = preview->GetCurrentPage();
276 if ((preview->GetMaxPage() > 0) &&
277 (currentPage < preview->GetMaxPage()) &&
278 preview->GetPrintout()->HasPage(currentPage + 1))
279 {
280 preview->SetCurrentPage(currentPage + 1);
281 }
282 }
283}
284
285void wxPreviewControlBar::OnPrevious(wxCommandEvent& WXUNUSED(event))
286{
287 wxPrintPreviewBase *preview = GetPrintPreview();
288 if (preview)
289 {
290 int currentPage = preview->GetCurrentPage();
291 if ((preview->GetMinPage() > 0) &&
292 (currentPage > preview->GetMinPage()) &&
293 preview->GetPrintout()->HasPage(currentPage - 1))
294 {
295 preview->SetCurrentPage(currentPage - 1);
296 }
297 }
298}
299
300void wxPreviewControlBar::OnZoom(wxCommandEvent& WXUNUSED(event))
301{
302 int zoom = GetZoomControl();
303 if (GetPrintPreview())
304 GetPrintPreview()->SetZoom(zoom);
305}
306
307void wxPreviewControlBar::CreateButtons()
308{
309 SetSize(0, 0, 400, 40);
310
311 /*
312 #ifdef __WXMSW__
313 int fontSize = 9;
314 #else
315 int fontSize = 10;
316 #endif
317
318 wxFont buttonFont(fontSize, wxSWISS, wxNORMAL, wxBOLD);
319 SetFont(buttonFont);
320 */
321
322 int buttonWidth = 65;
323#ifdef __WXGTK__
324 int buttonHeight = -1;
325#else
326 int buttonHeight = 24;
327#endif
328
329 int x = 5;
330 int y = 5;
331
332#ifdef __WXMOTIF__
333 int gap = 15;
334#else
335 int gap = 5;
336#endif
337
338 m_closeButton = new wxButton(this, wxID_PREVIEW_CLOSE, _("Close"),
339 wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
340
341 x += gap + buttonWidth;
342
343 if (m_buttonFlags & wxPREVIEW_PRINT)
344 {
345 m_printButton = new wxButton(this, wxID_PREVIEW_PRINT, _("Print..."), wxPoint(x, y),
346 wxSize(buttonWidth, buttonHeight));
347 x += gap + buttonWidth;
348 }
349
350 if (m_buttonFlags & wxPREVIEW_PREVIOUS)
351 {
352 m_previousPageButton = new wxButton(this, wxID_PREVIEW_PREVIOUS, "<<", wxPoint(x, y),
353 wxSize(buttonWidth, buttonHeight));
354 x += gap + buttonWidth;
355 }
356
357 if (m_buttonFlags & wxPREVIEW_NEXT)
358 {
359 m_nextPageButton = new wxButton(this, wxID_PREVIEW_NEXT, ">>",
360 wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
361 x += gap + buttonWidth;
362 }
363
364 if (m_buttonFlags & wxPREVIEW_ZOOM)
365 {
366 static const char *choices[] =
367 {
368 "10%", "15%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", "55%",
369 "60%", "65%", "70%", "75%", "80%", "85%", "90%", "95%", "100%", "110%",
370 "120%", "150%", "200%"
371 };
372
373 m_zoomControl = new wxChoice(this, wxID_PREVIEW_ZOOM,
374 wxPoint(x, y), wxSize(100, -1));
375
376 // Yes, this look stupid, but this is because gcc gives up otherwise.
377 int n = WXSIZEOF(choices);
378 for ( int i = 0; i < n; i++ )
379 m_zoomControl->Append(choices[i]);
380
381 SetZoomControl(m_printPreview->GetZoom());
382 }
383
384 // m_closeButton->SetDefault();
385}
386
387void wxPreviewControlBar::SetZoomControl(int zoom)
388{
389 char buf[20];
390 sprintf(buf, "%d%%", zoom);
391 if (m_zoomControl)
392 m_zoomControl->SetStringSelection(buf);
393}
394
395int wxPreviewControlBar::GetZoomControl()
396{
397 wxChar buf[20];
398 if (m_zoomControl && (m_zoomControl->GetStringSelection() != _T("")))
399 {
400 wxStrcpy(buf, m_zoomControl->GetStringSelection());
401 buf[wxStrlen(buf) - 1] = 0;
402 return (int)wxAtoi(buf);
403 }
404 else return 0;
405}
406
407
408/*
409* Preview frame
410*/
411
412BEGIN_EVENT_TABLE(wxPreviewFrame, wxFrame)
413EVT_CLOSE(wxPreviewFrame::OnCloseWindow)
414END_EVENT_TABLE()
415
416wxPreviewFrame::wxPreviewFrame(wxPrintPreviewBase *preview, wxFrame *parent, const wxString& title,
417 const wxPoint& pos, const wxSize& size, long style, const wxString& name):
418wxFrame(parent, -1, title, pos, size, style, name)
419{
420 m_printPreview = preview;
421 m_controlBar = NULL;
422 m_previewCanvas = NULL;
423}
424
425wxPreviewFrame::~wxPreviewFrame()
426{
427}
428
429void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
430{
431 MakeModal(FALSE);
432
433 // Need to delete the printout and the print preview
434 wxPrintout *printout = m_printPreview->GetPrintout();
435 if (printout)
436 {
437 delete printout;
438 m_printPreview->SetPrintout(NULL);
439 m_printPreview->SetCanvas(NULL);
440 m_printPreview->SetFrame(NULL);
441 }
442 delete m_printPreview;
443
444 Destroy();
445}
446
447void wxPreviewFrame::Initialize()
448{
449 CreateStatusBar();
450
451 CreateCanvas();
452 CreateControlBar();
453
454 m_printPreview->SetCanvas(m_previewCanvas);
455 m_printPreview->SetFrame(this);
456
457 // Set layout constraints here
458
459 // Control bar constraints
460 wxLayoutConstraints *c1 = new wxLayoutConstraints;
461 // int w, h;
462 // m_controlBar->GetSize(&w, &h);
463 int h;
464#if (defined(__WXMSW__) || defined(__WXGTK__))
465 h = 40;
466#else
467 h = 60;
468#endif
469
470 c1->left.SameAs (this, wxLeft);
471 c1->top.SameAs (this, wxTop);
472 c1->right.SameAs (this, wxRight);
473 c1->height.Absolute (h);
474
475 m_controlBar->SetConstraints(c1);
476
477 // Canvas constraints
478 wxLayoutConstraints *c2 = new wxLayoutConstraints;
479
480 c2->left.SameAs (this, wxLeft);
481 c2->top.Below (m_controlBar);
482 c2->right.SameAs (this, wxRight);
483 c2->bottom.SameAs (this, wxBottom);
484
485 m_previewCanvas->SetConstraints(c2);
486
487 SetAutoLayout(TRUE);
488
489 MakeModal(TRUE);
490
491 Layout();
492}
493
494void wxPreviewFrame::CreateCanvas()
495{
496 m_previewCanvas = new wxPreviewCanvas(m_printPreview, this);
497}
498
499void wxPreviewFrame::CreateControlBar()
500{
501 long buttons = wxPREVIEW_DEFAULT;
502 if (m_printPreview->GetPrintoutForPrinting())
503 buttons |= wxPREVIEW_PRINT;
504
505 m_controlBar = new wxPreviewControlBar(m_printPreview, buttons, this, wxPoint(0, 0), wxSize(400, 40));
506 m_controlBar->CreateButtons();
507}
508
509/*
510* Print preview
511*/
512
513wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout,
514 wxPrintout *printoutForPrinting,
515 wxPrintData *data)
516{
517 if (data)
518 m_printDialogData = (*data);
519
520 Init(printout, printoutForPrinting);
521}
522
523wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout,
524 wxPrintout *printoutForPrinting,
525 wxPrintDialogData *data)
526{
527 if (data)
528 m_printDialogData = (*data);
529
530 Init(printout, printoutForPrinting);
531}
532
533void wxPrintPreviewBase::Init(wxPrintout *printout,
534 wxPrintout *printoutForPrinting)
535{
536 m_isOk = TRUE;
537 m_previewPrintout = printout;
538 if (m_previewPrintout)
539 m_previewPrintout->SetIsPreview(TRUE);
540
541 m_printPrintout = printoutForPrinting;
542
543 m_previewCanvas = NULL;
544 m_previewFrame = NULL;
545 m_previewBitmap = NULL;
546 m_currentPage = 1;
547 m_currentZoom = 70;
548 m_topMargin = 40;
549 m_leftMargin = 40;
550 m_pageWidth = 0;
551 m_pageHeight = 0;
552
553 printout->OnPreparePrinting();
554
555 // Get some parameters from the printout, if defined
556 int selFrom, selTo;
557 printout->GetPageInfo(&m_minPage, &m_maxPage, &selFrom, &selTo);
558}
559
560wxPrintPreviewBase::~wxPrintPreviewBase()
561{
562 if (m_previewPrintout)
563 delete m_previewPrintout;
564 if (m_previewBitmap)
565 delete m_previewBitmap;
566 if (m_printPrintout)
567 delete m_printPrintout;
568}
569
570bool wxPrintPreviewBase::SetCurrentPage(int pageNum)
571{
572 if (m_currentPage == pageNum)
573 return TRUE;
574
575 m_currentPage = pageNum;
576 if (m_previewBitmap)
577 {
578 delete m_previewBitmap;
579 m_previewBitmap = NULL;
580 }
581
582 if (m_previewCanvas)
583 {
584 RenderPage(pageNum);
585 m_previewCanvas->Refresh();
586 }
587 return TRUE;
588}
589
590bool wxPrintPreviewBase::PaintPage(wxWindow *canvas, wxDC& dc)
591{
592 DrawBlankPage(canvas, dc);
593
594 if (!m_previewBitmap)
595 RenderPage(m_currentPage);
596
597 if (!m_previewBitmap)
598 return FALSE;
599
600 if (!canvas)
601 return FALSE;
602
603 int canvasWidth, canvasHeight;
604 canvas->GetSize(&canvasWidth, &canvasHeight);
605
606 double zoomScale = ((float)m_currentZoom/(float)100);
607 double actualWidth = (zoomScale*m_pageWidth*m_previewScale);
608 // float actualHeight = (float)(zoomScale*m_pageHeight*m_previewScale);
609
610 int x = (int) ((canvasWidth - actualWidth)/2.0);
611 if (x < m_leftMargin)
612 x = m_leftMargin;
613 int y = m_topMargin;
614
615 wxMemoryDC temp_dc;
616 temp_dc.SelectObject(*m_previewBitmap);
617
618 dc.Blit(x, y, m_previewBitmap->GetWidth(), m_previewBitmap->GetHeight(), &temp_dc, 0, 0);
619
620 temp_dc.SelectObject(wxNullBitmap);
621
622 return TRUE;
623}
624
625bool wxPrintPreviewBase::RenderPage(int pageNum)
626{
627 int canvasWidth, canvasHeight;
628
629 if (!m_previewCanvas)
630 {
631 wxMessageBox(_("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!"),
632 _("Print Preview Failure"), wxOK);
633 return FALSE;
634 }
635 m_previewCanvas->GetSize(&canvasWidth, &canvasHeight);
636
637 double zoomScale = (m_currentZoom/100.0);
638 int actualWidth = (int)(zoomScale*m_pageWidth*m_previewScale);
639 int actualHeight = (int)(zoomScale*m_pageHeight*m_previewScale);
640
641 int x = (int)((canvasWidth - actualWidth)/2.0);
642 if (x < m_leftMargin)
643 x = m_leftMargin;
644 // int y = m_topMargin;
645
646
647 if (!m_previewBitmap)
648 {
649 m_previewBitmap = new wxBitmap((int)actualWidth, (int)actualHeight);
650 if (!m_previewBitmap || !m_previewBitmap->Ok())
651 {
652 if (m_previewBitmap)
653 delete m_previewBitmap;
654 wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK);
655 return FALSE;
656 }
657 }
658
659 wxMemoryDC memoryDC;
660 memoryDC.SelectObject(*m_previewBitmap);
661
662 memoryDC.Clear();
663
664 m_previewPrintout->SetDC(&memoryDC);
665 m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight);
666
667 m_previewPrintout->OnBeginPrinting();
668
669 if (!m_previewPrintout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
670 {
671 wxMessageBox(_("Could not start document preview."), _("Print Preview Failure"), wxOK);
672
673 memoryDC.SelectObject(wxNullBitmap);
674
675 delete m_previewBitmap;
676 return FALSE;
677 }
678
679 m_previewPrintout->OnPrintPage(pageNum);
680 m_previewPrintout->OnEndDocument();
681 m_previewPrintout->OnEndPrinting();
682
683 m_previewPrintout->SetDC(NULL);
684
685 memoryDC.SelectObject(wxNullBitmap);
686
687 wxChar buf[200];
688 if (m_maxPage != 0)
689 wxSprintf(buf, _("Page %d of %d"), pageNum, m_maxPage);
690 else
691 wxSprintf(buf, _("Page %d"), pageNum);
692
693 if (m_previewFrame)
694 m_previewFrame->SetStatusText(buf);
695
696 return TRUE;
697}
698
699
700bool wxPrintPreviewBase::DrawBlankPage(wxWindow *canvas, wxDC& dc)
701{
702 int canvasWidth, canvasHeight;
703 canvas->GetSize(&canvasWidth, &canvasHeight);
704
705 float zoomScale = (float)((float)m_currentZoom/(float)100);
706 float actualWidth = zoomScale*m_pageWidth*m_previewScale;
707 float actualHeight = zoomScale*m_pageHeight*m_previewScale;
708
709 float x = (float)((canvasWidth - actualWidth)/2.0);
710 if (x < m_leftMargin)
711 x = (float)m_leftMargin;
712 float y = (float)m_topMargin;
713
714 // Draw shadow, allowing for 1-pixel border AROUND the actual page
715 int shadowOffset = 4;
716 dc.SetPen(*wxBLACK_PEN);
717 dc.SetBrush(*wxBLACK_BRUSH);
718 /*
719 dc.DrawRectangle((int)(x-1 + shadowOffset), (int)(y-1 + shadowOffset), (int)(actualWidth+2), (int)(actualHeight+2));
720 */
721 dc.DrawRectangle((int)(x + shadowOffset), (int)(y + actualHeight+1), (int)(actualWidth), shadowOffset);
722 dc.DrawRectangle((int)(x + actualWidth), (int)(y + shadowOffset), shadowOffset, (int)(actualHeight));
723
724 // Draw blank page allowing for 1-pixel border AROUND the actual page
725 dc.SetPen(*wxBLACK_PEN);
726 dc.SetBrush(*wxWHITE_BRUSH);
727
728 /*
729 wxRegion update_region = canvas->GetUpdateRegion();
730 wxRect r = update_region.GetBox();
731
732 printf( "x: %d y: %d w: %d h: %d.\n", (int)r.x, (int)r.y, (int)r.width, (int)r.height );
733 */
734
735 dc.DrawRectangle((int)(x-2), (int)(y-1), (int)(actualWidth+3), (int)(actualHeight+2));
736
737 return TRUE;
738}
739
740void wxPrintPreviewBase::SetZoom(int percent)
741{
742 if (m_currentZoom == percent)
743 return;
744
745 m_currentZoom = percent;
746 if (m_previewBitmap)
747 {
748 delete m_previewBitmap;
749 m_previewBitmap = NULL;
750 }
751
752
753 if (m_previewCanvas)
754 {
755 RenderPage(m_currentPage);
756 m_previewCanvas->Clear();
757 m_previewCanvas->Refresh();
758 }
759}
760
761#endif // wxUSE_PRINTING_ARCHITECTURE