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 #include <CoreFoundation/CoreFoundation.h>
26 class WXDLLEXPORT wxFrame
;
27 class WXDLLEXPORT wxWindowMac
;
28 class WXDLLEXPORT wxApp
;
29 class WXDLLEXPORT wxKeyEvent
;
30 class WXDLLEXPORT wxLog
;
32 #define wxPRINT_WINDOWS 1
33 #define wxPRINT_POSTSCRIPT 2
35 WXDLLEXPORT_DATA(extern wxApp
*) wxTheApp
;
37 // Force an exit from main loop
38 void WXDLLEXPORT
wxExit();
40 // Yield to other apps/messages
41 bool WXDLLEXPORT
wxYield();
43 // Represents the application. Derive OnInit and declare
44 // a new App object to start application
45 class WXDLLEXPORT wxApp
: public wxAppBase
47 DECLARE_DYNAMIC_CLASS(wxApp
)
52 virtual int MainLoop();
53 virtual void ExitMainLoop();
54 virtual bool Pending() ;
55 virtual bool Dispatch() ;
59 virtual bool Yield(bool onlyIfNeeded
= FALSE
);
60 virtual void WakeUpIdle();
62 virtual void SetPrintMode(int mode
) { m_printMode
= mode
; }
63 virtual int GetPrintMode() const { return m_printMode
; }
66 // setting up all MacOS Specific Event-Handlers etc
67 virtual bool OnInitGui();
69 // implementation only
70 void OnIdle(wxIdleEvent
& event
);
71 void OnEndSession(wxCloseEvent
& event
);
72 void OnQueryEndSession(wxCloseEvent
& event
);
76 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
80 static bool sm_isEmbedded
;
82 virtual bool Initialize(int& argc
, wxChar
**argv
);
83 virtual void CleanUp();
85 bool IsExiting() { return !m_keepGoing
; }
87 // the installed application event handler
88 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
89 WXEVENTHANDLERREF
MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef
; }
90 void MacSetCurrentEvent( WXEVENTREF event
, WXEVENTHANDLERCALLREF handler
)
91 { m_macCurrentEvent
= event
; m_macCurrentEventHandlerCallRef
= handler
; }
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
;
98 static long s_lastModifiers
;
107 WXEVENTHANDLERREF m_macEventHandler
;
108 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef
;
109 WXEVENTREF m_macCurrentEvent
;
110 CFRunLoopSourceRef m_macEventPosted
;
113 static bool s_macSupportPCMenuShortcuts
;
114 static long s_macAboutMenuItemId
;
115 static long s_macPreferencesMenuItemId
;
116 static long s_macExitMenuItemId
;
117 static wxString s_macHelpMenuTitleName
;
119 static bool s_macHasAppearance
;
120 static long s_macAppearanceVersion
;
121 static bool s_macHasNavigation
;
122 static bool s_macNavigationVersion
;
123 static bool s_macHasWindowManager
;
124 static long s_macWindowManagerVersion
;
125 static bool s_macHasMenuManager
;
126 static long s_macMenuManagerVersion
;
127 static bool s_macHasDialogManager
;
128 static long s_macDialogManagerVersion
;
130 WXHRGN m_macCursorRgn
;
131 WXHRGN m_macSleepRgn
;
132 WXHRGN m_macHelpRgn
;
134 void MacDoOneEvent() ;
135 WXEVENTREF
MacGetCurrentEvent() { return m_macCurrentEvent
; }
136 void MacHandleOneEvent( WXEVENTREF ev
) ;
138 // For embedded use. By default does nothing.
139 virtual void MacHandleUnhandledEvent( WXEVENTREF ev
);
141 bool MacSendKeyDownEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
142 bool MacSendKeyUpEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
144 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
145 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
146 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
147 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
148 virtual short MacHandleAERApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
150 // in response of an open-document apple event
151 virtual void MacOpenFile(const wxString
&fileName
) ;
152 // in response of a print-document apple event
153 virtual void MacPrintFile(const wxString
&fileName
) ;
154 // in response of a open-application apple event
155 virtual void MacNewFile() ;
156 // in response of a reopen-application apple event
157 virtual void MacReopenApp() ;
159 DECLARE_EVENT_TABLE()