1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/evtloop.mm
3 // Purpose: implementation of wxEventLoop for OS X
4 // Author: Vadim Zeitlin, Stefan Csomor
8 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #include "wx/evtloop.h"
36 #include "wx/nonownedwnd.h"
39 #include "wx/osx/private.h"
41 // ============================================================================
42 // wxEventLoop implementation
43 // ============================================================================
46 static int CalculateUIEventMaskFromEventCategory(wxEventCategory cat)
50 NSRightMouseDownMask |
51 NSRightMouseUpMask = 1 << NSRightMouseUp,
52 NSMouseMovedMask = 1 << NSMouseMoved,
53 NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged,
54 NSRightMouseDraggedMask = 1 << NSRightMouseDragged,
55 NSMouseEnteredMask = 1 << NSMouseEntered,
56 NSMouseExitedMask = 1 << NSMouseExited,
57 NSScrollWheelMask = 1 << NSScrollWheel,
58 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
59 NSTabletPointMask = 1 << NSTabletPoint,
60 NSTabletProximityMask = 1 << NSTabletProximity,
62 NSOtherMouseDownMask = 1 << NSOtherMouseDown,
63 NSOtherMouseUpMask = 1 << NSOtherMouseUp,
64 NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged,
68 NSKeyDownMask = 1 << NSKeyDown,
69 NSKeyUpMask = 1 << NSKeyUp,
70 NSFlagsChangedMask = 1 << NSFlagsChanged,
72 NSAppKitDefinedMask = 1 << NSAppKitDefined,
73 NSSystemDefinedMask = 1 << NSSystemDefined,
74 UIApplicationDefinedMask = 1 << UIApplicationDefined,
75 NSPeriodicMask = 1 << NSPeriodic,
76 NSCursorUpdateMask = 1 << NSCursorUpdate,
78 NSAnyEventMask = 0xffffffffU
82 wxGUIEventLoop::wxGUIEventLoop()
86 void wxGUIEventLoop::OSXDoRun()
90 wxMacAutoreleasePool pool;
91 const char* appname = "app";
92 UIApplicationMain( 1, (char**) &appname, nil, @"wxAppDelegate" );
96 wxCFEventLoop::OSXDoRun();
100 int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout)
102 return wxCFEventLoop::DoDispatchTimeout(timeout);
105 void wxGUIEventLoop::OSXDoStop()
107 return wxCFEventLoop::OSXDoStop();
110 CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const
112 return wxCFEventLoop::CFGetCurrentRunLoop();
115 void wxGUIEventLoop::WakeUp()
117 return wxCFEventLoop::WakeUp();
120 // TODO move into a evtloop_osx.cpp
122 wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow)
124 m_modalWindow = dynamic_cast<wxNonOwnedWindow*> (modalWindow);
125 wxASSERT_MSG( m_modalWindow != NULL, "must pass in a toplevel window for modal event loop" );
126 m_modalNativeWindow = m_modalWindow->GetWXWindow();
129 wxModalEventLoop::wxModalEventLoop(WXWindow modalNativeWindow)
131 m_modalWindow = NULL;
132 wxASSERT_MSG( modalNativeWindow != NULL, "must pass in a toplevel window for modal event loop" );
133 m_modalNativeWindow = modalNativeWindow;
136 // END move into a evtloop_osx.cpp
139 void wxModalEventLoop::OSXDoRun()
141 // presentModalViewController:animated:
144 void wxModalEventLoop::OSXDoStop()
146 // (void)dismissModalViewControllerAnimated:(BOOL)animated