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
{ return m_printDialogData; }
wxDC *GetPrintDC() wxOVERRIDE { return m_dc; }
void SetPrintDC(wxDC * printDC) { m_dc = printDC; }
wxDC *GetPrintDC() wxOVERRIDE;
virtual int ShowModal() wxOVERRIDE;
@ -105,7 +104,6 @@ private:
wxPrintDialogData m_printDialogData;
wxWindow *m_parent;
bool m_showDialog;
wxDC *m_dc;
wxDECLARE_DYNAMIC_CLASS(wxGtkPrintDialog);
};

View File

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