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