X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..c437fde9f90fc7dfcac79053d214fc9146d7be21:/wxPython/src/_app.i diff --git a/wxPython/src/_app.i b/wxPython/src/_app.i index 957afd9835..5628f0242b 100644 --- a/wxPython/src/_app.i +++ b/wxPython/src/_app.i @@ -40,14 +40,20 @@ enum +DocStr(wxPyApp, +"The ``wx.PyApp`` class is an *implementation detail*, please use the +`wx.App` class (or some other derived class) instead.", ""); class wxPyApp : public wxEvtHandler { public: - %addtofunc wxPyApp + %pythonAppend wxPyApp "self._setCallbackInfo(self, PyApp) self._setOORInfo(self)"; + %typemap(out) wxPyApp*; // turn off this typemap + DocStr(wxPyApp, + "Create a new application object, starting the bootstrap process.", ""); %extend { wxPyApp() { wxPythonApp = new wxPyApp(); @@ -57,101 +63,157 @@ public: ~wxPyApp(); - void _setCallbackInfo(PyObject* self, PyObject* _class); - - // set/get the application name - wxString GetAppName() const; - void SetAppName(const wxString& name); + // Turn it back on again + %typemap(out) wxPyApp* { $result = wxPyMake_wxObject($1, $owner); } - // set/get the app class name - wxString GetClassName() const; - void SetClassName(const wxString& name); - // set/get the vendor name - const wxString& GetVendorName() const; - void SetVendorName(const wxString& name); + void _setCallbackInfo(PyObject* self, PyObject* _class); - // create the app traits object to which we delegate for everything which - // either should be configurable by the user (then he can change the - // default behaviour simply by overriding CreateTraits() and returning his - // own traits object) or which is GUI/console dependent as then wxAppTraits - // allows us to abstract the differences behind the common façade - wxAppTraits *GetTraits(); - // process all events in the wxPendingEvents list -- it is necessary to - // call this function to process posted events. This happens during each - // event loop iteration. - virtual void ProcessPendingEvents(); + DocDeclStr( + wxString, GetAppName() const, + "Get the application name.", ""); + DocDeclStr( + void, SetAppName(const wxString& name), + "Set the application name. This value may be used automatically by +`wx.Config` and such.", ""); + + DocDeclStr( + wxString, GetClassName() const, + "Get the application's class name.", ""); + DocDeclStr( + void, SetClassName(const wxString& name), + "Set the application's class name. This value may be used for +X-resources if applicable for the platform", ""); + + DocDeclStr( + const wxString&, GetVendorName() const, + "Get the application's vendor name.", ""); + DocDeclStr( + void, SetVendorName(const wxString& name), + "Set the application's vendor name. This value may be used +automatically by `wx.Config` and such.", ""); + + + DocDeclStr( + wxAppTraits*, GetTraits(), + "Return (and create if necessary) the app traits object to which we +delegate for everything which either should be configurable by the +user (then he can change the default behaviour simply by overriding +CreateTraits() and returning his own traits object) or which is +GUI/console dependent as then wx.AppTraits allows us to abstract the +differences behind the common facade. + +:todo: Add support for overriding CreateAppTraits in wxPython.", ""); + + + DocDeclStr( + virtual void, ProcessPendingEvents(), + "Process all events in the Pending Events list -- it is necessary to +call this function to process posted events. This normally happens +during each event loop iteration.", ""); + + + DocDeclStr( + virtual bool, Yield(bool onlyIfNeeded = false), + "Process all currently pending events right now, instead of waiting +until return to the event loop. It is an error to call ``Yield`` +recursively unless the value of ``onlyIfNeeded`` is True. + +:warning: This function is dangerous as it can lead to unexpected + reentrancies (i.e. when called from an event handler it may + result in calling the same event handler again), use with + extreme care or, better, don't use at all! + +:see: `wx.Yield`, `wx.YieldIfNeeded`, `wx.SafeYield` +", ""); - // process all currently pending events right now - // - // it is an error to call Yield() recursively unless the value of - // onlyIfNeeded is TRUE - // - // WARNING: this function is dangerous as it can lead to unexpected - // reentrancies (i.e. when called from an event handler it - // may result in calling the same event handler again), use - // with _extreme_ care or, better, don't use at all! - virtual bool Yield(bool onlyIfNeeded = false); + + DocDeclStr( + virtual void, WakeUpIdle(), + "Make sure that idle events are sent again. +:see: `wx.WakeUpIdle`", ""); - // make sure that idle events are sent again - virtual void WakeUpIdle(); + + DocDeclStr( + static bool , IsMainLoopRunning() const, + "Returns True if we're running the main loop, i.e. if the events can +currently be dispatched.", ""); + + DocDeclStr( + virtual int, MainLoop(), + "Execute the main GUI loop, the function doesn't normally return until +all top level windows have been closed and destroyed.", ""); - // execute the main GUI loop, the function returns when the loop ends - virtual int MainLoop(); + + DocDeclStr( + virtual void, Exit(), + "Exit the main loop thus terminating the application. +:see: `wx.Exit`", ""); - // exit the main loop thus terminating the application - virtual void Exit(); + + DocDeclStr( + virtual void, ExitMainLoop(), + "Exit the main GUI loop during the next iteration of the main +loop, (i.e. it does not stop the program immediately!)", ""); - // exit the main GUI loop during the next iteration (i.e. it does not - // stop the program immediately!) - virtual void ExitMainLoop(); + + DocDeclStr( + virtual bool, Pending(), + "Returns True if there are unprocessed events in the event queue.", ""); - // returns TRUE if there are unprocessed events in the event queue - virtual bool Pending(); + + DocDeclStr( + virtual bool, Dispatch(), + "Process the first event in the event queue (blocks until an event +appears if there are none currently)", ""); - // process the first event in the event queue (blocks until an event - // apperas if there are none currently) - virtual bool Dispatch(); + DocDeclStr( + virtual bool, ProcessIdle(), + "Called from the MainLoop when the application becomes idle (there are +no pending events) and sends a `wx.IdleEvent` to all interested +parties. Returns True if more idle events are needed, False if not.", ""); - // this virtual function is called in the GUI mode when the application - // becomes idle and normally just sends wxIdleEvent to all interested - // parties - // - // it should return TRUE if more idle events are needed, FALSE if not - virtual bool ProcessIdle() ; + + DocDeclStr( + virtual bool, SendIdleEvents(wxWindow* win, wxIdleEvent& event), + "Send idle event to window and all subwindows. Returns True if more +idle time is requested.", ""); - // Send idle event to window and all subwindows - // Returns TRUE if more idle time is requested. - virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event); - // Perform standard OnIdle behaviour: call from port's OnIdle - void OnIdle(wxIdleEvent& event); + DocDeclStr( + virtual bool, IsActive() const, + "Return True if our app has focus.", ""); + + DocDeclStr( + void, SetTopWindow(wxWindow *win), + "Set the *main* top level window", ""); - // return TRUE if our app has focus - virtual bool IsActive() const; + DocDeclStr( + virtual wxWindow*, GetTopWindow() const, + "Return the *main* top level window (if it hadn't been set previously +with SetTopWindow(), will return just some top level window and, if +there not any, will return None)", ""); - // set the "main" top level window - void SetTopWindow(wxWindow *win); - // return the "main" top level window (if it hadn't been set previously - // with SetTopWindow(), will return just some top level window and, if - // there are none, will return NULL) - virtual wxWindow *GetTopWindow() const; + DocDeclStr( + void, SetExitOnFrameDelete(bool flag), + "Control the exit behaviour: by default, the program will exit the main +loop (and so, usually, terminate) when the last top-level program +window is deleted. Beware that if you disable this behaviour (with +SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop() +explicitly from somewhere.", ""); - // control the exit behaviour: by default, the program will exit the - // main loop (and so, usually, terminate) when the last top-level - // program window is deleted. Beware that if you disable this behaviour - // (with SetExitOnFrameDelete(FALSE)), you'll have to call - // ExitMainLoop() explicitly from somewhere. - void SetExitOnFrameDelete(bool flag); - bool GetExitOnFrameDelete() const; + + DocDeclStr( + bool, GetExitOnFrameDelete() const, + "Get the current exit behaviour setting.", ""); #if 0 - // Get display mode that is used use. This is only used in framebuffer + // Get display mode that is in use. This is only used in framebuffer // wxWin ports (such as wxMGL). virtual wxVideoMode GetDisplayMode() const; @@ -161,9 +223,16 @@ public: virtual bool SetDisplayMode(const wxVideoMode& info); #endif - // set use of best visual flag (see below) - void SetUseBestVisual( bool flag ); - bool GetUseBestVisual() const; + + DocDeclStr( + void, SetUseBestVisual( bool flag ), + "Set whether the app should try to use the best available visual on +systems where more than one is available, (Sun, SGI, XFree86 4, etc.)", ""); + + DocDeclStr( + bool, GetUseBestVisual() const, + "Get current UseBestVisual setting.", ""); + // set/get printing mode: see wxPRINT_XXX constants. // @@ -172,14 +241,25 @@ public: virtual void SetPrintMode(int mode); int GetPrintMode() const; - // Get/Set OnAssert behaviour. The following flags may be or'd together: - // - // wxPYAPP_ASSERT_SUPPRESS Don't do anything - // wxPYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible - // wxPYAPP_ASSERT_DIALOG Display a message dialog - // wxPYAPP_ASSERT_LOG Write the assertion info to the wxLog - int GetAssertMode(); - void SetAssertMode(int mode); + + DocDeclStr( + void, SetAssertMode(int mode), + "Set the OnAssert behaviour for debug and hybrid builds.", + "The following flags may be or'd together: + + ========================= ======================================= + wx.PYAPP_ASSERT_SUPPRESS Don't do anything + wx.PYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible + (default) + wx.PYAPP_ASSERT_DIALOG Display a message dialog + wx.PYAPP_ASSERT_LOG Write the assertion info to the wx.Log + ========================= ======================================= + +"); + + DocDeclStr( + int, GetAssertMode(), + "Get the current OnAssert behaviour setting.", ""); static bool GetMacSupportPCMenuShortcuts(); @@ -194,17 +274,20 @@ public: static void SetMacExitMenuItemId(long val); static void SetMacHelpMenuTitleName(const wxString& val); - // For internal use only - void _BootstrapApp(); + DocDeclStr( + void, _BootstrapApp(), + "For internal use only", ""); + + DocStr(GetComCtl32Version, + "Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or 0 if +it wasn't found at all. Raises an exception on non-Windows platforms.", ""); #ifdef __WXMSW__ - // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it - // wasn't found at all static int GetComCtl32Version(); #else %extend { static int GetComCtl32Version() - { PyErr_SetNone(PyExc_NotImplementedError); return 0; } + { wxPyRaiseNotImplemented(); return 0; } } #endif }; @@ -214,35 +297,85 @@ public: //--------------------------------------------------------------------------- %newgroup; -// Force an exit from main loop -void wxExit(); -// Yield to other apps/messages -bool wxYield(); -bool wxYieldIfNeeded(); -bool wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=FALSE); +DocDeclStr( + void, wxExit(), + "Force an exit of the application. Convenience for wx.GetApp().Exit()", ""); + + +DocDeclStr( + bool, wxYield(), + "Yield to other apps/messages. Convenience for wx.GetApp().Yield()", ""); + +DocDeclStr( + bool, wxYieldIfNeeded(), + "Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)", ""); + + +DocDeclStr( + bool, wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=false), + "This function is similar to `wx.Yield`, except that it disables the +user input to all program windows before calling `wx.Yield` and +re-enables it again afterwards. If ``win`` is not None, this window +will remain enabled, allowing the implementation of some limited user +interaction. + +:Returns: the result of the call to `wx.Yield`.", ""); + + +DocDeclStr( + void, wxWakeUpIdle(), + "Cause the message queue to become empty again, so idle events will be +sent.", ""); + -// Cause the message queue to become empty again -void wxWakeUpIdle(); +DocDeclStr( + void, wxPostEvent(wxEvtHandler *dest, wxEvent& event), + "Send an event to a window or other wx.EvtHandler to be processed +later.", ""); -// Send an event to be processed later -void wxPostEvent(wxEvtHandler *dest, wxEvent& event); -// This is used to cleanup after wxWindows when Python shuts down. +DocStr(wxApp_CleanUp, + "For internal use only, it is used to cleanup after wxWidgets when +Python shuts down.", ""); %inline %{ void wxApp_CleanUp() { __wxPyCleanup(); } %} -// Return a reference to the current wxApp object. -%inline %{ - wxPyApp* wxGetApp() { - return (wxPyApp*)wxTheApp; - } + +DocDeclStrName( + wxPyApp* , wxPyGetApp(), + "Return a reference to the current wx.App object.", "", + GetApp); +%{ + wxPyApp* wxPyGetApp() { return (wxPyApp*)wxTheApp; } %} + + + +DocDeclAStr( + void , wxSetDefaultPyEncoding(const char* encoding), + "SetDefaultPyEncoding(string encoding)", + "Sets the encoding that wxPython will use when it needs to convert a +Python string or unicode object to or from a wxString. + +The default encoding is the value of ``locale.getdefaultlocale()[1]`` +but please be aware that the default encoding within the same locale +may be slightly different on different platforms. For example, please +see http://www.alanwood.net/demos/charsetdiffs.html for differences +between the common latin/roman encodings.", ""); + +DocDeclAStr( + const char* , wxGetDefaultPyEncoding(), + "GetDefaultPyEncoding() -> string", + "Gets the current encoding that wxPython will use when it needs to +convert a Python string or unicode object to or from a wxString.", ""); + + //--------------------------------------------------------------------------- // Include some extra wxApp related python code here