]>
Commit | Line | Data |
---|---|---|
fb8dcb05 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/osx/cocoa/dialog.cpp | |
3 | // Purpose: wxDialog class | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id: dialog.cpp 54820 2008-07-29 20:04:11Z SC $ | |
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 | ||
25 | extern wxList wxModalDialogs; | |
26 | ||
27 | void wxDialog::DoShowModal() | |
28 | { | |
dbeddfb9 SC |
29 | wxCHECK_RET( !IsModal(), wxT("DoShowModal() called twice") ); |
30 | ||
b0a9bfc8 SC |
31 | // If the app hasn't started, flush the event queue |
32 | // If we don't do this, the Dock doesn't get the message that | |
33 | // the app has started so will refuse to activate it. | |
34 | NSApplication *theNSApp = [NSApplication sharedApplication]; | |
35 | if (![theNSApp isRunning]) | |
36 | { | |
37 | wxMacAutoreleasePool pool; | |
38 | while(NSEvent *event = [theNSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]) | |
39 | { | |
40 | [theNSApp sendEvent:event]; | |
41 | } | |
42 | } | |
43 | ||
dbeddfb9 | 44 | wxModalDialogs.Append(this); |
fb8dcb05 SC |
45 | |
46 | SetFocus() ; | |
47 | /* | |
48 | WindowGroupRef windowGroup; | |
49 | WindowGroupRef formerParentGroup; | |
50 | bool resetGroupParent = false; | |
51 | ||
52 | if ( GetParent() == NULL ) | |
53 | { | |
54 | windowGroup = GetWindowGroup(windowRef) ; | |
55 | formerParentGroup = GetWindowGroupParent( windowGroup ); | |
56 | SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) ); | |
57 | resetGroupParent = true; | |
58 | } | |
59 | */ | |
fb8dcb05 | 60 | NSWindow* theWindow = GetWXWindow(); |
03647350 | 61 | |
fb8dcb05 | 62 | NSModalSession session = [NSApp beginModalSessionForWindow:theWindow]; |
03647350 | 63 | while (IsModal()) |
fb8dcb05 | 64 | { |
dbeddfb9 | 65 | wxMacAutoreleasePool autoreleasepool; |
a43a9e55 SC |
66 | // we cannot break based on the return value, because nested |
67 | // alerts might set this to stopped as well, so it would be | |
68 | // unsafe | |
69 | [NSApp runModalSession:session]; | |
336775c0 | 70 | |
b0a9bfc8 SC |
71 | // break if ended, perform no further idle processing |
72 | if (!IsModal()) | |
73 | break; | |
74 | ||
03647350 | 75 | // do some idle processing |
b0a9bfc8 | 76 | bool needMore = false; |
03647350 | 77 | if (wxTheApp) |
b0a9bfc8 SC |
78 | { |
79 | wxTheApp->ProcessPendingEvents(); | |
80 | needMore = wxTheApp->ProcessIdle(); | |
81 | } | |
82 | ||
83 | if (!needMore) | |
84 | { | |
85 | // no more idle processing wanted - block until the next event | |
86 | [theNSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:NO]; | |
87 | } | |
fb8dcb05 SC |
88 | } |
89 | [NSApp endModalSession:session]; | |
90 | ||
91 | /* | |
92 | if ( resetGroupParent ) | |
93 | { | |
94 | SetWindowGroupParent( windowGroup , formerParentGroup ); | |
95 | } | |
96 | */ | |
97 | } |