bool useMask = false)
{ m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
- virtual void DrawScaledBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL)
- {
- if (bmp.GetWidth() != w || bmp.GetHeight() != h)
- {
- if (quality != wxIMAGE_QUALITY_HIGH)
- quality = wxIMAGE_QUALITY_NORMAL;
- wxImage tmpImg = bmp.ConvertToImage();
- tmpImg.Rescale( w, h, quality );
- wxBitmap scaledBmp(tmpImg);
- m_pimpl->DoDrawBitmap(scaledBmp, x, y, useMask);
- }
- else
- m_pimpl->DoDrawBitmap(bmp, x, y, useMask);
- }
- virtual void DrawScaledBitmap(const wxBitmap &bmp, const wxPoint& pt, const wxSize& sz, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL)
- {
- if (bmp.GetWidth() != sz.x || bmp.GetHeight() != sz.y)
- {
- if (quality != wxIMAGE_QUALITY_HIGH)
- quality = wxIMAGE_QUALITY_NORMAL;
- wxImage tmpImg = bmp.ConvertToImage();
- tmpImg.Rescale( sz.x, sz.y, quality );
- wxBitmap scaledBmp(tmpImg);
- m_pimpl->DoDrawBitmap(scaledBmp, pt.x, pt.y, useMask);
- }
- else
- m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask);
- }
- virtual void DrawScaledBitmap(const wxBitmap &bmp, const wxRect& rect, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL)
- {
- if (bmp.GetWidth() != rect.width || bmp.GetHeight() != rect.height)
- {
- if (quality != wxIMAGE_QUALITY_HIGH)
- quality = wxIMAGE_QUALITY_NORMAL;
- wxImage tmpImg = bmp.ConvertToImage();
- tmpImg.Rescale( rect.width, rect.height, quality );
- wxBitmap scaledBmp(tmpImg);
- m_pimpl->DoDrawBitmap(scaledBmp, rect.x, rect.y, useMask);
- }
- else
- m_pimpl->DoDrawBitmap(bmp, rect.x, rect.y, useMask);
- }
-
void DrawText(const wxString& text, wxCoord x, wxCoord y)
{ m_pimpl->DoDrawText(text, x, y); }
void DrawText(const wxString& text, const wxPoint& pt)
bool useMask = false)
{ DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
- virtual void DrawScaledBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL)
- {
- if (bmp.GetWidth() != w || bmp.GetHeight() != h)
- {
- if (quality != wxIMAGE_QUALITY_HIGH)
- quality = wxIMAGE_QUALITY_NORMAL;
- wxImage tmpImg = bmp.ConvertToImage();
- tmpImg.Rescale( w, h, quality );
- wxBitmap scaledBmp(tmpImg);
- DoDrawBitmap(scaledBmp, x, y, useMask);
- }
- else
- DoDrawBitmap(bmp, x, y, useMask);
- }
- virtual void DrawScaledBitmap(const wxBitmap &bmp, const wxPoint& pt, const wxSize& sz, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL)
- {
- if (bmp.GetWidth() != sz.x || bmp.GetHeight() != sz.y)
- {
- if (quality != wxIMAGE_QUALITY_HIGH)
- quality = wxIMAGE_QUALITY_NORMAL;
- wxImage tmpImg = bmp.ConvertToImage();
- tmpImg.Rescale( sz.x, sz.y, quality );
- wxBitmap scaledBmp(tmpImg);
- DoDrawBitmap(scaledBmp, pt.x, pt.y, useMask);
- }
- else
- DoDrawBitmap(bmp, pt.x, pt.y, useMask);
- }
- virtual void DrawScaledBitmap(const wxBitmap &bmp, const wxRect& rect, bool useMask = false, int quality = wxIMAGE_QUALITY_NORMAL)
- {
- if (bmp.GetWidth() != rect.width || bmp.GetHeight() != rect.height)
- {
- if (quality != wxIMAGE_QUALITY_HIGH)
- quality = wxIMAGE_QUALITY_NORMAL;
- wxImage tmpImg = bmp.ConvertToImage();
- tmpImg.Rescale( rect.width, rect.height, quality );
- wxBitmap scaledBmp(tmpImg);
- DoDrawBitmap(scaledBmp, rect.x, rect.y, useMask);
- }
- else
- DoDrawBitmap(bmp, rect.x, rect.y, useMask);
- }
-
void DrawText(const wxString& text, wxCoord x, wxCoord y)
{ DoDrawText(text, x, y); }
void DrawText(const wxString& text, const wxPoint& pt)
#include "mondrian.xpm"
#endif
-#if wxUSE_LIBGNOMEPRINT
-#include "wx/html/forcelnk.h"
-FORCE_LINK(gnome_print)
-#endif
-
-
// Declare a frame
MyFrame *frame = (MyFrame *) NULL;
// int orientation = wxPORTRAIT;
// between the screen image, the print preview image (at various zoom
// levels), and the printed page.
dc.SetBackground(*wxWHITE_BRUSH);
- dc.Clear();
+ // dc.Clear();
dc.SetFont(wxGetApp().m_testFont);
- dc.SetBackgroundMode(wxTRANSPARENT);
+ // dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRoundedRectangle(0, 20, 200, 80, 20);
-
+
dc.DrawText( wxT("Rectangle 200 by 80"), 40, 40);
dc.SetPen( wxPen(*wxBLACK,0,wxDOT_DASH) );
gs_cairo = wxCairoLibrary::Get();
if (gs_cairo && gtk_check_version(2,10,0) == NULL)
wxPrintFactory::SetPrintFactory( new wxGtkPrintFactory );
-
return true;
}
case GTK_PRINT_PAGES_CURRENT:
m_printDialogData.SetSelection( true );
break;
- case GTK_PRINT_PAGES_ALL:
- m_printDialogData.SetAllPages( true );
- m_printDialogData.SetFromPage( 0 );
- m_printDialogData.SetToPage( 9999 );
- break;
case GTK_PRINT_PAGES_RANGES:
- default:
- // wxWidgets doesn't support multiple ranges, so we can only save the first one even if the user wants to print others.
+ {// wxWidgets doesn't support multiple ranges, so we can only save the first one even if the user wants to print others.
// For example, the user enters "1-3;5-7" in the dialog: pages 1-3 and 5-7 will be correctly printed when the user
// will hit "OK" button. However we can only save 1-3 in the print data.
gint num_ranges = 0;
GtkPageRange* range;
range = gtk_print_settings_get_page_ranges (newSettings, &num_ranges);
+ if (num_ranges >= 1)
+ {
m_printDialogData.SetFromPage( range[0].start );
m_printDialogData.SetToPage( range[0].end );
+ }
+ else {
+ m_printDialogData.SetAllPages( true );
+ m_printDialogData.SetFromPage( 0 );
+ m_printDialogData.SetToPage( 9999 );
+ }
+ break;}
+ case GTK_PRINT_PAGES_ALL:
+ default:
+ m_printDialogData.SetAllPages( true );
+ m_printDialogData.SetFromPage( 0 );
+ m_printDialogData.SetToPage( 9999 );
break;
}
GtkPageRange* range;
range = gtk_print_settings_get_page_ranges (settings, &num_ranges);
// We don't need to verify these values as it has already been done in wxGtkPrinter::BeginPrint.
+ if (num_ranges >= 1)
+ {
startPage = range[0].start + 1;
endPage = range[0].end + 1;
+ }
+ else {
+ startPage = minPage;
+ endPage = maxPage;
+ }
break;}
case GTK_PRINT_PAGES_ALL:
default:
m_signX = 1; // default x-axis left to right.
m_signY = 1; // default y-axis bottom up -> top down.
+
+ // By default the origine of cairo contexte 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 (i.e. doesn't care about 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);
+ gs_cairo->cairo_translate(m_cairo, -ml, -mt);
}
wxGtkPrintDC::~wxGtkPrintDC()
alpha1 *= DEG2RAD;
alpha2 *= DEG2RAD;
+ gs_cairo->cairo_new_path(m_cairo);
+
gs_cairo->cairo_arc_negative ( m_cairo, XLOG2DEVREL(xc), YLOG2DEVREL(yc), XLOG2DEVREL((int)radius), alpha1, alpha2);
gs_cairo->cairo_line_to(m_cairo, XLOG2DEVREL(xc), YLOG2DEVREL(yc));
gs_cairo->cairo_close_path (m_cairo);
{
gs_cairo->cairo_save( m_cairo );
+ gs_cairo->cairo_new_path(m_cairo);
+
gs_cairo->cairo_translate( m_cairo, XLOG2DEVREL((wxCoord) (x + w / 2.)), XLOG2DEVREL((wxCoord) (y + h / 2.)) );
double scale = (double)YLOG2DEVREL(h) / (double) XLOG2DEVREL(w);
gs_cairo->cairo_scale( m_cairo, 1.0, scale );
void wxGtkPrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
+ gs_cairo->cairo_new_path(m_cairo);
gs_cairo->cairo_rectangle ( m_cairo, XLOG2DEVREL(x), YLOG2DEVREL(y), XLOG2DEVREL(width), YLOG2DEVREL(height));
SetBrush( m_brush );
{
gs_cairo->cairo_save (m_cairo);
+ gs_cairo->cairo_new_path(m_cairo);
+
gs_cairo->cairo_translate (m_cairo, XLOG2DEVREL((wxCoord) (x + width / 2.)), YLOG2DEVREL((wxCoord) (y + height / 2.)));
gs_cairo->cairo_scale(m_cairo, 1, (double)YLOG2DEVREL(height)/(double)XLOG2DEVREL(width));
gs_cairo->cairo_arc ( m_cairo, 0, 0, XLOG2DEVREL(width/2), 0, 2 * M_PI);
// blue. The 32-bit quantities are stored native-endian.
// Pre-multiplied alpha is used.
unsigned char alpha = p.Alpha();
+
+ if (!bmpSource.HasAlpha() && mask)
+ alpha = 255;
+
if (alpha == 0)
*data = 0;
else
- *data = ( alpha/255 << 24
+ *data = ( alpha << 24
| (p.Red() * alpha/255) << 16
| (p.Green() * alpha/255) << 8
| (p.Blue() * alpha/255) );
switch (m_pen.GetStyle())
{
- case wxDOT: gs_cairo->cairo_set_dash( m_cairo, dotted, 1, 0 ); break;
- case wxSHORT_DASH: gs_cairo->cairo_set_dash( m_cairo, short_dashed, 1, 0 ); break;
- case wxLONG_DASH: gs_cairo->cairo_set_dash( m_cairo, long_dashed, 1, 0 ); break;
- case wxDOT_DASH: gs_cairo->cairo_set_dash( m_cairo, dotted_dashed, 3, 0 ); break;
+ case wxDOT: gs_cairo->cairo_set_dash( m_cairo, dotted, 2, 0 ); break;
+ case wxSHORT_DASH: gs_cairo->cairo_set_dash( m_cairo, short_dashed, 2, 0 ); break;
+ case wxLONG_DASH: gs_cairo->cairo_set_dash( m_cairo, long_dashed, 2, 0 ); break;
+ case wxDOT_DASH: gs_cairo->cairo_set_dash( m_cairo, dotted_dashed, 4, 0 ); break;
case wxUSER_DASH:
{
wxDash *wx_dashes;
- int num = m_pen.GetDashes (&wx_dashes) - 1;
+ int num = m_pen.GetDashes (&wx_dashes);
gdouble *g_dashes = g_new( gdouble, num );
int i;
for (i = 0; i < num; ++i)