]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/app.h
Include wx/dataobj.h from wx/clipbrd.h.
[wxWidgets.git] / include / wx / osx / app.h
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_APP_H_
13 #define _WX_APP_H_
14
15 #include "wx/defs.h"
16 #include "wx/object.h"
17 #include "wx/gdicmn.h"
18 #include "wx/event.h"
19
20 class WXDLLIMPEXP_FWD_CORE wxFrame;
21 class WXDLLIMPEXP_FWD_CORE wxWindowMac;
22 class WXDLLIMPEXP_FWD_CORE wxApp ;
23 class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
24 class WXDLLIMPEXP_FWD_BASE wxLog;
25
26 // Force an exit from main loop
27 void WXDLLIMPEXP_CORE wxExit();
28
29 // Yield to other apps/messages
30 bool WXDLLIMPEXP_CORE wxYield();
31
32 // Represents the application. Derive OnInit and declare
33 // a new App object to start application
34 class WXDLLIMPEXP_CORE wxApp: public wxAppBase
35 {
36 DECLARE_DYNAMIC_CLASS(wxApp)
37
38 wxApp();
39 virtual ~wxApp() {}
40
41 virtual void WakeUpIdle();
42
43 virtual void SetPrintMode(int mode) { m_printMode = mode; }
44 virtual int GetPrintMode() const { return m_printMode; }
45
46 // calling OnInit with an auto-release pool ready ...
47 virtual bool CallOnInit();
48 #if wxUSE_GUI
49 // setting up all MacOS Specific Event-Handlers etc
50 virtual bool OnInitGui();
51 #endif // wxUSE_GUI
52
53 #ifdef __WXOSX_IPHONE__
54 virtual int OnRun();
55 #endif
56
57 virtual bool ProcessIdle();
58
59 // implementation only
60 void OnIdle(wxIdleEvent& event);
61 void OnEndSession(wxCloseEvent& event);
62 void OnQueryEndSession(wxCloseEvent& event);
63
64 protected:
65 int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
66
67 public:
68
69 static bool sm_isEmbedded;
70 // Implementation
71 virtual bool Initialize(int& argc, wxChar **argv);
72 virtual void CleanUp();
73
74 // the installed application event handler
75 WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
76 WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
77 void MacSetCurrentEvent( WXEVENTREF event , WXEVENTHANDLERCALLREF handler )
78 { m_macCurrentEvent = event ; m_macCurrentEventHandlerCallRef = handler ; }
79
80 // adding a CFType object to be released only at the end of the current event cycle (increases the
81 // refcount of the object passed), needed in case we are in the middle of an event concering an object
82 // we want to delete and cannot do it immediately
83 // TODO change semantics to be in line with cocoa (make autrelease NOT increase the count)
84 void MacAddToAutorelease( void* cfrefobj );
85 public:
86 static wxWindow* s_captureWindow ;
87 static long s_lastModifiers ;
88
89 int m_nCmdShow;
90
91 private:
92 // mac specifics
93 virtual bool DoInitGui();
94 virtual void DoCleanUp();
95
96 WXEVENTHANDLERREF m_macEventHandler ;
97 WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
98 WXEVENTREF m_macCurrentEvent ;
99 CFRunLoopSourceRef m_macEventPosted ;
100
101 public:
102 static long s_macAboutMenuItemId ;
103 static long s_macPreferencesMenuItemId ;
104 static long s_macExitMenuItemId ;
105 static wxString s_macHelpMenuTitleName ;
106
107 WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
108
109 // For embedded use. By default does nothing.
110 virtual void MacHandleUnhandledEvent( WXEVENTREF ev );
111
112 bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ;
113 bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ;
114 bool MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ;
115 void MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar ) ;
116 #if wxOSX_USE_CARBON
117 // we only have applescript on these
118 virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
119 virtual short MacHandleAEGURL(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
120 virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
121 virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
122 virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
123 virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
124 #endif
125 // in response of an open-document apple event
126 virtual void MacOpenFile(const wxString &fileName) ;
127 // in response of a get-url apple event
128 virtual void MacOpenURL(const wxString &url) ;
129 // in response of a print-document apple event
130 virtual void MacPrintFile(const wxString &fileName) ;
131 // in response of a open-application apple event
132 virtual void MacNewFile() ;
133 // in response of a reopen-application apple event
134 virtual void MacReopenApp() ;
135
136 // Hide the application windows the same as the system hide command would do it.
137 void MacHideApp();
138
139 DECLARE_EVENT_TABLE()
140 };
141
142 #endif
143 // _WX_APP_H_
144