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