X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/90254df808aa4261e414ebacbb1417f87fad3bc9..1abfa172c547a37751e598084fb8d541071471a3:/src/gtk/print.cpp diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index d1f3080828..53af6cc2e4 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -136,16 +136,29 @@ bool wxGtkPrintFactory::HasPrintSetupDialog() return false; } -wxDialog *wxGtkPrintFactory::CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ) +wxDialog * +wxGtkPrintFactory::CreatePrintSetupDialog(wxWindow * WXUNUSED(parent), + wxPrintData * WXUNUSED(data)) { return NULL; } +#if wxUSE_NEW_DC + +wxImplDC* wxGtkPrintFactory::CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ) +{ + return new wxGtkPrinterImplDC( owner, data ); +} + +#else + wxDC* wxGtkPrintFactory::CreatePrinterDC( const wxPrintData& data ) { - return new wxGtkPrintDC(data); + return new wxGtkPrinterDC(data); } +#endif + bool wxGtkPrintFactory::HasOwnPrintToFile() { return true; @@ -183,7 +196,7 @@ wxPrintNativeDataBase *wxGtkPrintFactory::CreatePrintNativeData() // Callback functions for Gtk Printings. //---------------------------------------------------------------------------- -// We use it to pass useful objets to gtk printing callback functions. +// We use it to pass useful objects to GTK printing callback functions. struct wxPrinterToGtkData { wxGtkPrinter * printer; @@ -206,20 +219,28 @@ extern "C" data->printer->DrawPage(data->printout, operation, context, page_nr); } - static void gtk_end_print_callback (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data) + static void gtk_end_print_callback(GtkPrintOperation * WXUNUSED(operation), + GtkPrintContext * WXUNUSED(context), + gpointer user_data) { wxPrintout *printout = (wxPrintout *) user_data; printout->OnEndPrinting(); } - static gboolean gtk_preview_print_callback (GtkPrintOperation *operation, GtkPrintOperationPreview *preview, GtkPrintContext *context, GtkWindow *parent, gpointer user_data) + 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 positionning. */ + /* 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); @@ -884,7 +905,11 @@ void wxGtkPrinter::BeginPrint(wxPrintout *printout, GtkPrintOperation *operation SetPrintContext(context); native->SetPrintContext( context ); - wxGtkPrintDC *printDC = new wxGtkPrintDC( printdata ); +#if wxUSE_NEW_DC + wxPrinterDC *printDC = new wxPrinterDC( printdata ); +#else + wxGtkPrinterDC *printDC = new wxGtkPrinterDC( printdata ); +#endif m_dc = printDC; if (!m_dc->IsOk()) @@ -892,7 +917,7 @@ void wxGtkPrinter::BeginPrint(wxPrintout *printout, GtkPrintOperation *operation if (sm_lastError != wxPRINTER_CANCELLED) { sm_lastError = wxPRINTER_ERROR; - wxFAIL_MSG(_("The wxGtkPrintDC cannot be used.")); + wxFAIL_MSG(_("The wxGtkPrinterDC cannot be used.")); } return; } @@ -968,7 +993,10 @@ void wxGtkPrinter::BeginPrint(wxPrintout *printout, GtkPrintOperation *operation gtk_print_operation_set_n_pages(operation, numPages); } -void wxGtkPrinter::DrawPage(wxPrintout *printout, GtkPrintOperation *operation, GtkPrintContext *context, int page_nr) +void wxGtkPrinter::DrawPage(wxPrintout *printout, + GtkPrintOperation *operation, + GtkPrintContext * WXUNUSED(context), + int page_nr) { int fromPage, toPage, minPage, maxPage, startPage, endPage; printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); @@ -1052,17 +1080,22 @@ wxDC* wxGtkPrinter::PrintDialog( wxWindow *parent ) } m_printDialogData = dialog.GetPrintDialogData(); - return new wxGtkPrintDC( m_printDialogData.GetPrintData() ); + +#if wxUSE_NEW_DC + return new wxPrinterDC( m_printDialogData.GetPrintData() ); +#else + return new wxGtkPrinterDC( m_printDialogData.GetPrintData() ); +#endif } -bool wxGtkPrinter::Setup( wxWindow *parent ) +bool wxGtkPrinter::Setup( wxWindow * WXUNUSED(parent) ) { // Obsolete, for backward compatibility. return false; } //----------------------------------------------------------------------------- -// wxGtkPrintDC +// wxGtkPrinterDC //----------------------------------------------------------------------------- #define XLOG2DEV(x) ((double)(LogicalToDeviceX(x)) * m_DEV2PS) @@ -1070,9 +1103,19 @@ bool wxGtkPrinter::Setup( wxWindow *parent ) #define YLOG2DEV(x) ((double)(LogicalToDeviceY(x)) * m_DEV2PS) #define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * m_DEV2PS) -IMPLEMENT_CLASS(wxGtkPrintDC, wxDC) -wxGtkPrintDC::wxGtkPrintDC( const wxPrintData& data ) +#if wxUSE_NEW_DC +IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterImplDC, wxImplDC) +#else +IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterDC, wxDC) +#endif + +#if wxUSE_NEW_DC +wxGtkPrinterImplDC::wxGtkPrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ) : + wxImplDC( owner ) +#else +wxGtkPrinterDC::wxGtkPrinterDC( const wxPrintData& data ) +#endif { m_printData = data; @@ -1102,7 +1145,7 @@ wxGtkPrintDC::wxGtkPrintDC( const wxPrintData& data ) 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 + // 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 ); @@ -1112,25 +1155,29 @@ wxGtkPrintDC::wxGtkPrintDC( const wxPrintData& data ) gs_cairo->cairo_translate(m_cairo, -ml, -mt); } -wxGtkPrintDC::~wxGtkPrintDC() +wxGtkPrinterImplDC::~wxGtkPrinterImplDC() { g_object_unref(m_context); g_object_unref(m_layout); } -bool wxGtkPrintDC::IsOk() const +bool wxGtkPrinterImplDC::IsOk() const { - return (m_gpc != NULL); + return m_gpc != NULL; } -bool wxGtkPrintDC::DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style ) +bool wxGtkPrinterImplDC::DoFloodFill(wxCoord WXUNUSED(x1), + wxCoord WXUNUSED(y1), + const wxColour& WXUNUSED(col), + int 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. + // We can't access the given coord as a Cairo context is scalable, ie a + // coord doesn't mean anything in this context. wxFAIL_MSG(_("not implemented")); return false; } -void wxGtkPrintDC::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) +void wxGtkPrinterImplDC::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter) { wxCoord xC = circleCenter.x; wxCoord yC = circleCenter.y; @@ -1176,7 +1223,7 @@ void wxGtkPrintDC::DoGradientFillConcentric(const wxRect& rect, const wxColour& CalcBoundingBox(xR+w, yR+h); } -void wxGtkPrintDC::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) +void wxGtkPrinterImplDC::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) { wxCoord x = rect.x; wxCoord y = rect.y; @@ -1226,14 +1273,15 @@ void wxGtkPrintDC::DoGradientFillLinear(const wxRect& rect, const wxColour& init CalcBoundingBox(x+w, y+h); } -bool wxGtkPrintDC::DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const +bool wxGtkPrinterImplDC::DoGetPixel(wxCoord WXUNUSED(x1), + wxCoord WXUNUSED(y1), + wxColour * WXUNUSED(col)) const { - // We can't access the given coord as a cairo context is scalable, ie a coord doesn't mean anything in this context. wxFAIL_MSG(_("not implemented")); return false; } -void wxGtkPrintDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +void wxGtkPrinterImplDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { if (m_pen.GetStyle() == wxTRANSPARENT) return; @@ -1246,7 +1294,7 @@ void wxGtkPrintDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) CalcBoundingBox( x2, y2 ); } -void wxGtkPrintDC::DoCrossHair(wxCoord x, wxCoord y) +void wxGtkPrinterImplDC::DoCrossHair(wxCoord x, wxCoord y) { int w, h; DoGetSize(&w, &h); @@ -1263,7 +1311,7 @@ void wxGtkPrintDC::DoCrossHair(wxCoord x, wxCoord y) CalcBoundingBox( w, h ); } -void wxGtkPrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) +void wxGtkPrinterImplDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) { double dx = x1 - xc; double dy = y1 - yc; @@ -1315,7 +1363,7 @@ void wxGtkPrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord CalcBoundingBox (x2, y2); } -void wxGtkPrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) +void wxGtkPrinterImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { gs_cairo->cairo_save( m_cairo ); @@ -1341,7 +1389,7 @@ void wxGtkPrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,dou CalcBoundingBox( x+w, y+h ); } -void wxGtkPrintDC::DoDrawPoint(wxCoord x, wxCoord y) +void wxGtkPrinterImplDC::DoDrawPoint(wxCoord x, wxCoord y) { if (m_pen.GetStyle() == wxTRANSPARENT) return; @@ -1354,7 +1402,7 @@ void wxGtkPrintDC::DoDrawPoint(wxCoord x, wxCoord y) CalcBoundingBox( x, y ); } -void wxGtkPrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxGtkPrinterImplDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { if (m_pen.GetStyle() == wxTRANSPARENT) return; @@ -1374,7 +1422,7 @@ void wxGtkPrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord gs_cairo->cairo_stroke ( m_cairo); } -void wxGtkPrintDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxGtkPrinterImplDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { if (n==0) return; @@ -1408,13 +1456,20 @@ void wxGtkPrintDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoo gs_cairo->cairo_restore(m_cairo); } -void wxGtkPrintDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +void wxGtkPrinterImplDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { +#if wxUSE_NEW_DC + wxImplDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); +#else wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); +#endif } -void wxGtkPrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGtkPrinterImplDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { + width--; + height--; + gs_cairo->cairo_new_path(m_cairo); gs_cairo->cairo_rectangle ( m_cairo, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEVREL(width), YLOG2DEVREL(height)); @@ -1428,8 +1483,11 @@ void wxGtkPrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord CalcBoundingBox( x + width, y + height ); } -void wxGtkPrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) +void wxGtkPrinterImplDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { + width--; + height--; + if (radius < 0.0) radius = - radius * ((width < height) ? width : height); wxCoord dd = 2 * (wxCoord) radius; @@ -1473,8 +1531,11 @@ void wxGtkPrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, w CalcBoundingBox(x+width,y+height); } -void wxGtkPrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGtkPrinterImplDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { + width--; + height--; + gs_cairo->cairo_save (m_cairo); gs_cairo->cairo_new_path(m_cairo); @@ -1496,20 +1557,20 @@ void wxGtkPrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord he } #if wxUSE_SPLINES -void wxGtkPrintDC::DoDrawSpline(wxList *points) +void wxGtkPrinterImplDC::DoDrawSpline(const wxPointList *points) { SetPen (m_pen); double c, d, x1, y1, x2, y2, x3, y3; wxPoint *p, *q; - wxList::compatibility_iterator node = points->GetFirst(); - p = (wxPoint *)node->GetData(); + wxPointList::compatibility_iterator node = points->GetFirst(); + p = node->GetData(); x1 = p->x; y1 = p->y; node = node->GetNext(); - p = (wxPoint *)node->GetData(); + p = node->GetData(); c = p->x; d = p->y; x3 = @@ -1527,7 +1588,7 @@ void wxGtkPrintDC::DoDrawSpline(wxList *points) node = node->GetNext(); while (node) { - q = (wxPoint *)node->GetData(); + q = node->GetData(); x1 = x3; y1 = y3; @@ -1555,10 +1616,16 @@ void wxGtkPrintDC::DoDrawSpline(wxList *points) } #endif // wxUSE_SPLINES -bool wxGtkPrintDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask, - wxCoord xsrcMask, wxCoord ysrcMask) +bool wxGtkPrinterImplDC::DoBlit(wxCoord xdest, wxCoord ydest, + wxCoord width, wxCoord height, + wxDC *source, wxCoord xsrc, wxCoord ysrc, + int rop, bool useMask, + wxCoord WXUNUSED_UNLESS_DEBUG(xsrcMask), + wxCoord WXUNUSED_UNLESS_DEBUG(ysrcMask)) { + wxASSERT_MSG( xsrcMask == wxDefaultCoord && ysrcMask == wxDefaultCoord, + wxT("mask coordinates are not supported") ); + wxCHECK_MSG( source, false, wxT("invalid source dc") ); // Blit into a bitmap. @@ -1569,19 +1636,19 @@ bool wxGtkPrintDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord h memDC.SelectObject(wxNullBitmap); // Draw bitmap. scaling and positioning is done there. - DrawBitmap( bitmap, xdest, ydest, useMask ); + GetOwner()->DrawBitmap( bitmap, xdest, ydest, useMask ); return true; } -void wxGtkPrintDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) +void wxGtkPrinterImplDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y ) { DoDrawBitmap( icon, x, y, true ); } -void wxGtkPrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) +void wxGtkPrinterImplDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) { - wxCHECK_RET( bitmap.IsOk(), wxT("Invalid bitmap in wxGtkPrintDC::DoDrawBitmap")); + wxCHECK_RET( bitmap.IsOk(), wxT("Invalid bitmap in wxGtkPrinterImplDC::DoDrawBitmap")); cairo_surface_t* surface; x = wxCoord(XLOG2DEV(x)); @@ -1692,12 +1759,12 @@ void wxGtkPrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, b gs_cairo->cairo_restore(m_cairo); } -void wxGtkPrintDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) +void wxGtkPrinterImplDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y ) { DoDrawRotatedText( text, x, y, 0.0 ); } -void wxGtkPrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) +void wxGtkPrinterImplDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) { double xx = XLOG2DEV(x); double yy = YLOG2DEV(y); @@ -1706,12 +1773,7 @@ void wxGtkPrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, bool underlined = m_font.Ok() && m_font.GetUnderlined(); -// FIXME-UTF8: wouldn't be needed if utf8_str() always returned a buffer -#if wxUSE_UNICODE_UTF8 - const char *data = text.utf8_str(); -#else - const wxCharBuffer data = text.utf8_str(); -#endif + const wxUTF8Buf data = text.utf8_str(); size_t datalen = strlen(data); pango_layout_set_text( m_layout, data, datalen); @@ -1814,7 +1876,7 @@ void wxGtkPrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, CalcBoundingBox (x + w, y + h); } -void wxGtkPrintDC::Clear() +void wxGtkPrinterImplDC::Clear() { // Clear does nothing for printing, but keep the code // for later reuse @@ -1827,7 +1889,7 @@ void wxGtkPrintDC::Clear() */ } -void wxGtkPrintDC::SetFont( const wxFont& font ) +void wxGtkPrinterImplDC::SetFont( const wxFont& font ) { m_font = font; @@ -1848,7 +1910,7 @@ void wxGtkPrintDC::SetFont( const wxFont& font ) } } -void wxGtkPrintDC::SetPen( const wxPen& pen ) +void wxGtkPrinterImplDC::SetPen( const wxPen& pen ) { if (!pen.Ok()) return; @@ -1927,7 +1989,7 @@ void wxGtkPrintDC::SetPen( const wxPen& pen ) } } -void wxGtkPrintDC::SetBrush( const wxBrush& brush ) +void wxGtkPrinterImplDC::SetBrush( const wxBrush& brush ) { if (!brush.Ok()) return; @@ -2020,7 +2082,7 @@ void wxGtkPrintDC::SetBrush( const wxBrush& brush ) } } -void wxGtkPrintDC::SetLogicalFunction( int function ) +void wxGtkPrinterImplDC::SetLogicalFunction( int function ) { if (function == wxCLEAR) gs_cairo->cairo_set_operator (m_cairo, CAIRO_OPERATOR_CLEAR); @@ -2038,7 +2100,7 @@ void wxGtkPrintDC::SetLogicalFunction( int function ) gs_cairo->cairo_set_operator (m_cairo, CAIRO_OPERATOR_SOURCE); } -void wxGtkPrintDC::SetBackground( const wxBrush& brush ) +void wxGtkPrinterImplDC::SetBackground( const wxBrush& brush ) { m_backgroundBrush = brush; gs_cairo->cairo_save(m_cairo); @@ -2049,44 +2111,46 @@ void wxGtkPrintDC::SetBackground( const wxBrush& brush ) gs_cairo->cairo_restore(m_cairo); } -void wxGtkPrintDC::SetBackgroundMode(int mode) +void wxGtkPrinterImplDC::SetBackgroundMode(int mode) { - if (mode == wxSOLID) m_backgroundMode = wxSOLID; - else m_backgroundMode = wxTRANSPARENT; + if (mode == wxSOLID) + m_backgroundMode = wxSOLID; + else + m_backgroundMode = wxTRANSPARENT; } -void wxGtkPrintDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +void wxGtkPrinterImplDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { gs_cairo->cairo_rectangle ( m_cairo, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEVREL(width), YLOG2DEVREL(height)); gs_cairo->cairo_clip(m_cairo); } -void wxGtkPrintDC::DestroyClippingRegion() +void wxGtkPrinterImplDC::DestroyClippingRegion() { gs_cairo->cairo_reset_clip(m_cairo); } -bool wxGtkPrintDC::StartDoc(const wxString& message) +bool wxGtkPrinterImplDC::StartDoc(const wxString& WXUNUSED(message)) { return true; } -void wxGtkPrintDC::EndDoc() +void wxGtkPrinterImplDC::EndDoc() { return; } -void wxGtkPrintDC::StartPage() +void wxGtkPrinterImplDC::StartPage() { return; } -void wxGtkPrintDC::EndPage() +void wxGtkPrinterImplDC::EndPage() { return; } -wxCoord wxGtkPrintDC::GetCharHeight() const +wxCoord wxGtkPrinterImplDC::GetCharHeight() const { pango_layout_set_text( m_layout, "H", 1 ); @@ -2096,7 +2160,7 @@ wxCoord wxGtkPrintDC::GetCharHeight() const return wxRound( h * m_PS2DEV ); } -wxCoord wxGtkPrintDC::GetCharWidth() const +wxCoord wxGtkPrinterImplDC::GetCharWidth() const { pango_layout_set_text( m_layout, "H", 1 ); @@ -2106,7 +2170,7 @@ wxCoord wxGtkPrintDC::GetCharWidth() const return wxRound( w * m_PS2DEV ); } -void wxGtkPrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height, +void wxGtkPrinterImplDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont ) const @@ -2126,12 +2190,7 @@ void wxGtkPrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoo } // Set layout's text - // FIXME-UTF8: wouldn't be needed if utf8_str() always returned a buffer -#if wxUSE_UNICODE_UTF8 - const char *dataUTF8 = string.utf8_str(); -#else - const wxCharBuffer dataUTF8 = string.utf8_str(); -#endif + const wxUTF8Buf dataUTF8 = string.utf8_str(); PangoFontDescription *desc = m_fontdesc; if (theFont) desc = theFont->GetNativeFontInfo()->description; @@ -2169,7 +2228,7 @@ void wxGtkPrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoo pango_layout_set_font_description( m_layout, m_fontdesc ); } -void wxGtkPrintDC::DoGetSize(int* width, int* height) const +void wxGtkPrinterImplDC::DoGetSize(int* width, int* height) const { GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc ); @@ -2179,7 +2238,7 @@ void wxGtkPrintDC::DoGetSize(int* width, int* height) const *height = wxRound( gtk_page_setup_get_paper_height( setup, GTK_UNIT_POINTS ) * m_PS2DEV ); } -void wxGtkPrintDC::DoGetSizeMM(int *width, int *height) const +void wxGtkPrinterImplDC::DoGetSizeMM(int *width, int *height) const { GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc ); @@ -2189,23 +2248,28 @@ void wxGtkPrintDC::DoGetSizeMM(int *width, int *height) const *height = wxRound( gtk_page_setup_get_paper_height( setup, GTK_UNIT_MM ) ); } -wxSize wxGtkPrintDC::GetPPI() const +wxSize wxGtkPrinterImplDC::GetPPI() const { return wxSize( (int)m_resolution, (int)m_resolution ); } -void wxGtkPrintDC::SetPrintData(const wxPrintData& data) +void wxGtkPrinterImplDC::SetPrintData(const wxPrintData& data) { m_printData = data; } -void wxGtkPrintDC::SetResolution(int ppi) +// overriden for wxPrinterDC Impl + +wxRect wxGtkPrinterImplDC::GetPaperRect() { - // We can't change ppi of the GtkPrintContext. - // TODO: should we really support this? + // Does GtkPrint support printer margins? + int w = 0; + int h = 0; + DoGetSize( &w, &h ); + return wxRect( 0,0,w,h ); } -int wxGtkPrintDC::GetResolution() +int wxGtkPrinterImplDC::GetResolution() { return m_resolution; }