]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/dialog_osx.cpp
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_isModalStyle
= false;
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
) )
60 void wxDialog::SetModal( bool flag
)
64 m_isModalStyle
= true;
68 m_isModalStyle
= false;
74 m_isBeingDeleted
= true;
76 // if the dialog is modal, this will end its event loop
80 // On mac command-stop does the same thing as Esc, let the base class know
82 bool wxDialog::IsEscapeKey(const wxKeyEvent
& event
)
84 if ( event
.GetKeyCode() == '.' && event
.GetModifiers() == wxMOD_CMD
)
87 return wxDialogBase::IsEscapeKey(event
);
90 bool wxDialog::IsModal() const
92 return wxModalDialogs
.Find((wxDialog
*)this) != NULL
; // const_cast
93 // return m_isModalStyle;
97 bool wxDialog::Show(bool show
)
99 if ( !wxDialogBase::Show(show
) )
103 if (show
&& CanDoLayoutAdaptation())
104 DoLayoutAdaptation();
107 // usually will result in TransferDataToWindow() being called
110 if ( m_isModalStyle
)
116 else // end of modal dialog
118 // this will cause IsModalShowing() return false and our local
119 // message loop will terminate
120 wxModalDialogs
.DeleteObject(this);
127 // Replacement for Show(true) for modal dialogs - returns return code
128 int wxDialog::ShowModal()
130 if ( !m_isModalStyle
)
138 return GetReturnCode();
141 // NB: this function (surprizingly) may be called for both modal and modeless
142 // dialogs and should work for both of them
143 void wxDialog::EndModal(int retCode
)
145 SetReturnCode(retCode
);