]>
Commit | Line | Data |
---|---|---|
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 | ||
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.", ""); | |
46 | ||
47 | class wxPyApp : public wxEvtHandler { | |
48 | public: | |
49 | ||
50 | %pythonAppend wxPyApp "self._setOORInfo(self, False);" setCallbackInfo(PyApp) | |
51 | %typemap(out) wxPyApp*; // turn off this typemap | |
52 | ||
53 | DocStr(wxPyApp, | |
54 | "Create a new application object, starting the bootstrap process.", ""); | |
55 | %extend { | |
56 | wxPyApp() { | |
57 | wxPythonApp = new wxPyApp(); | |
58 | return wxPythonApp; | |
59 | } | |
60 | } | |
61 | ||
62 | ~wxPyApp(); | |
63 | ||
64 | // Turn it back on again | |
65 | %typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1, $owner); } | |
66 | ||
67 | ||
68 | void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref=false); | |
69 | ||
70 | ||
71 | DocDeclStr( | |
72 | wxString, GetAppName() const, | |
73 | "Get the application name.", ""); | |
74 | DocDeclStr( | |
75 | void, SetAppName(const wxString& name), | |
76 | "Set the application name. This value may be used automatically by | |
77 | `wx.Config` and such.", ""); | |
78 | ||
79 | DocDeclStr( | |
80 | wxString, GetClassName() const, | |
81 | "Get the application's class name.", ""); | |
82 | DocDeclStr( | |
83 | void, SetClassName(const wxString& name), | |
84 | "Set the application's class name. This value may be used for | |
85 | X-resources if applicable for the platform", ""); | |
86 | ||
87 | DocDeclStr( | |
88 | const wxString&, GetVendorName() const, | |
89 | "Get the application's vendor name.", ""); | |
90 | DocDeclStr( | |
91 | void, SetVendorName(const wxString& name), | |
92 | "Set the application's vendor name. This value may be used | |
93 | automatically by `wx.Config` and such.", ""); | |
94 | ||
95 | ||
96 | DocDeclStr( | |
97 | wxAppTraits*, GetTraits(), | |
98 | "Return (and create if necessary) the app traits object to which we | |
99 | delegate for everything which either should be configurable by the | |
100 | user (then he can change the default behaviour simply by overriding | |
101 | CreateTraits() and returning his own traits object) or which is | |
102 | GUI/console dependent as then wx.AppTraits allows us to abstract the | |
103 | differences behind the common facade. | |
104 | ||
105 | :todo: Add support for overriding CreateAppTraits in wxPython.", ""); | |
106 | ||
107 | ||
108 | DocDeclStr( | |
109 | virtual void, ProcessPendingEvents(), | |
110 | "Process all events in the Pending Events list -- it is necessary to | |
111 | call this function to process posted events. This normally happens | |
112 | during each event loop iteration.", ""); | |
113 | ||
114 | ||
115 | DocDeclStr( | |
116 | virtual bool, Yield(bool onlyIfNeeded = false), | |
117 | "Process all currently pending events right now, instead of waiting | |
118 | until return to the event loop. It is an error to call ``Yield`` | |
119 | recursively unless the value of ``onlyIfNeeded`` is True. | |
120 | ||
121 | :warning: This function is dangerous as it can lead to unexpected | |
122 | reentrancies (i.e. when called from an event handler it may | |
123 | result in calling the same event handler again), use with | |
124 | extreme care or, better, don't use at all! | |
125 | ||
126 | :see: `wx.Yield`, `wx.YieldIfNeeded`, `wx.SafeYield` | |
127 | ", ""); | |
128 | ||
129 | ||
130 | DocDeclStr( | |
131 | virtual void, WakeUpIdle(), | |
132 | "Make sure that idle events are sent again. | |
133 | :see: `wx.WakeUpIdle`", ""); | |
134 | ||
135 | ||
136 | DocDeclStr( | |
137 | static bool , IsMainLoopRunning() const, | |
138 | "Returns True if we're running the main loop, i.e. if the events can | |
139 | currently be dispatched.", ""); | |
140 | ||
141 | ||
142 | DocDeclStr( | |
143 | virtual int, MainLoop(), | |
144 | "Execute the main GUI loop, the function doesn't normally return until | |
145 | all top level windows have been closed and destroyed.", ""); | |
146 | ||
147 | ||
148 | DocDeclStr( | |
149 | virtual void, Exit(), | |
150 | "Exit the main loop thus terminating the application. | |
151 | :see: `wx.Exit`", ""); | |
152 | ||
153 | ||
154 | DocDeclStr( | |
155 | virtual wxLayoutDirection , GetLayoutDirection() const, | |
156 | "Return the layout direction for the current locale.", ""); | |
157 | ||
158 | ||
159 | DocDeclStr( | |
160 | virtual void, ExitMainLoop(), | |
161 | "Exit the main GUI loop during the next iteration of the main | |
162 | loop, (i.e. it does not stop the program immediately!)", ""); | |
163 | ||
164 | ||
165 | DocDeclStr( | |
166 | virtual bool, Pending(), | |
167 | "Returns True if there are unprocessed events in the event queue.", ""); | |
168 | ||
169 | ||
170 | DocDeclStr( | |
171 | virtual bool, Dispatch(), | |
172 | "Process the first event in the event queue (blocks until an event | |
173 | appears if there are none currently)", ""); | |
174 | ||
175 | ||
176 | DocDeclStr( | |
177 | virtual bool, ProcessIdle(), | |
178 | "Called from the MainLoop when the application becomes idle (there are | |
179 | no pending events) and sends a `wx.IdleEvent` to all interested | |
180 | parties. Returns True if more idle events are needed, False if not.", ""); | |
181 | ||
182 | ||
183 | DocDeclStr( | |
184 | virtual bool, SendIdleEvents(wxWindow* win, wxIdleEvent& event), | |
185 | "Send idle event to window and all subwindows. Returns True if more | |
186 | idle time is requested.", ""); | |
187 | ||
188 | ||
189 | DocDeclStr( | |
190 | virtual bool, IsActive() const, | |
191 | "Return True if our app has focus.", ""); | |
192 | ||
193 | ||
194 | DocDeclStr( | |
195 | void, SetTopWindow(wxWindow *win), | |
196 | "Set the *main* top level window", ""); | |
197 | ||
198 | DocDeclStr( | |
199 | virtual wxWindow*, GetTopWindow() const, | |
200 | "Return the *main* top level window (if it hadn't been set previously | |
201 | with SetTopWindow(), will return just some top level window and, if | |
202 | there not any, will return None)", ""); | |
203 | ||
204 | ||
205 | DocDeclStr( | |
206 | void, SetExitOnFrameDelete(bool flag), | |
207 | "Control the exit behaviour: by default, the program will exit the main | |
208 | loop (and so, usually, terminate) when the last top-level program | |
209 | window is deleted. Beware that if you disable this behaviour (with | |
210 | SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop() | |
211 | explicitly from somewhere.", ""); | |
212 | ||
213 | ||
214 | DocDeclStr( | |
215 | bool, GetExitOnFrameDelete() const, | |
216 | "Get the current exit behaviour setting.", ""); | |
217 | ||
218 | #if 0 | |
219 | // Get display mode that is in use. This is only used in framebuffer | |
220 | // wxWin ports (such as wxMGL). | |
221 | virtual wxVideoMode GetDisplayMode() const; | |
222 | ||
223 | // Set display mode to use. This is only used in framebuffer wxWin | |
224 | // ports (such as wxMGL). This method should be called from | |
225 | // wxApp::OnInitGui | |
226 | virtual bool SetDisplayMode(const wxVideoMode& info); | |
227 | #endif | |
228 | ||
229 | ||
230 | DocDeclStr( | |
231 | void, SetUseBestVisual( bool flag, bool forceTrueColour = false ), | |
232 | "Set whether the app should try to use the best available visual on | |
233 | systems where more than one is available, (Sun, SGI, XFree86 4, etc.)", ""); | |
234 | ||
235 | DocDeclStr( | |
236 | bool, GetUseBestVisual() const, | |
237 | "Get current UseBestVisual setting.", ""); | |
238 | ||
239 | ||
240 | // set/get printing mode: see wxPRINT_XXX constants. | |
241 | // | |
242 | // default behaviour is the normal one for Unix: always use PostScript | |
243 | // printing. | |
244 | virtual void SetPrintMode(int mode); | |
245 | int GetPrintMode() const; | |
246 | ||
247 | ||
248 | DocDeclStr( | |
249 | void, SetAssertMode(int mode), | |
250 | "Set the OnAssert behaviour for debug and hybrid builds.", | |
251 | "The following flags may be or'd together: | |
252 | ||
253 | ========================= ======================================= | |
254 | wx.PYAPP_ASSERT_SUPPRESS Don't do anything | |
255 | wx.PYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible | |
256 | (default) | |
257 | wx.PYAPP_ASSERT_DIALOG Display a message dialog | |
258 | wx.PYAPP_ASSERT_LOG Write the assertion info to the wx.Log | |
259 | ========================= ======================================= | |
260 | ||
261 | "); | |
262 | ||
263 | DocDeclStr( | |
264 | int, GetAssertMode(), | |
265 | "Get the current OnAssert behaviour setting.", ""); | |
266 | ||
267 | ||
268 | static bool GetMacSupportPCMenuShortcuts(); // TODO, deprecate this | |
269 | static long GetMacAboutMenuItemId(); | |
270 | static long GetMacPreferencesMenuItemId(); | |
271 | static long GetMacExitMenuItemId(); | |
272 | static wxString GetMacHelpMenuTitleName(); | |
273 | ||
274 | static void SetMacSupportPCMenuShortcuts(bool val); // TODO, deprecate this | |
275 | static void SetMacAboutMenuItemId(long val); | |
276 | static void SetMacPreferencesMenuItemId(long val); | |
277 | static void SetMacExitMenuItemId(long val); | |
278 | static void SetMacHelpMenuTitleName(const wxString& val); | |
279 | ||
280 | ||
281 | DocDeclStr( | |
282 | void, _BootstrapApp(), | |
283 | "For internal use only", ""); | |
284 | ||
285 | DocStr(GetComCtl32Version, | |
286 | "Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or 0 if | |
287 | it wasn't found at all. Raises an exception on non-Windows platforms.", ""); | |
288 | #ifdef __WXMSW__ | |
289 | static int GetComCtl32Version(); | |
290 | #else | |
291 | %extend { | |
292 | static int GetComCtl32Version() | |
293 | { wxPyRaiseNotImplemented(); return 0; } | |
294 | } | |
295 | #endif | |
296 | ||
297 | %extend { | |
298 | DocStr(IsDisplayAvailable, | |
299 | "Tests if it is possible to create a GUI in the current environment. | |
300 | This will mean different things on the different platforms. | |
301 | ||
302 | * On X Windows systems this function will return ``False`` if it is | |
303 | not able to open a connection to the X display, which can happen | |
304 | if $DISPLAY is not set, or is not set correctly. | |
305 | ||
306 | * On Mac OS X a ``False`` return value will mean that wx is not | |
307 | able to access the window manager, which can happen if logged in | |
308 | remotely or if running from the normal version of python instead | |
309 | of the framework version, (i.e., pythonw.) | |
310 | ||
311 | * On MS Windows... | |
312 | ", ""); | |
313 | static bool IsDisplayAvailable() { | |
314 | return wxPyTestDisplayAvailable(); | |
315 | } | |
316 | } | |
317 | ||
318 | ||
319 | %property(AppName, GetAppName, SetAppName, doc="See `GetAppName` and `SetAppName`"); | |
320 | %property(AssertMode, GetAssertMode, SetAssertMode, doc="See `GetAssertMode` and `SetAssertMode`"); | |
321 | %property(ClassName, GetClassName, SetClassName, doc="See `GetClassName` and `SetClassName`"); | |
322 | %property(ExitOnFrameDelete, GetExitOnFrameDelete, SetExitOnFrameDelete, doc="See `GetExitOnFrameDelete` and `SetExitOnFrameDelete`"); | |
323 | %property(LayoutDirection, GetLayoutDirection, doc="See `GetLayoutDirection`"); | |
324 | %property(PrintMode, GetPrintMode, SetPrintMode, doc="See `GetPrintMode` and `SetPrintMode`"); | |
325 | %property(TopWindow, GetTopWindow, SetTopWindow, doc="See `GetTopWindow` and `SetTopWindow`"); | |
326 | %property(Traits, GetTraits, doc="See `GetTraits`"); | |
327 | %property(UseBestVisual, GetUseBestVisual, SetUseBestVisual, doc="See `GetUseBestVisual` and `SetUseBestVisual`"); | |
328 | %property(VendorName, GetVendorName, SetVendorName, doc="See `GetVendorName` and `SetVendorName`"); | |
329 | ||
330 | %property(Active, IsActive); | |
331 | }; | |
332 | ||
333 | ||
334 | ||
335 | //--------------------------------------------------------------------------- | |
336 | %newgroup; | |
337 | ||
338 | ||
339 | DocDeclStr( | |
340 | void, wxExit(), | |
341 | "Force an exit of the application. Convenience for wx.GetApp().Exit()", ""); | |
342 | ||
343 | ||
344 | DocDeclStr( | |
345 | bool, wxYield(), | |
346 | "Yield to other apps/messages. Convenience for wx.GetApp().Yield()", ""); | |
347 | ||
348 | DocDeclStr( | |
349 | bool, wxYieldIfNeeded(), | |
350 | "Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)", ""); | |
351 | ||
352 | ||
353 | DocDeclStr( | |
354 | bool, wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=false), | |
355 | "This function is similar to `wx.Yield`, except that it disables the | |
356 | user input to all program windows before calling `wx.Yield` and | |
357 | re-enables it again afterwards. If ``win`` is not None, this window | |
358 | will remain enabled, allowing the implementation of some limited user | |
359 | interaction. | |
360 | ||
361 | :Returns: the result of the call to `wx.Yield`.", ""); | |
362 | ||
363 | ||
364 | DocDeclStr( | |
365 | void, wxWakeUpIdle(), | |
366 | "Cause the message queue to become empty again, so idle events will be | |
367 | sent.", ""); | |
368 | ||
369 | ||
370 | DocDeclStr( | |
371 | void, wxPostEvent(wxEvtHandler *dest, wxEvent& event), | |
372 | "Send an event to a window or other wx.EvtHandler to be processed | |
373 | later.", ""); | |
374 | ||
375 | ||
376 | DocStr(wxApp_CleanUp, | |
377 | "For internal use only, it is used to cleanup after wxWidgets when | |
378 | Python shuts down.", ""); | |
379 | %inline %{ | |
380 | void wxApp_CleanUp() { | |
381 | __wxPyCleanup(); | |
382 | } | |
383 | %} | |
384 | ||
385 | ||
386 | DocDeclStrName( | |
387 | wxPyApp* , wxPyGetApp(), | |
388 | "Return a reference to the current wx.App object.", "", | |
389 | GetApp); | |
390 | %{ | |
391 | wxPyApp* wxPyGetApp() { return (wxPyApp*)wxTheApp; } | |
392 | %} | |
393 | ||
394 | ||
395 | ||
396 | ||
397 | ||
398 | DocDeclAStr( | |
399 | void , wxSetDefaultPyEncoding(const char* encoding), | |
400 | "SetDefaultPyEncoding(string encoding)", | |
401 | "Sets the encoding that wxPython will use when it needs to convert a | |
402 | Python string or unicode object to or from a wxString. | |
403 | ||
404 | The default encoding is the value of ``locale.getdefaultlocale()[1]`` | |
405 | but please be aware that the default encoding within the same locale | |
406 | may be slightly different on different platforms. For example, please | |
407 | see http://www.alanwood.net/demos/charsetdiffs.html for differences | |
408 | between the common latin/roman encodings.", ""); | |
409 | ||
410 | DocDeclAStr( | |
411 | const char* , wxGetDefaultPyEncoding(), | |
412 | "GetDefaultPyEncoding() -> string", | |
413 | "Gets the current encoding that wxPython will use when it needs to | |
414 | convert a Python string or unicode object to or from a wxString.", ""); | |
415 | ||
416 | ||
417 | //--------------------------------------------------------------------------- | |
418 | // Include some extra wxApp related python code here | |
419 | ||
420 | %pythoncode "_app_ex.py" | |
421 | ||
422 | //--------------------------------------------------------------------------- | |
423 |