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 {
51 "self._setCallbackInfo(self, PyApp)
52 self._setOORInfo(self)";
55 "Create a new application object, starting the bootstrap process.", "");
58 wxPythonApp = new wxPyApp();
65 void _setCallbackInfo(PyObject* self, PyObject* _class);
69 wxString, GetAppName() const,
70 "Get the application name.", "");
72 void, SetAppName(const wxString& name),
73 "Set the application name. This value may be used automatically by
74 `wx.Config` and such.", "");
77 wxString, GetClassName() const,
78 "Get the application's class name.", "");
80 void, SetClassName(const wxString& name),
81 "Set the application's class name. This value may be used for
82 X-resources if applicable for the platform", "");
85 const wxString&, GetVendorName() const,
86 "Get the application's vendor name.", "");
88 void, SetVendorName(const wxString& name),
89 "Set the application's vendor name. This value may be used
90 automatically by `wx.Config` and such.", "");
94 wxAppTraits*, GetTraits(),
95 "Return (and create if necessary) the app traits object to which we
96 delegate for everything which either should be configurable by the
97 user (then he can change the default behaviour simply by overriding
98 CreateTraits() and returning his own traits object) or which is
99 GUI/console dependent as then wx.AppTraits allows us to abstract the
100 differences behind the common facade.
102 :todo: Add support for overriding CreateAppTraits in wxPython.", "");
106 virtual void, ProcessPendingEvents(),
107 "Process all events in the Pending Events list -- it is necessary to
108 call this function to process posted events. This normally happens
109 during each event loop iteration.", "");
113 virtual bool, Yield(bool onlyIfNeeded = False),
114 "Process all currently pending events right now, instead of waiting
115 until return to the event loop. It is an error to call ``Yield``
116 recursively unless the value of ``onlyIfNeeded`` is True.
118 :warning: This function is dangerous as it can lead to unexpected
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!
123 :see: `wx.Yield`, `wx.YieldIfNeeded`, `wx.SafeYield`
128 virtual void, WakeUpIdle(),
129 "Make sure that idle events are sent again.
130 :see: `wx.WakeUpIdle`", "");
134 virtual int, MainLoop(),
135 "Execute the main GUI loop, the function doesn't normally return until
136 all top level windows have been closed and destroyed.", "");
140 virtual void, Exit(),
141 "Exit the main loop thus terminating the application.
142 :see: `wx.Exit`", "");
146 virtual void, ExitMainLoop(),
147 "Exit the main GUI loop during the next iteration of the main
148 loop, (i.e. it does not stop the program immediately!)", "");
152 virtual bool, Pending(),
153 "Returns True if there are unprocessed events in the event queue.", "");
157 virtual bool, Dispatch(),
158 "Process the first event in the event queue (blocks until an event
159 appears if there are none currently)", "");
163 virtual bool, ProcessIdle(),
164 "Called from the MainLoop when the application becomes idle (there are
165 no pending events) and sends a `wx.IdleEvent` to all interested
166 parties. Returns True if more idle events are needed, False if not.", "");
170 virtual bool, SendIdleEvents(wxWindow* win, wxIdleEvent& event),
171 "Send idle event to window and all subwindows. Returns True if more
172 idle time is requested.", "");
176 virtual bool, IsActive() const,
177 "Return True if our app has focus.", "");
181 void, SetTopWindow(wxWindow *win),
182 "Set the *main* top level window", "");
185 virtual wxWindow*, GetTopWindow() const,
186 "Return the *main* top level window (if it hadn't been set previously
187 with SetTopWindow(), will return just some top level window and, if
188 there not any, will return None)", "");
192 void, SetExitOnFrameDelete(bool flag),
193 "Control the exit behaviour: by default, the program will exit the main
194 loop (and so, usually, terminate) when the last top-level program
195 window is deleted. Beware that if you disable this behaviour (with
196 SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop()
197 explicitly from somewhere.", "");
201 bool, GetExitOnFrameDelete() const,
202 "Get the current exit behaviour setting.", "");
205 // Get display mode that is in use. This is only used in framebuffer
206 // wxWin ports (such as wxMGL).
207 virtual wxVideoMode GetDisplayMode() const;
209 // Set display mode to use. This is only used in framebuffer wxWin
210 // ports (such as wxMGL). This method should be called from
212 virtual bool SetDisplayMode(const wxVideoMode& info);
217 void, SetUseBestVisual( bool flag ),
218 "Set whether the app should try to use the best available visual on
219 systems where more than one is available, (Sun, SGI, XFree86 4, etc.)", "");
222 bool, GetUseBestVisual() const,
223 "Get current UseBestVisual setting.", "");
226 // set/get printing mode: see wxPRINT_XXX constants.
228 // default behaviour is the normal one for Unix: always use PostScript
230 virtual void SetPrintMode(int mode);
231 int GetPrintMode() const;
235 void, SetAssertMode(int mode),
236 "Set the OnAssert behaviour for debug and hybrid builds.",
237 "The following flags may be or'd together:
239 ========================= =======================================
240 wx.PYAPP_ASSERT_SUPPRESS Don't do anything
241 wx.PYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible
243 wx.PYAPP_ASSERT_DIALOG Display a message dialog
244 wx.PYAPP_ASSERT_LOG Write the assertion info to the wx.Log
245 ========================= =======================================
250 int, GetAssertMode(),
251 "Get the current OnAssert behaviour setting.", "");
254 static bool GetMacSupportPCMenuShortcuts();
255 static long GetMacAboutMenuItemId();
256 static long GetMacPreferencesMenuItemId();
257 static long GetMacExitMenuItemId();
258 static wxString GetMacHelpMenuTitleName();
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);
268 void, _BootstrapApp(),
269 "For internal use only", "");
271 DocStr(GetComCtl32Version,
272 "Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or 0 if
273 it wasn't found at all. Raises an exception on non-Windows platforms.", "");
275 static int GetComCtl32Version();
278 static int GetComCtl32Version()
279 { wxPyRaiseNotImplemented(); return 0; }
286 //---------------------------------------------------------------------------
292 "Force an exit of the application. Convenience for wx.GetApp().Exit()", "");
297 "Yield to other apps/messages. Convenience for wx.GetApp().Yield()", "");
300 bool, wxYieldIfNeeded(),
301 "Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)", "");
305 bool, wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=False),
306 "This function is similar to `wx.Yield`, except that it disables the
307 user input to all program windows before calling `wx.Yield` and
308 re-enables it again afterwards. If ``win`` is not None, this window
309 will remain enabled, allowing the implementation of some limited user
312 :Returns: the result of the call to `wx.Yield`.", "");
316 void, wxWakeUpIdle(),
317 "Cause the message queue to become empty again, so idle events will be
322 void, wxPostEvent(wxEvtHandler *dest, wxEvent& event),
323 "Send an event to a window or other wx.EvtHandler to be processed
327 DocStr(wxApp_CleanUp,
328 "For internal use only, it is used to cleanup after wxWidgets when
329 Python shuts down.", "");
331 void wxApp_CleanUp() {
338 wxPyApp* , wxPyGetApp(),
339 "Return a reference to the current wx.App object.", "",
342 wxPyApp* wxPyGetApp() { return (wxPyApp*)wxTheApp; }
347 //---------------------------------------------------------------------------
348 // Include some extra wxApp related python code here
350 %pythoncode "_app_ex.py"
352 //---------------------------------------------------------------------------