X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bb03d283bef07de18d0dd584eb047d2f7e1b3856..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/gtk/print.cpp?ds=sidebyside diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index 3c689cbba9..9b7e7a2ca0 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -34,6 +34,7 @@ #include "wx/dynlib.h" #include "wx/paper.h" #include "wx/scopeguard.h" +#include "wx/modalhook.h" #include @@ -623,6 +624,8 @@ wxGtkPrintDialog::~wxGtkPrintDialog() // This is called even if we actually don't want the dialog to appear. int wxGtkPrintDialog::ShowModal() { + WX_HOOK_MODAL_DIALOG(); + // We need to restore the settings given in the constructor. wxPrintData data = m_printDialogData.GetPrintData(); wxGtkPrintNativeData *native = @@ -747,6 +750,8 @@ wxGtkPageSetupDialog::~wxGtkPageSetupDialog() int wxGtkPageSetupDialog::ShowModal() { + WX_HOOK_MODAL_DIALOG(); + // Get the config. m_pageDialogData.GetPrintData().ConvertToNative(); wxGtkPrintNativeData *native = (wxGtkPrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData(); @@ -1179,8 +1184,6 @@ wxGtkPrinterDCImpl::wxGtkPrinterDCImpl(wxPrinterDC *owner, const wxPrintData& da #if wxCAIRO_SCALE m_PS2DEV = 1.0; m_DEV2PS = 1.0; - - cairo_scale( m_cairo, 72.0 / (double)m_resolution, 72.0 / (double)m_resolution ); #else m_PS2DEV = (double)m_resolution / 72.0; m_DEV2PS = 72.0 / (double)m_resolution; @@ -1192,15 +1195,6 @@ wxGtkPrinterDCImpl::wxGtkPrinterDCImpl(wxPrinterDC *owner, const wxPrintData& da m_signX = 1; // default x-axis left to right. m_signY = 1; // default y-axis bottom up -> top down. - - // By default the origin of the Cairo context is in the upper left - // corner of the printable area. We need to translate it so that it - // is in the upper left corner of the paper (without margins) - GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc ); - gdouble ml, mt; - ml = gtk_page_setup_get_left_margin (setup, GTK_UNIT_POINTS); - mt = gtk_page_setup_get_top_margin (setup, GTK_UNIT_POINTS); - cairo_translate(m_cairo, -ml, -mt); } wxGtkPrinterDCImpl::~wxGtkPrinterDCImpl() @@ -1463,7 +1457,7 @@ void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y) CalcBoundingBox( x, y ); } -void wxGtkPrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxGtkPrinterDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) { if ( m_pen.IsTransparent() ) return; @@ -1485,7 +1479,7 @@ void wxGtkPrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, w cairo_stroke ( m_cairo); } -void wxGtkPrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], +void wxGtkPrinterDCImpl::DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { @@ -1521,7 +1515,7 @@ void wxGtkPrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], cairo_restore(m_cairo); } -void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], +void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { @@ -2083,6 +2077,8 @@ void wxGtkPrinterDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width { cairo_rectangle ( m_cairo, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEVREL(width), YLOG2DEVREL(height)); cairo_clip(m_cairo); + + wxDCImpl::DoSetClippingRegion(x, y, width, height); } void wxGtkPrinterDCImpl::DestroyClippingRegion() @@ -2102,7 +2098,24 @@ void wxGtkPrinterDCImpl::EndDoc() void wxGtkPrinterDCImpl::StartPage() { - return; + // Notice that we may change the Cairo transformation matrix only here and + // not before (e.g. in wxGtkPrinterDCImpl ctor as we used to do) in order + // to not affect _gtk_print_context_rotate_according_to_orientation() which + // is used in GTK+ itself and wouldn't work correctly if we applied these + // transformations before it is called. + + // By default the origin of the Cairo context is in the upper left + // corner of the printable area. We need to translate it so that it + // is in the upper left corner of the paper (without margins) + GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc ); + gdouble ml, mt; + ml = gtk_page_setup_get_left_margin (setup, GTK_UNIT_POINTS); + mt = gtk_page_setup_get_top_margin (setup, GTK_UNIT_POINTS); + cairo_translate(m_cairo, -ml, -mt); + +#if wxCAIRO_SCALE + cairo_scale( m_cairo, 72.0 / (double)m_resolution, 72.0 / (double)m_resolution ); +#endif } void wxGtkPrinterDCImpl::EndPage()