]>
Commit | Line | Data |
---|---|---|
8cf73271 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: app.h | |
3 | // Purpose: wxApp class | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
65571936 | 9 | // Licence: wxWindows licence |
8cf73271 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_APP_H_ | |
13 | #define _WX_APP_H_ | |
14 | ||
8cf73271 SC |
15 | #include "wx/defs.h" |
16 | #include "wx/object.h" | |
17 | #include "wx/gdicmn.h" | |
18 | #include "wx/event.h" | |
19 | ||
b5dbe15d VS |
20 | class WXDLLIMPEXP_FWD_CORE wxFrame; |
21 | class WXDLLIMPEXP_FWD_CORE wxWindowMac; | |
22 | class WXDLLIMPEXP_FWD_CORE wxApp ; | |
23 | class WXDLLIMPEXP_FWD_CORE wxKeyEvent; | |
4f7d425f | 24 | class WXDLLIMPEXP_FWD_BASE wxLog; |
8cf73271 | 25 | |
8cf73271 SC |
26 | // Force an exit from main loop |
27 | void WXDLLEXPORT wxExit(); | |
28 | ||
29 | // Yield to other apps/messages | |
30 | bool WXDLLEXPORT wxYield(); | |
31 | ||
32 | // Represents the application. Derive OnInit and declare | |
33 | // a new App object to start application | |
34 | class WXDLLEXPORT wxApp: public wxAppBase | |
35 | { | |
36 | DECLARE_DYNAMIC_CLASS(wxApp) | |
37 | ||
38 | wxApp(); | |
39 | virtual ~wxApp() {} | |
40 | ||
8cf73271 SC |
41 | virtual bool Yield(bool onlyIfNeeded = FALSE); |
42 | virtual void WakeUpIdle(); | |
43 | ||
44 | virtual void SetPrintMode(int mode) { m_printMode = mode; } | |
45 | virtual int GetPrintMode() const { return m_printMode; } | |
46 | ||
47 | #if wxUSE_GUI | |
48 | // setting up all MacOS Specific Event-Handlers etc | |
49 | virtual bool OnInitGui(); | |
50 | #endif // wxUSE_GUI | |
51 | // implementation only | |
52 | void OnIdle(wxIdleEvent& event); | |
53 | void OnEndSession(wxCloseEvent& event); | |
54 | void OnQueryEndSession(wxCloseEvent& event); | |
55 | ||
4d90072c VZ |
56 | void MacDoOneEvent() ; |
57 | ||
8cf73271 | 58 | protected: |
8cf73271 | 59 | int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT |
4f305456 | 60 | |
8cf73271 SC |
61 | public: |
62 | ||
63 | static bool sm_isEmbedded; | |
64 | // Implementation | |
65 | virtual bool Initialize(int& argc, wxChar **argv); | |
66 | virtual void CleanUp(); | |
67 | ||
8cf73271 SC |
68 | // the installed application event handler |
69 | WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; } | |
70 | WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; } | |
71 | void MacSetCurrentEvent( WXEVENTREF event , WXEVENTHANDLERCALLREF handler ) | |
72 | { m_macCurrentEvent = event ; m_macCurrentEventHandlerCallRef = handler ; } | |
8cf73271 | 73 | |
96116866 SC |
74 | // adding a CFType object to be released only at the end of the current event cycle (increases the |
75 | // refcount of the object passed), needed in case we are in the middle of an event concering an object | |
76 | // we want to delete and cannot do it immediately | |
ebf2a1ec | 77 | // TODO change semantics to be in line with cocoa (make autrelease NOT increase the count) |
96116866 | 78 | void MacAddToAutorelease( void* cfrefobj ); |
8cf73271 | 79 | public: |
8cf73271 | 80 | static wxWindow* s_captureWindow ; |
8cf73271 SC |
81 | static long s_lastModifiers ; |
82 | ||
83 | int m_nCmdShow; | |
84 | ||
85 | private: | |
8cf73271 | 86 | // mac specifics |
4f305456 | 87 | |
8cf73271 SC |
88 | WXEVENTHANDLERREF m_macEventHandler ; |
89 | WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ; | |
8cf73271 | 90 | WXEVENTREF m_macCurrentEvent ; |
95e568ee | 91 | CFRunLoopSourceRef m_macEventPosted ; |
8cf73271 SC |
92 | |
93 | public: | |
8cf73271 SC |
94 | static long s_macAboutMenuItemId ; |
95 | static long s_macPreferencesMenuItemId ; | |
96 | static long s_macExitMenuItemId ; | |
97 | static wxString s_macHelpMenuTitleName ; | |
98 | ||
8cf73271 SC |
99 | WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; } |
100 | void MacHandleOneEvent( WXEVENTREF ev ) ; | |
101 | ||
102 | // For embedded use. By default does nothing. | |
103 | virtual void MacHandleUnhandledEvent( WXEVENTREF ev ); | |
104 | ||
2d17efa9 SC |
105 | bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ; |
106 | bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ; | |
f139ea01 SC |
107 | bool MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ; |
108 | void MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ; | |
8cf73271 | 109 | virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; |
947848a1 | 110 | virtual short MacHandleAEGURL(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; |
8cf73271 SC |
111 | virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; |
112 | virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; | |
113 | virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; | |
114 | virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ; | |
115 | ||
116 | // in response of an open-document apple event | |
117 | virtual void MacOpenFile(const wxString &fileName) ; | |
947848a1 VZ |
118 | // in response of a get-url apple event |
119 | virtual void MacOpenURL(const wxString &url) ; | |
8cf73271 SC |
120 | // in response of a print-document apple event |
121 | virtual void MacPrintFile(const wxString &fileName) ; | |
122 | // in response of a open-application apple event | |
123 | virtual void MacNewFile() ; | |
124 | // in response of a reopen-application apple event | |
125 | virtual void MacReopenApp() ; | |
126 | ||
975bcfda RD |
127 | // Hide the application windows the same as the system hide command would do it. |
128 | void MacHideApp(); | |
129 | ||
8cf73271 SC |
130 | DECLARE_EVENT_TABLE() |
131 | }; | |
132 | ||
8cf73271 SC |
133 | #endif |
134 | // _WX_APP_H_ | |
135 |