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