Added support for native print preview (GNOME)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -150,6 +150,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
GnomePrintContext *m_gpc;
|
GnomePrintContext *m_gpc;
|
||||||
|
bool m_native_preview;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
|
DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
|
||||||
|
@@ -150,6 +150,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
GnomePrintContext *m_gpc;
|
GnomePrintContext *m_gpc;
|
||||||
|
bool m_native_preview;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
|
DECLARE_DYNAMIC_CLASS(wxGnomePrinter)
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <libgnomeprint/gnome-print.h>
|
#include <libgnomeprint/gnome-print.h>
|
||||||
#include <libgnomeprint/gnome-print-pango.h>
|
#include <libgnomeprint/gnome-print-pango.h>
|
||||||
#include <libgnomeprintui/gnome-print-dialog.h>
|
#include <libgnomeprintui/gnome-print-dialog.h>
|
||||||
|
#include <libgnomeprintui/gnome-print-job-preview.h>
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// wxGnomePrintNativeData
|
// wxGnomePrintNativeData
|
||||||
@@ -242,6 +243,9 @@ int wxGnomePrintDialog::ShowModal()
|
|||||||
gtk_widget_destroy(m_widget);
|
gtk_widget_destroy(m_widget);
|
||||||
m_widget = NULL;
|
m_widget = NULL;
|
||||||
|
|
||||||
|
if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW)
|
||||||
|
return wxID_PREVIEW;
|
||||||
|
|
||||||
return wxID_OK;
|
return wxID_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,6 +280,7 @@ wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) :
|
|||||||
wxPrinterBase( data )
|
wxPrinterBase( data )
|
||||||
{
|
{
|
||||||
m_gpc = NULL;
|
m_gpc = NULL;
|
||||||
|
m_native_preview = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGnomePrinter::~wxGnomePrinter()
|
wxGnomePrinter::~wxGnomePrinter()
|
||||||
@@ -313,6 +318,9 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
|||||||
else
|
else
|
||||||
dc = new wxGnomePrintDC( this );
|
dc = new wxGnomePrintDC( this );
|
||||||
|
|
||||||
|
if (m_native_preview)
|
||||||
|
printout->SetIsPreview(true);
|
||||||
|
|
||||||
if (!dc)
|
if (!dc)
|
||||||
{
|
{
|
||||||
gnome_print_job_close( job );
|
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_close( 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 );
|
gnome_print_job_print( job );
|
||||||
|
}
|
||||||
|
|
||||||
delete dc;
|
delete dc;
|
||||||
|
|
||||||
@@ -397,12 +413,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
|||||||
wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
|
wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
|
||||||
{
|
{
|
||||||
wxGnomePrintDialog dialog( parent, &m_printDialogData );
|
wxGnomePrintDialog dialog( parent, &m_printDialogData );
|
||||||
if (dialog.ShowModal() == wxID_CANCEL)
|
int ret = dialog.ShowModal();
|
||||||
|
if (ret == wxID_CANCEL)
|
||||||
{
|
{
|
||||||
sm_lastError = wxPRINTER_ERROR;
|
sm_lastError = wxPRINTER_ERROR;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_native_preview = ret == wxID_PREVIEW;
|
||||||
|
|
||||||
m_printDialogData = dialog.GetPrintDialogData();
|
m_printDialogData = dialog.GetPrintDialogData();
|
||||||
return new wxGnomePrintDC( this );
|
return new wxGnomePrintDC( this );
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <libgnomeprint/gnome-print.h>
|
#include <libgnomeprint/gnome-print.h>
|
||||||
#include <libgnomeprint/gnome-print-pango.h>
|
#include <libgnomeprint/gnome-print-pango.h>
|
||||||
#include <libgnomeprintui/gnome-print-dialog.h>
|
#include <libgnomeprintui/gnome-print-dialog.h>
|
||||||
|
#include <libgnomeprintui/gnome-print-job-preview.h>
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// wxGnomePrintNativeData
|
// wxGnomePrintNativeData
|
||||||
@@ -242,6 +243,9 @@ int wxGnomePrintDialog::ShowModal()
|
|||||||
gtk_widget_destroy(m_widget);
|
gtk_widget_destroy(m_widget);
|
||||||
m_widget = NULL;
|
m_widget = NULL;
|
||||||
|
|
||||||
|
if (response == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW)
|
||||||
|
return wxID_PREVIEW;
|
||||||
|
|
||||||
return wxID_OK;
|
return wxID_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,6 +280,7 @@ wxGnomePrinter::wxGnomePrinter( wxPrintDialogData *data ) :
|
|||||||
wxPrinterBase( data )
|
wxPrinterBase( data )
|
||||||
{
|
{
|
||||||
m_gpc = NULL;
|
m_gpc = NULL;
|
||||||
|
m_native_preview = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGnomePrinter::~wxGnomePrinter()
|
wxGnomePrinter::~wxGnomePrinter()
|
||||||
@@ -313,6 +318,9 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
|||||||
else
|
else
|
||||||
dc = new wxGnomePrintDC( this );
|
dc = new wxGnomePrintDC( this );
|
||||||
|
|
||||||
|
if (m_native_preview)
|
||||||
|
printout->SetIsPreview(true);
|
||||||
|
|
||||||
if (!dc)
|
if (!dc)
|
||||||
{
|
{
|
||||||
gnome_print_job_close( job );
|
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_close( 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 );
|
gnome_print_job_print( job );
|
||||||
|
}
|
||||||
|
|
||||||
delete dc;
|
delete dc;
|
||||||
|
|
||||||
@@ -397,12 +413,15 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
|||||||
wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
|
wxDC* wxGnomePrinter::PrintDialog( wxWindow *parent )
|
||||||
{
|
{
|
||||||
wxGnomePrintDialog dialog( parent, &m_printDialogData );
|
wxGnomePrintDialog dialog( parent, &m_printDialogData );
|
||||||
if (dialog.ShowModal() == wxID_CANCEL)
|
int ret = dialog.ShowModal();
|
||||||
|
if (ret == wxID_CANCEL)
|
||||||
{
|
{
|
||||||
sm_lastError = wxPRINTER_ERROR;
|
sm_lastError = wxPRINTER_ERROR;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_native_preview = ret == wxID_PREVIEW;
|
||||||
|
|
||||||
m_printDialogData = dialog.GetPrintDialogData();
|
m_printDialogData = dialog.GetPrintDialogData();
|
||||||
return new wxGnomePrintDC( this );
|
return new wxGnomePrintDC( this );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user