X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a7060b8cae0d3aa2fecd4ecaee4e89f0ce7e11c3..001f0f8273679e2ad85c8b7246db0f4d95db3ebb:/src/gtk/print.cpp diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index 1da779765f..24b50d68ef 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -644,7 +644,7 @@ int wxGtkPrintDialog::ShowModal() if (GetShowDialog()) response = gtk_print_operation_run (native->GetPrintJob(), GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW(gtk_widget_get_toplevel(m_parent->m_widget) ), &gError); else - response = gtk_print_operation_run (native->GetPrintJob(), GTK_PRINT_OPERATION_ACTION_PRINT, (GtkWindow *) m_parent, &gError); + response = gtk_print_operation_run (native->GetPrintJob(), GTK_PRINT_OPERATION_ACTION_PRINT, GTK_WINDOW(gtk_widget_get_toplevel(m_parent->m_widget)), &gError); // Does everything went well? if (response == GTK_PRINT_OPERATION_RESULT_CANCEL) @@ -847,19 +847,29 @@ bool wxGtkPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) dataToSend.printer = this; dataToSend.printout = printout; - // These Gtk signals are catched here. + // These Gtk signals are caught here. 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); - m_showDialog = true; - if (!prompt) - m_showDialog = false; + // This is used to setup the DC and + // show the dialog if desired + wxGtkPrintDialog dialog( parent, &m_printDialogData ); + dialog.SetPrintDC(m_dc); + dialog.SetShowDialog(prompt); - // PrintDialog returns a wxDC but we created it before so we don't need it anymore: we just delete it. - wxDC* uselessdc = PrintDialog( parent ); - delete uselessdc; + // doesn't necessarily show + int ret = dialog.ShowModal(); + if (ret == wxID_CANCEL) + { + sm_lastError = wxPRINTER_CANCELLED; + } + if (ret == wxID_NO) + { + sm_lastError = wxPRINTER_ERROR; + wxFAIL_MSG(_("The print dialog returned an error.")); + } g_object_unref (printOp); @@ -1023,13 +1033,11 @@ void wxGtkPrinter::DrawPage(wxPrintout *printout, GtkPrintOperation *operation, wxDC* wxGtkPrinter::PrintDialog( wxWindow *parent ) { wxGtkPrintDialog dialog( parent, &m_printDialogData ); - int ret; dialog.SetPrintDC(m_dc); + dialog.SetShowDialog(true); - dialog.SetShowDialog(m_showDialog); - - ret = dialog.ShowModal(); + int ret = dialog.ShowModal(); if (ret == wxID_CANCEL) { @@ -1073,13 +1081,11 @@ wxGtkPrintDC::wxGtkPrintDC( const wxPrintData& data ) m_gpc = native->GetPrintContext(); - // RR: what does this do? + // Match print quality to resolution (high = 1200dpi) m_resolution = m_printData.GetQuality(); // (int) gtk_print_context_get_dpi_x( m_gpc ); if (m_resolution < 0) m_resolution = (1 << (m_resolution+4)) *150; - wxPrintf( "resolution %d\n", m_resolution ); - m_PS2DEV = (double)m_resolution / 72.0; m_DEV2PS = 72.0 / (double)m_resolution; @@ -1093,11 +1099,12 @@ wxGtkPrintDC::wxGtkPrintDC( const wxPrintData& data ) m_currentBlue = 0; m_currentGreen = 0; - 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. - // 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) + // 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 ); gdouble ml, mt; ml = gtk_page_setup_get_left_margin (setup, GTK_UNIT_POINTS); @@ -1408,6 +1415,9 @@ void wxGtkPrintDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoo void wxGtkPrintDC::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)); @@ -1423,6 +1433,9 @@ void wxGtkPrintDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord void wxGtkPrintDC::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; @@ -1468,6 +1481,9 @@ void wxGtkPrintDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, w void wxGtkPrintDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { + width--; + height--; + gs_cairo->cairo_save (m_cairo); gs_cairo->cairo_new_path(m_cairo); @@ -1847,10 +1863,14 @@ void wxGtkPrintDC::SetPen( const wxPen& pen ) m_pen = pen; - double width = (double) m_pen.GetWidth(); - if (width == 0) width = 0.1; + double width; + + if (m_pen.GetWidth() <= 0) + width = 0.1; + else + width = (double) m_pen.GetWidth(); - gs_cairo->cairo_set_line_width( m_cairo, (width * m_PS2DEV) / m_scaleX ); + gs_cairo->cairo_set_line_width( m_cairo, width * m_DEV2PS * m_scaleX ); static const double dotted[] = {2.0, 5.0}; static const double short_dashed[] = {4.0, 4.0}; static const double long_dashed[] = {4.0, 8.0};