From: Vadim Zeitlin Date: Sun, 26 Apr 2009 13:41:21 +0000 (+0000) Subject: add parent parameter to wxAboutBox() (closes #9952) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c173e541b8ffb01ad0992a4f4c991be9e95db2ba add parent parameter to wxAboutBox() (closes #9952) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60389 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/aboutdlg.h b/include/wx/aboutdlg.h index 44e86b06f6..8a4ccb36a1 100644 --- a/include/wx/aboutdlg.h +++ b/include/wx/aboutdlg.h @@ -151,7 +151,7 @@ private: }; // functions to show the about dialog box -WXDLLIMPEXP_ADV void wxAboutBox(const wxAboutDialogInfo& info); +WXDLLIMPEXP_ADV void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = NULL); #endif // wxUSE_ABOUTDLG diff --git a/include/wx/generic/aboutdlgg.h b/include/wx/generic/aboutdlgg.h index c275ed7ba7..e45fc24d0d 100644 --- a/include/wx/generic/aboutdlgg.h +++ b/include/wx/generic/aboutdlgg.h @@ -35,15 +35,15 @@ public: wxGenericAboutDialog() { Init(); } // ctor which fully initializes the object - wxGenericAboutDialog(const wxAboutDialogInfo& info) + wxGenericAboutDialog(const wxAboutDialogInfo& info, wxWindow* parent = NULL) { Init(); - (void)Create(info); + (void)Create(info, parent); } // this method must be called if and only if the default ctor was used - bool Create(const wxAboutDialogInfo& info); + bool Create(const wxAboutDialogInfo& info, wxWindow* parent = NULL); protected: // this virtual method may be overridden to add some more controls to the @@ -79,7 +79,7 @@ private: // unlike wxAboutBox which can show either the native or generic about dialog, // this function always shows the generic one -WXDLLIMPEXP_ADV void wxGenericAboutBox(const wxAboutDialogInfo& info); +WXDLLIMPEXP_ADV void wxGenericAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = NULL); #endif // wxUSE_ABOUTDLG diff --git a/interface/wx/aboutdlg.h b/interface/wx/aboutdlg.h index 7342a3ed0a..9d19a3f2fe 100644 --- a/interface/wx/aboutdlg.h +++ b/interface/wx/aboutdlg.h @@ -201,7 +201,7 @@ public: @header{wx/aboutdlg.h} */ -void wxAboutBox(const wxAboutDialogInfo& info); +void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = NULL); /** This function does the same thing as wxAboutBox() except that it always uses @@ -218,6 +218,6 @@ void wxAboutBox(const wxAboutDialogInfo& info); @header{wx/aboutdlg.h} */ -void wxGenericAboutBox(const wxAboutDialogInfo& info); +void wxGenericAboutBox(const wxAboutDialogInfo& info, wxWindow* parent = NULL); //@} diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index ceed79323d..f9dbb0a3cc 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -1741,7 +1741,7 @@ void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event)) wxAboutDialogInfo info; InitAboutInfoMinimal(info); - wxAboutBox(info); + wxAboutBox(info, this); } void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event)) @@ -1749,7 +1749,7 @@ void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event)) wxAboutDialogInfo info; InitAboutInfoWebsite(info); - wxAboutBox(info); + wxAboutBox(info, this); } void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event)) @@ -1757,16 +1757,16 @@ void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event)) wxAboutDialogInfo info; InitAboutInfoAll(info); - wxAboutBox(info); + wxAboutBox(info, this); } // a trivial example of a custom dialog class class MyAboutDialog : public wxGenericAboutDialog { public: - MyAboutDialog(const wxAboutDialogInfo& info) + MyAboutDialog(const wxAboutDialogInfo& info, wxWindow* parent) { - Create(info); + Create(info, parent); } // add some custom controls @@ -1783,7 +1783,7 @@ void MyFrame::ShowCustomAboutDialog(wxCommandEvent& WXUNUSED(event)) wxAboutDialogInfo info; InitAboutInfoAll(info); - MyAboutDialog dlg(info); + MyAboutDialog dlg(info, this); dlg.ShowModal(); } diff --git a/src/generic/aboutdlgg.cpp b/src/generic/aboutdlgg.cpp index 1992228b6d..a30e613070 100644 --- a/src/generic/aboutdlgg.cpp +++ b/src/generic/aboutdlgg.cpp @@ -113,10 +113,9 @@ wxString wxAboutDialogInfo::GetCopyrightToDisplay() const // wxGenericAboutDialog // ---------------------------------------------------------------------------- -bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info) +bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* parent) { - // this is a modal dialog thus we'll use GetParentForModalDialog: - if ( !wxDialog::Create(GetParentForModalDialog(), wxID_ANY, _("About ") + info.GetName(), + if ( !wxDialog::Create(parent, wxID_ANY, _("About ") + info.GetName(), wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE) ) return false; @@ -196,7 +195,7 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info) SetSizerAndFit(sizerTop); - CentreOnScreen(); + CentreOnParent(); return true; } @@ -240,10 +239,10 @@ void wxGenericAboutDialog::AddCollapsiblePane(const wxString& title, // public functions // ---------------------------------------------------------------------------- -void wxGenericAboutBox(const wxAboutDialogInfo& info) +void wxGenericAboutBox(const wxAboutDialogInfo& info, wxWindow* parent) { #if !defined(__WXGTK__) && !defined(__WXMAC__) - wxGenericAboutDialog dlg(info); + wxGenericAboutDialog dlg(info, parent); dlg.ShowModal(); #else wxGenericAboutDialog* dlg = new wxGenericAboutDialog(info); @@ -255,9 +254,9 @@ void wxGenericAboutBox(const wxAboutDialogInfo& info) // the others we provide a generic fallback here #if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXGTK26__) -void wxAboutBox(const wxAboutDialogInfo& info) +void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent) { - wxGenericAboutBox(info); + wxGenericAboutBox(info, parent); } #endif // platforms without native about dialog diff --git a/src/gtk/aboutdlg.cpp b/src/gtk/aboutdlg.cpp index 1094233cd8..a6fc079e05 100644 --- a/src/gtk/aboutdlg.cpp +++ b/src/gtk/aboutdlg.cpp @@ -109,7 +109,7 @@ wxGtkAboutDialogOnLink(GtkAboutDialog * WXUNUSED(about), wxLaunchDefaultBrowser(wxGTK_CONV_BACK_SYS(link)); } -void wxAboutBox(const wxAboutDialogInfo& info) +void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent)) { if ( !gtk_check_version(2,6,0) ) { diff --git a/src/msw/aboutdlg.cpp b/src/msw/aboutdlg.cpp index 5f556453fe..123e9823e0 100644 --- a/src/msw/aboutdlg.cpp +++ b/src/msw/aboutdlg.cpp @@ -37,7 +37,7 @@ // ============================================================================ // our public entry point -void wxAboutBox(const wxAboutDialogInfo& info) +void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent) { // we prefer to show a simple message box if we don't have any fields which // can't be shown in it because as much as there is a standard about box @@ -62,12 +62,12 @@ void wxAboutBox(const wxAboutDialogInfo& info) // add everything remaining msg << info.GetDescriptionAndCredits(); - wxMessageBox(msg, wxString::Format(_("About %s"), name)); + wxMessageBox(msg, wxString::Format(_("About %s"), name, wxOK | wxCENTRE, parent)); } else // simple "native" version is not enough { // we need to use the full-blown generic version - wxGenericAboutBox(info); + wxGenericAboutBox(info, parent); } } diff --git a/src/osx/carbon/aboutdlg.cpp b/src/osx/carbon/aboutdlg.cpp index 9188a221c7..81cff671e5 100644 --- a/src/osx/carbon/aboutdlg.cpp +++ b/src/osx/carbon/aboutdlg.cpp @@ -56,7 +56,7 @@ public: // implementation // ============================================================================ -void wxAboutBox(const wxAboutDialogInfo& info) +void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent)) { // Mac native about box currently can show only name, version, copyright // and description fields and we also shoehorn the credits text into the