1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Printing framework base class implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "prntbase.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
25 #if wxUSE_PRINTING_ARCHITECTURE
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"
39 #include "wx/textdlg.h"
43 #include "wx/prntbase.h"
44 #include "wx/dcprint.h"
45 #include "wx/printdlg.h"
46 #include "wx/module.h"
52 #include "wx/msw/private.h"
60 IMPLEMENT_CLASS(wxPrinterBase
, wxObject
)
61 IMPLEMENT_ABSTRACT_CLASS(wxPrintout
, wxObject
)
62 IMPLEMENT_CLASS(wxPreviewCanvas
, wxWindow
)
63 IMPLEMENT_CLASS(wxPreviewControlBar
, wxWindow
)
64 IMPLEMENT_CLASS(wxPreviewFrame
, wxFrame
)
65 IMPLEMENT_CLASS(wxPrintPreviewBase
, wxObject
)
67 BEGIN_EVENT_TABLE(wxPrintAbortDialog
, wxDialog
)
68 EVT_BUTTON(wxID_CANCEL
, wxPrintAbortDialog::OnCancel
)
71 BEGIN_EVENT_TABLE(wxPreviewCanvas
, wxScrolledWindow
)
72 EVT_PAINT(wxPreviewCanvas::OnPaint
)
73 EVT_SYS_COLOUR_CHANGED(wxPreviewCanvas::OnSysColourChanged
)
80 wxPrinterBase::wxPrinterBase(wxPrintDialogData
*data
)
82 m_currentPrintout
= (wxPrintout
*) NULL
;
83 sm_abortWindow
= (wxWindow
*) NULL
;
86 m_printDialogData
= (*data
);
87 sm_lastError
= wxPRINTER_NO_ERROR
;
90 wxWindow
*wxPrinterBase::sm_abortWindow
= (wxWindow
*) NULL
;
91 bool wxPrinterBase::sm_abortIt
= FALSE
;
92 wxPrinterError
wxPrinterBase::sm_lastError
= wxPRINTER_NO_ERROR
;
94 wxPrinterBase::~wxPrinterBase()
98 void wxPrintAbortDialog::OnCancel(wxCommandEvent
& WXUNUSED(event
))
100 wxPrinterBase::sm_abortIt
= TRUE
;
101 wxPrinterBase::sm_abortWindow
->Show(FALSE
);
102 wxPrinterBase::sm_abortWindow
->Close(TRUE
);
103 wxPrinterBase::sm_abortWindow
= (wxWindow
*) NULL
;
106 wxWindow
*wxPrinterBase::CreateAbortWindow(wxWindow
*parent
, wxPrintout
* printout
)
108 wxPrintAbortDialog
*dialog
= new wxPrintAbortDialog(parent
, _("Printing ") , wxDefaultPosition
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
);
110 wxBoxSizer
*button_sizer
= new wxBoxSizer( wxVERTICAL
);
111 button_sizer
->Add( new wxStaticText(dialog
, -1, _("Please wait while printing\n") + printout
->GetTitle() ), 0, wxALL
, 10 );
112 button_sizer
->Add( new wxButton( dialog
, wxID_CANCEL
, wxT("Cancel") ), 0, wxALL
| wxALIGN_CENTER
, 10 );
114 dialog
->SetAutoLayout( TRUE
);
115 dialog
->SetSizer( button_sizer
);
117 button_sizer
->Fit(dialog
);
118 button_sizer
->SetSizeHints (dialog
) ;
123 void wxPrinterBase::ReportError(wxWindow
*parent
, wxPrintout
*WXUNUSED(printout
), const wxString
& message
)
125 wxMessageBox(message
, _("Printing Error"), wxOK
, parent
);
132 wxPrintout::wxPrintout(const wxString
& title
)
134 m_printoutTitle
= title
;
135 m_printoutDC
= (wxDC
*) NULL
;
138 m_pageWidthPixels
= 0;
139 m_pageHeightPixels
= 0;
147 wxPrintout::~wxPrintout()
151 bool wxPrintout::OnBeginDocument(int WXUNUSED(startPage
), int WXUNUSED(endPage
))
153 return GetDC()->StartDoc(_("Printing ") + m_printoutTitle
);
156 void wxPrintout::OnEndDocument()
161 void wxPrintout::OnBeginPrinting()
165 void wxPrintout::OnEndPrinting()
169 bool wxPrintout::HasPage(int page
)
174 void wxPrintout::GetPageInfo(int *minPage
, int *maxPage
, int *fromPage
, int *toPage
)
186 wxPreviewCanvas::wxPreviewCanvas(wxPrintPreviewBase
*preview
, wxWindow
*parent
,
187 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
188 wxScrolledWindow(parent
, -1, pos
, size
, style
, name
)
190 m_printPreview
= preview
;
192 // The app workspace colour is always white, but we should have
193 // a contrast with the page.
194 wxSystemColour colourIndex
= wxSYS_COLOUR_3DDKSHADOW
;
196 wxSystemColour colourIndex
= wxSYS_COLOUR_APPWORKSPACE
;
198 SetBackgroundColour(wxSystemSettings::GetColour(colourIndex
));
200 SetScrollbars(15, 18, 100, 100);
203 wxPreviewCanvas::~wxPreviewCanvas()
207 void wxPreviewCanvas::OnPaint(wxPaintEvent
& WXUNUSED(event
))
214 if (!GetUpdateRegion().IsEmpty())
215 dc.SetClippingRegion( GetUpdateRegion() );
221 m_printPreview
->PaintPage(this, dc
);
225 // Responds to colour changes, and passes event on to children.
226 void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent
& event
)
229 // The app workspace colour is always white, but we should have
230 // a contrast with the page.
231 wxSystemColour colourIndex
= wxSYS_COLOUR_3DDKSHADOW
;
233 wxSystemColour colourIndex
= wxSYS_COLOUR_APPWORKSPACE
;
235 SetBackgroundColour(wxSystemSettings::GetColour(colourIndex
));
238 // Propagate the event to the non-top-level children
239 wxWindow::OnSysColourChanged(event
);
243 * Preview control bar
246 BEGIN_EVENT_TABLE(wxPreviewControlBar
, wxPanel
)
247 EVT_BUTTON(wxID_PREVIEW_CLOSE
, wxPreviewControlBar::OnWindowClose
)
248 EVT_BUTTON(wxID_PREVIEW_PRINT
, wxPreviewControlBar::OnPrint
)
249 EVT_BUTTON(wxID_PREVIEW_PREVIOUS
, wxPreviewControlBar::OnPreviousButton
)
250 EVT_BUTTON(wxID_PREVIEW_NEXT
, wxPreviewControlBar::OnNextButton
)
251 EVT_BUTTON(wxID_PREVIEW_FIRST
, wxPreviewControlBar::OnFirstButton
)
252 EVT_BUTTON(wxID_PREVIEW_LAST
, wxPreviewControlBar::OnLastButton
)
253 EVT_BUTTON(wxID_PREVIEW_GOTO
, wxPreviewControlBar::OnGotoButton
)
254 EVT_CHAR(wxPreviewControlBar::OnChar
)
255 EVT_CHOICE(wxID_PREVIEW_ZOOM
, wxPreviewControlBar::OnZoom
)
256 EVT_PAINT(wxPreviewControlBar::OnPaint
)
259 wxPreviewControlBar::wxPreviewControlBar(wxPrintPreviewBase
*preview
, long buttons
,
260 wxWindow
*parent
, const wxPoint
& pos
, const wxSize
& size
,
261 long style
, const wxString
& name
):
262 wxPanel(parent
, -1, pos
, size
, style
, name
)
264 m_printPreview
= preview
;
265 m_closeButton
= (wxButton
*) NULL
;
266 m_nextPageButton
= (wxButton
*) NULL
;
267 m_previousPageButton
= (wxButton
*) NULL
;
268 m_printButton
= (wxButton
*) NULL
;
269 m_zoomControl
= (wxChoice
*) NULL
;
270 m_buttonFlags
= buttons
;
273 wxPreviewControlBar::~wxPreviewControlBar()
277 void wxPreviewControlBar::OnPaint(wxPaintEvent
& WXUNUSED(event
))
283 dc
.SetPen(*wxBLACK_PEN
);
284 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
285 dc
.DrawLine( 0, h
-1, w
, h
-1 );
288 void wxPreviewControlBar::OnWindowClose(wxCommandEvent
& WXUNUSED(event
))
290 wxPreviewFrame
*frame
= (wxPreviewFrame
*)GetParent();
294 void wxPreviewControlBar::OnPrint(wxCommandEvent
& WXUNUSED(event
))
296 wxPrintPreviewBase
*preview
= GetPrintPreview();
297 preview
->Print(TRUE
);
300 void wxPreviewControlBar::OnChar(wxKeyEvent
&event
)
302 switch(event
.GetKeyCode())
319 void wxPreviewControlBar::OnNext(void)
321 wxPrintPreviewBase
*preview
= GetPrintPreview();
324 int currentPage
= preview
->GetCurrentPage();
325 if ((preview
->GetMaxPage() > 0) &&
326 (currentPage
< preview
->GetMaxPage()) &&
327 preview
->GetPrintout()->HasPage(currentPage
+ 1))
329 preview
->SetCurrentPage(currentPage
+ 1);
334 void wxPreviewControlBar::OnPrevious(void)
336 wxPrintPreviewBase
*preview
= GetPrintPreview();
339 int currentPage
= preview
->GetCurrentPage();
340 if ((preview
->GetMinPage() > 0) &&
341 (currentPage
> preview
->GetMinPage()) &&
342 preview
->GetPrintout()->HasPage(currentPage
- 1))
344 preview
->SetCurrentPage(currentPage
- 1);
349 void wxPreviewControlBar::OnFirst(void)
351 wxPrintPreviewBase
*preview
= GetPrintPreview();
354 int currentPage
= preview
->GetMinPage();
355 if (preview
->GetPrintout()->HasPage(currentPage
))
357 preview
->SetCurrentPage(currentPage
);
362 void wxPreviewControlBar::OnLast(void)
364 wxPrintPreviewBase
*preview
= GetPrintPreview();
367 int currentPage
= preview
->GetMaxPage();
368 if (preview
->GetPrintout()->HasPage(currentPage
))
370 preview
->SetCurrentPage(currentPage
);
375 void wxPreviewControlBar::OnGoto(void)
377 wxPrintPreviewBase
*preview
= GetPrintPreview();
382 if (preview
->GetMinPage() > 0)
387 strPrompt
.Printf( wxT("%d...%d"),
388 preview
->GetMinPage(), preview
->GetMaxPage());
389 strPage
.Printf( wxT("%d"), preview
->GetCurrentPage() );
392 wxGetTextFromUser( strPrompt
, _("Goto Page"), strPage
);
394 if ( strPage
.ToLong( ¤tPage
) )
395 if (preview
->GetPrintout()->HasPage(currentPage
))
397 preview
->SetCurrentPage(currentPage
);
403 void wxPreviewControlBar::OnZoom(wxCommandEvent
& WXUNUSED(event
))
405 int zoom
= GetZoomControl();
406 if (GetPrintPreview())
407 GetPrintPreview()->SetZoom(zoom
);
410 void wxPreviewControlBar::CreateButtons()
412 SetSize(0, 0, 400, 40);
414 wxBoxSizer
*item0
= new wxBoxSizer( wxHORIZONTAL
);
416 int smallButtonWidth
= 45;
418 m_closeButton
= new wxButton( this, wxID_PREVIEW_CLOSE
, _("&Close"), wxDefaultPosition
, wxDefaultSize
, 0 );
419 item0
->Add( m_closeButton
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
421 if (m_buttonFlags
& wxPREVIEW_PRINT
)
423 m_printButton
= new wxButton( this, wxID_PREVIEW_PRINT
, _("&Print..."), wxDefaultPosition
, wxDefaultSize
, 0 );
424 item0
->Add( m_printButton
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
427 if (m_buttonFlags
& wxPREVIEW_FIRST
)
429 m_firstPageButton
= new wxButton( this, wxID_PREVIEW_FIRST
, _("|<<"), wxDefaultPosition
, wxSize(smallButtonWidth
,-1), 0 );
430 item0
->Add( m_firstPageButton
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
433 if (m_buttonFlags
& wxPREVIEW_PREVIOUS
)
435 m_previousPageButton
= new wxButton( this, wxID_PREVIEW_PREVIOUS
, _("<<"), wxDefaultPosition
, wxSize(smallButtonWidth
,-1), 0 );
436 item0
->Add( m_previousPageButton
, 0, wxALIGN_CENTRE
|wxRIGHT
|wxTOP
|wxBOTTOM
, 5 );
439 if (m_buttonFlags
& wxPREVIEW_NEXT
)
441 m_nextPageButton
= new wxButton( this, wxID_PREVIEW_NEXT
, _(">>"), wxDefaultPosition
, wxSize(smallButtonWidth
,-1), 0 );
442 item0
->Add( m_nextPageButton
, 0, wxALIGN_CENTRE
|wxRIGHT
|wxTOP
|wxBOTTOM
, 5 );
445 if (m_buttonFlags
& wxPREVIEW_LAST
)
447 m_lastPageButton
= new wxButton( this, wxID_PREVIEW_LAST
, _(">>|"), wxDefaultPosition
, wxSize(smallButtonWidth
,-1), 0 );
448 item0
->Add( m_lastPageButton
, 0, wxALIGN_CENTRE
|wxRIGHT
|wxTOP
|wxBOTTOM
, 5 );
451 if (m_buttonFlags
& wxPREVIEW_GOTO
)
453 m_gotoPageButton
= new wxButton( this, wxID_PREVIEW_GOTO
, _("&Goto..."), wxDefaultPosition
, wxDefaultSize
, 0 );
454 item0
->Add( m_gotoPageButton
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
457 if (m_buttonFlags
& wxPREVIEW_ZOOM
)
461 wxT("10%"), wxT("15%"), wxT("20%"), wxT("25%"), wxT("30%"), wxT("35%"), wxT("40%"), wxT("45%"), wxT("50%"), wxT("55%"),
462 wxT("60%"), wxT("65%"), wxT("70%"), wxT("75%"), wxT("80%"), wxT("85%"), wxT("90%"), wxT("95%"), wxT("100%"), wxT("110%"),
463 wxT("120%"), wxT("150%"), wxT("200%")
465 int n
= WXSIZEOF(choices
);
467 m_zoomControl
= new wxChoice( this, wxID_PREVIEW_ZOOM
, wxDefaultPosition
, wxSize(70,-1), n
, choices
, 0 );
468 item0
->Add( m_zoomControl
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
469 SetZoomControl(m_printPreview
->GetZoom());
476 void wxPreviewControlBar::SetZoomControl(int zoom
)
479 wxSprintf( buf
, wxT("%d%%"), zoom
);
482 m_zoomControl
->SetStringSelection(buf
);
485 int wxPreviewControlBar::GetZoomControl()
488 if (m_zoomControl
&& (m_zoomControl
->GetStringSelection() != wxT("")))
490 wxStrcpy(buf
, m_zoomControl
->GetStringSelection());
491 buf
[wxStrlen(buf
) - 1] = 0;
492 return (int)wxAtoi(buf
);
502 BEGIN_EVENT_TABLE(wxPreviewFrame
, wxFrame
)
503 EVT_CLOSE(wxPreviewFrame::OnCloseWindow
)
506 wxPreviewFrame::wxPreviewFrame(wxPrintPreviewBase
*preview
, wxWindow
*parent
, const wxString
& title
,
507 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
):
508 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
510 m_printPreview
= preview
;
512 m_previewCanvas
= NULL
;
514 // Give the application icon
516 wxFrame
* topFrame
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxFrame
);
518 SetIcon(topFrame
->GetIcon());
522 wxPreviewFrame::~wxPreviewFrame()
526 void wxPreviewFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
528 // MakeModal doesn't work on wxMac, especially when there
529 // are multiple top-level windows.
534 // Need to delete the printout and the print preview
535 wxPrintout
*printout
= m_printPreview
->GetPrintout();
539 m_printPreview
->SetPrintout(NULL
);
540 m_printPreview
->SetCanvas(NULL
);
541 m_printPreview
->SetFrame(NULL
);
543 delete m_printPreview
;
548 void wxPreviewFrame::Initialize()
554 m_printPreview
->SetCanvas(m_previewCanvas
);
555 m_printPreview
->SetFrame(this);
557 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
559 item0
->Add( m_controlBar
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5 );
560 item0
->Add( m_previewCanvas
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5 );
562 SetAutoLayout( TRUE
);
565 // MakeModal doesn't work on wxMac, especially when there
566 // are multiple top-level windows.
574 void wxPreviewFrame::CreateCanvas()
576 m_previewCanvas
= new wxPreviewCanvas(m_printPreview
, this);
579 void wxPreviewFrame::CreateControlBar()
581 long buttons
= wxPREVIEW_DEFAULT
;
582 if (m_printPreview
->GetPrintoutForPrinting())
583 buttons
|= wxPREVIEW_PRINT
;
585 m_controlBar
= new wxPreviewControlBar(m_printPreview
, buttons
, this, wxPoint(0, 0), wxSize(400, 40));
586 m_controlBar
->CreateButtons();
593 wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout
*printout
,
594 wxPrintout
*printoutForPrinting
,
598 m_printDialogData
= (*data
);
600 Init(printout
, printoutForPrinting
);
603 wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout
*printout
,
604 wxPrintout
*printoutForPrinting
,
605 wxPrintDialogData
*data
)
608 m_printDialogData
= (*data
);
610 Init(printout
, printoutForPrinting
);
613 void wxPrintPreviewBase::Init(wxPrintout
*printout
,
614 wxPrintout
*printoutForPrinting
)
617 m_previewPrintout
= printout
;
618 if (m_previewPrintout
)
619 m_previewPrintout
->SetIsPreview(TRUE
);
621 m_printPrintout
= printoutForPrinting
;
623 m_previewCanvas
= NULL
;
624 m_previewFrame
= NULL
;
625 m_previewBitmap
= NULL
;
632 m_printingPrepared
= FALSE
;
634 // Too soon! Moved to RenderPage.
635 // printout->OnPreparePrinting();
637 // Get some parameters from the printout, if defined
639 printout
->GetPageInfo(&m_minPage
, &m_maxPage
, &selFrom
, &selTo
);
642 wxPrintPreviewBase::~wxPrintPreviewBase()
644 if (m_previewPrintout
)
645 delete m_previewPrintout
;
647 delete m_previewBitmap
;
649 delete m_printPrintout
;
652 bool wxPrintPreviewBase::SetCurrentPage(int pageNum
)
654 if (m_currentPage
== pageNum
)
657 m_currentPage
= pageNum
;
660 delete m_previewBitmap
;
661 m_previewBitmap
= NULL
;
666 if (!RenderPage(pageNum
))
668 m_previewCanvas
->Refresh();
673 bool wxPrintPreviewBase::PaintPage(wxWindow
*canvas
, wxDC
& dc
)
675 DrawBlankPage(canvas
, dc
);
677 if (!m_previewBitmap
)
678 if (!RenderPage(m_currentPage
))
681 if (!m_previewBitmap
)
687 int canvasWidth
, canvasHeight
;
688 canvas
->GetSize(&canvasWidth
, &canvasHeight
);
690 double zoomScale
= ((float)m_currentZoom
/(float)100);
691 double actualWidth
= (zoomScale
*m_pageWidth
*m_previewScale
);
692 // float actualHeight = (float)(zoomScale*m_pageHeight*m_previewScale);
694 int x
= (int) ((canvasWidth
- actualWidth
)/2.0);
695 if (x
< m_leftMargin
)
700 temp_dc
.SelectObject(*m_previewBitmap
);
702 dc
.Blit(x
, y
, m_previewBitmap
->GetWidth(), m_previewBitmap
->GetHeight(), &temp_dc
, 0, 0);
704 temp_dc
.SelectObject(wxNullBitmap
);
709 bool wxPrintPreviewBase::RenderPage(int pageNum
)
713 int canvasWidth
, canvasHeight
;
715 if (!m_previewCanvas
)
717 wxFAIL_MSG(_T("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!"));
721 m_previewCanvas
->GetSize(&canvasWidth
, &canvasHeight
);
723 double zoomScale
= (m_currentZoom
/100.0);
724 int actualWidth
= (int)(zoomScale
*m_pageWidth
*m_previewScale
);
725 int actualHeight
= (int)(zoomScale
*m_pageHeight
*m_previewScale
);
727 int x
= (int)((canvasWidth
- actualWidth
)/2.0);
728 if (x
< m_leftMargin
)
730 // int y = m_topMargin;
733 if (!m_previewBitmap
)
735 m_previewBitmap
= new wxBitmap((int)actualWidth
, (int)actualHeight
);
736 if (!m_previewBitmap
|| !m_previewBitmap
->Ok())
738 if (m_previewBitmap
) {
739 delete m_previewBitmap
;
740 m_previewBitmap
= NULL
;
742 wxMessageBox(_("Sorry, not enough memory to create a preview."), _("Print Preview Failure"), wxOK
);
748 memoryDC
.SelectObject(*m_previewBitmap
);
752 m_previewPrintout
->SetDC(&memoryDC
);
753 m_previewPrintout
->SetPageSizePixels(m_pageWidth
, m_pageHeight
);
755 // Need to delay OnPreparePrinting until here, so we have enough information.
756 if (!m_printingPrepared
)
758 m_previewPrintout
->OnPreparePrinting();
759 m_printingPrepared
= TRUE
;
762 m_previewPrintout
->OnBeginPrinting();
764 if (!m_previewPrintout
->OnBeginDocument(m_printDialogData
.GetFromPage(), m_printDialogData
.GetToPage()))
766 wxMessageBox(_("Could not start document preview."), _("Print Preview Failure"), wxOK
);
768 memoryDC
.SelectObject(wxNullBitmap
);
770 delete m_previewBitmap
;
771 m_previewBitmap
= NULL
;
775 m_previewPrintout
->OnPrintPage(pageNum
);
776 m_previewPrintout
->OnEndDocument();
777 m_previewPrintout
->OnEndPrinting();
779 m_previewPrintout
->SetDC(NULL
);
781 memoryDC
.SelectObject(wxNullBitmap
);
785 wxSprintf(buf
, _("Page %d of %d"), pageNum
, m_maxPage
);
787 wxSprintf(buf
, _("Page %d"), pageNum
);
790 m_previewFrame
->SetStatusText(buf
);
796 bool wxPrintPreviewBase::DrawBlankPage(wxWindow
*canvas
, wxDC
& dc
)
798 int canvasWidth
, canvasHeight
;
799 canvas
->GetSize(&canvasWidth
, &canvasHeight
);
801 float zoomScale
= (float)((float)m_currentZoom
/(float)100);
802 float actualWidth
= zoomScale
*m_pageWidth
*m_previewScale
;
803 float actualHeight
= zoomScale
*m_pageHeight
*m_previewScale
;
805 float x
= (float)((canvasWidth
- actualWidth
)/2.0);
806 if (x
< m_leftMargin
)
807 x
= (float)m_leftMargin
;
808 float y
= (float)m_topMargin
;
810 // Draw shadow, allowing for 1-pixel border AROUND the actual page
811 int shadowOffset
= 4;
812 dc
.SetPen(*wxBLACK_PEN
);
813 dc
.SetBrush(*wxBLACK_BRUSH
);
815 dc.DrawRectangle((int)(x-1 + shadowOffset), (int)(y-1 + shadowOffset), (int)(actualWidth+2), (int)(actualHeight+2));
817 dc
.DrawRectangle((int)(x
+ shadowOffset
), (int)(y
+ actualHeight
+1), (int)(actualWidth
), shadowOffset
);
818 dc
.DrawRectangle((int)(x
+ actualWidth
), (int)(y
+ shadowOffset
), shadowOffset
, (int)(actualHeight
));
820 // Draw blank page allowing for 1-pixel border AROUND the actual page
821 dc
.SetPen(*wxBLACK_PEN
);
822 dc
.SetBrush(*wxWHITE_BRUSH
);
825 wxRegion update_region = canvas->GetUpdateRegion();
826 wxRect r = update_region.GetBox();
828 printf( "x: %d y: %d w: %d h: %d.\n", (int)r.x, (int)r.y, (int)r.width, (int)r.height );
831 dc
.DrawRectangle((int)(x
-2), (int)(y
-1), (int)(actualWidth
+3), (int)(actualHeight
+2));
836 void wxPrintPreviewBase::SetZoom(int percent
)
838 if (m_currentZoom
== percent
)
841 m_currentZoom
= percent
;
844 delete m_previewBitmap
;
845 m_previewBitmap
= NULL
;
850 RenderPage(m_currentPage
);
851 ((wxScrolledWindow
*) m_previewCanvas
)->Scroll(0, 0);
852 m_previewCanvas
->Clear();
853 m_previewCanvas
->Refresh();
857 #endif // wxUSE_PRINTING_ARCHITECTURE