]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: app.h | |
3 | // Purpose: wxApp class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_APP_H_ | |
13 | #define _WX_APP_H_ | |
14 | ||
af49c4b8 | 15 | #if defined(__GNUG__) && !defined(__APPLE__) |
0dbd6262 SC |
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; | |
e766c8a9 | 25 | class WXDLLEXPORT wxWindowMac; |
0dbd6262 SC |
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 | |
05adb9d2 | 43 | class WXDLLEXPORT wxApp: public wxAppBase |
0dbd6262 | 44 | { |
fbbdb7cd GD |
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 | virtual bool Yield(bool onlyIfNeeded = FALSE); | |
90a1a975 | 56 | virtual bool ProcessIdle(); |
fbbdb7cd GD |
57 | |
58 | virtual void SetPrintMode(int mode) { m_printMode = mode; } | |
59 | virtual int GetPrintMode() const { return m_printMode; } | |
60 | ||
61 | // implementation only | |
62 | void OnIdle(wxIdleEvent& event); | |
63 | void OnEndSession(wxCloseEvent& event); | |
64 | void OnQueryEndSession(wxCloseEvent& event); | |
65 | ||
66 | // Send idle event to all top-level windows. | |
67 | // Returns TRUE if more idle time is requested. | |
68 | bool SendIdleEvents(); | |
69 | ||
70 | // Send idle event to window and all subwindows | |
71 | // Returns TRUE if more idle time is requested. | |
72 | bool SendIdleEvents(wxWindowMac* win); | |
73 | ||
74 | // Windows only, but for compatibility... | |
75 | inline void SetAuto3D(bool flag) { m_auto3D = flag; } | |
76 | inline bool GetAuto3D() const { return m_auto3D; } | |
77 | ||
0dbd6262 | 78 | protected: |
fbbdb7cd GD |
79 | bool m_showOnInit; |
80 | int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT | |
81 | bool m_auto3D ; // Always use 3D controls, except | |
82 | // where overriden | |
0dbd6262 SC |
83 | public: |
84 | ||
fbbdb7cd GD |
85 | // Implementation |
86 | static bool Initialize(); | |
87 | static void CleanUp(); | |
88 | ||
6c28ba0c | 89 | virtual bool OnInit(); |
fbbdb7cd | 90 | void DeletePendingObjects(); |
fbbdb7cd GD |
91 | bool IsExiting() { return !m_keepGoing ; } |
92 | ||
0dbd6262 | 93 | public: |
fbbdb7cd GD |
94 | static long sm_lastMessageTime; |
95 | static wxWindow* s_captureWindow ; | |
96 | static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right | |
97 | static WXHRGN s_macCursorRgn ; | |
41d368a4 | 98 | static long s_lastModifiers ; |
fbbdb7cd GD |
99 | WXEVENTREF m_macCurrentEvent ; |
100 | ||
101 | int m_nCmdShow; | |
102 | ||
0dbd6262 | 103 | protected: |
fbbdb7cd | 104 | bool m_keepGoing ; |
519cb848 | 105 | |
fbbdb7cd | 106 | // mac specifics |
519cb848 | 107 | |
fbbdb7cd GD |
108 | public: |
109 | static bool s_macDefaultEncodingIsPC ; | |
110 | static bool s_macSupportPCMenuShortcuts ; | |
111 | static long s_macAboutMenuItemId ; | |
2b5f62a0 VZ |
112 | static long s_macPreferencesMenuItemId ; |
113 | static long s_macExitMenuItemId ; | |
fbbdb7cd GD |
114 | static wxString s_macHelpMenuTitleName ; |
115 | ||
116 | static bool s_macHasAppearance ; | |
117 | static long s_macAppearanceVersion ; | |
118 | static bool s_macHasNavigation ; | |
119 | static bool s_macNavigationVersion ; | |
120 | static bool s_macHasWindowManager ; | |
121 | static long s_macWindowManagerVersion ; | |
122 | static bool s_macHasMenuManager ; | |
123 | static long s_macMenuManagerVersion ; | |
124 | static bool s_macHasDialogManager ; | |
125 | static long s_macDialogManagerVersion ; | |
126 | ||
127 | WXHRGN m_macCursorRgn ; | |
128 | WXHRGN m_macSleepRgn ; | |
129 | WXHRGN m_macHelpRgn ; | |
130 | ||
131 | virtual void MacSuspend( bool convertClipboard ) ; | |
132 | virtual void MacResume( bool convertClipboard ) ; | |
133 | ||
134 | virtual void MacConvertPrivateToPublicScrap() ; | |
135 | virtual void MacConvertPublicToPrivateScrap() ; | |
136 | ||
137 | // event main methods | |
138 | ||
139 | void MacDoOneEvent() ; | |
140 | void MacHandleOneEvent( WXEVENTREF ev ) ; | |
41d368a4 | 141 | void MacHandleModifierEvents( WXEVENTREF ev ) ; |
fbbdb7cd GD |
142 | WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; } |
143 | ||
144 | // primary events | |
8be97d65 | 145 | |
fbbdb7cd GD |
146 | virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ; |
147 | virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ; | |
148 | virtual void MacHandleActivateEvent( WXEVENTREF ev ) ; | |
149 | virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ; | |
150 | virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ; | |
151 | virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ; | |
152 | virtual void MacHandleDiskEvent( WXEVENTREF ev ) ; | |
153 | virtual void MacHandleOSEvent( WXEVENTREF ev ) ; | |
154 | virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ; | |
155 | virtual void MacHandleMenuSelect( int menuid , int menuitem ) ; | |
156 | ||
72ddb593 SC |
157 | virtual bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ; |
158 | virtual bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ; | |
159 | ||
fbbdb7cd GD |
160 | virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; |
161 | virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; | |
162 | virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; | |
163 | virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; | |
164 | ||
2072fbbb SC |
165 | // in response of an open-document apple event |
166 | virtual void MacOpenFile(const wxString &fileName) ; | |
167 | // in response of a print-document apple event | |
168 | virtual void MacPrintFile(const wxString &fileName) ; | |
169 | // in response of a open-application apple event | |
170 | virtual void MacNewFile() ; | |
171 | ||
fbbdb7cd | 172 | DECLARE_EVENT_TABLE() |
0dbd6262 SC |
173 | }; |
174 | ||
fa15551c SC |
175 | class WXDLLEXPORT wxStAppResource |
176 | { | |
fbbdb7cd | 177 | public: |
fa15551c SC |
178 | wxStAppResource() ; |
179 | ~wxStAppResource() ; | |
fbbdb7cd GD |
180 | |
181 | // opaque pointer for CFragInitBlock | |
182 | static void OpenSharedLibraryResource(const void *) ; | |
183 | static void CloseSharedLibraryResource() ; | |
184 | ||
185 | private: | |
186 | short m_currentRefNum ; | |
fa15551c SC |
187 | } ; |
188 | ||
0dbd6262 | 189 | // TODO: add platform-specific arguments |
1bfec677 | 190 | #ifndef __DARWIN__ |
05adb9d2 | 191 | int WXDLLEXPORT wxEntry( int argc, char *argv[] , bool enterLoop = TRUE); |
1bfec677 | 192 | #endif |
0dbd6262 | 193 | |
519cb848 SC |
194 | void wxMacConvertFromPCForControls( char * p ) ; |
195 | ||
196 | void wxMacConvertToPC( const char *from , char *to , int len ) ; | |
197 | void wxMacConvertFromPC( const char *from , char *to , int len ) ; | |
198 | void wxMacConvertToPC( const char *from , char *to , int len ) ; | |
199 | void wxMacConvertFromPC( char * p ) ; | |
200 | void wxMacConvertFromPC( unsigned char *p ) ; | |
201 | wxString wxMacMakeMacStringFromPC( const char * p ) ; | |
202 | void wxMacConvertToPC( char * p ) ; | |
203 | void wxMacConvertToPC( unsigned char *p ) ; | |
204 | wxString wxMacMakePCStringFromMac( const char * p ) ; | |
205 | ||
3d2791f1 | 206 | // converts this string into a pascal with optional pc 2 mac encoding |
5273bf2f | 207 | void wxMacStringToPascal( const char * from , unsigned char* to , bool pc2macEncoding ) ; |
3d2791f1 SC |
208 | |
209 | // converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC | |
5273bf2f | 210 | inline void wxMacStringToPascal( const char * from , unsigned char* to ) |
3d2791f1 SC |
211 | { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; } |
212 | ||
213 | // converts this string into a pascal with optional mac 2 pc encoding | |
5273bf2f | 214 | wxString wxMacMakeStringFromPascal( unsigned char* from , bool mac2pcEncoding ) ; |
3d2791f1 SC |
215 | |
216 | // converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC | |
5273bf2f | 217 | inline wxString wxMacMakeStringFromPascal( unsigned char* from ) |
3d2791f1 SC |
218 | { return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; } |
219 | ||
220 | // converts this c string into a wxString with optional mac 2 pc encoding | |
221 | wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ; | |
222 | ||
223 | // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC | |
224 | inline wxString wxMacMakeStringFromMacString( const char* from ) | |
225 | { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; } | |
226 | ||
0dbd6262 SC |
227 | #endif |
228 | // _WX_APP_H_ | |
229 |