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:
Robert Roebling 2004-11-18 14:45:40 +00:00
parent ae4bd80aa0
commit 0be7709e71
4 changed files with 44 additions and 4 deletions

View File

@ -150,6 +150,7 @@ public:
private:
GnomePrintContext *m_gpc;
bool m_native_preview;
private:
DECLARE_DYNAMIC_CLASS(wxGnomePrinter)

View File

@ -150,6 +150,7 @@ public:
private:
GnomePrintContext *m_gpc;
bool m_native_preview;
private:
DECLARE_DYNAMIC_CLASS(wxGnomePrinter)

View File

@ -31,6 +31,7 @@
#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-print-pango.h>
#include <libgnomeprintui/gnome-print-dialog.h>
#include <libgnomeprintui/gnome-print-job-preview.h>
//----------------------------------------------------------------------------
// 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 );
}

View File

@ -31,6 +31,7 @@
#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-print-pango.h>
#include <libgnomeprintui/gnome-print-dialog.h>
#include <libgnomeprintui/gnome-print-job-preview.h>
//----------------------------------------------------------------------------
// 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 );
}