]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/app.h
include "ToolUtils.h" for LoWord and friends
[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 virtual bool Yield(bool onlyIfNeeded = FALSE);
56 virtual bool ProcessIdle();
57
58 virtual void SetPrintMode(int mode) { m_printMode = mode; }
59 virtual int GetPrintMode() const { return m_printMode; }
60
61 #if wxUSE_GUI
62 // setting up all MacOS Specific Event-Handlers etc
63 virtual bool OnInitGui();
64 #endif // wxUSE_GUI
65 // implementation only
66 void OnIdle(wxIdleEvent& event);
67 void OnEndSession(wxCloseEvent& event);
68 void OnQueryEndSession(wxCloseEvent& event);
69
70 // Send idle event to all top-level windows.
71 // Returns TRUE if more idle time is requested.
72 bool SendIdleEvents();
73
74 // Send idle event to window and all subwindows
75 // Returns TRUE if more idle time is requested.
76 bool SendIdleEvents(wxWindowMac* win);
77
78 // Windows only, but for compatibility...
79 inline void SetAuto3D(bool flag) { m_auto3D = flag; }
80 inline bool GetAuto3D() const { return m_auto3D; }
81
82 protected:
83 bool m_showOnInit;
84 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
85 bool m_auto3D ; // Always use 3D controls, except
86 // where overriden
87 public:
88
89 // Implementation
90 static bool Initialize();
91 static void CleanUp();
92
93 void DeletePendingObjects();
94 bool IsExiting() { return !m_keepGoing ; }
95 #if TARGET_CARBON
96 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
97 WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
98 #endif
99
100 public:
101 static long sm_lastMessageTime;
102 static wxWindow* s_captureWindow ;
103 static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right
104 static WXHRGN s_macCursorRgn ;
105 static long s_lastModifiers ;
106
107 int m_nCmdShow;
108
109 private:
110 bool m_keepGoing ;
111
112 // mac specifics
113 #if TARGET_CARBON
114 WXEVENTHANDLERREF m_macEventHandler ;
115 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
116 #endif
117 WXEVENTREF m_macCurrentEvent ;
118
119 public:
120 static bool s_macDefaultEncodingIsPC ;
121 static bool s_macSupportPCMenuShortcuts ;
122 static long s_macAboutMenuItemId ;
123 static long s_macPreferencesMenuItemId ;
124 static long s_macExitMenuItemId ;
125 static wxString s_macHelpMenuTitleName ;
126
127 static bool s_macHasAppearance ;
128 static long s_macAppearanceVersion ;
129 static bool s_macHasNavigation ;
130 static bool s_macNavigationVersion ;
131 static bool s_macHasWindowManager ;
132 static long s_macWindowManagerVersion ;
133 static bool s_macHasMenuManager ;
134 static long s_macMenuManagerVersion ;
135 static bool s_macHasDialogManager ;
136 static long s_macDialogManagerVersion ;
137
138 WXHRGN m_macCursorRgn ;
139 WXHRGN m_macSleepRgn ;
140 WXHRGN m_macHelpRgn ;
141
142 virtual void MacSuspend( bool convertClipboard ) ;
143 virtual void MacResume( bool convertClipboard ) ;
144 virtual void MacConvertPrivateToPublicScrap() ;
145 virtual void MacConvertPublicToPrivateScrap() ;
146
147 void MacDoOneEvent() ;
148 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
149 void MacHandleOneEvent( WXEVENTREF ev ) ;
150 #if !TARGET_CARBON
151 virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
152 virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;
153 virtual void MacHandleOSEvent( WXEVENTREF ev ) ;
154 virtual void MacHandleDiskEvent( WXEVENTREF ev ) ;
155 virtual void MacHandleActivateEvent( WXEVENTREF ev ) ;
156 virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ;
157 virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ;
158
159 void MacHandleModifierEvents( WXEVENTREF ev ) ;
160
161 virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ;
162 virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ;
163 virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ;
164
165 #endif
166
167 void MacHandleMenuCommand( wxUint32 command ) ;
168 bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
169 bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
170
171 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
172 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
173 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
174 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
175
176 // in response of an open-document apple event
177 virtual void MacOpenFile(const wxString &fileName) ;
178 // in response of a print-document apple event
179 virtual void MacPrintFile(const wxString &fileName) ;
180 // in response of a open-application apple event
181 virtual void MacNewFile() ;
182
183 DECLARE_EVENT_TABLE()
184 };
185
186 class WXDLLEXPORT wxStAppResource
187 {
188 public:
189 wxStAppResource() ;
190 ~wxStAppResource() ;
191
192 // opaque pointer for CFragInitBlock
193 static void OpenSharedLibraryResource(const void *) ;
194 static void CloseSharedLibraryResource() ;
195
196 private:
197 short m_currentRefNum ;
198 } ;
199
200 #endif
201 // _WX_APP_H_
202