X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cbab1556578ae39b1f00e0c4f6ca8016ac8124ac..75a2c6a1ee034a5d866b4a121a97351603bce98b:/src/osx/dialog_osx.cpp diff --git a/src/osx/dialog_osx.cpp b/src/osx/dialog_osx.cpp index c51035b969..1408ea0fb3 100644 --- a/src/osx/dialog_osx.cpp +++ b/src/osx/dialog_osx.cpp @@ -32,7 +32,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow) void wxDialog::Init() { - m_isModalStyle = false; + m_modality = wxDIALOG_MODALITY_NONE; } bool wxDialog::Create( wxWindow *parent, @@ -57,18 +57,6 @@ bool wxDialog::Create( wxWindow *parent, return true; } -void wxDialog::SetModal( bool flag ) -{ - if ( flag ) - { - m_isModalStyle = true; - } - else - { - m_isModalStyle = false; - } -} - wxDialog::~wxDialog() { SendDestroyEvent(); @@ -89,16 +77,23 @@ bool wxDialog::IsEscapeKey(const wxKeyEvent& event) bool wxDialog::IsModal() const { - return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast - // return m_isModalStyle; + return m_modality != wxDIALOG_MODALITY_NONE; } - bool wxDialog::Show(bool show) { - if ( !wxDialogBase::Show(show) ) - // nothing to do - return false; + if ( m_modality == wxDIALOG_MODALITY_WINDOW_MODAL ) + { + if ( !wxWindow::Show(show) ) + // nothing to do + return false; + } + else + { + if ( !wxDialogBase::Show(show) ) + // nothing to do + return false; + } if (show && CanDoLayoutAdaptation()) DoLayoutAdaptation(); @@ -107,43 +102,54 @@ bool wxDialog::Show(bool show) // usually will result in TransferDataToWindow() being called InitDialog(); - if ( m_isModalStyle ) + if ( !show ) { - if ( show ) - { - DoShowModal(); - } - else // end of modal dialog + switch( m_modality ) { - // this will cause IsModalShowing() return false and our local - // message loop will terminate - wxModalDialogs.DeleteObject(this); + case wxDIALOG_MODALITY_WINDOW_MODAL: + EndWindowModal(); // OS X implementation method for cleanup + SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED ); + break; + default: + break; } + m_modality = wxDIALOG_MODALITY_NONE; } - + return true; } // Replacement for Show(true) for modal dialogs - returns return code int wxDialog::ShowModal() { - if ( !m_isModalStyle ) - SetModal(true); + m_modality = wxDIALOG_MODALITY_APP_MODAL; + + Show(); - if ( IsShown() ) - DoShowModal(); - else - Show(true); + DoShowModal(); return GetReturnCode(); } +void wxDialog::ShowWindowModal() +{ + m_modality = wxDIALOG_MODALITY_WINDOW_MODAL; + + Show(); + + DoShowWindowModal(); +} + +wxDialogModality wxDialog::GetModality() const +{ + return m_modality; +} + // NB: this function (surprisingly) may be called for both modal and modeless // dialogs and should work for both of them void wxDialog::EndModal(int retCode) { SetReturnCode(retCode); Show(false); - SetModal(false); }