X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12bba77343654dc309a69ca2bcb5e0041c658395..bfdaa9173ed5b20dd5a9cd83241ce44fc0eff960:/src/univ/dialog.cpp diff --git a/src/univ/dialog.cpp b/src/univ/dialog.cpp index 0f5e47b9a4..f12d20baa1 100644 --- a/src/univ/dialog.cpp +++ b/src/univ/dialog.cpp @@ -1,7 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/univ/dialog.cpp // Author: Robert Roebling, Vaclav Slavik -// Id: $Id$ // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,10 +13,6 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation "univdialog.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -25,13 +20,15 @@ #pragma hdrstop #endif +#include "wx/dialog.h" + #ifndef WX_PRECOMP - #include "wx/dialog.h" #include "wx/utils.h" #include "wx/app.h" #endif #include "wx/evtloop.h" +#include "wx/modalhook.h" //----------------------------------------------------------------------------- // wxDialog @@ -44,18 +41,19 @@ BEGIN_EVENT_TABLE(wxDialog,wxDialogBase) EVT_CLOSE (wxDialog::OnCloseWindow) END_EVENT_TABLE() -IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxTopLevelWindow) - void wxDialog::Init() { m_returnCode = 0; m_windowDisabler = NULL; m_eventLoop = NULL; - m_isShowingModal = FALSE; + m_isShowingModal = false; } wxDialog::~wxDialog() { + // if the dialog is modal, this will end its event loop + Show(false); + delete m_eventLoop; } @@ -74,7 +72,7 @@ bool wxDialog::Create(wxWindow *parent, void wxDialog::OnApply(wxCommandEvent &WXUNUSED(event)) { - if ( Validate() ) + if ( Validate() ) TransferDataFromWindow(); } @@ -87,7 +85,7 @@ void wxDialog::OnCancel(wxCommandEvent &WXUNUSED(event)) else { SetReturnCode(wxID_CANCEL); - Show(FALSE); + Show(false); } } @@ -102,7 +100,7 @@ void wxDialog::OnOK(wxCommandEvent &WXUNUSED(event)) else { SetReturnCode(wxID_OK); - Show(FALSE); + Show(false); } } } @@ -130,7 +128,7 @@ void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) s_closing.Append(this); - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + wxCommandEvent cancelEvent(wxEVT_BUTTON, wxID_CANCEL); cancelEvent.SetEventObject(this); GetEventHandler()->ProcessEvent(cancelEvent); s_closing.DeleteObject(this); @@ -143,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; @@ -166,13 +163,10 @@ bool wxDialog::IsModal() const return m_isShowingModal; } -void wxDialog::SetModal(bool WXUNUSED(flag)) -{ - wxFAIL_MSG( wxT("wxDialog:SetModal obsolete now") ); -} - int wxDialog::ShowModal() { + WX_HOOK_MODAL_DIALOG(); + if ( IsModal() ) { wxFAIL_MSG( wxT("wxDialog:ShowModal called twice") ); @@ -181,20 +175,21 @@ 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); + Show(true); + + m_isShowingModal = true; - m_isShowingModal = TRUE; + wxASSERT_MSG( !m_windowDisabler, wxT("disabling windows twice?") ); - wxASSERT_MSG( !m_windowDisabler, _T("disabling windows twice?") ); +#if defined(__WXGTK__) + wxBusyCursorSuspender suspender; +#endif m_windowDisabler = new wxWindowDisabler(this); if ( !m_eventLoop ) @@ -207,7 +202,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); @@ -217,9 +212,9 @@ void wxDialog::EndModal(int retCode) return; } - m_isShowingModal = FALSE; - + m_isShowingModal = false; + m_eventLoop->Exit(); - Show(FALSE); + Show(false); }