X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fdf565feca722eddb84168a95dbef329ba23d719..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/univ/dialog.cpp diff --git a/src/univ/dialog.cpp b/src/univ/dialog.cpp index 50fa18cacf..c8b9e7aa7d 100644 --- a/src/univ/dialog.cpp +++ b/src/univ/dialog.cpp @@ -41,8 +41,6 @@ BEGIN_EVENT_TABLE(wxDialog,wxDialogBase) EVT_CLOSE (wxDialog::OnCloseWindow) END_EVENT_TABLE() -IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxTopLevelWindow) - void wxDialog::Init() { m_returnCode = 0; @@ -53,6 +51,9 @@ void wxDialog::Init() wxDialog::~wxDialog() { + // if the dialog is modal, this will end its event loop + Show(false); + delete m_eventLoop; } @@ -71,7 +72,7 @@ bool wxDialog::Create(wxWindow *parent, void wxDialog::OnApply(wxCommandEvent &WXUNUSED(event)) { - if ( Validate() ) + if ( Validate() ) TransferDataFromWindow(); } @@ -140,19 +141,18 @@ bool wxDialog::Show(bool show) // if we had disabled other app windows, reenable them back now because // if they stay disabled Windows will activate another window (one // which is enabled, anyhow) and we will lose activation - if ( m_windowDisabler ) - { - delete m_windowDisabler; - m_windowDisabler = NULL; - } + wxDELETE(m_windowDisabler); if ( IsModal() ) EndModal(wxID_CANCEL); } + if (show && CanDoLayoutAdaptation()) + DoLayoutAdaptation(); + bool ret = wxDialogBase::Show(show); - if ( show ) + if ( show ) InitDialog(); return ret; @@ -173,24 +173,20 @@ int wxDialog::ShowModal() // use the apps top level window as parent if none given unless explicitly // forbidden - if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) + wxWindow * const parent = GetParentForModalDialog(); + if ( parent && parent != this ) { - wxWindow *parent = wxTheApp->GetTopWindow(); - if ( parent && parent != this ) - { - m_parent = parent; - } + m_parent = parent; } Show(true); m_isShowingModal = true; - wxASSERT_MSG( !m_windowDisabler, _T("disabling windows twice?") ); + wxASSERT_MSG( !m_windowDisabler, wxT("disabling windows twice?") ); -#if defined(__WXGTK__) || defined(__WXMGL__) +#if defined(__WXGTK__) wxBusyCursorSuspender suspender; - // FIXME (FIXME_MGL) - make sure busy cursor disappears under MSW too #endif m_windowDisabler = new wxWindowDisabler(this); @@ -204,7 +200,7 @@ int wxDialog::ShowModal() void wxDialog::EndModal(int retCode) { - wxASSERT_MSG( m_eventLoop, _T("wxDialog is not modal") ); + wxASSERT_MSG( m_eventLoop, wxT("wxDialog is not modal") ); SetReturnCode(retCode);