First update patch for GTK+ print
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48649 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -874,49 +874,6 @@ public:
|
|||||||
bool useMask = false)
|
bool useMask = false)
|
||||||
{ m_pimpl->DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
|
{ 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)
|
void DrawText(const wxString& text, wxCoord x, wxCoord y)
|
||||||
{ m_pimpl->DoDrawText(text, x, y); }
|
{ m_pimpl->DoDrawText(text, x, y); }
|
||||||
void DrawText(const wxString& text, const wxPoint& pt)
|
void DrawText(const wxString& text, const wxPoint& pt)
|
||||||
@@ -1233,49 +1190,6 @@ public:
|
|||||||
bool useMask = false)
|
bool useMask = false)
|
||||||
{ DoDrawBitmap(bmp, pt.x, pt.y, useMask); }
|
{ 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)
|
void DrawText(const wxString& text, wxCoord x, wxCoord y)
|
||||||
{ DoDrawText(text, x, y); }
|
{ DoDrawText(text, x, y); }
|
||||||
void DrawText(const wxString& text, const wxPoint& pt)
|
void DrawText(const wxString& text, const wxPoint& pt)
|
||||||
|
@@ -50,12 +50,6 @@
|
|||||||
#include "mondrian.xpm"
|
#include "mondrian.xpm"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_LIBGNOMEPRINT
|
|
||||||
#include "wx/html/forcelnk.h"
|
|
||||||
FORCE_LINK(gnome_print)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// Declare a frame
|
// Declare a frame
|
||||||
MyFrame *frame = (MyFrame *) NULL;
|
MyFrame *frame = (MyFrame *) NULL;
|
||||||
// int orientation = wxPORTRAIT;
|
// int orientation = wxPORTRAIT;
|
||||||
@@ -337,10 +331,10 @@ void MyFrame::Draw(wxDC& dc)
|
|||||||
// between the screen image, the print preview image (at various zoom
|
// between the screen image, the print preview image (at various zoom
|
||||||
// levels), and the printed page.
|
// levels), and the printed page.
|
||||||
dc.SetBackground(*wxWHITE_BRUSH);
|
dc.SetBackground(*wxWHITE_BRUSH);
|
||||||
dc.Clear();
|
// dc.Clear();
|
||||||
dc.SetFont(wxGetApp().m_testFont);
|
dc.SetFont(wxGetApp().m_testFont);
|
||||||
|
|
||||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
// dc.SetBackgroundMode(wxTRANSPARENT);
|
||||||
|
|
||||||
dc.SetPen(*wxBLACK_PEN);
|
dc.SetPen(*wxBLACK_PEN);
|
||||||
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||||
|
@@ -79,7 +79,6 @@ bool wxGtkPrintModule::OnInit()
|
|||||||
gs_cairo = wxCairoLibrary::Get();
|
gs_cairo = wxCairoLibrary::Get();
|
||||||
if (gs_cairo && gtk_check_version(2,10,0) == NULL)
|
if (gs_cairo && gtk_check_version(2,10,0) == NULL)
|
||||||
wxPrintFactory::SetPrintFactory( new wxGtkPrintFactory );
|
wxPrintFactory::SetPrintFactory( new wxGtkPrintFactory );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,21 +669,29 @@ int wxGtkPrintDialog::ShowModal()
|
|||||||
case GTK_PRINT_PAGES_CURRENT:
|
case GTK_PRINT_PAGES_CURRENT:
|
||||||
m_printDialogData.SetSelection( true );
|
m_printDialogData.SetSelection( true );
|
||||||
break;
|
break;
|
||||||
case GTK_PRINT_PAGES_ALL:
|
|
||||||
m_printDialogData.SetAllPages( true );
|
|
||||||
m_printDialogData.SetFromPage( 0 );
|
|
||||||
m_printDialogData.SetToPage( 9999 );
|
|
||||||
break;
|
|
||||||
case GTK_PRINT_PAGES_RANGES:
|
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
|
// 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.
|
// will hit "OK" button. However we can only save 1-3 in the print data.
|
||||||
gint num_ranges = 0;
|
gint num_ranges = 0;
|
||||||
GtkPageRange* range;
|
GtkPageRange* range;
|
||||||
range = gtk_print_settings_get_page_ranges (newSettings, &num_ranges);
|
range = gtk_print_settings_get_page_ranges (newSettings, &num_ranges);
|
||||||
|
if (num_ranges >= 1)
|
||||||
|
{
|
||||||
m_printDialogData.SetFromPage( range[0].start );
|
m_printDialogData.SetFromPage( range[0].start );
|
||||||
m_printDialogData.SetToPage( range[0].end );
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -972,8 +979,15 @@ void wxGtkPrinter::DrawPage(wxPrintout *printout, GtkPrintOperation *operation,
|
|||||||
GtkPageRange* range;
|
GtkPageRange* range;
|
||||||
range = gtk_print_settings_get_page_ranges (settings, &num_ranges);
|
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.
|
// 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;
|
startPage = range[0].start + 1;
|
||||||
endPage = range[0].end + 1;
|
endPage = range[0].end + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startPage = minPage;
|
||||||
|
endPage = maxPage;
|
||||||
|
}
|
||||||
break;}
|
break;}
|
||||||
case GTK_PRINT_PAGES_ALL:
|
case GTK_PRINT_PAGES_ALL:
|
||||||
default:
|
default:
|
||||||
@@ -1081,6 +1095,14 @@ wxGtkPrintDC::wxGtkPrintDC( const wxPrintData& data )
|
|||||||
|
|
||||||
m_signX = 1; // default x-axis left to right.
|
m_signX = 1; // default x-axis left to right.
|
||||||
m_signY = 1; // default y-axis bottom up -> top down.
|
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()
|
wxGtkPrintDC::~wxGtkPrintDC()
|
||||||
@@ -1269,6 +1291,8 @@ void wxGtkPrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord
|
|||||||
alpha1 *= DEG2RAD;
|
alpha1 *= DEG2RAD;
|
||||||
alpha2 *= 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_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_line_to(m_cairo, XLOG2DEVREL(xc), YLOG2DEVREL(yc));
|
||||||
gs_cairo->cairo_close_path (m_cairo);
|
gs_cairo->cairo_close_path (m_cairo);
|
||||||
@@ -1288,6 +1312,8 @@ void wxGtkPrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,dou
|
|||||||
{
|
{
|
||||||
gs_cairo->cairo_save( 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.)) );
|
gs_cairo->cairo_translate( m_cairo, XLOG2DEVREL((wxCoord) (x + w / 2.)), XLOG2DEVREL((wxCoord) (y + h / 2.)) );
|
||||||
double scale = (double)YLOG2DEVREL(h) / (double) XLOG2DEVREL(w);
|
double scale = (double)YLOG2DEVREL(h) / (double) XLOG2DEVREL(w);
|
||||||
gs_cairo->cairo_scale( m_cairo, 1.0, scale );
|
gs_cairo->cairo_scale( m_cairo, 1.0, scale );
|
||||||
@@ -1382,6 +1408,7 @@ void wxGtkPrintDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoo
|
|||||||
|
|
||||||
void wxGtkPrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
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));
|
gs_cairo->cairo_rectangle ( m_cairo, XLOG2DEVREL(x), YLOG2DEVREL(y), XLOG2DEVREL(width), YLOG2DEVREL(height));
|
||||||
|
|
||||||
SetBrush( m_brush );
|
SetBrush( m_brush );
|
||||||
@@ -1443,6 +1470,8 @@ void wxGtkPrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord he
|
|||||||
{
|
{
|
||||||
gs_cairo->cairo_save (m_cairo);
|
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_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_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);
|
gs_cairo->cairo_arc ( m_cairo, 0, 0, XLOG2DEVREL(width/2), 0, 2 * M_PI);
|
||||||
@@ -1580,10 +1609,14 @@ void wxGtkPrintDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, b
|
|||||||
// blue. The 32-bit quantities are stored native-endian.
|
// blue. The 32-bit quantities are stored native-endian.
|
||||||
// Pre-multiplied alpha is used.
|
// Pre-multiplied alpha is used.
|
||||||
unsigned char alpha = p.Alpha();
|
unsigned char alpha = p.Alpha();
|
||||||
|
|
||||||
|
if (!bmpSource.HasAlpha() && mask)
|
||||||
|
alpha = 255;
|
||||||
|
|
||||||
if (alpha == 0)
|
if (alpha == 0)
|
||||||
*data = 0;
|
*data = 0;
|
||||||
else
|
else
|
||||||
*data = ( alpha/255 << 24
|
*data = ( alpha << 24
|
||||||
| (p.Red() * alpha/255) << 16
|
| (p.Red() * alpha/255) << 16
|
||||||
| (p.Green() * alpha/255) << 8
|
| (p.Green() * alpha/255) << 8
|
||||||
| (p.Blue() * alpha/255) );
|
| (p.Blue() * alpha/255) );
|
||||||
@@ -1809,14 +1842,14 @@ void wxGtkPrintDC::SetPen( const wxPen& pen )
|
|||||||
|
|
||||||
switch (m_pen.GetStyle())
|
switch (m_pen.GetStyle())
|
||||||
{
|
{
|
||||||
case wxDOT: gs_cairo->cairo_set_dash( m_cairo, dotted, 1, 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, 1, 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, 1, 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, 3, 0 ); break;
|
case wxDOT_DASH: gs_cairo->cairo_set_dash( m_cairo, dotted_dashed, 4, 0 ); break;
|
||||||
case wxUSER_DASH:
|
case wxUSER_DASH:
|
||||||
{
|
{
|
||||||
wxDash *wx_dashes;
|
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 );
|
gdouble *g_dashes = g_new( gdouble, num );
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < num; ++i)
|
for (i = 0; i < num; ++i)
|
||||||
|
Reference in New Issue
Block a user