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