From 0be7709e711626996060757eb62fa506cf3d9e06 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Thu, 18 Nov 2004 14:45:40 +0000 Subject: [PATCH] Added support for native print preview (GNOME) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/gnome/gprint.h | 1 + include/wx/gtk1/gnome/gprint.h | 1 + src/gtk/gnome/gprint.cpp | 23 +++++++++++++++++++++-- src/gtk1/gnome/gprint.cpp | 23 +++++++++++++++++++++-- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/wx/gtk/gnome/gprint.h b/include/wx/gtk/gnome/gprint.h index aa40765418..77e924d711 100644 --- a/include/wx/gtk/gnome/gprint.h +++ b/include/wx/gtk/gnome/gprint.h @@ -150,6 +150,7 @@ public: private: GnomePrintContext *m_gpc; + bool m_native_preview; private: DECLARE_DYNAMIC_CLASS(wxGnomePrinter) diff --git a/include/wx/gtk1/gnome/gprint.h b/include/wx/gtk1/gnome/gprint.h index aa40765418..77e924d711 100644 --- a/include/wx/gtk1/gnome/gprint.h +++ b/include/wx/gtk1/gnome/gprint.h @@ -150,6 +150,7 @@ public: private: GnomePrintContext *m_gpc; + bool m_native_preview; private: DECLARE_DYNAMIC_CLASS(wxGnomePrinter) diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index c79170f630..2f35e43987 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -31,6 +31,7 @@ #include #include #include +#include //---------------------------------------------------------------------------- // wxGnomePrintNativeData @@ -242,6 +243,9 @@ int wxGnomePrintDialog::ShowModal() gtk_widget_destroy(m_widget); m_widget = NULL; + if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW) + return wxID_PREVIEW; + return wxID_OK; } @@ -276,6 +280,7 @@ wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) : wxPrinterBase( data ) { m_gpc = NULL; + m_native_preview = false; } wxGnomePrinter::~wxGnomePrinter() @@ -313,6 +318,9 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) else dc = new wxGnomePrintDC( this ); + if (m_native_preview) + printout->SetIsPreview(true); + if (!dc) { gnome_print_job_close( job ); @@ -387,7 +395,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) } gnome_print_job_close( job ); - gnome_print_job_print( job ); + if (m_native_preview) + { + wxString title( _("Print preview") ); + gtk_widget_show( gnome_print_job_preview_new( job, (const guchar*)(const char*)wxGTK_CONV(title) )); + } + else + { + gnome_print_job_print( job ); + } delete dc; @@ -397,12 +413,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent ) { wxGnomePrintDialog dialog( parent, &m_printDialogData ); - if (dialog.ShowModal() == wxID_CANCEL) + int ret = dialog.ShowModal(); + if (ret == wxID_CANCEL) { sm_lastError = wxPRINTER_ERROR; return NULL; } + m_native_preview = ret == wxID_PREVIEW; + m_printDialogData = dialog.GetPrintDialogData(); return new wxGnomePrintDC( this ); } diff --git a/src/gtk1/gnome/gprint.cpp b/src/gtk1/gnome/gprint.cpp index c79170f630..2f35e43987 100644 --- a/src/gtk1/gnome/gprint.cpp +++ b/src/gtk1/gnome/gprint.cpp @@ -31,6 +31,7 @@ #include #include #include +#include //---------------------------------------------------------------------------- // wxGnomePrintNativeData @@ -242,6 +243,9 @@ int wxGnomePrintDialog::ShowModal() gtk_widget_destroy(m_widget); m_widget = NULL; + if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW) + return wxID_PREVIEW; + return wxID_OK; } @@ -276,6 +280,7 @@ wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) : wxPrinterBase( data ) { m_gpc = NULL; + m_native_preview = false; } wxGnomePrinter::~wxGnomePrinter() @@ -313,6 +318,9 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) else dc = new wxGnomePrintDC( this ); + if (m_native_preview) + printout->SetIsPreview(true); + if (!dc) { gnome_print_job_close( job ); @@ -387,7 +395,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) } gnome_print_job_close( job ); - gnome_print_job_print( job ); + if (m_native_preview) + { + wxString title( _("Print preview") ); + gtk_widget_show( gnome_print_job_preview_new( job, (const guchar*)(const char*)wxGTK_CONV(title) )); + } + else + { + gnome_print_job_print( job ); + } delete dc; @@ -397,12 +413,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent ) { wxGnomePrintDialog dialog( parent, &m_printDialogData ); - if (dialog.ShowModal() == wxID_CANCEL) + int ret = dialog.ShowModal(); + if (ret == wxID_CANCEL) { sm_lastError = wxPRINTER_ERROR; return NULL; } + m_native_preview = ret == wxID_PREVIEW; + m_printDialogData = dialog.GetPrintDialogData(); return new wxGnomePrintDC( this ); } -- 2.45.2