]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/app.h
extracted common initialization/cleanup functions in common/init.cpp; standardized...
[wxWidgets.git] / include / wx / mac / app.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: app.h
3 // Purpose: wxApp class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_APP_H_
13 #define _WX_APP_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "app.h"
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/object.h"
21 #include "wx/gdicmn.h"
22 #include "wx/event.h"
23
24 class WXDLLEXPORT wxFrame;
25 class WXDLLEXPORT wxWindowMac;
26 class WXDLLEXPORT wxApp ;
27 class WXDLLEXPORT wxKeyEvent;
28 class WXDLLEXPORT wxLog;
29
30 #define wxPRINT_WINDOWS 1
31 #define wxPRINT_POSTSCRIPT 2
32
33 WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
34
35 // Force an exit from main loop
36 void WXDLLEXPORT wxExit();
37
38 // Yield to other apps/messages
39 bool WXDLLEXPORT wxYield();
40
41 // Represents the application. Derive OnInit and declare
42 // a new App object to start application
43 class WXDLLEXPORT wxApp: public wxAppBase
44 {
45 DECLARE_DYNAMIC_CLASS(wxApp)
46
47 wxApp();
48 virtual ~wxApp() {}
49
50 virtual int MainLoop();
51 virtual void ExitMainLoop();
52 virtual bool Initialized();
53 virtual bool Pending() ;
54 virtual void Dispatch() ;
55
56 virtual void Exit();
57
58 virtual bool Yield(bool onlyIfNeeded = FALSE);
59 virtual bool ProcessIdle();
60 virtual void WakeUpIdle();
61
62 virtual void SetPrintMode(int mode) { m_printMode = mode; }
63 virtual int GetPrintMode() const { return m_printMode; }
64
65 #if wxUSE_GUI
66 // setting up all MacOS Specific Event-Handlers etc
67 virtual bool OnInitGui();
68 #endif // wxUSE_GUI
69 // implementation only
70 void OnIdle(wxIdleEvent& event);
71 void OnEndSession(wxCloseEvent& event);
72 void OnQueryEndSession(wxCloseEvent& event);
73
74 // Send idle event to all top-level windows.
75 // Returns TRUE if more idle time is requested.
76 bool SendIdleEvents();
77
78 // Send idle event to window and all subwindows
79 // Returns TRUE if more idle time is requested.
80 bool SendIdleEvents(wxWindowMac* win);
81
82 // Windows only, but for compatibility...
83 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
84 inline bool GetAuto3D() const { return m_auto3D; }
85
86 protected:
87 bool m_showOnInit;
88 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
89 bool m_auto3D ; // Always use 3D controls, except
90 // where overriden
91 public:
92
93 // Implementation
94 virtual bool Initialize(int argc, wxChar **argv);
95 virtual void CleanUp();
96
97 bool IsExiting() { return !m_keepGoing ; }
98 #if TARGET_CARBON
99 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
100 WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
101 #endif
102
103 public:
104 static long sm_lastMessageTime;
105 static wxWindow* s_captureWindow ;
106 static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right
107 static WXHRGN s_macCursorRgn ;
108 static long s_lastModifiers ;
109
110 int m_nCmdShow;
111
112 private:
113 bool m_keepGoing ;
114
115 // mac specifics
116 #if TARGET_CARBON
117 WXEVENTHANDLERREF m_macEventHandler ;
118 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
119 #endif
120 WXEVENTREF m_macCurrentEvent ;
121
122 public:
123 static bool s_macDefaultEncodingIsPC ;
124 static bool s_macSupportPCMenuShortcuts ;
125 static long s_macAboutMenuItemId ;
126 static long s_macPreferencesMenuItemId ;
127 static long s_macExitMenuItemId ;
128 static wxString s_macHelpMenuTitleName ;
129
130 static bool s_macHasAppearance ;
131 static long s_macAppearanceVersion ;
132 static bool s_macHasNavigation ;
133 static bool s_macNavigationVersion ;
134 static bool s_macHasWindowManager ;
135 static long s_macWindowManagerVersion ;
136 static bool s_macHasMenuManager ;
137 static long s_macMenuManagerVersion ;
138 static bool s_macHasDialogManager ;
139 static long s_macDialogManagerVersion ;
140
141 WXHRGN m_macCursorRgn ;
142 WXHRGN m_macSleepRgn ;
143 WXHRGN m_macHelpRgn ;
144
145 virtual void MacSuspend( bool convertClipboard ) ;
146 virtual void MacResume( bool convertClipboard ) ;
147 virtual void MacConvertPrivateToPublicScrap() ;
148 virtual void MacConvertPublicToPrivateScrap() ;
149
150 void MacDoOneEvent() ;
151 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
152 void MacHandleOneEvent( WXEVENTREF ev ) ;
153 #if !TARGET_CARBON
154 virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
155 virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;
156 virtual void MacHandleOSEvent( WXEVENTREF ev ) ;
157 virtual void MacHandleDiskEvent( WXEVENTREF ev ) ;
158 virtual void MacHandleActivateEvent( WXEVENTREF ev ) ;
159 virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ;
160 virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ;
161
162 void MacHandleModifierEvents( WXEVENTREF ev ) ;
163
164 virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ;
165 virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ;
166 virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ;
167
168 #endif
169
170 void MacHandleMenuCommand( wxUint32 command ) ;
171 bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
172 bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
173
174 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
175 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
176 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
177 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
178
179 // in response of an open-document apple event
180 virtual void MacOpenFile(const wxString &fileName) ;
181 // in response of a print-document apple event
182 virtual void MacPrintFile(const wxString &fileName) ;
183 // in response of a open-application apple event
184 virtual void MacNewFile() ;
185
186 DECLARE_EVENT_TABLE()
187 };
188
189 class WXDLLEXPORT wxStAppResource
190 {
191 public:
192 wxStAppResource() ;
193 ~wxStAppResource() ;
194
195 // opaque pointer for CFragInitBlock
196 static void OpenSharedLibraryResource(const void *) ;
197 static void CloseSharedLibraryResource() ;
198
199 private:
200 short m_currentRefNum ;
201 } ;
202
203 #endif
204 // _WX_APP_H_
205