]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: app.cpp | |
3 | // Purpose: wxApp | |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
e9576ca5 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "app.h" | |
14 | #endif | |
15 | ||
df06d1a4 GD |
16 | #include "wx/defs.h" |
17 | ||
03e11df5 | 18 | #include "wx/window.h" |
e9576ca5 | 19 | #include "wx/frame.h" |
e8566d35 | 20 | #include "wx/button.h" |
e9576ca5 SC |
21 | #include "wx/app.h" |
22 | #include "wx/utils.h" | |
23 | #include "wx/gdicmn.h" | |
24 | #include "wx/pen.h" | |
25 | #include "wx/brush.h" | |
26 | #include "wx/cursor.h" | |
ed5b9811 | 27 | #include "wx/intl.h" |
e9576ca5 SC |
28 | #include "wx/icon.h" |
29 | #include "wx/palette.h" | |
30 | #include "wx/dc.h" | |
31 | #include "wx/dialog.h" | |
32 | #include "wx/msgdlg.h" | |
33 | #include "wx/log.h" | |
34 | #include "wx/module.h" | |
35 | #include "wx/memory.h" | |
2f1ae414 | 36 | #include "wx/tooltip.h" |
b3c406a5 | 37 | #include "wx/textctrl.h" |
03e11df5 | 38 | #include "wx/menu.h" |
738a6daa | 39 | #include "wx/docview.h" |
1c32ded3 | 40 | #include "wx/filename.h" |
738a6daa | 41 | |
e9576ca5 SC |
42 | #include <string.h> |
43 | ||
8be97d65 SC |
44 | // mac |
45 | ||
f5c6eb5c | 46 | #ifndef __DARWIN__ |
03e11df5 | 47 | #if __option(profile) |
8461e4c2 | 48 | #include <profiler.h> |
03e11df5 | 49 | #endif |
9779893b | 50 | #endif |
519cb848 | 51 | |
9d331599 | 52 | // #include "apprsrc.h" |
8be97d65 | 53 | |
03e11df5 GD |
54 | #include "wx/mac/uma.h" |
55 | #include "wx/mac/macnotfy.h" | |
2f1ae414 | 56 | |
df06d1a4 GD |
57 | #ifdef __DARWIN__ |
58 | # include <CoreServices/CoreServices.h> | |
21870a5d | 59 | # if defined(WXMAKINGDLL_CORE) |
ed581ee2 GD |
60 | # include <mach-o/dyld.h> |
61 | # endif | |
df06d1a4 GD |
62 | #else |
63 | # include <Sound.h> | |
64 | # include <Threads.h> | |
65 | # include <ToolUtils.h> | |
66 | # include <DiskInit.h> | |
67 | # include <Devices.h> | |
2f1ae414 | 68 | #endif |
519cb848 | 69 | |
e9576ca5 | 70 | extern wxList wxPendingDelete; |
facd6764 | 71 | |
3fbf8e7f SC |
72 | // set wxMAC_USE_RAEL to 1 if RunApplicationEventLoop should be used |
73 | // if 0 the lower level CarbonEventLoop will be used | |
74 | // on the long run RAEL should replace the low level event loop | |
75 | // we will have to clean up event handling to make sure we don't | |
76 | // miss handling of things like pending events etc | |
77 | // perhaps we will also have to pipe events through an ueber-event-handler | |
78 | // to make sure we have one place to do all these house-keeping functions | |
79 | ||
80 | #define wxMAC_USE_RAEL 0 | |
81 | ||
c944ce35 | 82 | #if wxUSE_THREADS |
e64313ba | 83 | extern size_t g_numberOfThreads; |
c944ce35 | 84 | #endif // wxUSE_THREADS |
e9576ca5 | 85 | |
c5c9378c SC |
86 | // statics for implementation |
87 | ||
738a6daa | 88 | static bool s_inYield = FALSE; |
c5c9378c | 89 | |
c5c9378c SC |
90 | static bool s_inReceiveEvent = FALSE ; |
91 | static EventTime sleepTime = kEventDurationNoWait ; | |
738a6daa | 92 | |
2f1ae414 | 93 | #if !USE_SHARED_LIBRARY |
e9576ca5 SC |
94 | IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) |
95 | BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) | |
96 | EVT_IDLE(wxApp::OnIdle) | |
15b41e90 SC |
97 | EVT_END_SESSION(wxApp::OnEndSession) |
98 | EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession) | |
e9576ca5 | 99 | END_EVENT_TABLE() |
2f1ae414 | 100 | #endif |
e9576ca5 | 101 | |
169935ad | 102 | |
8461e4c2 | 103 | const short kMacMinHeap = (29 * 1024) ; |
8be97d65 | 104 | // platform specific static variables |
169935ad | 105 | |
519cb848 SC |
106 | const short kwxMacMenuBarResource = 1 ; |
107 | const short kwxMacAppleMenuId = 1 ; | |
108 | ||
fbbdb7cd GD |
109 | WXHRGN wxApp::s_macCursorRgn = NULL; |
110 | wxWindow* wxApp::s_captureWindow = NULL ; | |
111 | int wxApp::s_lastMouseDown = 0 ; | |
112 | long wxApp::sm_lastMessageTime = 0; | |
41d368a4 SC |
113 | long wxApp::s_lastModifiers = 0 ; |
114 | ||
519cb848 | 115 | |
fbbdb7cd GD |
116 | bool wxApp::s_macSupportPCMenuShortcuts = true ; |
117 | long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; | |
882b0479 | 118 | long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ; |
2b5f62a0 | 119 | long wxApp::s_macExitMenuItemId = wxID_EXIT ; |
427ff662 | 120 | wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ; |
519cb848 | 121 | |
e128397f DS |
122 | // Normally we're not a plugin |
123 | bool wxApp::sm_isEmbedded = false; | |
15b41e90 SC |
124 | //---------------------------------------------------------------------- |
125 | // Core Apple Event Support | |
126 | //---------------------------------------------------------------------- | |
127 | ||
72055702 SC |
128 | pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long refcon ) ; |
129 | pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon ) ; | |
130 | pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon ) ; | |
131 | pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon ) ; | |
1c32ded3 | 132 | pascal OSErr AEHandleRApp( const AppleEvent *event , AppleEvent *reply , long refcon ) ; |
72055702 | 133 | |
2a294857 | 134 | pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) |
519cb848 | 135 | { |
8461e4c2 | 136 | return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ; |
519cb848 SC |
137 | } |
138 | ||
2a294857 | 139 | pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) |
519cb848 | 140 | { |
8461e4c2 | 141 | return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ; |
519cb848 SC |
142 | } |
143 | ||
2a294857 | 144 | pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) |
519cb848 | 145 | { |
8461e4c2 | 146 | return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ; |
519cb848 SC |
147 | } |
148 | ||
2a294857 | 149 | pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) |
519cb848 | 150 | { |
8461e4c2 | 151 | return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ; |
519cb848 SC |
152 | } |
153 | ||
1c32ded3 SC |
154 | pascal OSErr AEHandleRApp( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) ) |
155 | { | |
156 | return wxTheApp->MacHandleAERApp( (AppleEvent*) event , reply) ; | |
157 | } | |
158 | ||
15b41e90 | 159 | // AEODoc Calls MacOpenFile on each of the files passed |
5ab6aab8 | 160 | |
2072fbbb SC |
161 | short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply)) |
162 | { | |
163 | AEDescList docList; | |
164 | AEKeyword keywd; | |
165 | DescType returnedType; | |
166 | Size actualSize; | |
167 | long itemsInList; | |
168 | FSSpec theSpec; | |
169 | OSErr err; | |
170 | short i; | |
171 | err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList); | |
172 | if (err != noErr) | |
173 | return err; | |
7c9955d1 | 174 | |
2072fbbb SC |
175 | err = AECountItems(&docList, &itemsInList); |
176 | if (err != noErr) | |
177 | return err; | |
7c9955d1 | 178 | |
8461e4c2 VZ |
179 | ProcessSerialNumber PSN ; |
180 | PSN.highLongOfPSN = 0 ; | |
181 | PSN.lowLongOfPSN = kCurrentProcess ; | |
182 | SetFrontProcess( &PSN ) ; | |
7c9955d1 | 183 | |
2072fbbb SC |
184 | for (i = 1; i <= itemsInList; i++) { |
185 | AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType, | |
186 | (Ptr) & theSpec, sizeof(theSpec), &actualSize); | |
187 | wxString fName = wxMacFSSpec2MacFilename(&theSpec); | |
188 | MacOpenFile(fName); | |
189 | } | |
190 | return noErr; | |
519cb848 SC |
191 | } |
192 | ||
15b41e90 SC |
193 | // AEPDoc Calls MacPrintFile on each of the files passed |
194 | ||
2072fbbb | 195 | short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply)) |
519cb848 | 196 | { |
2072fbbb SC |
197 | AEDescList docList; |
198 | AEKeyword keywd; | |
199 | DescType returnedType; | |
200 | Size actualSize; | |
201 | long itemsInList; | |
202 | FSSpec theSpec; | |
203 | OSErr err; | |
204 | short i; | |
205 | err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList); | |
206 | if (err != noErr) | |
207 | return err; | |
7c9955d1 | 208 | |
2072fbbb SC |
209 | err = AECountItems(&docList, &itemsInList); |
210 | if (err != noErr) | |
211 | return err; | |
7c9955d1 | 212 | |
2072fbbb SC |
213 | ProcessSerialNumber PSN ; |
214 | PSN.highLongOfPSN = 0 ; | |
215 | PSN.lowLongOfPSN = kCurrentProcess ; | |
216 | SetFrontProcess( &PSN ) ; | |
7c9955d1 | 217 | |
2072fbbb SC |
218 | for (i = 1; i <= itemsInList; i++) { |
219 | AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType, | |
220 | (Ptr) & theSpec, sizeof(theSpec), &actualSize); | |
221 | wxString fName = wxMacFSSpec2MacFilename(&theSpec); | |
222 | MacPrintFile(fName); | |
223 | } | |
224 | return noErr; | |
519cb848 SC |
225 | } |
226 | ||
15b41e90 SC |
227 | // AEOApp calls MacNewFile |
228 | ||
2a294857 | 229 | short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) |
519cb848 | 230 | { |
2072fbbb | 231 | MacNewFile() ; |
8461e4c2 | 232 | return noErr ; |
519cb848 SC |
233 | } |
234 | ||
76a60a81 | 235 | // AEQuit attempts to quit the application |
15b41e90 | 236 | |
2a294857 | 237 | short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) |
519cb848 | 238 | { |
38106243 | 239 | wxWindow* win = GetTopWindow() ; |
8461e4c2 VZ |
240 | if ( win ) |
241 | { | |
38106243 JS |
242 | wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId); |
243 | if (!win->ProcessEvent(exitEvent)) | |
244 | win->Close(TRUE ) ; | |
8461e4c2 | 245 | } |
38106243 | 246 | else |
8461e4c2 VZ |
247 | { |
248 | ExitMainLoop() ; | |
249 | } | |
250 | return noErr ; | |
519cb848 SC |
251 | } |
252 | ||
1c32ded3 SC |
253 | // AEROApp calls MacReopenApp |
254 | ||
255 | short wxApp::MacHandleAERApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply)) | |
256 | { | |
257 | MacReopenApp() ; | |
258 | return noErr ; | |
259 | } | |
260 | ||
261 | ||
15b41e90 SC |
262 | //---------------------------------------------------------------------- |
263 | // Support Routines linking the Mac...File Calls to the Document Manager | |
264 | //---------------------------------------------------------------------- | |
265 | ||
266 | void wxApp::MacOpenFile(const wxString & fileName ) | |
267 | { | |
268 | wxDocManager* dm = wxDocManager::GetDocumentManager() ; | |
269 | if ( dm ) | |
270 | dm->CreateDocument(fileName , wxDOC_SILENT ) ; | |
271 | } | |
272 | ||
273 | void wxApp::MacPrintFile(const wxString & fileName ) | |
274 | { | |
275 | wxDocManager* dm = wxDocManager::GetDocumentManager() ; | |
276 | if ( dm ) | |
277 | { | |
278 | wxDocument *doc = dm->CreateDocument(fileName , wxDOC_SILENT ) ; | |
279 | if ( doc ) | |
280 | { | |
281 | wxView* view = doc->GetFirstView() ; | |
282 | if( view ) | |
283 | { | |
284 | wxPrintout *printout = view->OnCreatePrintout(); | |
285 | if (printout) | |
286 | { | |
287 | wxPrinter printer; | |
288 | printer.Print(view->GetFrame(), printout, TRUE); | |
289 | delete printout; | |
290 | } | |
291 | } | |
292 | if (doc->Close()) | |
293 | { | |
294 | doc->DeleteAllViews(); | |
295 | dm->RemoveDocument(doc) ; | |
296 | } | |
297 | } | |
298 | } | |
299 | } | |
300 | ||
301 | void wxApp::MacNewFile() | |
302 | { | |
303 | } | |
304 | ||
1c32ded3 SC |
305 | void wxApp::MacReopenApp() |
306 | { | |
307 | // eventually check for open docs, if none, call MacNewFile | |
43790a0d JS |
308 | wxTopLevelWindowMac* topLevelWindow = wxDynamicCast(GetTopWindow(), wxTopLevelWindowMac); |
309 | ||
310 | if (topLevelWindow && topLevelWindow->IsIconized()) | |
311 | topLevelWindow->Iconize(false); | |
1c32ded3 SC |
312 | } |
313 | ||
c5c9378c SC |
314 | //---------------------------------------------------------------------- |
315 | // Carbon Event Handler | |
316 | //---------------------------------------------------------------------- | |
9779893b | 317 | |
facd6764 SC |
318 | static const EventTypeSpec eventList[] = |
319 | { | |
320 | { kEventClassCommand, kEventProcessCommand } , | |
321 | { kEventClassCommand, kEventCommandUpdateStatus } , | |
7c9955d1 | 322 | |
facd6764 SC |
323 | { kEventClassMenu, kEventMenuOpening }, |
324 | { kEventClassMenu, kEventMenuClosed }, | |
325 | { kEventClassMenu, kEventMenuTargetItem }, | |
e32f4a9f | 326 | |
facd6764 SC |
327 | { kEventClassApplication , kEventAppActivated } , |
328 | { kEventClassApplication , kEventAppDeactivated } , | |
329 | // handling the quit event is not recommended by apple | |
330 | // rather using the quit apple event - which we do | |
7c9955d1 | 331 | |
facd6764 | 332 | { kEventClassAppleEvent , kEventAppleEvent } , |
7c9955d1 | 333 | |
facd6764 SC |
334 | { kEventClassMouse , kEventMouseDown } , |
335 | { kEventClassMouse , kEventMouseMoved } , | |
336 | { kEventClassMouse , kEventMouseUp } , | |
337 | { kEventClassMouse , kEventMouseDragged } , | |
338 | { 'WXMC' , 'WXMC' } | |
339 | } ; | |
519cb848 | 340 | |
e32f4a9f | 341 | static pascal OSStatus |
facd6764 | 342 | wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
519cb848 | 343 | { |
dae6d730 SC |
344 | EventRef formerEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ; |
345 | EventHandlerCallRef formerEventHandlerCallRef = (EventHandlerCallRef) wxTheApp->MacGetCurrentEventHandlerCallRef() ; | |
346 | wxTheApp->MacSetCurrentEvent( event , handler ) ; | |
852b1185 | 347 | |
dae6d730 SC |
348 | wxMacCarbonEvent cEvent( event ) ; |
349 | MenuRef menuRef = cEvent.GetParameter<MenuRef>(kEventParamDirectObject) ; | |
350 | wxMenu* menu = wxFindMenuFromMacMenu( menuRef ) ; | |
351 | ||
352 | if ( menu ) | |
e32f4a9f | 353 | { |
dae6d730 SC |
354 | wxEventType type=0; |
355 | MenuCommand cmd=0; | |
356 | switch (GetEventKind(event)) | |
852b1185 | 357 | { |
dae6d730 SC |
358 | case kEventMenuOpening: |
359 | type = wxEVT_MENU_OPEN; | |
360 | break; | |
361 | case kEventMenuClosed: | |
362 | type = wxEVT_MENU_CLOSE; | |
363 | break; | |
364 | case kEventMenuTargetItem: | |
365 | cmd = cEvent.GetParameter<MenuCommand>(kEventParamMenuCommand,typeMenuCommand) ; | |
366 | if (cmd != 0) | |
9f2bfce7 | 367 | type = wxEVT_MENU_HIGHLIGHT; |
dae6d730 SC |
368 | break; |
369 | default: | |
370 | wxFAIL_MSG(wxT("Unexpected menu event kind")); | |
371 | break; | |
372 | } | |
852b1185 | 373 | |
dae6d730 SC |
374 | if ( type ) |
375 | { | |
9f2bfce7 | 376 | wxMenuEvent wxevent(type, cmd); |
dae6d730 | 377 | wxevent.SetEventObject(menu); |
e32f4a9f | 378 | |
dae6d730 SC |
379 | wxEvtHandler* handler = menu->GetEventHandler(); |
380 | if (handler && handler->ProcessEvent(wxevent)) | |
381 | { | |
382 | // handled | |
383 | } | |
384 | else | |
385 | { | |
386 | wxWindow *win = menu->GetInvokingWindow(); | |
387 | if (win) | |
388 | win->GetEventHandler()->ProcessEvent(wxevent); | |
389 | } | |
390 | } | |
e32f4a9f | 391 | } |
dae6d730 SC |
392 | |
393 | wxTheApp->MacSetCurrentEvent( formerEvent, formerEventHandlerCallRef ) ; | |
e32f4a9f VZ |
394 | |
395 | return eventNotHandledErr; | |
519cb848 SC |
396 | } |
397 | ||
facd6764 | 398 | static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
15b41e90 SC |
399 | { |
400 | OSStatus result = eventNotHandledErr ; | |
401 | ||
e40298d5 | 402 | HICommand command ; |
7c9955d1 | 403 | |
dae6d730 SC |
404 | wxMacCarbonEvent cEvent( event ) ; |
405 | cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ; | |
406 | ||
407 | wxMenuItem* item = NULL ; | |
e40298d5 | 408 | MenuCommand id = command.commandID ; |
dae6d730 | 409 | // for items we don't really control |
e40298d5 | 410 | if ( id == kHICommandPreferences ) |
6d565349 | 411 | { |
dae6d730 SC |
412 | id = wxApp::s_macPreferencesMenuItemId ; |
413 | ||
414 | wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ; | |
415 | if ( mbar ) | |
6d565349 | 416 | { |
dae6d730 SC |
417 | wxMenu* menu = NULL ; |
418 | item = mbar->FindItem( id , &menu ) ; | |
6d565349 SC |
419 | } |
420 | } | |
dae6d730 SC |
421 | else if ( id != 0 && command.menu.menuRef != 0 && command.menu.menuItemIndex != 0 ) |
422 | { | |
423 | GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , (UInt32*) &item ) ; | |
424 | } | |
425 | ||
426 | if ( item ) | |
427 | { | |
428 | switch( cEvent.GetKind() ) | |
e40298d5 JS |
429 | { |
430 | case kEventProcessCommand : | |
431 | { | |
432 | if (item->IsCheckable()) | |
433 | { | |
434 | item->Check( !item->IsChecked() ) ; | |
435 | } | |
7c9955d1 | 436 | |
dae6d730 | 437 | item->GetMenu()->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; |
e40298d5 JS |
438 | result = noErr ; |
439 | } | |
dae6d730 | 440 | break ; |
e40298d5 JS |
441 | case kEventCommandUpdateStatus: |
442 | // eventually trigger an updateui round | |
6d565349 | 443 | result = noErr ; |
e40298d5 | 444 | break ; |
dae6d730 SC |
445 | default : |
446 | break ; | |
447 | } | |
448 | } | |
15b41e90 SC |
449 | return result ; |
450 | } | |
451 | ||
facd6764 | 452 | static pascal OSStatus wxMacAppApplicationEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
15b41e90 SC |
453 | { |
454 | OSStatus result = eventNotHandledErr ; | |
e40298d5 JS |
455 | switch ( GetEventKind( event ) ) |
456 | { | |
457 | case kEventAppActivated : | |
458 | { | |
3470af1c | 459 | if ( wxTheApp ) |
facd6764 | 460 | wxTheApp->SetActive( true , NULL ) ; |
e40298d5 JS |
461 | result = noErr ; |
462 | } | |
463 | break ; | |
464 | case kEventAppDeactivated : | |
465 | { | |
3470af1c | 466 | if ( wxTheApp ) |
facd6764 | 467 | wxTheApp->SetActive( false , NULL ) ; |
e40298d5 JS |
468 | result = noErr ; |
469 | } | |
470 | break ; | |
471 | default : | |
472 | break ; | |
473 | } | |
15b41e90 SC |
474 | return result ; |
475 | } | |
476 | ||
facd6764 | 477 | pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
15b41e90 SC |
478 | { |
479 | OSStatus result = eventNotHandledErr ; | |
480 | switch( GetEventClass( event ) ) | |
481 | { | |
e40298d5 | 482 | case kEventClassCommand : |
facd6764 | 483 | result = wxMacAppCommandEventHandler( handler , event , data ) ; |
e40298d5 JS |
484 | break ; |
485 | case kEventClassApplication : | |
facd6764 | 486 | result = wxMacAppApplicationEventHandler( handler , event , data ) ; |
e40298d5 JS |
487 | break ; |
488 | case kEventClassMenu : | |
facd6764 | 489 | result = wxMacAppMenuEventHandler( handler , event , data ) ; |
e40298d5 JS |
490 | break ; |
491 | case kEventClassMouse : | |
58ddb76c | 492 | result = wxMacTopLevelMouseEventHandler( handler , event , NULL ) ; |
e40298d5 JS |
493 | break ; |
494 | case kEventClassAppleEvent : | |
495 | { | |
496 | EventRecord rec ; | |
497 | wxMacConvertEventToRecord( event , &rec ) ; | |
498 | result = AEProcessAppleEvent( &rec ) ; | |
499 | } | |
500 | break ; | |
501 | default : | |
502 | break ; | |
15b41e90 SC |
503 | } |
504 | ||
505 | return result ; | |
506 | } | |
507 | ||
facd6764 | 508 | DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacAppEventHandler ) |
15b41e90 | 509 | |
21870a5d | 510 | #if defined(WXMAKINGDLL_CORE) && !defined(__DARWIN__) |
53fd991c SC |
511 | // we know it's there ;-) |
512 | WXIMPORT char std::__throws_bad_alloc ; | |
513 | #endif | |
514 | ||
facd6764 SC |
515 | pascal static void wxMacAssertOutputHandler(OSType componentSignature, UInt32 options, |
516 | const char *assertionString, const char *exceptionLabelString, | |
517 | const char *errorString, const char *fileName, long lineNumber, void *value, ConstStr255Param outputMsg) | |
e9576ca5 | 518 | { |
facd6764 SC |
519 | // flow into assert handling |
520 | wxString fileNameStr ; | |
521 | wxString assertionStr ; | |
522 | wxString exceptionStr ; | |
523 | wxString errorStr ; | |
524 | #if wxUSE_UNICODE | |
525 | fileNameStr = wxString(fileName, wxConvLocal); | |
526 | assertionStr = wxString(assertionString, wxConvLocal); | |
527 | exceptionStr = wxString((exceptionLabelString!=0) ? exceptionLabelString : "", wxConvLocal) ; | |
528 | errorStr = wxString((errorString!=0) ? errorString : "", wxConvLocal) ; | |
529 | #else | |
530 | fileNameStr = fileName; | |
531 | assertionStr = assertionString; | |
532 | exceptionStr = (exceptionLabelString!=0) ? exceptionLabelString : "" ; | |
533 | errorStr = (errorString!=0) ? errorString : "" ; | |
534 | #endif | |
9779893b | 535 | |
facd6764 SC |
536 | #if 1 |
537 | // flow into log | |
c847adaa | 538 | wxLogDebug( wxT("AssertMacros: %s %s %s file: %s, line: %ld (value %p)\n"), |
facd6764 SC |
539 | assertionStr.c_str() , |
540 | exceptionStr.c_str() , | |
541 | errorStr.c_str(), | |
542 | fileNameStr.c_str(), lineNumber , | |
543 | value ) ; | |
544 | #else | |
545 | ||
546 | wxOnAssert(fileNameStr, lineNumber , assertionStr , | |
c847adaa | 547 | wxString::Format( wxT("%s %s value (%p)") ,exceptionStr, errorStr , value ) ) ; |
facd6764 SC |
548 | #endif |
549 | } | |
550 | ||
551 | bool wxApp::Initialize(int& argc, wxChar **argv) | |
552 | { | |
fbbdb7cd | 553 | // Mac-specific |
9779893b | 554 | |
facd6764 SC |
555 | #if __WXDEBUG__ |
556 | InstallDebugAssertOutputHandler ( NewDebugAssertOutputHandlerUPP( wxMacAssertOutputHandler ) ); | |
557 | #endif | |
e128397f | 558 | UMAInitToolbox( 4, sm_isEmbedded ) ; |
fbbdb7cd | 559 | SetEventMask( everyEvent ) ; |
8461e4c2 | 560 | UMAShowWatchCursor() ; |
8be97d65 | 561 | |
21870a5d | 562 | #if defined(WXMAKINGDLL_CORE) && defined(__DARWIN__) |
fbbdb7cd GD |
563 | // open shared library resources from here since we don't have |
564 | // __wxinitialize in Mach-O shared libraries | |
565 | wxStAppResource::OpenSharedLibraryResource(NULL); | |
566 | #endif | |
84c1ffa9 | 567 | |
f5c6eb5c | 568 | #ifndef __DARWIN__ |
fbbdb7cd | 569 | # if __option(profile) |
882b0479 | 570 | ProfilerInit( collectDetailed, bestTimeBase , 40000 , 50 ) ; |
fbbdb7cd | 571 | # endif |
9779893b | 572 | #endif |
519cb848 | 573 | |
f5c6eb5c | 574 | #ifndef __DARWIN__ |
ed581ee2 | 575 | // now avoid exceptions thrown for new (bad_alloc) |
e40298d5 | 576 | // FIXME CS for some changes outside wxMac does not compile anymore |
15b41e90 SC |
577 | #if 0 |
578 | std::__throws_bad_alloc = 0 ; | |
579 | #endif | |
580 | ||
03e11df5 | 581 | #endif |
7c9955d1 | 582 | |
8461e4c2 | 583 | s_macCursorRgn = ::NewRgn() ; |
8be97d65 | 584 | |
05e2b077 VZ |
585 | // Mac OS X passes a process serial number command line argument when |
586 | // the application is launched from the Finder. This argument must be | |
587 | // removed from the command line arguments before being handled by the | |
588 | // application (otherwise applications would need to handle it) | |
589 | if ( argc > 1 ) | |
590 | { | |
591 | static const wxChar *ARG_PSN = _T("-psn_"); | |
46e2a2e7 | 592 | if ( wxStrncmp(argv[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 ) |
05e2b077 VZ |
593 | { |
594 | // remove this argument | |
33f39af3 GD |
595 | --argc; |
596 | memmove(argv + 1, argv + 2, argc * sizeof(char *)); | |
05e2b077 VZ |
597 | } |
598 | } | |
599 | ||
94826170 VZ |
600 | if ( !wxAppBase::Initialize(argc, argv) ) |
601 | return false; | |
e9576ca5 | 602 | |
d9d19e75 SC |
603 | #if wxUSE_INTL |
604 | wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); | |
605 | #endif | |
606 | ||
607 | ||
376b18ea | 608 | wxMacCreateNotifierTable() ; |
9779893b | 609 | |
376b18ea | 610 | UMAShowArrowCursor() ; |
8461e4c2 | 611 | |
94826170 | 612 | return true; |
e9576ca5 SC |
613 | } |
614 | ||
15b41e90 SC |
615 | bool wxApp::OnInitGui() |
616 | { | |
e40298d5 JS |
617 | if( !wxAppBase::OnInitGui() ) |
618 | return false ; | |
7c9955d1 | 619 | |
e40298d5 | 620 | InstallStandardEventHandler( GetApplicationEventTarget() ) ; |
7c9955d1 | 621 | |
e128397f DS |
622 | if (!sm_isEmbedded) |
623 | { | |
624 | InstallApplicationEventHandler( | |
facd6764 | 625 | GetwxMacAppEventHandlerUPP(), |
e128397f DS |
626 | GetEventTypeCount(eventList), eventList, wxTheApp, (EventHandlerRef *)&(wxTheApp->m_macEventHandler)); |
627 | } | |
7c9955d1 | 628 | |
e128397f DS |
629 | if (!sm_isEmbedded) |
630 | { | |
e128397f DS |
631 | AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , |
632 | NewAEEventHandlerUPP(AEHandleODoc) , | |
633 | 0 , FALSE ) ; | |
634 | AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , | |
635 | NewAEEventHandlerUPP(AEHandleOApp) , | |
636 | 0 , FALSE ) ; | |
637 | AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , | |
638 | NewAEEventHandlerUPP(AEHandlePDoc) , | |
639 | 0 , FALSE ) ; | |
1c32ded3 SC |
640 | AEInstallEventHandler( kCoreEventClass , kAEReopenApplication , |
641 | NewAEEventHandlerUPP(AEHandleRApp) , | |
642 | 0 , FALSE ) ; | |
e128397f DS |
643 | AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , |
644 | NewAEEventHandlerUPP(AEHandleQuit) , | |
645 | 0 , FALSE ) ; | |
e128397f | 646 | } |
15b41e90 | 647 | |
e40298d5 | 648 | return TRUE ; |
15b41e90 SC |
649 | } |
650 | ||
e9576ca5 SC |
651 | void wxApp::CleanUp() |
652 | { | |
12cd5f34 | 653 | wxToolTip::RemoveToolTips() ; |
2f1ae414 SC |
654 | |
655 | // One last chance for pending objects to be cleaned up | |
656 | wxTheApp->DeletePendingObjects(); | |
657 | ||
fbbdb7cd | 658 | wxMacDestroyNotifierTable() ; |
84c1ffa9 | 659 | |
f5c6eb5c | 660 | #ifndef __DARWIN__ |
fbbdb7cd | 661 | # if __option(profile) |
ac2153a6 | 662 | ProfilerDump( (StringPtr)"\papp.prof" ) ; |
fbbdb7cd GD |
663 | ProfilerTerm() ; |
664 | # endif | |
9779893b | 665 | #endif |
519cb848 | 666 | |
21870a5d | 667 | #if defined(WXMAKINGDLL_CORE) && defined(__DARWIN__) |
fbbdb7cd GD |
668 | // close shared library resources from here since we don't have |
669 | // __wxterminate in Mach-O shared libraries | |
670 | wxStAppResource::CloseSharedLibraryResource(); | |
671 | #endif | |
7c9955d1 | 672 | |
8461e4c2 | 673 | UMACleanupToolbox() ; |
fbbdb7cd | 674 | if (s_macCursorRgn) { |
76a5e5d2 | 675 | ::DisposeRgn((RgnHandle)s_macCursorRgn); |
fbbdb7cd | 676 | } |
84c1ffa9 | 677 | |
8461e4c2 VZ |
678 | #if 0 |
679 | TerminateAE() ; | |
680 | #endif | |
94826170 VZ |
681 | |
682 | wxAppBase::CleanUp(); | |
e9576ca5 SC |
683 | } |
684 | ||
92b002a4 | 685 | //---------------------------------------------------------------------- |
05e2b077 | 686 | // misc initialization stuff |
92b002a4 RD |
687 | //---------------------------------------------------------------------- |
688 | ||
fbbdb7cd GD |
689 | // extern variable for shared library resource id |
690 | // need to be able to find it with NSLookupAndBindSymbol | |
facd6764 | 691 | short gSharedLibraryResource = kResFileNotOpened ; |
fbbdb7cd | 692 | |
21870a5d | 693 | #if defined(WXMAKINGDLL_CORE) && defined(__DARWIN__) |
fbbdb7cd | 694 | CFBundleRef gSharedLibraryBundle = NULL; |
21870a5d | 695 | #endif /* WXMAKINGDLL_CORE && __DARWIN__ */ |
53fd991c SC |
696 | |
697 | wxStAppResource::wxStAppResource() | |
698 | { | |
fbbdb7cd GD |
699 | m_currentRefNum = CurResFile() ; |
700 | if ( gSharedLibraryResource != kResFileNotOpened ) | |
701 | { | |
702 | UseResFile( gSharedLibraryResource ) ; | |
703 | } | |
704 | } | |
705 | ||
706 | wxStAppResource::~wxStAppResource() | |
707 | { | |
708 | if ( m_currentRefNum != kResFileNotOpened ) | |
709 | { | |
710 | UseResFile( m_currentRefNum ) ; | |
711 | } | |
712 | } | |
713 | ||
714 | void wxStAppResource::OpenSharedLibraryResource(const void *initBlock) | |
715 | { | |
716 | gSharedLibraryResource = kResFileNotOpened; | |
717 | ||
21870a5d | 718 | #ifdef WXMAKINGDLL_CORE |
fbbdb7cd GD |
719 | if ( initBlock != NULL ) { |
720 | const CFragInitBlock *theInitBlock = (const CFragInitBlock *)initBlock; | |
721 | FSSpec *fileSpec = NULL; | |
84c1ffa9 | 722 | |
fbbdb7cd GD |
723 | if (theInitBlock->fragLocator.where == kDataForkCFragLocator) { |
724 | fileSpec = theInitBlock->fragLocator.u.onDisk.fileSpec; | |
725 | } | |
726 | else if (theInitBlock->fragLocator.where == kResourceCFragLocator) { | |
727 | fileSpec = theInitBlock->fragLocator.u.inSegs.fileSpec; | |
728 | } | |
84c1ffa9 | 729 | |
fbbdb7cd GD |
730 | if (fileSpec != NULL) { |
731 | gSharedLibraryResource = FSpOpenResFile(fileSpec, fsRdPerm); | |
732 | } | |
733 | } | |
734 | else { | |
735 | #ifdef __DARWIN__ | |
736 | // Open the shared library resource file if it is not yet open | |
ed581ee2 GD |
737 | NSSymbol theSymbol; |
738 | NSModule theModule; | |
739 | const char *theLibPath; | |
84c1ffa9 | 740 | |
77ffb593 | 741 | gSharedLibraryBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.wxwindows.wxWidgets")); |
fbbdb7cd | 742 | if (gSharedLibraryBundle != NULL) { |
77ffb593 | 743 | // wxWidgets has been bundled into a framework |
ed581ee2 | 744 | // load the framework resources |
84c1ffa9 | 745 | |
fbbdb7cd | 746 | gSharedLibraryResource = CFBundleOpenBundleResourceMap(gSharedLibraryBundle); |
ed581ee2 GD |
747 | } |
748 | else { | |
77ffb593 | 749 | // wxWidgets is a simple dynamic shared library |
ed581ee2 | 750 | // load the resources from the data fork of a separate resource file |
21870a5d RD |
751 | wxString theResPath; |
752 | wxString theName; | |
ed581ee2 GD |
753 | FSRef theResRef; |
754 | OSErr theErr = noErr; | |
84c1ffa9 | 755 | |
ed581ee2 | 756 | // get the library path |
fbbdb7cd | 757 | theSymbol = NSLookupAndBindSymbol("_gSharedLibraryResource"); |
ed581ee2 GD |
758 | theModule = NSModuleForSymbol(theSymbol); |
759 | theLibPath = NSLibraryNameForModule(theModule); | |
ed581ee2 | 760 | |
376b18ea VZ |
761 | // if we call wxLogDebug from here then, as wxTheApp hasn't been |
762 | // created yet when we're called from wxApp::Initialize(), wxLog | |
763 | // is going to create a default stderr-based log target instead of | |
764 | // the expected normal GUI one -- don't do it, if we really want | |
765 | // to see this message just use fprintf() here | |
766 | #if 0 | |
f346733b GD |
767 | wxLogDebug( wxT("wxMac library installation name is '%s'"), |
768 | theLibPath ); | |
376b18ea | 769 | #endif |
f346733b | 770 | |
ed581ee2 | 771 | // allocate copy to replace .dylib.* extension with .rsrc |
21870a5d | 772 | if (theLibPath != NULL) { |
bc93670d GD |
773 | #if wxUSE_UNICODE |
774 | theResPath = wxString(theLibPath, wxConvLocal); | |
775 | #else | |
776 | theResPath = wxString(theLibPath); | |
777 | #endif | |
21870a5d RD |
778 | // replace '_core' with '' in case of multi-lib build |
779 | theResPath.Replace(wxT("_core"), wxEmptyString); | |
780 | // replace ".dylib" shared library extension with ".rsrc" | |
781 | theResPath.Replace(wxT(".dylib"), wxT(".rsrc")); | |
782 | // Find the begining of the filename | |
783 | theName = theResPath.AfterLast('/'); | |
84c1ffa9 | 784 | |
376b18ea | 785 | #if 0 |
f346733b | 786 | wxLogDebug( wxT("wxMac resources file name is '%s'"), |
21870a5d | 787 | theResPath.mb_str() ); |
376b18ea | 788 | #endif |
ed581ee2 | 789 | |
21870a5d | 790 | theErr = FSPathMakeRef((UInt8 *) theResPath.mb_str(), &theResRef, false); |
ed581ee2 GD |
791 | if (theErr != noErr) { |
792 | // try in current directory (using name only) | |
21870a5d | 793 | theErr = FSPathMakeRef((UInt8 *) theName.mb_str(), &theResRef, false); |
ed581ee2 | 794 | } |
84c1ffa9 | 795 | |
ed581ee2 GD |
796 | // open the resource file |
797 | if (theErr == noErr) { | |
798 | theErr = FSOpenResourceFile( &theResRef, 0, NULL, fsRdPerm, | |
fbbdb7cd | 799 | &gSharedLibraryResource); |
ed581ee2 | 800 | } |
f346733b | 801 | if (theErr != noErr) { |
376b18ea | 802 | #ifdef __WXDEBUG__ |
bc93670d GD |
803 | wxLogDebug( wxT("unable to open wxMac resource file '%s'\n"), |
804 | theResPath.mb_str() ); | |
376b18ea | 805 | #endif // __WXDEBUG__ |
f346733b GD |
806 | } |
807 | ||
ed581ee2 GD |
808 | } |
809 | } | |
fbbdb7cd | 810 | #endif /* __DARWIN__ */ |
53fd991c | 811 | } |
21870a5d | 812 | #endif /* WXMAKINGDLL_CORE */ |
53fd991c SC |
813 | } |
814 | ||
fbbdb7cd | 815 | void wxStAppResource::CloseSharedLibraryResource() |
53fd991c | 816 | { |
21870a5d | 817 | #ifdef WXMAKINGDLL_CORE |
ed581ee2 | 818 | // Close the shared library resource file |
fbbdb7cd GD |
819 | if (gSharedLibraryResource != kResFileNotOpened) { |
820 | #ifdef __DARWIN__ | |
821 | if (gSharedLibraryBundle != NULL) { | |
822 | CFBundleCloseBundleResourceMap(gSharedLibraryBundle, | |
823 | gSharedLibraryResource); | |
824 | gSharedLibraryBundle = NULL; | |
ed581ee2 | 825 | } |
fbbdb7cd GD |
826 | else |
827 | #endif /* __DARWIN__ */ | |
828 | { | |
829 | CloseResFile(gSharedLibraryResource); | |
ed581ee2 | 830 | } |
fbbdb7cd | 831 | gSharedLibraryResource = kResFileNotOpened; |
84c1ffa9 | 832 | } |
21870a5d | 833 | #endif /* WXMAKINGDLL_CORE */ |
53fd991c SC |
834 | } |
835 | ||
21870a5d | 836 | #if defined(WXMAKINGDLL_CORE) && !defined(__DARWIN__) |
53fd991c | 837 | |
ed581ee2 GD |
838 | // for shared libraries we have to manually get the correct resource |
839 | // ref num upon initializing and releasing when terminating, therefore | |
840 | // the __wxinitialize and __wxterminate must be used | |
53fd991c | 841 | |
53fd991c | 842 | extern "C" { |
e40298d5 | 843 | void __sinit(void); /* (generated by linker) */ |
fbbdb7cd GD |
844 | pascal OSErr __initialize(const CFragInitBlock *theInitBlock); |
845 | pascal void __terminate(void); | |
53fd991c | 846 | } |
53fd991c SC |
847 | |
848 | pascal OSErr __wxinitialize(const CFragInitBlock *theInitBlock) | |
849 | { | |
fbbdb7cd GD |
850 | wxStAppResource::OpenSharedLibraryResource( theInitBlock ) ; |
851 | return __initialize( theInitBlock ) ; | |
53fd991c SC |
852 | } |
853 | ||
854 | pascal void __wxterminate(void) | |
855 | { | |
fbbdb7cd | 856 | wxStAppResource::CloseSharedLibraryResource() ; |
53fd991c SC |
857 | __terminate() ; |
858 | } | |
ed581ee2 | 859 | |
21870a5d | 860 | #endif /* WXMAKINGDLL_CORE && !__DARWIN__ */ |
53fd991c | 861 | |
b4efa069 SC |
862 | bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) |
863 | { | |
864 | bool converted = ConvertEventRefToEventRecord( event,rec) ; | |
865 | OSStatus err = noErr ; | |
866 | if ( !converted ) | |
867 | { | |
868 | switch( GetEventClass( event ) ) | |
869 | { | |
870 | case kEventClassKeyboard : | |
871 | { | |
872 | converted = true ; | |
84c1ffa9 | 873 | switch( GetEventKind(event) ) |
b4efa069 SC |
874 | { |
875 | case kEventRawKeyDown : | |
876 | rec->what = keyDown ; | |
877 | break ; | |
878 | case kEventRawKeyRepeat : | |
879 | rec->what = autoKey ; | |
880 | break ; | |
881 | case kEventRawKeyUp : | |
882 | rec->what = keyUp ; | |
883 | break ; | |
884 | case kEventRawKeyModifiersChanged : | |
885 | rec->what = nullEvent ; | |
886 | break ; | |
887 | default : | |
888 | converted = false ; | |
889 | break ; | |
890 | } | |
891 | if ( converted ) | |
892 | { | |
893 | UInt32 keyCode ; | |
894 | unsigned char charCode ; | |
895 | UInt32 modifiers ; | |
896 | GetMouse( &rec->where) ; | |
897 | ||
898 | err = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers); | |
899 | err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode); | |
900 | err = GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode); | |
901 | rec->modifiers = modifiers ; | |
902 | rec->message = (keyCode << 8 ) + charCode ; | |
903 | } | |
904 | } | |
905 | break ; | |
906 | case kEventClassTextInput : | |
907 | { | |
908 | switch( GetEventKind( event ) ) | |
909 | { | |
910 | case kEventTextInputUnicodeForKeyEvent : | |
911 | { | |
912 | EventRef rawEvent ; | |
913 | err = GetEventParameter( event , kEventParamTextInputSendKeyboardEvent ,typeEventRef,NULL,sizeof(rawEvent),NULL,&rawEvent ) ; | |
914 | converted = true ; | |
915 | { | |
916 | UInt32 keyCode ; | |
917 | unsigned char charCode ; | |
918 | UInt32 modifiers ; | |
919 | GetMouse( &rec->where) ; | |
920 | rec->what = keyDown ; | |
921 | err = GetEventParameter(rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers); | |
922 | err = GetEventParameter(rawEvent, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode); | |
923 | err = GetEventParameter(rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode); | |
924 | rec->modifiers = modifiers ; | |
925 | rec->message = (keyCode << 8 ) + charCode ; | |
926 | } | |
927 | } | |
928 | break ; | |
929 | default : | |
930 | break ; | |
931 | } | |
932 | } | |
933 | break ; | |
934 | } | |
935 | } | |
84c1ffa9 | 936 | |
b4efa069 SC |
937 | return converted ; |
938 | } | |
939 | ||
e9576ca5 SC |
940 | wxApp::wxApp() |
941 | { | |
e9576ca5 | 942 | m_printMode = wxPRINT_WINDOWS; |
1ea39a03 SC |
943 | |
944 | m_macCurrentEvent = NULL ; | |
945 | m_macCurrentEventHandlerCallRef = NULL ; | |
e9576ca5 SC |
946 | } |
947 | ||
e9576ca5 SC |
948 | int wxApp::MainLoop() |
949 | { | |
e40298d5 | 950 | m_keepGoing = TRUE; |
3fbf8e7f SC |
951 | #if wxMAC_USE_RAEL |
952 | RunApplicationEventLoop() ; | |
953 | #else | |
e40298d5 JS |
954 | while (m_keepGoing) |
955 | { | |
956 | MacDoOneEvent() ; | |
957 | } | |
3fbf8e7f | 958 | #endif |
e40298d5 | 959 | return 0; |
e9576ca5 SC |
960 | } |
961 | ||
e9576ca5 SC |
962 | void wxApp::ExitMainLoop() |
963 | { | |
3fbf8e7f SC |
964 | m_keepGoing = FALSE; |
965 | #if wxMAC_USE_RAEL | |
966 | QuitApplicationEventLoop() ; | |
967 | #endif | |
e9576ca5 SC |
968 | } |
969 | ||
970 | // Is a message/event pending? | |
971 | bool wxApp::Pending() | |
972 | { | |
2dd35daa SC |
973 | // without the receive event (with pull param = false ) nothing is ever reported |
974 | EventRef theEvent; | |
975 | ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &theEvent); | |
976 | return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ; | |
e9576ca5 SC |
977 | } |
978 | ||
979 | // Dispatch a message. | |
1bf77ee5 | 980 | bool wxApp::Dispatch() |
e9576ca5 | 981 | { |
8461e4c2 | 982 | MacDoOneEvent() ; |
1bf77ee5 VZ |
983 | |
984 | return true; | |
e9576ca5 SC |
985 | } |
986 | ||
987 | void wxApp::OnIdle(wxIdleEvent& event) | |
988 | { | |
955a9197 | 989 | wxAppBase::OnIdle(event); |
21870a5d | 990 | |
2f1ae414 SC |
991 | // If they are pending events, we must process them: pending events are |
992 | // either events to the threads other than main or events posted with | |
993 | // wxPostEvent() functions | |
994 | wxMacProcessNotifierAndPendingEvents(); | |
995 | ||
3fdac2ab DE |
996 | if(!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar()) |
997 | wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar(); | |
e9576ca5 SC |
998 | } |
999 | ||
e2478fde | 1000 | void wxApp::WakeUpIdle() |
9779893b | 1001 | { |
8461e4c2 | 1002 | wxMacWakeUp() ; |
9779893b RD |
1003 | } |
1004 | ||
e2478fde | 1005 | void wxApp::Exit() |
e9576ca5 | 1006 | { |
2f1ae414 | 1007 | wxApp::CleanUp(); |
8461e4c2 | 1008 | ::ExitToShell() ; |
e9576ca5 SC |
1009 | } |
1010 | ||
2f1ae414 SC |
1011 | void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event)) |
1012 | { | |
1013 | if (GetTopWindow()) | |
1014 | GetTopWindow()->Close(TRUE); | |
1015 | } | |
1016 | ||
1017 | // Default behaviour: close the application with prompts. The | |
1018 | // user can veto the close, and therefore the end session. | |
1019 | void wxApp::OnQueryEndSession(wxCloseEvent& event) | |
1020 | { | |
1021 | if (GetTopWindow()) | |
1022 | { | |
1023 | if (!GetTopWindow()->Close(!event.CanVeto())) | |
1024 | event.Veto(TRUE); | |
1025 | } | |
1026 | } | |
1027 | ||
1028 | extern "C" void wxCYield() ; | |
1029 | void wxCYield() | |
1030 | { | |
8461e4c2 | 1031 | wxYield() ; |
2f1ae414 SC |
1032 | } |
1033 | ||
e9576ca5 | 1034 | // Yield to other processes |
cb2713bf | 1035 | |
8461e4c2 | 1036 | bool wxApp::Yield(bool onlyIfNeeded) |
e9576ca5 | 1037 | { |
8461e4c2 VZ |
1038 | if (s_inYield) |
1039 | { | |
1040 | if ( !onlyIfNeeded ) | |
1041 | { | |
1042 | wxFAIL_MSG( wxT("wxYield called recursively" ) ); | |
1043 | } | |
1044 | ||
1045 | return FALSE; | |
1046 | } | |
1047 | ||
1048 | s_inYield = TRUE; | |
cb2713bf | 1049 | |
e40298d5 | 1050 | // by definition yield should handle all non-processed events |
facd6764 | 1051 | |
e40298d5 JS |
1052 | EventRef theEvent; |
1053 | ||
1054 | OSStatus status = noErr ; | |
1055 | do | |
1056 | { | |
1057 | s_inReceiveEvent = true ; | |
1058 | status = ReceiveNextEvent(0, NULL,kEventDurationNoWait,true,&theEvent) ; | |
1059 | s_inReceiveEvent = false ; | |
7c9955d1 | 1060 | |
e40298d5 JS |
1061 | if ( status == eventLoopTimedOutErr ) |
1062 | { | |
1063 | // make sure next time the event loop will trigger idle events | |
1064 | sleepTime = kEventDurationNoWait ; | |
1065 | } | |
1066 | else if ( status == eventLoopQuitErr ) | |
1067 | { | |
1068 | // according to QA1061 this may also occur when a WakeUp Process | |
1069 | // is executed | |
1070 | } | |
1071 | else | |
1072 | { | |
1073 | MacHandleOneEvent( theEvent ) ; | |
1074 | ReleaseEvent(theEvent); | |
1075 | } | |
1076 | } while( status == noErr ) ; | |
2f1ae414 | 1077 | |
8461e4c2 | 1078 | wxMacProcessNotifierAndPendingEvents() ; |
8461e4c2 | 1079 | s_inYield = FALSE; |
cb2713bf | 1080 | |
8461e4c2 | 1081 | return TRUE; |
169935ad SC |
1082 | } |
1083 | ||
9779893b | 1084 | void wxApp::MacDoOneEvent() |
169935ad | 1085 | { |
e40298d5 | 1086 | EventRef theEvent; |
c5c9378c | 1087 | |
e40298d5 JS |
1088 | s_inReceiveEvent = true ; |
1089 | OSStatus status = ReceiveNextEvent(0, NULL,sleepTime,true,&theEvent) ; | |
1090 | s_inReceiveEvent = false ; | |
1091 | if ( status == eventLoopTimedOutErr ) | |
1092 | { | |
c5c9378c | 1093 | if ( wxTheApp->ProcessIdle() ) |
e40298d5 | 1094 | sleepTime = kEventDurationNoWait ; |
c5c9378c | 1095 | else |
820d6bac | 1096 | sleepTime = kEventDurationSecond; |
e40298d5 JS |
1097 | } |
1098 | else if ( status == eventLoopQuitErr ) | |
1099 | { | |
1100 | // according to QA1061 this may also occur when a WakeUp Process | |
1101 | // is executed | |
1102 | } | |
1103 | else | |
1104 | { | |
1105 | MacHandleOneEvent( theEvent ) ; | |
1106 | ReleaseEvent(theEvent); | |
3470af1c | 1107 | sleepTime = kEventDurationNoWait ; |
e40298d5 | 1108 | } |
8461e4c2 | 1109 | // repeaters |
519cb848 | 1110 | |
6264b550 | 1111 | DeletePendingObjects() ; |
8461e4c2 | 1112 | wxMacProcessNotifierAndPendingEvents() ; |
169935ad SC |
1113 | } |
1114 | ||
e128397f DS |
1115 | /*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr ) |
1116 | { | |
1117 | // Override to process unhandled events as you please | |
1118 | } | |
1119 | ||
76a5e5d2 | 1120 | void wxApp::MacHandleOneEvent( WXEVENTREF evr ) |
169935ad | 1121 | { |
e40298d5 JS |
1122 | EventTargetRef theTarget; |
1123 | theTarget = GetEventDispatcherTarget(); | |
c5c9378c | 1124 | m_macCurrentEvent = evr ; |
e128397f DS |
1125 | OSStatus status = SendEventToEventTarget ((EventRef) evr , theTarget); |
1126 | if(status == eventNotHandledErr) | |
1127 | { | |
1128 | MacHandleUnhandledEvent(evr); | |
1129 | } | |
8461e4c2 | 1130 | wxMacProcessNotifierAndPendingEvents() ; |
f8df60f2 SC |
1131 | #if wxUSE_THREADS |
1132 | wxMutexGuiLeaveOrEnter(); | |
1133 | #endif // wxUSE_THREADS | |
169935ad SC |
1134 | } |
1135 | ||
72055702 | 1136 | long wxMacTranslateKey(unsigned char key, unsigned char code) ; |
7c551d95 | 1137 | long wxMacTranslateKey(unsigned char key, unsigned char code) |
9779893b | 1138 | { |
8461e4c2 | 1139 | long retval = key ; |
9779893b | 1140 | switch (key) |
519cb848 | 1141 | { |
12e049f6 | 1142 | case kHomeCharCode : |
8461e4c2 VZ |
1143 | retval = WXK_HOME; |
1144 | break; | |
12e049f6 | 1145 | case kEnterCharCode : |
8461e4c2 VZ |
1146 | retval = WXK_RETURN; |
1147 | break; | |
12e049f6 | 1148 | case kEndCharCode : |
8461e4c2 VZ |
1149 | retval = WXK_END; |
1150 | break; | |
12e049f6 | 1151 | case kHelpCharCode : |
8461e4c2 VZ |
1152 | retval = WXK_HELP; |
1153 | break; | |
12e049f6 | 1154 | case kBackspaceCharCode : |
8461e4c2 VZ |
1155 | retval = WXK_BACK; |
1156 | break; | |
12e049f6 | 1157 | case kTabCharCode : |
8461e4c2 VZ |
1158 | retval = WXK_TAB; |
1159 | break; | |
12e049f6 | 1160 | case kPageUpCharCode : |
8461e4c2 VZ |
1161 | retval = WXK_PAGEUP; |
1162 | break; | |
12e049f6 | 1163 | case kPageDownCharCode : |
8461e4c2 VZ |
1164 | retval = WXK_PAGEDOWN; |
1165 | break; | |
12e049f6 | 1166 | case kReturnCharCode : |
8461e4c2 VZ |
1167 | retval = WXK_RETURN; |
1168 | break; | |
12e049f6 | 1169 | case kFunctionKeyCharCode : |
8461e4c2 VZ |
1170 | { |
1171 | switch( code ) | |
1172 | { | |
1173 | case 0x7a : | |
1174 | retval = WXK_F1 ; | |
1175 | break; | |
1176 | case 0x78 : | |
1177 | retval = WXK_F2 ; | |
1178 | break; | |
1179 | case 0x63 : | |
1180 | retval = WXK_F3 ; | |
1181 | break; | |
1182 | case 0x76 : | |
1183 | retval = WXK_F4 ; | |
1184 | break; | |
1185 | case 0x60 : | |
1186 | retval = WXK_F5 ; | |
1187 | break; | |
1188 | case 0x61 : | |
1189 | retval = WXK_F6 ; | |
1190 | break; | |
1191 | case 0x62: | |
1192 | retval = WXK_F7 ; | |
1193 | break; | |
1194 | case 0x64 : | |
1195 | retval = WXK_F8 ; | |
1196 | break; | |
1197 | case 0x65 : | |
1198 | retval = WXK_F9 ; | |
1199 | break; | |
1200 | case 0x6D : | |
1201 | retval = WXK_F10 ; | |
1202 | break; | |
1203 | case 0x67 : | |
1204 | retval = WXK_F11 ; | |
1205 | break; | |
1206 | case 0x6F : | |
1207 | retval = WXK_F12 ; | |
1208 | break; | |
1209 | case 0x69 : | |
1210 | retval = WXK_F13 ; | |
1211 | break; | |
1212 | case 0x6B : | |
1213 | retval = WXK_F14 ; | |
1214 | break; | |
1215 | case 0x71 : | |
1216 | retval = WXK_F15 ; | |
1217 | break; | |
1218 | } | |
1219 | } | |
1220 | break ; | |
12e049f6 | 1221 | case kEscapeCharCode : |
8461e4c2 VZ |
1222 | retval = WXK_ESCAPE ; |
1223 | break ; | |
12e049f6 | 1224 | case kLeftArrowCharCode : |
8461e4c2 VZ |
1225 | retval = WXK_LEFT ; |
1226 | break ; | |
12e049f6 | 1227 | case kRightArrowCharCode : |
8461e4c2 VZ |
1228 | retval = WXK_RIGHT ; |
1229 | break ; | |
12e049f6 | 1230 | case kUpArrowCharCode : |
8461e4c2 VZ |
1231 | retval = WXK_UP ; |
1232 | break ; | |
12e049f6 | 1233 | case kDownArrowCharCode : |
8461e4c2 VZ |
1234 | retval = WXK_DOWN ; |
1235 | break ; | |
12e049f6 | 1236 | case kDeleteCharCode : |
8461e4c2 VZ |
1237 | retval = WXK_DELETE ; |
1238 | default: | |
1239 | break ; | |
1240 | } // end switch | |
1241 | ||
1242 | return retval; | |
169935ad SC |
1243 | } |
1244 | ||
facd6764 | 1245 | int wxMacKeyCodeToModifier(wxKeyCode key) |
6ed892f3 RN |
1246 | { |
1247 | switch (key) | |
1248 | { | |
1249 | case WXK_START: | |
15c2acd2 | 1250 | case WXK_MENU: |
6ed892f3 RN |
1251 | return cmdKey; |
1252 | ||
1253 | case WXK_SHIFT: | |
1254 | return shiftKey; | |
1255 | ||
1256 | case WXK_CAPITAL: | |
1257 | return alphaLock; | |
1258 | ||
15c2acd2 RN |
1259 | case WXK_ALT: |
1260 | return optionKey; | |
6ed892f3 RN |
1261 | |
1262 | case WXK_CONTROL: | |
1263 | return controlKey; | |
1264 | ||
1265 | default: | |
1266 | return 0; | |
1267 | } | |
1268 | } | |
1269 | ||
1270 | bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below | |
1271 | { | |
7f71c4c8 RN |
1272 | //#ifdef __DARWIN__ |
1273 | // wxHIDKeyboard keyboard; | |
1274 | // return keyboard.IsActive(key); | |
1275 | //#else | |
104cdef6 | 1276 | // TODO: Have it use HID Manager on OSX... |
6ed892f3 RN |
1277 | //if OS X > 10.2 (i.e. 10.2.x) |
1278 | //a known apple bug prevents the system from determining led | |
1279 | //states with GetKeys... can only determine caps lock led | |
facd6764 | 1280 | return !!(GetCurrentKeyModifiers() & wxMacKeyCodeToModifier(key)); |
6ed892f3 RN |
1281 | //else |
1282 | // KeyMapByteArray keymap; | |
1283 | // GetKeys((BigEndianLong*)keymap); | |
1284 | // return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey)); | |
7f71c4c8 | 1285 | //#endif |
6ed892f3 RN |
1286 | } |
1287 | ||
c5c9378c | 1288 | |
12e049f6 | 1289 | bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey ) |
ac2d1ca6 | 1290 | { |
ba12463b SC |
1291 | if ( !focus ) |
1292 | return false ; | |
7c9955d1 | 1293 | |
12e049f6 SC |
1294 | short keycode ; |
1295 | short keychar ; | |
1296 | keychar = short(keymessage & charCodeMask); | |
1297 | keycode = short(keymessage & keyCodeMask) >> 8 ; | |
7c9955d1 | 1298 | |
ef08713a | 1299 | if ( modifiers & ( controlKey|shiftKey|optionKey ) ) |
12e049f6 SC |
1300 | { |
1301 | // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier | |
1302 | // and look at the character after | |
1303 | UInt32 state = 0; | |
ef08713a | 1304 | UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state); |
12e049f6 SC |
1305 | keychar = short(keyInfo & charCodeMask); |
1306 | keycode = short(keyInfo & keyCodeMask) >> 8 ; | |
1307 | } | |
1308 | long keyval = wxMacTranslateKey(keychar, keycode) ; | |
e40298d5 JS |
1309 | long realkeyval = keyval ; |
1310 | if ( keyval == keychar ) | |
1311 | { | |
1312 | // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY (make upper first) | |
1313 | realkeyval = short(keymessage & charCodeMask) ; | |
1314 | keyval = wxToupper( keyval ) ; | |
1315 | } | |
7c9955d1 | 1316 | |
ac2d1ca6 | 1317 | wxKeyEvent event(wxEVT_KEY_DOWN); |
41d368a4 | 1318 | bool handled = false ; |
ac2d1ca6 SC |
1319 | event.m_shiftDown = modifiers & shiftKey; |
1320 | event.m_controlDown = modifiers & controlKey; | |
1321 | event.m_altDown = modifiers & optionKey; | |
1322 | event.m_metaDown = modifiers & cmdKey; | |
ef08713a | 1323 | event.m_keyCode = keyval ; |
ac2d1ca6 SC |
1324 | |
1325 | event.m_x = wherex; | |
1326 | event.m_y = wherey; | |
1327 | event.m_timeStamp = when; | |
1328 | event.SetEventObject(focus); | |
1329 | handled = focus->GetEventHandler()->ProcessEvent( event ) ; | |
1330 | if ( handled && event.GetSkipped() ) | |
1331 | handled = false ; | |
1332 | if ( !handled ) | |
1333 | { | |
ba2928c6 | 1334 | #if wxUSE_ACCEL |
ac2d1ca6 SC |
1335 | if (!handled) |
1336 | { | |
1337 | wxWindow *ancestor = focus; | |
1338 | while (ancestor) | |
1339 | { | |
1340 | int command = ancestor->GetAcceleratorTable()->GetCommand( event ); | |
1341 | if (command != -1) | |
8461e4c2 | 1342 | { |
ac2d1ca6 SC |
1343 | wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command ); |
1344 | handled = ancestor->GetEventHandler()->ProcessEvent( command_event ); | |
1345 | break; | |
8461e4c2 | 1346 | } |
ac2d1ca6 SC |
1347 | if (ancestor->IsTopLevel()) |
1348 | break; | |
1349 | ancestor = ancestor->GetParent(); | |
8461e4c2 | 1350 | } |
ac2d1ca6 SC |
1351 | } |
1352 | #endif // wxUSE_ACCEL | |
1353 | } | |
1354 | if (!handled) | |
1355 | { | |
1356 | event.Skip( FALSE ) ; | |
1357 | event.SetEventType( wxEVT_CHAR ) ; | |
12e049f6 | 1358 | // raw value again |
ef08713a | 1359 | event.m_keyCode = realkeyval ; |
ac2d1ca6 SC |
1360 | |
1361 | handled = focus->GetEventHandler()->ProcessEvent( event ) ; | |
1362 | if ( handled && event.GetSkipped() ) | |
1363 | handled = false ; | |
1364 | } | |
bdf956fb | 1365 | if ( !handled && (keyval == WXK_TAB) ) |
ac2d1ca6 | 1366 | { |
bdf956fb SC |
1367 | wxWindow* iter = focus->GetParent() ; |
1368 | while( iter && !handled ) | |
1369 | { | |
1370 | if ( iter->HasFlag( wxTAB_TRAVERSAL ) ) | |
1371 | { | |
1372 | wxNavigationKeyEvent new_event; | |
1373 | new_event.SetEventObject( focus ); | |
1374 | new_event.SetDirection( !event.ShiftDown() ); | |
1375 | /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */ | |
1376 | new_event.SetWindowChange( event.ControlDown() ); | |
1377 | new_event.SetCurrentFocus( focus ); | |
1378 | handled = focus->GetParent()->GetEventHandler()->ProcessEvent( new_event ); | |
1379 | if ( handled && new_event.GetSkipped() ) | |
1380 | handled = false ; | |
1381 | } | |
1382 | iter = iter->GetParent() ; | |
1383 | } | |
ac2d1ca6 SC |
1384 | } |
1385 | // backdoor handler for default return and command escape | |
1386 | if ( !handled && (!focus->IsKindOf(CLASSINFO(wxControl) ) || !focus->MacCanFocus() ) ) | |
1387 | { | |
1388 | // if window is not having a focus still testing for default enter or cancel | |
1389 | // TODO add the UMA version for ActiveNonFloatingWindow | |
1390 | wxWindow* focus = wxFindWinFromMacWindow( FrontWindow() ) ; | |
e562df9b SC |
1391 | if ( focus ) |
1392 | { | |
1393 | if ( keyval == WXK_RETURN ) | |
1394 | { | |
1395 | wxButton *def = wxDynamicCast(focus->GetDefaultItem(), | |
1396 | wxButton); | |
1397 | if ( def && def->IsEnabled() ) | |
1398 | { | |
1399 | wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); | |
1400 | event.SetEventObject(def); | |
1401 | def->Command(event); | |
ac2d1ca6 | 1402 | return true ; |
e562df9b SC |
1403 | } |
1404 | } | |
8461e4c2 | 1405 | /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */ |
ac2d1ca6 | 1406 | else if (keyval == WXK_ESCAPE || (keyval == '.' && modifiers & cmdKey ) ) |
8461e4c2 | 1407 | { |
e562df9b SC |
1408 | wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); |
1409 | new_event.SetEventObject( focus ); | |
1410 | handled = focus->GetEventHandler()->ProcessEvent( new_event ); | |
8461e4c2 | 1411 | } |
e562df9b | 1412 | } |
8461e4c2 | 1413 | } |
ac2d1ca6 | 1414 | return handled ; |
169935ad SC |
1415 | } |
1416 | ||
12e049f6 | 1417 | bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey ) |
ac2d1ca6 | 1418 | { |
ba12463b SC |
1419 | if ( !focus ) |
1420 | return false ; | |
1421 | ||
12e049f6 SC |
1422 | short keycode ; |
1423 | short keychar ; | |
1424 | keychar = short(keymessage & charCodeMask); | |
1425 | keycode = short(keymessage & keyCodeMask) >> 8 ; | |
ef08713a | 1426 | if ( modifiers & ( controlKey|shiftKey|optionKey ) ) |
12e049f6 SC |
1427 | { |
1428 | // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier | |
1429 | // and look at the character after | |
1430 | UInt32 state = 0; | |
ef08713a | 1431 | UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state); |
12e049f6 SC |
1432 | keychar = short(keyInfo & charCodeMask); |
1433 | keycode = short(keyInfo & keyCodeMask) >> 8 ; | |
1434 | } | |
1435 | long keyval = wxMacTranslateKey(keychar, keycode) ; | |
1436 | ||
e40298d5 JS |
1437 | if ( keyval == keychar ) |
1438 | { | |
7c9955d1 | 1439 | keyval = wxToupper( keyval ) ; |
e40298d5 | 1440 | } |
ac2d1ca6 | 1441 | bool handled = false ; |
ac2d1ca6 | 1442 | |
ba12463b SC |
1443 | wxKeyEvent event(wxEVT_KEY_UP); |
1444 | event.m_shiftDown = modifiers & shiftKey; | |
1445 | event.m_controlDown = modifiers & controlKey; | |
1446 | event.m_altDown = modifiers & optionKey; | |
1447 | event.m_metaDown = modifiers & cmdKey; | |
ef08713a | 1448 | event.m_keyCode = keyval ; |
ba12463b SC |
1449 | |
1450 | event.m_x = wherex; | |
1451 | event.m_y = wherey; | |
1452 | event.m_timeStamp = when; | |
1453 | event.SetEventObject(focus); | |
1454 | handled = focus->GetEventHandler()->ProcessEvent( event ) ; | |
1455 | ||
ac2d1ca6 SC |
1456 | return handled ; |
1457 | } |