]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _app.i | |
3 | // Purpose: SWIG interface for wxApp | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 9-Aug-2003 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | // TODOs: | |
18 | // | |
19 | // 1. Provide another app object that allows FilterEvent to be overloaded. | |
20 | // 2. Wrap wxAppTraits and allow wxApp::CreateTraits to be overloaded. | |
21 | // | |
22 | //--------------------------------------------------------------------------- | |
23 | %newgroup; | |
24 | ||
25 | %{ | |
26 | %} | |
27 | ||
28 | enum { | |
29 | wxPYAPP_ASSERT_SUPPRESS = 1, | |
30 | wxPYAPP_ASSERT_EXCEPTION = 2, | |
31 | wxPYAPP_ASSERT_DIALOG = 4, | |
32 | wxPYAPP_ASSERT_LOG = 8 | |
33 | }; | |
34 | ||
35 | enum | |
36 | { | |
37 | wxPRINT_WINDOWS = 1, | |
38 | wxPRINT_POSTSCRIPT = 2 | |
39 | }; | |
40 | ||
41 | ||
42 | ||
dce2bd22 RD |
43 | DocStr(wxPyApp, |
44 | "The ``wx.PyApp`` class is an *implementation detail*, please use the | |
45 | `wx.App` class (or some other derived class) instead."); | |
d14a1e28 RD |
46 | |
47 | class wxPyApp : public wxEvtHandler { | |
48 | public: | |
49 | ||
2b9048c5 | 50 | %pythonAppend wxPyApp |
d14a1e28 RD |
51 | "self._setCallbackInfo(self, PyApp) |
52 | self._setOORInfo(self)"; | |
53 | ||
856bf319 RD |
54 | DocStr(wxPyApp, |
55 | "Create a new application object, starting the bootstrap process."); | |
d14a1e28 RD |
56 | %extend { |
57 | wxPyApp() { | |
58 | wxPythonApp = new wxPyApp(); | |
59 | return wxPythonApp; | |
60 | } | |
61 | } | |
62 | ||
63 | ~wxPyApp(); | |
64 | ||
65 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
66 | ||
d14a1e28 | 67 | |
6c3b4aae RD |
68 | DocDeclStr( |
69 | wxString, GetAppName() const, | |
70 | "Get the application name."); | |
71 | DocDeclStr( | |
72 | void, SetAppName(const wxString& name), | |
dce2bd22 RD |
73 | "Set the application name. This value may be used automatically by |
74 | `wx.Config` and such."); | |
6c3b4aae RD |
75 | |
76 | DocDeclStr( | |
77 | wxString, GetClassName() const, | |
78 | "Get the application's class name."); | |
79 | DocDeclStr( | |
80 | void, SetClassName(const wxString& name), | |
dce2bd22 RD |
81 | "Set the application's class name. This value may be used for |
82 | X-resources if applicable for the platform"); | |
6c3b4aae RD |
83 | |
84 | DocDeclStr( | |
85 | const wxString&, GetVendorName() const, | |
86 | "Get the application's vendor name."); | |
87 | DocDeclStr( | |
88 | void, SetVendorName(const wxString& name), | |
dce2bd22 RD |
89 | "Set the application's vendor name. This value may be used |
90 | automatically by `wx.Config` and such."); | |
6c3b4aae RD |
91 | |
92 | ||
93 | DocDeclStr( | |
94 | wxAppTraits*, GetTraits(), | |
dce2bd22 RD |
95 | "Return (and create if necessary) the app traits object to which we |
96 | delegate for everything which either should be configurable by the | |
97 | user (then he can change the default behaviour simply by overriding | |
98 | CreateTraits() and returning his own traits object) or which is | |
99 | GUI/console dependent as then wx.AppTraits allows us to abstract the | |
100 | differences behind the common facade. | |
101 | ||
102 | :todo: Add support for overriding CreateAppTraits in wxPython."); | |
6c3b4aae RD |
103 | |
104 | ||
105 | DocDeclStr( | |
106 | virtual void, ProcessPendingEvents(), | |
dce2bd22 RD |
107 | "Process all events in the Pending Events list -- it is necessary to |
108 | call this function to process posted events. This normally happens | |
109 | during each event loop iteration."); | |
6c3b4aae RD |
110 | |
111 | ||
112 | DocDeclStr( | |
113 | virtual bool, Yield(bool onlyIfNeeded = False), | |
dce2bd22 RD |
114 | "Process all currently pending events right now, instead of waiting |
115 | until return to the event loop. It is an error to call ``Yield`` | |
116 | recursively unless the value of ``onlyIfNeeded`` is True. | |
117 | ||
118 | :warning: This function is dangerous as it can lead to unexpected | |
119 | reentrancies (i.e. when called from an event handler it may | |
120 | result in calling the same event handler again), use with | |
121 | _extreme_ care or, better, don't use at all! | |
122 | ||
123 | :see: `wx.Yield`, `wx.YieldIfNeeded`, `wx.SafeYield`"); | |
d14a1e28 | 124 | |
6c3b4aae RD |
125 | |
126 | DocDeclStr( | |
127 | virtual void, WakeUpIdle(), | |
dce2bd22 RD |
128 | "Make sure that idle events are sent again. |
129 | :see: `wx.WakeUpIdle`"); | |
d14a1e28 | 130 | |
d14a1e28 | 131 | |
6c3b4aae RD |
132 | DocDeclStr( |
133 | virtual int, MainLoop(), | |
dce2bd22 RD |
134 | "Execute the main GUI loop, the function doesn't normally return until |
135 | all top level windows have been closed and destroyed."); | |
d14a1e28 | 136 | |
6c3b4aae RD |
137 | |
138 | DocDeclStr( | |
139 | virtual void, Exit(), | |
dce2bd22 RD |
140 | "Exit the main loop thus terminating the application. |
141 | :see: `wx.Exit`"); | |
d14a1e28 | 142 | |
6c3b4aae RD |
143 | |
144 | DocDeclStr( | |
145 | virtual void, ExitMainLoop(), | |
dce2bd22 RD |
146 | "Exit the main GUI loop during the next iteration of the main |
147 | loop, (i.e. it does not stop the program immediately!)"); | |
d14a1e28 | 148 | |
6c3b4aae RD |
149 | |
150 | DocDeclStr( | |
151 | virtual bool, Pending(), | |
152 | "Returns True if there are unprocessed events in the event queue."); | |
d14a1e28 | 153 | |
6c3b4aae RD |
154 | |
155 | DocDeclStr( | |
156 | virtual bool, Dispatch(), | |
dce2bd22 RD |
157 | "Process the first event in the event queue (blocks until an event |
158 | appears if there are none currently)"); | |
d14a1e28 | 159 | |
d14a1e28 | 160 | |
6c3b4aae RD |
161 | DocDeclStr( |
162 | virtual bool, ProcessIdle(), | |
dce2bd22 RD |
163 | "Called from the MainLoop when the application becomes idle (there are |
164 | no pending events) and sends a `wx.IdleEvent` to all interested | |
165 | parties. Returns True if more idle events are needed, False if not."); | |
6c3b4aae RD |
166 | |
167 | ||
168 | DocDeclStr( | |
169 | virtual bool, SendIdleEvents(wxWindow* win, wxIdleEvent& event), | |
dce2bd22 RD |
170 | "Send idle event to window and all subwindows. Returns True if more |
171 | idle time is requested."); | |
d14a1e28 | 172 | |
d14a1e28 | 173 | |
6c3b4aae RD |
174 | DocDeclStr( |
175 | virtual bool, IsActive() const, | |
176 | "Return True if our app has focus."); | |
d14a1e28 | 177 | |
6c3b4aae RD |
178 | |
179 | DocDeclStr( | |
180 | void, SetTopWindow(wxWindow *win), | |
dce2bd22 | 181 | "Set the *main* top level window"); |
d14a1e28 | 182 | |
6c3b4aae RD |
183 | DocDeclStr( |
184 | virtual wxWindow*, GetTopWindow() const, | |
dce2bd22 RD |
185 | "Return the *main* top level window (if it hadn't been set previously |
186 | with SetTopWindow(), will return just some top level window and, if | |
187 | there not any, will return None)"); | |
d14a1e28 | 188 | |
d14a1e28 | 189 | |
6c3b4aae RD |
190 | DocDeclStr( |
191 | void, SetExitOnFrameDelete(bool flag), | |
dce2bd22 RD |
192 | "Control the exit behaviour: by default, the program will exit the main |
193 | loop (and so, usually, terminate) when the last top-level program | |
194 | window is deleted. Beware that if you disable this behaviour (with | |
195 | SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop() | |
196 | explicitly from somewhere."); | |
6c3b4aae RD |
197 | |
198 | ||
199 | DocDeclStr( | |
200 | bool, GetExitOnFrameDelete() const, | |
201 | "Get the current exit behaviour setting."); | |
d14a1e28 RD |
202 | |
203 | #if 0 | |
856bf319 | 204 | // Get display mode that is in use. This is only used in framebuffer |
d14a1e28 RD |
205 | // wxWin ports (such as wxMGL). |
206 | virtual wxVideoMode GetDisplayMode() const; | |
207 | ||
208 | // Set display mode to use. This is only used in framebuffer wxWin | |
209 | // ports (such as wxMGL). This method should be called from | |
210 | // wxApp::OnInitGui | |
211 | virtual bool SetDisplayMode(const wxVideoMode& info); | |
212 | #endif | |
213 | ||
6c3b4aae RD |
214 | |
215 | DocDeclStr( | |
216 | void, SetUseBestVisual( bool flag ), | |
dce2bd22 RD |
217 | "Set whether the app should try to use the best available visual on |
218 | systems where more than one is available, (Sun, SGI, XFree86 4, etc.)"); | |
6c3b4aae RD |
219 | |
220 | DocDeclStr( | |
221 | bool, GetUseBestVisual() const, | |
222 | "Get current UseBestVisual setting."); | |
223 | ||
d14a1e28 RD |
224 | |
225 | // set/get printing mode: see wxPRINT_XXX constants. | |
226 | // | |
227 | // default behaviour is the normal one for Unix: always use PostScript | |
228 | // printing. | |
229 | virtual void SetPrintMode(int mode); | |
230 | int GetPrintMode() const; | |
231 | ||
6c3b4aae RD |
232 | |
233 | DocDeclStr( | |
234 | void, SetAssertMode(int mode), | |
dce2bd22 RD |
235 | "Set the OnAssert behaviour for debug and hybrid builds. The following |
236 | flags may be or'd together: | |
237 | ||
238 | ========================= ======================================= | |
239 | wx.PYAPP_ASSERT_SUPPRESS Don't do anything | |
240 | wx.PYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible | |
241 | (default) | |
242 | wx.PYAPP_ASSERT_DIALOG Display a message dialog | |
243 | wx.PYAPP_ASSERT_LOG Write the assertion info to the wx.Log | |
244 | ========================= ======================================= | |
245 | ||
246 | "); | |
6c3b4aae RD |
247 | |
248 | DocDeclStr( | |
249 | int, GetAssertMode(), | |
250 | "Get the current OnAssert behaviour setting."); | |
d14a1e28 RD |
251 | |
252 | ||
253 | static bool GetMacSupportPCMenuShortcuts(); | |
254 | static long GetMacAboutMenuItemId(); | |
255 | static long GetMacPreferencesMenuItemId(); | |
256 | static long GetMacExitMenuItemId(); | |
257 | static wxString GetMacHelpMenuTitleName(); | |
258 | ||
259 | static void SetMacSupportPCMenuShortcuts(bool val); | |
260 | static void SetMacAboutMenuItemId(long val); | |
261 | static void SetMacPreferencesMenuItemId(long val); | |
262 | static void SetMacExitMenuItemId(long val); | |
263 | static void SetMacHelpMenuTitleName(const wxString& val); | |
264 | ||
d14a1e28 | 265 | |
6c3b4aae RD |
266 | DocDeclStr( |
267 | void, _BootstrapApp(), | |
268 | "For internal use only"); | |
269 | ||
270 | DocStr(GetComCtl32Version, | |
dce2bd22 RD |
271 | "Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or 0 if |
272 | it wasn't found at all. Raises an exception on non-Windows platforms."); | |
d14a1e28 | 273 | #ifdef __WXMSW__ |
d14a1e28 RD |
274 | static int GetComCtl32Version(); |
275 | #else | |
276 | %extend { | |
277 | static int GetComCtl32Version() | |
81cfe5e1 | 278 | { wxPyRaiseNotImplemented(); return 0; } |
d14a1e28 RD |
279 | } |
280 | #endif | |
281 | }; | |
282 | ||
283 | ||
284 | ||
285 | //--------------------------------------------------------------------------- | |
286 | %newgroup; | |
287 | ||
d14a1e28 | 288 | |
6c3b4aae RD |
289 | DocDeclStr( |
290 | void, wxExit(), | |
291 | "Force an exit of the application. Convenience for wx.GetApp().Exit()"); | |
292 | ||
293 | ||
294 | DocDeclStr( | |
295 | bool, wxYield(), | |
296 | "Yield to other apps/messages. Convenience for wx.GetApp().Yield()"); | |
d14a1e28 | 297 | |
6c3b4aae RD |
298 | DocDeclStr( |
299 | bool, wxYieldIfNeeded(), | |
300 | "Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)"); | |
d14a1e28 | 301 | |
d14a1e28 | 302 | |
6c3b4aae RD |
303 | DocDeclStr( |
304 | bool, wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=False), | |
dce2bd22 RD |
305 | "This function is similar to `wx.Yield`, except that it disables the |
306 | user input to all program windows before calling `wx.Yield` and | |
307 | re-enables it again afterwards. If ``win`` is not None, this window | |
308 | will remain enabled, allowing the implementation of some limited user | |
309 | interaction. | |
310 | ||
311 | :Returns: the result of the call to `wx.Yield`."); | |
6c3b4aae RD |
312 | |
313 | ||
314 | DocDeclStr( | |
315 | void, wxWakeUpIdle(), | |
dce2bd22 RD |
316 | "Cause the message queue to become empty again, so idle events will be |
317 | sent."); | |
6c3b4aae RD |
318 | |
319 | ||
320 | DocDeclStr( | |
321 | void, wxPostEvent(wxEvtHandler *dest, wxEvent& event), | |
dce2bd22 RD |
322 | "Send an event to a window or other wx.EvtHandler to be processed |
323 | later."); | |
6c3b4aae RD |
324 | |
325 | ||
326 | DocStr(wxApp_CleanUp, | |
dce2bd22 RD |
327 | "For internal use only, it is used to cleanup after wxWindows when |
328 | Python shuts down."); | |
d14a1e28 RD |
329 | %inline %{ |
330 | void wxApp_CleanUp() { | |
331 | __wxPyCleanup(); | |
332 | } | |
333 | %} | |
334 | ||
6c3b4aae RD |
335 | |
336 | DocStr(wxGetApp, | |
64e8a1f0 | 337 | "Return a reference to the current wx.App object."); |
d14a1e28 RD |
338 | %inline %{ |
339 | wxPyApp* wxGetApp() { | |
340 | return (wxPyApp*)wxTheApp; | |
341 | } | |
342 | %} | |
343 | ||
344 | ||
345 | //--------------------------------------------------------------------------- | |
346 | // Include some extra wxApp related python code here | |
347 | ||
348 | %pythoncode "_app_ex.py" | |
349 | ||
350 | //--------------------------------------------------------------------------- | |
351 |