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 class wxPyApp : public wxEvtHandler {
48 "self._setCallbackInfo(self, PyApp)
49 self._setOORInfo(self)";
52 "Create a new application object, starting the bootstrap process.");
55 wxPythonApp = new wxPyApp();
62 void _setCallbackInfo(PyObject* self, PyObject* _class);
66 wxString, GetAppName() const,
67 "Get the application name.");
69 void, SetAppName(const wxString& name),
70 "Set the application name. This value may be used automatically\n"
71 "by wx.Config and such.");
74 wxString, GetClassName() const,
75 "Get the application's class name.");
77 void, SetClassName(const wxString& name),
78 "Set the application's class name. This value may be used for X-resources if\n"
79 "applicable for the platform");
82 const wxString&, GetVendorName() const,
83 "Get the application's vendor name.");
85 void, SetVendorName(const wxString& name),
86 "Set the application's vendor name. This value may be used automatically\n"
87 "by wx.Config and such.");
91 wxAppTraits*, GetTraits(),
92 "Create the app traits object to which we delegate for everything which either\n"
93 "should be configurable by the user (then he can change the default behaviour\n"
94 "simply by overriding CreateTraits() and returning his own traits object) or\n"
95 "which is GUI/console dependent as then wx.AppTraits allows us to abstract the\n"
96 "differences behind the common facade");
100 virtual void, ProcessPendingEvents(),
101 "Process all events in the Pending Events list -- it is necessary to call this\n"
102 "function to process posted events. This happens during each event loop\n"
107 virtual bool, Yield(bool onlyIfNeeded = False),
108 "Process all currently pending events right now, instead of waiting until\n"
109 "return to the event loop. It is an error to call Yield() recursively unless\n"
110 "the value of onlyIfNeeded is True.\n"
112 "WARNING: This function is dangerous as it can lead to unexpected\n"
113 " reentrancies (i.e. when called from an event handler it\n"
114 " may result in calling the same event handler again), use\n"
115 " with _extreme_ care or, better, don't use at all!\n");
119 virtual void, WakeUpIdle(),
120 "Make sure that idle events are sent again");
124 virtual int, MainLoop(),
125 "Execute the main GUI loop, the function returns when the loop ends.");
129 virtual void, Exit(),
130 "Exit the main loop thus terminating the application.");
134 virtual void, ExitMainLoop(),
135 "Exit the main GUI loop during the next iteration (i.e. it does not\n"
136 "stop the program immediately!)");
140 virtual bool, Pending(),
141 "Returns True if there are unprocessed events in the event queue.");
145 virtual bool, Dispatch(),
146 "Process the first event in the event queue (blocks until an event\n"
147 "appears if there are none currently)");
151 virtual bool, ProcessIdle(),
152 "Called from the MainLoop when the application becomes idle and sends an\n"
153 "IdleEvent to all interested parties. Returns True is more idle events are\n"
154 "needed, False if not.");
158 virtual bool, SendIdleEvents(wxWindow* win, wxIdleEvent& event),
159 "Send idle event to window and all subwindows. Returns True if more idle time\n"
164 virtual bool, IsActive() const,
165 "Return True if our app has focus.");
169 void, SetTopWindow(wxWindow *win),
170 "Set the \"main\" top level window");
173 virtual wxWindow*, GetTopWindow() const,
174 "Return the \"main\" top level window (if it hadn't been set previously with\n"
175 "SetTopWindow(), will return just some top level window and, if there not any,\n"
176 "will return None)");
180 void, SetExitOnFrameDelete(bool flag),
181 "Control the exit behaviour: by default, the program will exit the main loop\n"
182 "(and so, usually, terminate) when the last top-level program window is\n"
183 "deleted. Beware that if you disable this behaviour (with\n"
184 "SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop() explicitly\n"
185 "from somewhere.\n");
189 bool, GetExitOnFrameDelete() const,
190 "Get the current exit behaviour setting.");
193 // Get display mode that is in use. This is only used in framebuffer
194 // wxWin ports (such as wxMGL).
195 virtual wxVideoMode GetDisplayMode() const;
197 // Set display mode to use. This is only used in framebuffer wxWin
198 // ports (such as wxMGL). This method should be called from
200 virtual bool SetDisplayMode(const wxVideoMode& info);
205 void, SetUseBestVisual( bool flag ),
206 "Set whether the app should try to use the best available visual on systems\n"
207 "where more than one is available, (Sun, SGI, XFree86 4, etc.)");
210 bool, GetUseBestVisual() const,
211 "Get current UseBestVisual setting.");
214 // set/get printing mode: see wxPRINT_XXX constants.
216 // default behaviour is the normal one for Unix: always use PostScript
218 virtual void SetPrintMode(int mode);
219 int GetPrintMode() const;
223 void, SetAssertMode(int mode),
224 "Set the OnAssert behaviour for debug and hybrid builds. The following flags\n"
225 "may be or'd together:\n"
227 " wx.PYAPP_ASSERT_SUPPRESS Don't do anything\n"
228 " wx.PYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible (default)\n"
229 " wx.PYAPP_ASSERT_DIALOG Display a message dialog\n"
230 " wx.PYAPP_ASSERT_LOG Write the assertion info to the wx.Log\n");
233 int, GetAssertMode(),
234 "Get the current OnAssert behaviour setting.");
237 static bool GetMacSupportPCMenuShortcuts();
238 static long GetMacAboutMenuItemId();
239 static long GetMacPreferencesMenuItemId();
240 static long GetMacExitMenuItemId();
241 static wxString GetMacHelpMenuTitleName();
243 static void SetMacSupportPCMenuShortcuts(bool val);
244 static void SetMacAboutMenuItemId(long val);
245 static void SetMacPreferencesMenuItemId(long val);
246 static void SetMacExitMenuItemId(long val);
247 static void SetMacHelpMenuTitleName(const wxString& val);
251 void, _BootstrapApp(),
252 "For internal use only");
254 DocStr(GetComCtl32Version,
255 "Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or
256 0 if it wasn't found at all. Raises an exception on non-Windows
259 static int GetComCtl32Version();
262 static int GetComCtl32Version()
263 { wxPyRaiseNotImplemented(); return 0; }
270 //---------------------------------------------------------------------------
276 "Force an exit of the application. Convenience for wx.GetApp().Exit()");
281 "Yield to other apps/messages. Convenience for wx.GetApp().Yield()");
284 bool, wxYieldIfNeeded(),
285 "Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)");
289 bool, wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=False),
290 "This function is similar to wx.Yield, except that it disables the user input\n"
291 "to all program windows before calling wx.Yield and re-enables it again\n"
292 "afterwards. If win is not None, this window will remain enabled, allowing the\n"
293 "implementation of some limited user interaction.\n"
295 "Returns the result of the call to wx.Yield.");
299 void, wxWakeUpIdle(),
300 "Cause the message queue to become empty again, so idle events will be sent.");
304 void, wxPostEvent(wxEvtHandler *dest, wxEvent& event),
305 "Send an event to a window or other wx.EvtHandler to be processed later.");
308 DocStr(wxApp_CleanUp,
309 "For internal use only, it is used to cleanup after wxWindows when Python shuts down.");
311 void wxApp_CleanUp() {
318 "Return a reference to the current wx.App object.");
320 wxPyApp* wxGetApp() {
321 return (wxPyApp*)wxTheApp;
326 //---------------------------------------------------------------------------
327 // Include some extra wxApp related python code here
329 %pythoncode "_app_ex.py"
331 //---------------------------------------------------------------------------