1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wxApp
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
19 // 1. Provide another app object that allows FilterEvent to be overloaded.
20 // 2. Wrap wxAppTraits and allow wxApp::CreateTraits to be overloaded.
22 //---------------------------------------------------------------------------
29 wxPYAPP_ASSERT_SUPPRESS = 1,
30 wxPYAPP_ASSERT_EXCEPTION = 2,
31 wxPYAPP_ASSERT_DIALOG = 4,
32 wxPYAPP_ASSERT_LOG = 8
38 wxPRINT_POSTSCRIPT = 2
44 "The ``wx.PyApp`` class is an *implementation detail*, please use the
45 `wx.App` class (or some other derived class) instead.", "");
47 class wxPyApp : public wxEvtHandler {
50 %pythonAppend wxPyApp "self._setOORInfo(self, False);" setCallbackInfo(PyApp)
51 %typemap(out) wxPyApp*; // turn off this typemap
54 "Create a new application object, starting the bootstrap process.", "");
57 wxPythonApp = new wxPyApp();
64 // Turn it back on again
65 %typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1, $owner); }
68 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref=false);
72 wxString, GetAppName() const,
73 "Get the application name.", "");
75 void, SetAppName(const wxString& name),
76 "Set the application name. This value may be used automatically by
77 `wx.Config` and such.", "");
80 wxString, GetClassName() const,
81 "Get the application's class name.", "");
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", "");
88 const wxString&, GetVendorName() const,
89 "Get the application's vendor name.", "");
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.", "");
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.
105 :todo: Add support for overriding CreateAppTraits in wxPython.", "");
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.", "");
116 bool , HasPendingEvents() const,
117 "Check if there are pending events on global pending event list", "");
121 virtual bool, Yield(bool onlyIfNeeded = false),
122 "Process all currently pending events right now, instead of waiting
123 until return to the event loop. It is an error to call ``Yield``
124 recursively unless the value of ``onlyIfNeeded`` is True.
126 :warning: This function is dangerous as it can lead to unexpected
127 reentrancies (i.e. when called from an event handler it may
128 result in calling the same event handler again), use with
129 extreme care or, better, don't use at all!
131 :see: `wx.Yield`, `wx.YieldIfNeeded`, `wx.SafeYield`
136 virtual void, WakeUpIdle(),
137 "Make sure that idle events are sent again.
138 :see: `wx.WakeUpIdle`", "");
142 static bool , IsMainLoopRunning() const,
143 "Returns True if we're running the main loop, i.e. if the events can
144 currently be dispatched.", "");
148 virtual int, MainLoop(),
149 "Execute the main GUI loop, the function doesn't normally return until
150 all top level windows have been closed and destroyed.", "");
154 virtual void, Exit(),
155 "Exit the main loop thus terminating the application.
156 :see: `wx.Exit`", "");
160 virtual wxLayoutDirection , GetLayoutDirection() const,
161 "Return the layout direction for the current locale.", "");
165 virtual void, ExitMainLoop(),
166 "Exit the main GUI loop during the next iteration of the main
167 loop, (i.e. it does not stop the program immediately!)", "");
171 virtual bool, Pending(),
172 "Returns True if there are unprocessed events in the event queue.", "");
176 virtual bool, Dispatch(),
177 "Process the first event in the event queue (blocks until an event
178 appears if there are none currently)", "");
182 virtual bool, ProcessIdle(),
183 "Called from the MainLoop when the application becomes idle (there are
184 no pending events) and sends a `wx.IdleEvent` to all interested
185 parties. Returns True if more idle events are needed, False if not.", "");
189 virtual bool, SendIdleEvents(wxWindow* win, wxIdleEvent& event),
190 "Send idle event to window and all subwindows. Returns True if more
191 idle time is requested.", "");
195 virtual bool, IsActive() const,
196 "Return True if our app has focus.", "");
200 void, SetTopWindow(wxWindow *win),
201 "Set the *main* top level window", "");
204 virtual wxWindow*, GetTopWindow() const,
205 "Return the *main* top level window (if it hadn't been set previously
206 with SetTopWindow(), will return just some top level window and, if
207 there not any, will return None)", "");
211 void, SetExitOnFrameDelete(bool flag),
212 "Control the exit behaviour: by default, the program will exit the main
213 loop (and so, usually, terminate) when the last top-level program
214 window is deleted. Beware that if you disable this behaviour (with
215 SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop()
216 explicitly from somewhere.", "");
220 bool, GetExitOnFrameDelete() const,
221 "Get the current exit behaviour setting.", "");
224 // Get display mode that is in use. This is only used in framebuffer
225 // wxWin ports (such as wxMGL).
226 virtual wxVideoMode GetDisplayMode() const;
228 // Set display mode to use. This is only used in framebuffer wxWin
229 // ports (such as wxMGL). This method should be called from
231 virtual bool SetDisplayMode(const wxVideoMode& info);
236 void, SetUseBestVisual( bool flag, bool forceTrueColour = false ),
237 "Set whether the app should try to use the best available visual on
238 systems where more than one is available, (Sun, SGI, XFree86 4, etc.)", "");
241 bool, GetUseBestVisual() const,
242 "Get current UseBestVisual setting.", "");
245 // set/get printing mode: see wxPRINT_XXX constants.
247 // default behaviour is the normal one for Unix: always use PostScript
249 virtual void SetPrintMode(int mode);
250 int GetPrintMode() const;
254 void, SetAssertMode(int mode),
255 "Set the OnAssert behaviour for debug and hybrid builds.",
256 "The following flags may be or'd together:
258 ========================= =======================================
259 wx.PYAPP_ASSERT_SUPPRESS Don't do anything
260 wx.PYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible
262 wx.PYAPP_ASSERT_DIALOG Display a message dialog
263 wx.PYAPP_ASSERT_LOG Write the assertion info to the wx.Log
264 ========================= =======================================
269 int, GetAssertMode(),
270 "Get the current OnAssert behaviour setting.", "");
273 static bool GetMacSupportPCMenuShortcuts(); // TODO, deprecate this
274 static long GetMacAboutMenuItemId();
275 static long GetMacPreferencesMenuItemId();
276 static long GetMacExitMenuItemId();
277 static wxString GetMacHelpMenuTitleName();
279 static void SetMacSupportPCMenuShortcuts(bool val); // TODO, deprecate this
280 static void SetMacAboutMenuItemId(long val);
281 static void SetMacPreferencesMenuItemId(long val);
282 static void SetMacExitMenuItemId(long val);
283 static void SetMacHelpMenuTitleName(const wxString& val);
287 void, _BootstrapApp(),
288 "For internal use only", "");
290 DocStr(GetComCtl32Version,
291 "Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or 0 if
292 it wasn't found at all. Raises an exception on non-Windows platforms.", "");
294 static int GetComCtl32Version();
297 static int GetComCtl32Version()
298 { wxPyRaiseNotImplemented(); return 0; }
303 DocStr(IsDisplayAvailable,
304 "Tests if it is possible to create a GUI in the current environment.
305 This will mean different things on the different platforms.
307 * On X Windows systems this function will return ``False`` if it is
308 not able to open a connection to the X display, which can happen
309 if $DISPLAY is not set, or is not set correctly.
311 * On Mac OS X a ``False`` return value will mean that wx is not
312 able to access the window manager, which can happen if logged in
313 remotely or if running from the normal version of python instead
314 of the framework version, (i.e., pythonw.)
318 static bool IsDisplayAvailable() {
319 return wxPyTestDisplayAvailable();
324 %property(AppName, GetAppName, SetAppName, doc="See `GetAppName` and `SetAppName`");
325 %property(AssertMode, GetAssertMode, SetAssertMode, doc="See `GetAssertMode` and `SetAssertMode`");
326 %property(ClassName, GetClassName, SetClassName, doc="See `GetClassName` and `SetClassName`");
327 %property(ExitOnFrameDelete, GetExitOnFrameDelete, SetExitOnFrameDelete, doc="See `GetExitOnFrameDelete` and `SetExitOnFrameDelete`");
328 %property(LayoutDirection, GetLayoutDirection, doc="See `GetLayoutDirection`");
329 %property(PrintMode, GetPrintMode, SetPrintMode, doc="See `GetPrintMode` and `SetPrintMode`");
330 %property(TopWindow, GetTopWindow, SetTopWindow, doc="See `GetTopWindow` and `SetTopWindow`");
331 %property(Traits, GetTraits, doc="See `GetTraits`");
332 %property(UseBestVisual, GetUseBestVisual, SetUseBestVisual, doc="See `GetUseBestVisual` and `SetUseBestVisual`");
333 %property(VendorName, GetVendorName, SetVendorName, doc="See `GetVendorName` and `SetVendorName`");
335 %property(Active, IsActive);
340 //---------------------------------------------------------------------------
346 "Force an exit of the application. Convenience for wx.GetApp().Exit()", "");
351 "Yield to other apps/messages. Convenience for wx.GetApp().Yield()", "");
354 bool, wxYieldIfNeeded(),
355 "Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)", "");
359 bool, wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=false),
360 "This function is similar to `wx.Yield`, except that it disables the
361 user input to all program windows before calling `wx.Yield` and
362 re-enables it again afterwards. If ``win`` is not None, this window
363 will remain enabled, allowing the implementation of some limited user
366 :Returns: the result of the call to `wx.Yield`.", "");
370 void, wxWakeUpIdle(),
371 "Cause the message queue to become empty again, so idle events will be
376 void, wxPostEvent(wxEvtHandler *dest, wxEvent& event),
377 "Send an event to a window or other wx.EvtHandler to be processed
381 DocStr(wxApp_CleanUp,
382 "For internal use only, it is used to cleanup after wxWidgets when
383 Python shuts down.", "");
385 void wxApp_CleanUp() {
392 wxPyApp* , wxPyGetApp(),
393 "Return a reference to the current wx.App object.", "",
396 wxPyApp* wxPyGetApp() { return (wxPyApp*)wxTheApp; }
404 void , wxSetDefaultPyEncoding(const char* encoding),
405 "SetDefaultPyEncoding(string encoding)",
406 "Sets the encoding that wxPython will use when it needs to convert a
407 Python string or unicode object to or from a wxString.
409 The default encoding is the value of ``locale.getdefaultlocale()[1]``
410 but please be aware that the default encoding within the same locale
411 may be slightly different on different platforms. For example, please
412 see http://www.alanwood.net/demos/charsetdiffs.html for differences
413 between the common latin/roman encodings.", "");
416 const char* , wxGetDefaultPyEncoding(),
417 "GetDefaultPyEncoding() -> string",
418 "Gets the current encoding that wxPython will use when it needs to
419 convert a Python string or unicode object to or from a wxString.", "");
422 //---------------------------------------------------------------------------
423 // Include some extra wxApp related python code here
425 %pythoncode "_app_ex.py"
427 //---------------------------------------------------------------------------