1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/dialog_osx.cpp
3 // Purpose: wxDialog class
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: dialog.cpp 54820 2008-07-29 20:04:11Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/dialog.h"
20 #include "wx/settings.h"
23 #include "wx/osx/private.h"
26 // Lists to keep track of windows, so we can disable/enable them
29 wxList wxModalDialogs
;
31 IMPLEMENT_DYNAMIC_CLASS(wxDialog
, wxTopLevelWindow
)
35 m_modality
= wxDIALOG_MODALITY_NONE
;
38 bool wxDialog::Create( wxWindow
*parent
,
40 const wxString
& title
,
44 const wxString
& name
)
46 SetExtraStyle( GetExtraStyle() | wxTOPLEVEL_EX_DIALOG
);
48 // All dialogs should really have this style...
49 style
|= wxTAB_TRAVERSAL
;
51 // ...but not these styles
52 style
&= ~(wxYES
| wxOK
| wxNO
); // | wxCANCEL
54 if ( !wxTopLevelWindow::Create( parent
, id
, title
, pos
, size
, style
, name
) )
64 // if the dialog is modal, this will end its event loop
68 // On mac command-stop does the same thing as Esc, let the base class know
70 bool wxDialog::IsEscapeKey(const wxKeyEvent
& event
)
72 if ( event
.GetKeyCode() == '.' && event
.GetModifiers() == wxMOD_CMD
)
75 return wxDialogBase::IsEscapeKey(event
);
78 bool wxDialog::IsModal() const
80 return m_modality
!= wxDIALOG_MODALITY_NONE
;
83 bool wxDialog::Show(bool show
)
85 if ( m_modality
== wxDIALOG_MODALITY_WINDOW_MODAL
)
87 if ( !wxWindow::Show(show
) )
93 if ( !wxDialogBase::Show(show
) )
98 if (show
&& CanDoLayoutAdaptation())
102 // usually will result in TransferDataToWindow() being called
109 case wxDIALOG_MODALITY_WINDOW_MODAL
:
110 EndWindowModal(); // OS X implementation method for cleanup
111 SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED
);
116 m_modality
= wxDIALOG_MODALITY_NONE
;
122 // Replacement for Show(true) for modal dialogs - returns return code
123 int wxDialog::ShowModal()
125 m_modality
= wxDIALOG_MODALITY_APP_MODAL
;
131 return GetReturnCode();
134 void wxDialog::ShowWindowModal()
136 m_modality
= wxDIALOG_MODALITY_WINDOW_MODAL
;
143 wxDialogModality
wxDialog::GetModality() const
148 // NB: this function (surprisingly) may be called for both modal and modeless
149 // dialogs and should work for both of them
150 void wxDialog::EndModal(int retCode
)
152 SetReturnCode(retCode
);