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 WXDLLIMPEXP_FWD_CORE wxFrame
;
25 class WXDLLIMPEXP_FWD_CORE wxWindowMac
;
26 class WXDLLIMPEXP_FWD_CORE wxApp
;
27 class WXDLLIMPEXP_FWD_CORE wxKeyEvent
;
28 class WXDLLIMPEXP_FWD_CORE wxLog
;
30 // Force an exit from main loop
31 void WXDLLEXPORT
wxExit();
33 // Yield to other apps/messages
34 bool WXDLLEXPORT
wxYield();
36 // Represents the application. Derive OnInit and declare
37 // a new App object to start application
38 class WXDLLEXPORT wxApp
: public wxAppBase
40 DECLARE_DYNAMIC_CLASS(wxApp
)
45 virtual bool Yield(bool onlyIfNeeded
= FALSE
);
46 virtual void WakeUpIdle();
48 virtual void SetPrintMode(int mode
) { m_printMode
= mode
; }
49 virtual int GetPrintMode() const { return m_printMode
; }
52 // setting up all MacOS Specific Event-Handlers etc
53 virtual bool OnInitGui();
55 // implementation only
56 void OnIdle(wxIdleEvent
& event
);
57 void OnEndSession(wxCloseEvent
& event
);
58 void OnQueryEndSession(wxCloseEvent
& event
);
60 void MacDoOneEvent() ;
63 int m_printMode
; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
67 static bool sm_isEmbedded
;
69 virtual bool Initialize(int& argc
, wxChar
**argv
);
70 virtual void CleanUp();
72 // the installed application event handler
73 WXEVENTHANDLERREF
MacGetEventHandler() { return m_macEventHandler
; }
74 WXEVENTHANDLERREF
MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef
; }
75 void MacSetCurrentEvent( WXEVENTREF event
, WXEVENTHANDLERCALLREF handler
)
76 { m_macCurrentEvent
= event
; m_macCurrentEventHandlerCallRef
= handler
; }
78 // adding a CFType object to be released only at the end of the current event cycle (increases the
79 // refcount of the object passed), needed in case we are in the middle of an event concering an object
80 // we want to delete and cannot do it immediately
81 // TODO change semantics to be in line with cocoa (make autrelease NOT increase the count)
82 void MacAddToAutorelease( void* cfrefobj
);
84 static wxWindow
* s_captureWindow
;
85 static long s_lastModifiers
;
92 WXEVENTHANDLERREF m_macEventHandler
;
93 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef
;
94 WXEVENTREF m_macCurrentEvent
;
96 CFRunLoopSourceRef m_macEventPosted
;
100 static long s_macAboutMenuItemId
;
101 static long s_macPreferencesMenuItemId
;
102 static long s_macExitMenuItemId
;
103 static wxString s_macHelpMenuTitleName
;
105 WXEVENTREF
MacGetCurrentEvent() { return m_macCurrentEvent
; }
106 void MacHandleOneEvent( WXEVENTREF ev
) ;
108 // For embedded use. By default does nothing.
109 virtual void MacHandleUnhandledEvent( WXEVENTREF ev
);
111 bool MacSendKeyDownEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
112 bool MacSendKeyUpEvent( wxWindow
* focus
, long keyval
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
113 bool MacSendCharEvent( wxWindow
* focus
, long keymessage
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
114 void MacCreateKeyEvent( wxKeyEvent
& event
, wxWindow
* focus
, long keymessage
, long modifiers
, long when
, short wherex
, short wherey
, wxChar uniChar
) ;
115 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
116 virtual short MacHandleAEGURL(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
117 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
118 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
119 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
120 virtual short MacHandleAERApp(const WXAPPLEEVENTREF event
, WXAPPLEEVENTREF reply
) ;
122 // in response of an open-document apple event
123 virtual void MacOpenFile(const wxString
&fileName
) ;
124 // in response of a get-url apple event
125 virtual void MacOpenURL(const wxString
&url
) ;
126 // in response of a print-document apple event
127 virtual void MacPrintFile(const wxString
&fileName
) ;
128 // in response of a open-application apple event
129 virtual void MacNewFile() ;
130 // in response of a reopen-application apple event
131 virtual void MacReopenApp() ;
133 DECLARE_EVENT_TABLE()