X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8cf694d4eab7cf96423456a543bafb211b7ac779..d67fc8b73514909eb198223333e11be4d900f431:/src/gtk/print.cpp diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index 02f8376d5d..451fe2a82a 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -34,10 +34,8 @@ #include "wx/gtk/private.h" #include "wx/dynlib.h" #include "wx/paper.h" -#include "wx/rawbmp.h" #include -#include #if wxUSE_GRAPHICS_CONTEXT #include "wx/graphics.h" @@ -213,25 +211,6 @@ extern "C" printout->OnEndPrinting(); } - - static gboolean - gtk_preview_print_callback(GtkPrintOperation * WXUNUSED(operation), - GtkPrintOperationPreview * WXUNUSED(preview), - GtkPrintContext *context, - GtkWindow *parent, - gpointer user_data) - { - wxPrintout *printout = (wxPrintout *) user_data; - - printout->SetIsPreview(true); - - /* We create a Cairo context with 72dpi resolution. This resolution is - * only used for positioning. */ - cairo_t *cairo = gdk_cairo_create(GTK_WIDGET(parent)->window); - gtk_print_context_set_cairo_context(context, cairo, 72, 72); - - return false; - } } //---------------------------------------------------------------------------- @@ -857,8 +836,6 @@ bool wxGtkPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) native->SetPrintJob( printOp ); - printout->SetIsPreview(false); - wxPrinterToGtkData dataToSend; dataToSend.printer = this; dataToSend.printout = printout; @@ -867,7 +844,6 @@ bool wxGtkPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) g_signal_connect (printOp, "begin-print", G_CALLBACK (gtk_begin_print_callback), &dataToSend); g_signal_connect (printOp, "draw-page", G_CALLBACK (gtk_draw_page_print_callback), &dataToSend); g_signal_connect (printOp, "end-print", G_CALLBACK (gtk_end_print_callback), printout); - g_signal_connect (printOp, "preview", G_CALLBACK (gtk_preview_print_callback), printout); // This is used to setup the DC and // show the dialog if desired @@ -1074,7 +1050,7 @@ wxDC* wxGtkPrinter::PrintDialog( wxWindow *parent ) } m_printDialogData = dialog.GetPrintDialogData(); - + return new wxPrinterDC( m_printDialogData.GetPrintData() ); } @@ -1132,7 +1108,7 @@ 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; @@ -1175,7 +1151,7 @@ void* wxGtkPrinterDCImpl::GetCairoContext() const bool wxGtkPrinterDCImpl::DoFloodFill(wxCoord WXUNUSED(x1), wxCoord WXUNUSED(y1), const wxColour& WXUNUSED(col), - int WXUNUSED(style)) + wxFloodFillStyle WXUNUSED(style)) { // We can't access the given coord as a Cairo context is scalable, ie a // coord doesn't mean anything in this context. @@ -1192,7 +1168,8 @@ void wxGtkPrinterDCImpl::DoGradientFillConcentric(const wxRect& rect, const wxCo wxCoord w = rect.width; wxCoord h = rect.height; - double radius = sqrt((w/2)*(w/2)+(h/2)*(h/2)); + const double r2 = (w/2)*(w/2)+(h/2)*(h/2); + double radius = sqrt(r2); unsigned char redI = initialColour.Red(); unsigned char blueI = initialColour.Blue(); @@ -1428,7 +1405,9 @@ void wxGtkPrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, w cairo_stroke ( m_cairo); } -void wxGtkPrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxGtkPrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + wxPolygonFillMode fillStyle) { if (n==0) return; @@ -1462,7 +1441,9 @@ void wxGtkPrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, cairo_restore(m_cairo); } -void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + wxPolygonFillMode fillStyle) { wxDCImpl::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); } @@ -1621,7 +1602,7 @@ void wxGtkPrinterDCImpl::DoDrawSpline(const wxPointList *points) bool wxGtkPrinterDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop, bool useMask, + wxRasterOperationMode rop, bool useMask, wxCoord WXUNUSED_UNLESS_DEBUG(xsrcMask), wxCoord WXUNUSED_UNLESS_DEBUG(ysrcMask)) { @@ -1652,84 +1633,13 @@ void wxGtkPrinterDCImpl::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoor { wxCHECK_RET( bitmap.IsOk(), wxT("Invalid bitmap in wxGtkPrinterDCImpl::DoDrawBitmap")); - cairo_surface_t* surface; x = wxCoord(XLOG2DEV(x)); y = wxCoord(YLOG2DEV(y)); int bw = bitmap.GetWidth(); int bh = bitmap.GetHeight(); wxBitmap bmpSource = bitmap; // we need a non-const instance. - unsigned char* buffer = new unsigned char[bw*bh*4]; - wxUint32* data = (wxUint32*)buffer; - - wxMask *mask = NULL; - if (useMask) mask = bmpSource.GetMask(); - - // Create a surface object and copy the bitmap pixel data to it. If the image has alpha (or a mask represented as alpha) - // then we'll use a different format and iterator than if it doesn't. - if (bmpSource.HasAlpha() || mask) - { - surface = cairo_image_surface_create_for_data( - buffer, CAIRO_FORMAT_ARGB32, bw, bh, bw*4); - wxAlphaPixelData pixData(bmpSource, wxPoint(0,0), wxSize(bw, bh)); - wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data.")); - - wxAlphaPixelData::Iterator p(pixData); - int y, x; - for (y=0; yGetSizeDeviceUnits()); sizeDevUnits.x = wxRound((double)sizeDevUnits.x * (double)m_resolution / 72.0); sizeDevUnits.y = wxRound((double)sizeDevUnits.y * (double)m_resolution / 72.0); - + wxSize sizeTenthsMM(paper->GetSize()); wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10);