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)";
53 %typemap(out) wxPyApp*; // turn off this typemap
56 "Create a new application object, starting the bootstrap process.", "");
59 wxPythonApp = new wxPyApp();
66 // Turn it back on again
67 %typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1, $owner); }
70 void _setCallbackInfo(PyObject* self, PyObject* _class);
74 wxString, GetAppName() const,
75 "Get the application name.", "");
77 void, SetAppName(const wxString& name),
78 "Set the application name. This value may be used automatically by
79 `wx.Config` and such.", "");
82 wxString, GetClassName() const,
83 "Get the application's class name.", "");
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", "");
90 const wxString&, GetVendorName() const,
91 "Get the application's vendor name.", "");
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.", "");
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.
107 :todo: Add support for overriding CreateAppTraits in wxPython.", "");
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.", "");
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.
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!
128 :see: `wx.Yield`, `wx.YieldIfNeeded`, `wx.SafeYield`
133 virtual void, WakeUpIdle(),
134 "Make sure that idle events are sent again.
135 :see: `wx.WakeUpIdle`", "");
139 virtual int, MainLoop(),
140 "Execute the main GUI loop, the function doesn't normally return until
141 all top level windows have been closed and destroyed.", "");
145 virtual void, Exit(),
146 "Exit the main loop thus terminating the application.
147 :see: `wx.Exit`", "");
151 virtual void, ExitMainLoop(),
152 "Exit the main GUI loop during the next iteration of the main
153 loop, (i.e. it does not stop the program immediately!)", "");
157 virtual bool, Pending(),
158 "Returns True if there are unprocessed events in the event queue.", "");
162 virtual bool, Dispatch(),
163 "Process the first event in the event queue (blocks until an event
164 appears if there are none currently)", "");
168 virtual bool, ProcessIdle(),
169 "Called from the MainLoop when the application becomes idle (there are
170 no pending events) and sends a `wx.IdleEvent` to all interested
171 parties. Returns True if more idle events are needed, False if not.", "");
175 virtual bool, SendIdleEvents(wxWindow* win, wxIdleEvent& event),
176 "Send idle event to window and all subwindows. Returns True if more
177 idle time is requested.", "");
181 virtual bool, IsActive() const,
182 "Return True if our app has focus.", "");
186 void, SetTopWindow(wxWindow *win),
187 "Set the *main* top level window", "");
190 virtual wxWindow*, GetTopWindow() const,
191 "Return the *main* top level window (if it hadn't been set previously
192 with SetTopWindow(), will return just some top level window and, if
193 there not any, will return None)", "");
197 void, SetExitOnFrameDelete(bool flag),
198 "Control the exit behaviour: by default, the program will exit the main
199 loop (and so, usually, terminate) when the last top-level program
200 window is deleted. Beware that if you disable this behaviour (with
201 SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop()
202 explicitly from somewhere.", "");
206 bool, GetExitOnFrameDelete() const,
207 "Get the current exit behaviour setting.", "");
210 // Get display mode that is in use. This is only used in framebuffer
211 // wxWin ports (such as wxMGL).
212 virtual wxVideoMode GetDisplayMode() const;
214 // Set display mode to use. This is only used in framebuffer wxWin
215 // ports (such as wxMGL). This method should be called from
217 virtual bool SetDisplayMode(const wxVideoMode& info);
222 void, SetUseBestVisual( bool flag ),
223 "Set whether the app should try to use the best available visual on
224 systems where more than one is available, (Sun, SGI, XFree86 4, etc.)", "");
227 bool, GetUseBestVisual() const,
228 "Get current UseBestVisual setting.", "");
231 // set/get printing mode: see wxPRINT_XXX constants.
233 // default behaviour is the normal one for Unix: always use PostScript
235 virtual void SetPrintMode(int mode);
236 int GetPrintMode() const;
240 void, SetAssertMode(int mode),
241 "Set the OnAssert behaviour for debug and hybrid builds.",
242 "The following flags may be or'd together:
244 ========================= =======================================
245 wx.PYAPP_ASSERT_SUPPRESS Don't do anything
246 wx.PYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible
248 wx.PYAPP_ASSERT_DIALOG Display a message dialog
249 wx.PYAPP_ASSERT_LOG Write the assertion info to the wx.Log
250 ========================= =======================================
255 int, GetAssertMode(),
256 "Get the current OnAssert behaviour setting.", "");
259 static bool GetMacSupportPCMenuShortcuts();
260 static long GetMacAboutMenuItemId();
261 static long GetMacPreferencesMenuItemId();
262 static long GetMacExitMenuItemId();
263 static wxString GetMacHelpMenuTitleName();
265 static void SetMacSupportPCMenuShortcuts(bool val);
266 static void SetMacAboutMenuItemId(long val);
267 static void SetMacPreferencesMenuItemId(long val);
268 static void SetMacExitMenuItemId(long val);
269 static void SetMacHelpMenuTitleName(const wxString& val);
273 void, _BootstrapApp(),
274 "For internal use only", "");
276 DocStr(GetComCtl32Version,
277 "Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or 0 if
278 it wasn't found at all. Raises an exception on non-Windows platforms.", "");
280 static int GetComCtl32Version();
283 static int GetComCtl32Version()
284 { wxPyRaiseNotImplemented(); return 0; }
291 //---------------------------------------------------------------------------
297 "Force an exit of the application. Convenience for wx.GetApp().Exit()", "");
302 "Yield to other apps/messages. Convenience for wx.GetApp().Yield()", "");
305 bool, wxYieldIfNeeded(),
306 "Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)", "");
310 bool, wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=False),
311 "This function is similar to `wx.Yield`, except that it disables the
312 user input to all program windows before calling `wx.Yield` and
313 re-enables it again afterwards. If ``win`` is not None, this window
314 will remain enabled, allowing the implementation of some limited user
317 :Returns: the result of the call to `wx.Yield`.", "");
321 void, wxWakeUpIdle(),
322 "Cause the message queue to become empty again, so idle events will be
327 void, wxPostEvent(wxEvtHandler *dest, wxEvent& event),
328 "Send an event to a window or other wx.EvtHandler to be processed
332 DocStr(wxApp_CleanUp,
333 "For internal use only, it is used to cleanup after wxWidgets when
334 Python shuts down.", "");
336 void wxApp_CleanUp() {
343 wxPyApp* , wxPyGetApp(),
344 "Return a reference to the current wx.App object.", "",
347 wxPyApp* wxPyGetApp() { return (wxPyApp*)wxTheApp; }
352 //---------------------------------------------------------------------------
353 // Include some extra wxApp related python code here
355 %pythoncode "_app_ex.py"
357 //---------------------------------------------------------------------------