X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/39bc0347fda3505f7fb43447f21efd84b9e00b3c..850df2d78866c3edcf848103b5dbc7e7fa1ee5fa:/src/common/dlgcmn.cpp diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 67b0c89f10..5621cbc6a9 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -27,6 +27,7 @@ #include "wx/dialog.h" #ifndef WX_PRECOMP + #include "wx/app.h" #include "wx/button.h" #include "wx/dcclient.h" #include "wx/intl.h" @@ -51,12 +52,8 @@ BEGIN_EVENT_TABLE(wxDialogBase, wxTopLevelWindow) EVT_CLOSE(wxDialogBase::OnCloseWindow) EVT_CHAR_HOOK(wxDialogBase::OnCharHook) - - WX_EVENT_TABLE_CONTROL_CONTAINER(wxDialogBase) END_EVENT_TABLE() -WX_DELEGATE_TO_CONTROL_CONTAINER(wxDialogBase, wxTopLevelWindow) - void wxDialogBase::Init() { m_returnCode = 0; @@ -67,8 +64,36 @@ void wxDialogBase::Init() // dialog controls from reaching the parent frame which is usually // undesirable and can lead to unexpected and hard to find bugs SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS); +} + +// helper of GetParentForModalDialog() +static bool CanBeUsedAsParent(wxWindow *parent) +{ + extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete; + + return !parent->HasExtraStyle(wxWS_EX_TRANSIENT) && + parent->IsShownOnScreen() && + !wxPendingDelete.Member(parent) && + !parent->IsBeingDeleted(); +} + +wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const +{ + // creating a parent-less modal dialog will result (under e.g. wxGTK2) + // in an unfocused dialog, so try to find a valid parent for it: + if ( parent ) + parent = wxGetTopLevelParent(parent); + + if ( !parent || !CanBeUsedAsParent(parent) ) + parent = wxTheApp->GetTopWindow(); + + if ( parent && !CanBeUsedAsParent(parent) ) + { + // can't use this one, it's going to disappear + parent = NULL; + } - WX_INIT_CONTROL_CONTAINER(); + return parent; } #if wxUSE_STATTEXT @@ -167,7 +192,9 @@ wxSizer *wxDialogBase::CreateButtonSizer(long flags) { sizer = CreateStdDialogButtonSizer(flags); } -#endif // wxUSE_BUTTON +#else // !wxUSE_BUTTON + wxUnusedVar(flags); +#endif // wxUSE_BUTTON/!wxUSE_BUTTON #endif // __SMARTPHONE__/!__SMARTPHONE__ @@ -227,6 +254,18 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) sizer->AddButton(no); } + if (flags & wxAPPLY) + { + wxButton *apply = new wxButton(this, wxID_APPLY); + sizer->AddButton(apply); + } + + if (flags & wxCLOSE) + { + wxButton *close = new wxButton(this, wxID_CLOSE); + sizer->AddButton(close); + } + if (flags & wxHELP) { wxButton *help = new wxButton(this, wxID_HELP); @@ -411,8 +450,12 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) closing.DeleteObject(this); } -void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) +void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& event) { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); - Refresh(); +#ifndef __WXGTK__ + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); + Refresh(); +#endif + + event.Skip(); }