]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/dialog.cpp
A call to wxPopupWindow::Show shouldn't automatically cause the popup window to steal...
[wxWidgets.git] / src / osx / carbon / dialog.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/dialog.cpp
3 // Purpose: wxDialog class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/dialog.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/app.h"
18 #include "wx/utils.h"
19 #include "wx/frame.h"
20 #include "wx/settings.h"
21 #endif // WX_PRECOMP
22
23 #include "wx/osx/private.h"
24 #include "wx/evtloop.h"
25
26 void wxDialog::EndWindowModal()
27 {
28 // Nothing to do for now.
29 }
30
31 void wxDialog::DoShowWindowModal()
32 {
33 // If someone wants to add support for this to wxOSX Carbon, here would
34 // be the place to start: http://trac.wxwidgets.org/ticket/9459
35 // Unfortunately, supporting sheets in Carbon isn't as straightforward
36 // as with Cocoa, so it will probably take some tweaking.
37
38 m_modality = wxDIALOG_MODALITY_APP_MODAL;
39 ShowModal();
40 SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED );
41 }
42
43 void wxDialog::DoShowModal()
44 {
45
46 SetFocus() ;
47
48 WindowRef windowRef = (WindowRef) GetWXWindow();
49 WindowGroupRef windowGroup = NULL;
50 WindowGroupRef formerParentGroup = NULL;
51 bool resetGroupParent = false;
52
53 if ( GetParent() == NULL )
54 {
55 windowGroup = GetWindowGroup(windowRef) ;
56 if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) )
57 {
58 formerParentGroup = GetWindowGroupParent( windowGroup );
59 SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) );
60 resetGroupParent = true;
61 }
62 }
63 BeginAppModalStateForWindow(windowRef) ;
64
65 #if wxUSE_CONSOLE_EVENTLOOP
66 wxEventLoopGuarantor ensureHasLoop;
67 #endif
68 wxEventLoopBase * const loop = wxEventLoop::GetActive();
69 while ( IsModal() )
70 loop->Dispatch();
71
72 EndAppModalStateForWindow(windowRef) ;
73 if ( resetGroupParent )
74 {
75 SetWindowGroupParent( windowGroup , formerParentGroup );
76 }
77 }