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