Create new instance of wxPrintDC in wxGtkPrintDialog

GetPrintDC() should return a new device context created by the print
dialog, not the duplicate of existing context passed from the caller
(e.g. from wxGtkPrinter) through SetPrintDC(). Therefore SetPrintDC() is
no longer useful and can be removed.
This commit is contained in:
Artur Wieczorek
2017-05-28 23:05:34 +02:00
parent 91cb0b4875
commit 79a7fa0330
2 changed files with 12 additions and 7 deletions

View File

@@ -80,8 +80,7 @@ public:
wxPrintDialogData& GetPrintDialogData() wxOVERRIDE wxPrintDialogData& GetPrintDialogData() wxOVERRIDE
{ return m_printDialogData; } { return m_printDialogData; }
wxDC *GetPrintDC() wxOVERRIDE { return m_dc; } wxDC *GetPrintDC() wxOVERRIDE;
void SetPrintDC(wxDC * printDC) { m_dc = printDC; }
virtual int ShowModal() wxOVERRIDE; virtual int ShowModal() wxOVERRIDE;
@@ -105,7 +104,6 @@ private:
wxPrintDialogData m_printDialogData; wxPrintDialogData m_printDialogData;
wxWindow *m_parent; wxWindow *m_parent;
bool m_showDialog; bool m_showDialog;
wxDC *m_dc;
wxDECLARE_DYNAMIC_CLASS(wxGtkPrintDialog); wxDECLARE_DYNAMIC_CLASS(wxGtkPrintDialog);
}; };

View File

@@ -771,6 +771,11 @@ int wxGtkPrintDialog::ShowModal()
return wxID_OK; return wxID_OK;
} }
wxDC* wxGtkPrintDialog::GetPrintDC()
{
return new wxPrinterDC(m_printDialogData.GetPrintData());
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// wxGtkPageSetupDialog // wxGtkPageSetupDialog
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -967,7 +972,6 @@ bool wxGtkPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
// This is used to setup the DC and // This is used to setup the DC and
// show the dialog if desired // show the dialog if desired
dialog.SetPrintDC(m_dc);
dialog.SetShowDialog(prompt); dialog.SetShowDialog(prompt);
// doesn't necessarily show // doesn't necessarily show
@@ -1153,7 +1157,6 @@ wxDC* wxGtkPrinter::PrintDialog( wxWindow *parent )
{ {
wxGtkPrintDialog dialog( parent, &m_printDialogData ); wxGtkPrintDialog dialog( parent, &m_printDialogData );
dialog.SetPrintDC(m_dc);
dialog.SetShowDialog(true); dialog.SetShowDialog(true);
int ret = dialog.ShowModal(); int ret = dialog.ShowModal();
@@ -1169,9 +1172,13 @@ wxDC* wxGtkPrinter::PrintDialog( wxWindow *parent )
return NULL; return NULL;
} }
wxDC* dc = dialog.GetPrintDC();
if ( dc )
{
m_printDialogData = dialog.GetPrintDialogData(); m_printDialogData = dialog.GetPrintDialogData();
}
return new wxPrinterDC( m_printDialogData.GetPrintData() ); return dc;
} }
bool wxGtkPrinter::Setup( wxWindow * WXUNUSED(parent) ) bool wxGtkPrinter::Setup( wxWindow * WXUNUSED(parent) )