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