1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxApp class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #include "wx/object.h"
17 #include "wx/gdicmn.h"
21 typedef struct __CFRunLoopSource
* CFRunLoopSourceRef
;
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 bool Yield(bool onlyIfNeeded
= FALSE
);
51 virtual void WakeUpIdle();
53 virtual void SetPrintMode(int mode
) { m_printMode
= mode
; }
54 virtual int GetPrintMode() const { return m_printMode
; }
57 // setting up all MacOS Specific Event-Handlers etc
58 virtual bool OnInitGui();
60 // implementation only
61 void OnIdle(wxIdleEvent
& event
);
62 void OnEndSession(wxCloseEvent
& event
);
63 void OnQueryEndSession(wxCloseEvent
& event
);
65 void MacDoOneEvent() ;
69 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
73 static bool sm_isEmbedded
;
75 virtual bool Initialize(int& argc
, wxChar
**argv
);
76 virtual void CleanUp();
78 // the installed application event handler
79 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
80 WXEVENTHANDLERREF
MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef
; }
81 void MacSetCurrentEvent( WXEVENTREF event
, WXEVENTHANDLERCALLREF handler
)
82 { m_macCurrentEvent
= event
; m_macCurrentEventHandlerCallRef
= handler
; }
85 static long sm_lastMessageTime
;
86 static wxWindow
* s_captureWindow
;
87 static int s_lastMouseDown
; // 0 = none , 1 = left , 2 = right
88 static WXHRGN s_macCursorRgn
;
89 static long s_lastModifiers
;
96 WXEVENTHANDLERREF m_macEventHandler
;
97 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef
;
98 WXEVENTREF m_macCurrentEvent
;
100 CFRunLoopSourceRef m_macEventPosted
;
104 static bool s_macSupportPCMenuShortcuts
;
105 static long s_macAboutMenuItemId
;
106 static long s_macPreferencesMenuItemId
;
107 static long s_macExitMenuItemId
;
108 static wxString s_macHelpMenuTitleName
;
110 static bool s_macHasAppearance
;
111 static long s_macAppearanceVersion
;
112 static bool s_macHasNavigation
;
113 static bool s_macNavigationVersion
;
114 static bool s_macHasWindowManager
;
115 static long s_macWindowManagerVersion
;
116 static bool s_macHasMenuManager
;
117 static long s_macMenuManagerVersion
;
118 static bool s_macHasDialogManager
;
119 static long s_macDialogManagerVersion
;
121 WXHRGN m_macCursorRgn
;
122 WXHRGN m_macSleepRgn
;
123 WXHRGN m_macHelpRgn
;
125 WXEVENTREF
MacGetCurrentEvent() { return m_macCurrentEvent
; }
126 void MacHandleOneEvent( WXEVENTREF ev
) ;
128 // For embedded use. By default does nothing.
129 virtual void MacHandleUnhandledEvent( WXEVENTREF ev
);
131 bool MacSendKeyDownEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
132 bool MacSendKeyUpEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
133 bool MacSendCharEvent( wxWindow
* focus
, long keymessage
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
134 void MacCreateKeyEvent( wxKeyEvent
& event
, wxWindow
* focus
, long keymessage
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
135 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
136 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
137 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
138 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
139 virtual short MacHandleAERApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
141 // in response of an open-document apple event
142 virtual void MacOpenFile(const wxString
&fileName
) ;
143 // in response of a print-document apple event
144 virtual void MacPrintFile(const wxString
&fileName
) ;
145 // in response of a open-application apple event
146 virtual void MacNewFile() ;
147 // in response of a reopen-application apple event
148 virtual void MacReopenApp() ;
150 DECLARE_EVENT_TABLE()