1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxApp class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "app.h"
20 #include "wx/object.h"
21 #include "wx/gdicmn.h"
24 class WXDLLEXPORT wxFrame
;
25 class WXDLLEXPORT wxWindowMac
;
26 class WXDLLEXPORT wxApp
;
27 class WXDLLEXPORT wxKeyEvent
;
28 class WXDLLEXPORT wxLog
;
30 #define wxPRINT_WINDOWS 1
31 #define wxPRINT_POSTSCRIPT 2
33 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
35 // Force an exit from main loop
36 void WXDLLEXPORT
wxExit();
38 // Yield to other apps/messages
39 bool WXDLLEXPORT
wxYield();
41 // Represents the application. Derive OnInit and declare
42 // a new App object to start application
43 class WXDLLEXPORT wxApp
: public wxAppBase
45 DECLARE_DYNAMIC_CLASS(wxApp
)
50 virtual int MainLoop();
51 virtual void ExitMainLoop();
52 virtual bool Initialized();
53 virtual bool Pending() ;
54 virtual void Dispatch() ;
58 virtual bool Yield(bool onlyIfNeeded
= FALSE
);
59 virtual void WakeUpIdle();
61 virtual void SetPrintMode(int mode
) { m_printMode
= mode
; }
62 virtual int GetPrintMode() const { return m_printMode
; }
65 // setting up all MacOS Specific Event-Handlers etc
66 virtual bool OnInitGui();
68 // implementation only
69 void OnIdle(wxIdleEvent
& event
);
70 void OnEndSession(wxCloseEvent
& event
);
71 void OnQueryEndSession(wxCloseEvent
& event
);
73 // Windows only, but for compatibility...
74 inline void SetAuto3D(bool flag
) { m_auto3D
= flag
; }
75 inline bool GetAuto3D() const { return m_auto3D
; }
79 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
80 bool m_auto3D
; // Always use 3D controls, except
85 virtual bool Initialize(int& argc
, wxChar
**argv
);
86 virtual void CleanUp();
88 bool IsExiting() { return !m_keepGoing
; }
90 // the installed application event handler
91 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
92 WXEVENTHANDLERREF
MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef
; }
93 void MacSetCurrentEvent( WXEVENTREF event
, WXEVENTHANDLERCALLREF handler
)
94 { m_macCurrentEvent
= event
; m_macCurrentEventHandlerCallRef
= handler
; }
98 static long sm_lastMessageTime
;
99 static wxWindow
* s_captureWindow
;
100 static int s_lastMouseDown
; // 0 = none , 1 = left , 2 = right
101 static WXHRGN s_macCursorRgn
;
102 static long s_lastModifiers
;
111 WXEVENTHANDLERREF m_macEventHandler
;
112 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef
;
114 WXEVENTREF m_macCurrentEvent
;
117 static bool s_macDefaultEncodingIsPC
;
118 static bool s_macSupportPCMenuShortcuts
;
119 static long s_macAboutMenuItemId
;
120 static long s_macPreferencesMenuItemId
;
121 static long s_macExitMenuItemId
;
122 static wxString s_macHelpMenuTitleName
;
124 static bool s_macHasAppearance
;
125 static long s_macAppearanceVersion
;
126 static bool s_macHasNavigation
;
127 static bool s_macNavigationVersion
;
128 static bool s_macHasWindowManager
;
129 static long s_macWindowManagerVersion
;
130 static bool s_macHasMenuManager
;
131 static long s_macMenuManagerVersion
;
132 static bool s_macHasDialogManager
;
133 static long s_macDialogManagerVersion
;
135 WXHRGN m_macCursorRgn
;
136 WXHRGN m_macSleepRgn
;
137 WXHRGN m_macHelpRgn
;
139 virtual void MacSuspend( bool convertClipboard
) ;
140 virtual void MacResume( bool convertClipboard
) ;
141 virtual void MacConvertPrivateToPublicScrap() ;
142 virtual void MacConvertPublicToPrivateScrap() ;
144 void MacDoOneEvent() ;
145 WXEVENTREF
MacGetCurrentEvent() { return m_macCurrentEvent
; }
146 void MacHandleOneEvent( WXEVENTREF ev
) ;
148 virtual void MacHandleMenuSelect( int menuid
, int menuitem
) ;
149 virtual void MacHandleMouseUpEvent( WXEVENTREF ev
) ;
150 virtual void MacHandleOSEvent( WXEVENTREF ev
) ;
151 virtual void MacHandleDiskEvent( WXEVENTREF ev
) ;
152 virtual void MacHandleActivateEvent( WXEVENTREF ev
) ;
153 virtual void MacHandleUpdateEvent( WXEVENTREF ev
) ;
154 virtual void MacHandleMouseDownEvent( WXEVENTREF ev
) ;
156 void MacHandleModifierEvents( WXEVENTREF ev
) ;
158 virtual void MacHandleKeyDownEvent( WXEVENTREF ev
) ;
159 virtual void MacHandleKeyUpEvent( WXEVENTREF ev
) ;
160 virtual void MacHandleHighLevelEvent( WXEVENTREF ev
) ;
164 void MacHandleMenuCommand( wxUint32 command
) ;
165 bool MacSendKeyDownEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
) ;
166 bool MacSendKeyUpEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
) ;
168 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
169 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
170 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
171 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
173 // in response of an open-document apple event
174 virtual void MacOpenFile(const wxString
&fileName
) ;
175 // in response of a print-document apple event
176 virtual void MacPrintFile(const wxString
&fileName
) ;
177 // in response of a open-application apple event
178 virtual void MacNewFile() ;
180 DECLARE_EVENT_TABLE()
183 class WXDLLEXPORT wxStAppResource
189 // opaque pointer for CFragInitBlock
190 static void OpenSharedLibraryResource(const void *) ;
191 static void CloseSharedLibraryResource() ;
194 short m_currentRefNum
;