From: Václav Slavík Date: Thu, 9 Aug 2012 15:52:04 +0000 (+0000) Subject: Create wxPrintAbortDialog more sensibly. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1a19b3210d97b2c8ad8f3621334cdcd99d5e172a?ds=inline Create wxPrintAbortDialog more sensibly. Instead of having an empty constructor and filling the dialog with controls from outside, do the work in the constructor. This changes the meaning of ctor's 'title' argument, but this class' terrible API made it unusable for direct use anyway, so it doesn't seem to be harmful. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72305 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/prntbase.h b/include/wx/prntbase.h index ac78189a42..c40358006d 100644 --- a/include/wx/prntbase.h +++ b/include/wx/prntbase.h @@ -733,14 +733,11 @@ class WXDLLIMPEXP_CORE wxPrintAbortDialog: public wxDialog { public: wxPrintAbortDialog(wxWindow *parent, - const wxString& title, + const wxString& documentTitle, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxT("dialog")) - : wxDialog(parent, wxID_ANY, title, pos, size, style, name) - { - } + long style = wxDEFAULT_DIALOG_STYLE, + const wxString& name = wxT("dialog")); void OnCancel(wxCommandEvent& event); diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index b1bb44c064..fb640b2af5 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -323,19 +323,7 @@ wxPrinterBase::~wxPrinterBase() wxWindow *wxPrinterBase::CreateAbortWindow(wxWindow *parent, wxPrintout * printout) { - wxPrintAbortDialog *dialog = new wxPrintAbortDialog(parent, _("Printing ") , wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE); - - wxBoxSizer *button_sizer = new wxBoxSizer( wxVERTICAL ); - button_sizer->Add( new wxStaticText(dialog, wxID_ANY, _("Please wait while printing\n") + printout->GetTitle() ), 0, wxALL, 10 ); - button_sizer->Add( new wxButton( dialog, wxID_CANCEL, wxT("Cancel") ), 0, wxALL | wxALIGN_CENTER, 10 ); - - dialog->SetAutoLayout( true ); - dialog->SetSizer( button_sizer ); - - button_sizer->Fit(dialog); - button_sizer->SetSizeHints (dialog) ; - - return dialog; + return new wxPrintAbortDialog(parent, printout->GetTitle()); } void wxPrinterBase::ReportError(wxWindow *parent, wxPrintout *WXUNUSED(printout), const wxString& message) @@ -522,6 +510,25 @@ BEGIN_EVENT_TABLE(wxPrintAbortDialog, wxDialog) EVT_BUTTON(wxID_CANCEL, wxPrintAbortDialog::OnCancel) END_EVENT_TABLE() +wxPrintAbortDialog::wxPrintAbortDialog(wxWindow *parent, + const wxString& documentTitle, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) + : wxDialog(parent, wxID_ANY, _("Printing"), pos, size, style, name) +{ + wxBoxSizer *button_sizer = new wxBoxSizer(wxVERTICAL); + button_sizer->Add(new wxStaticText(this, wxID_ANY, _("Please wait while printing\n") + documentTitle), 0, wxALL, 10 ); + button_sizer->Add(new wxButton(this, wxID_CANCEL, wxT("Cancel") ), 0, wxALL | wxALIGN_CENTER, 10); + + SetAutoLayout(true); + SetSizer(button_sizer); + + button_sizer->Fit(this); + button_sizer->SetSizeHints(this); +} + void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { wxPrinterBase::sm_abortIt = true;