]> git.saurik.com Git - wxWidgets.git/blob - src/osx/iphone/evtloop.mm
streamlining OSX event support third step, using platform specific native run methods...
[wxWidgets.git] / src / osx / iphone / evtloop.mm
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/evtloop.mm
3 // Purpose: implementation of wxEventLoop for OS X
4 // Author: Vadim Zeitlin, Stefan Csomor
5 // Modified by:
6 // Created: 2006-01-12
7 // RCS-ID: $Id: evtloop.cpp 54845 2008-07-30 14:52:41Z SC $
8 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #include "wx/evtloop.h"
28
29 #ifndef WX_PRECOMP
30 #include "wx/app.h"
31 #endif // WX_PRECOMP
32
33 #include "wx/log.h"
34
35 #include "wx/osx/private.h"
36
37 // ============================================================================
38 // wxEventLoop implementation
39 // ============================================================================
40
41 /*
42 static int CalculateUIEventMaskFromEventCategory(wxEventCategory cat)
43 {
44 NSLeftMouseDownMask |
45 NSLeftMouseUpMask |
46 NSRightMouseDownMask |
47 NSRightMouseUpMask = 1 << NSRightMouseUp,
48 NSMouseMovedMask = 1 << NSMouseMoved,
49 NSLeftMouseDraggedMask = 1 << NSLeftMouseDragged,
50 NSRightMouseDraggedMask = 1 << NSRightMouseDragged,
51 NSMouseEnteredMask = 1 << NSMouseEntered,
52 NSMouseExitedMask = 1 << NSMouseExited,
53 NSScrollWheelMask = 1 << NSScrollWheel,
54 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
55 NSTabletPointMask = 1 << NSTabletPoint,
56 NSTabletProximityMask = 1 << NSTabletProximity,
57 #endif
58 NSOtherMouseDownMask = 1 << NSOtherMouseDown,
59 NSOtherMouseUpMask = 1 << NSOtherMouseUp,
60 NSOtherMouseDraggedMask = 1 << NSOtherMouseDragged,
61
62
63
64 NSKeyDownMask = 1 << NSKeyDown,
65 NSKeyUpMask = 1 << NSKeyUp,
66 NSFlagsChangedMask = 1 << NSFlagsChanged,
67
68 NSAppKitDefinedMask = 1 << NSAppKitDefined,
69 NSSystemDefinedMask = 1 << NSSystemDefined,
70 UIApplicationDefinedMask = 1 << UIApplicationDefined,
71 NSPeriodicMask = 1 << NSPeriodic,
72 NSCursorUpdateMask = 1 << NSCursorUpdate,
73
74 NSAnyEventMask = 0xffffffffU
75 }
76 */
77
78 @interface wxAppDelegate : NSObject <UIApplicationDelegate> {
79 }
80
81 @end
82
83 @implementation wxAppDelegate
84
85 - (void)applicationDidFinishLaunching:(UIApplication *)application {
86 wxTheApp->OnInit();
87 }
88
89 - (void)applicationWillTerminate:(UIApplication *)application {
90 wxCloseEvent event;
91 wxTheApp->OnEndSession(event);
92 }
93
94 - (void)dealloc {
95 [super dealloc];
96 }
97
98 @end
99
100 wxGUIEventLoop::wxGUIEventLoop()
101 {
102 }
103
104 void wxGUIEventLoop::DoRun()
105 {
106 if ( IsMain() )
107 {
108 wxMacAutoreleasePool pool;
109 const char* appname = "app";
110 UIApplicationMain( 1, (char**) &appname, nil, @"wxAppDelegate" );
111 }
112 else
113 {
114 wxCFEventLoop::DoRun();
115 }
116 }
117