]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/dialog.cpp
a17700638088d822b1ea985ad9dcb46c61cab217
[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 extern wxList wxModalDialogs;
27
28 void wxDialog::EndWindowModal()
29 {
30 // Nothing to do for now.
31 }
32
33 void wxDialog::ShowWindowModal()
34 {
35 // If someone wants to add support for this to wxOSX Carbon, here would
36 // be the place to start: http://trac.wxwidgets.org/ticket/9459
37 // Unfortunately, supporting sheets in Carbon isn't as straightforward
38 // as with Cocoa, so it will probably take some tweaking.
39 wxDialogBase::ShowWindowModal();
40 }
41
42 void wxDialog::DoShowModal()
43 {
44 wxCHECK_RET( !IsModal(), wxT("DoShowModal() called twice") );
45
46 wxModalDialogs.Append(this);
47
48 SetFocus() ;
49
50 WindowRef windowRef = (WindowRef) GetWXWindow();
51 WindowGroupRef windowGroup = NULL;
52 WindowGroupRef formerParentGroup = NULL;
53 bool resetGroupParent = false;
54
55 if ( GetParent() == NULL )
56 {
57 windowGroup = GetWindowGroup(windowRef) ;
58 if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) )
59 {
60 formerParentGroup = GetWindowGroupParent( windowGroup );
61 SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) );
62 resetGroupParent = true;
63 }
64 }
65 BeginAppModalStateForWindow(windowRef) ;
66
67 #if wxUSE_CONSOLE_EVENTLOOP
68 wxEventLoopGuarantor ensureHasLoop;
69 #endif
70 wxEventLoopBase * const loop = wxEventLoop::GetActive();
71 while ( IsModal() )
72 loop->Dispatch();
73
74 EndAppModalStateForWindow(windowRef) ;
75 if ( resetGroupParent )
76 {
77 SetWindowGroupParent( windowGroup , formerParentGroup );
78 }
79 }