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"
25 #include <CoreFoundation/CFRunLoop.h>
28 class WXDLLEXPORT wxFrame
;
29 class WXDLLEXPORT wxWindowMac
;
30 class WXDLLEXPORT wxApp
;
31 class WXDLLEXPORT wxKeyEvent
;
32 class WXDLLEXPORT wxLog
;
34 #define wxPRINT_WINDOWS 1
35 #define wxPRINT_POSTSCRIPT 2
37 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
39 // Force an exit from main loop
40 void WXDLLEXPORT
wxExit();
42 // Yield to other apps/messages
43 bool WXDLLEXPORT
wxYield();
45 // Represents the application. Derive OnInit and declare
46 // a new App object to start application
47 class WXDLLEXPORT wxApp
: public wxAppBase
49 DECLARE_DYNAMIC_CLASS(wxApp
)
54 virtual int MainLoop();
55 virtual void ExitMainLoop();
56 virtual bool Pending() ;
57 virtual bool Dispatch() ;
61 virtual bool Yield(bool onlyIfNeeded
= FALSE
);
62 virtual void WakeUpIdle();
64 virtual void SetPrintMode(int mode
) { m_printMode
= mode
; }
65 virtual int GetPrintMode() const { return m_printMode
; }
68 // setting up all MacOS Specific Event-Handlers etc
69 virtual bool OnInitGui();
71 // implementation only
72 void OnIdle(wxIdleEvent
& event
);
73 void OnEndSession(wxCloseEvent
& event
);
74 void OnQueryEndSession(wxCloseEvent
& event
);
78 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
82 static bool sm_isEmbedded
;
84 virtual bool Initialize(int& argc
, wxChar
**argv
);
85 virtual void CleanUp();
87 bool IsExiting() { return !m_keepGoing
; }
89 // the installed application event handler
90 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
91 WXEVENTHANDLERREF
MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef
; }
92 void MacSetCurrentEvent( WXEVENTREF event
, WXEVENTHANDLERCALLREF handler
)
93 { m_macCurrentEvent
= event
; m_macCurrentEventHandlerCallRef
= handler
; }
96 static long sm_lastMessageTime
;
97 static wxWindow
* s_captureWindow
;
98 static int s_lastMouseDown
; // 0 = none , 1 = left , 2 = right
99 static WXHRGN s_macCursorRgn
;
100 static long s_lastModifiers
;
109 WXEVENTHANDLERREF m_macEventHandler
;
110 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef
;
111 WXEVENTREF m_macCurrentEvent
;
113 CFRunLoopSourceRef m_macEventPosted
;
117 static bool s_macSupportPCMenuShortcuts
;
118 static long s_macAboutMenuItemId
;
119 static long s_macPreferencesMenuItemId
;
120 static long s_macExitMenuItemId
;
121 static wxString s_macHelpMenuTitleName
;
123 static bool s_macHasAppearance
;
124 static long s_macAppearanceVersion
;
125 static bool s_macHasNavigation
;
126 static bool s_macNavigationVersion
;
127 static bool s_macHasWindowManager
;
128 static long s_macWindowManagerVersion
;
129 static bool s_macHasMenuManager
;
130 static long s_macMenuManagerVersion
;
131 static bool s_macHasDialogManager
;
132 static long s_macDialogManagerVersion
;
134 WXHRGN m_macCursorRgn
;
135 WXHRGN m_macSleepRgn
;
136 WXHRGN m_macHelpRgn
;
138 void MacDoOneEvent() ;
139 WXEVENTREF
MacGetCurrentEvent() { return m_macCurrentEvent
; }
140 void MacHandleOneEvent( WXEVENTREF ev
) ;
142 // For embedded use. By default does nothing.
143 virtual void MacHandleUnhandledEvent( WXEVENTREF ev
);
145 bool MacSendKeyDownEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
146 bool MacSendKeyUpEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
148 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
149 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
150 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
151 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
152 virtual short MacHandleAERApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
154 // in response of an open-document apple event
155 virtual void MacOpenFile(const wxString
&fileName
) ;
156 // in response of a print-document apple event
157 virtual void MacPrintFile(const wxString
&fileName
) ;
158 // in response of a open-application apple event
159 virtual void MacNewFile() ;
160 // in response of a reopen-application apple event
161 virtual void MacReopenApp() ;
163 DECLARE_EVENT_TABLE()