/////////////////////////////////////////////////////////////////////////////
-// Name: wx/gtk/print.cpp
+// Name: src/gtk/print.cpp
// Author: Anthony Bretaudeau
// Purpose: GTK printing support
// Created: 2007-08-25
#endif
#include "wx/fontutil.h"
-#include "wx/gtk/private.h"
#include "wx/dynlib.h"
#include "wx/paper.h"
#include <gtk/gtk.h>
+
+#if GTK_CHECK_VERSION(2,14,0)
+#include <gtk/gtkunixprint.h>
+#else
#include <gtk/gtkpagesetupunixdialog.h>
+#endif
+
#if wxUSE_GRAPHICS_CONTEXT
#include "wx/graphics.h"
#include "wx/gtk/private/object.h"
-// Usefull to convert angles from/to Rad to/from Deg.
+// Useful to convert angles from/to Rad to/from Deg.
static const double RAD2DEG = 180.0 / M_PI;
static const double DEG2RAD = M_PI / 180.0;
}
else if (response == GTK_PRINT_OPERATION_RESULT_ERROR)
{
+ wxLogError(_("Error while printing: ") + wxString(gError ? gError->message : "???"));
g_error_free (gError);
- wxLogError(_("Error while printing: ") + wxString::Format(_("%s"), gError->message));
return wxID_NO; // We use wxID_NO because there is no wxID_ERROR available
}
angle = -angle;
- bool underlined = m_font.Ok() && m_font.GetUnderlined();
-
const wxScopedCharBuffer data = text.utf8_str();
- size_t datalen = strlen(data);
- pango_layout_set_text( m_layout, data, datalen);
+ pango_layout_set_text(m_layout, data, data.length());
- if (underlined)
- {
- PangoAttrList *attrs = pango_attr_list_new();
- PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
- a->start_index = 0;
- a->end_index = datalen;
- pango_attr_list_insert(attrs, a);
- pango_layout_set_attributes(m_layout, attrs);
- pango_attr_list_unref(attrs);
- }
-
- if (m_textForegroundColour.Ok())
+ const bool setAttrs = m_font.GTKSetPangoAttrs(m_layout);
+ if (m_textForegroundColour.IsOk())
{
unsigned char red = m_textForegroundColour.Red();
unsigned char blue = m_textForegroundColour.Blue();
cairo_restore( m_cairo );
- if (underlined)
+ if (setAttrs)
{
// Undo underline attributes setting
pango_layout_set_attributes(m_layout, NULL);
{
m_font = font;
- if (m_font.Ok())
+ if (m_font.IsOk())
{
if (m_fontdesc)
pango_font_description_free( m_fontdesc );
void wxGtkPrinterDCImpl::SetPen( const wxPen& pen )
{
- if (!pen.Ok()) return;
+ if (!pen.IsOk()) return;
m_pen = pen;
void wxGtkPrinterDCImpl::SetBrush( const wxBrush& brush )
{
- if (!brush.Ok()) return;
+ if (!brush.IsOk()) return;
m_brush = brush;
{
// scale the font and apply it
PangoFontDescription *desc = theFont->GetNativeFontInfo()->description;
- float size = pango_font_description_get_size(desc);
- size = size * GetFontPointSizeAdjustment(72.0);
+ oldSize = pango_font_description_get_size(desc);
+ const float size = oldSize * GetFontPointSizeAdjustment(72.0);
pango_font_description_set_size(desc, (gint)size);
pango_layout_set_font_description(m_layout, desc);
m_printData = data;
}
-// overriden for wxPrinterDC Impl
+// overridden for wxPrinterDC Impl
wxRect wxGtkPrinterDCImpl::GetPaperRect() const
{