1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/evtloop.mm
3 // Purpose: implementation of wxEventLoop for OS X
4 // Author: Vadim Zeitlin, Stefan Csomor
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #include "wx/evtloop.h"
35 #include "wx/nonownedwnd.h"
38 #include "wx/osx/private.h"
40 // ============================================================================
41 // wxEventLoop implementation
42 // ============================================================================
45 static int CalculateUIEventMaskFromEventCategory(wxEventCategory cat)
49 NSRightMouseDownMask |
50 NSRightMouseUpMask = 1 << NSRightMouseUp,
51 NSMouseMovedMask = 1 << NSMouseMoved,
52 NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged,
53 NSRightMouseDraggedMask = 1 << NSRightMouseDragged,
54 NSMouseEnteredMask = 1 << NSMouseEntered,
55 NSMouseExitedMask = 1 << NSMouseExited,
56 NSScrollWheelMask = 1 << NSScrollWheel,
57 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
58 NSTabletPointMask = 1 << NSTabletPoint,
59 NSTabletProximityMask = 1 << NSTabletProximity,
61 NSOtherMouseDownMask = 1 << NSOtherMouseDown,
62 NSOtherMouseUpMask = 1 << NSOtherMouseUp,
63 NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged,
67 NSKeyDownMask = 1 << NSKeyDown,
68 NSKeyUpMask = 1 << NSKeyUp,
69 NSFlagsChangedMask = 1 << NSFlagsChanged,
71 NSAppKitDefinedMask = 1 << NSAppKitDefined,
72 NSSystemDefinedMask = 1 << NSSystemDefined,
73 UIApplicationDefinedMask = 1 << UIApplicationDefined,
74 NSPeriodicMask = 1 << NSPeriodic,
75 NSCursorUpdateMask = 1 << NSCursorUpdate,
77 NSAnyEventMask = 0xffffffffU
81 wxGUIEventLoop::wxGUIEventLoop()
85 void wxGUIEventLoop::OSXDoRun()
89 wxMacAutoreleasePool pool;
90 const char* appname = "app";
91 UIApplicationMain( 1, (char**) &appname, nil, @"wxAppDelegate" );
95 wxCFEventLoop::OSXDoRun();
99 int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout)
101 return wxCFEventLoop::DoDispatchTimeout(timeout);
104 void wxGUIEventLoop::OSXDoStop()
106 return wxCFEventLoop::OSXDoStop();
109 CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const
111 return wxCFEventLoop::CFGetCurrentRunLoop();
114 void wxGUIEventLoop::WakeUp()
116 return wxCFEventLoop::WakeUp();
119 // TODO move into a evtloop_osx.cpp
121 wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow)
123 m_modalWindow = dynamic_cast<wxNonOwnedWindow*> (modalWindow);
124 wxASSERT_MSG( m_modalWindow != NULL, "must pass in a toplevel window for modal event loop" );
125 m_modalNativeWindow = m_modalWindow->GetWXWindow();
128 wxModalEventLoop::wxModalEventLoop(WXWindow modalNativeWindow)
130 m_modalWindow = NULL;
131 wxASSERT_MSG( modalNativeWindow != NULL, "must pass in a toplevel window for modal event loop" );
132 m_modalNativeWindow = modalNativeWindow;
135 // END move into a evtloop_osx.cpp
138 void wxModalEventLoop::OSXDoRun()
140 // presentModalViewController:animated:
143 void wxModalEventLoop::OSXDoStop()
145 // (void)dismissModalViewControllerAnimated:(BOOL)animated