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)";
53 wxPythonApp = new wxPyApp();
60 void _setCallbackInfo(PyObject* self, PyObject* _class);
62 // set/get the application name
63 wxString GetAppName() const;
64 void SetAppName(const wxString& name);
66 // set/get the app class name
67 wxString GetClassName() const;
68 void SetClassName(const wxString& name);
70 // set/get the vendor name
71 const wxString& GetVendorName() const;
72 void SetVendorName(const wxString& name);
74 // create the app traits object to which we delegate for everything which
75 // either should be configurable by the user (then he can change the
76 // default behaviour simply by overriding CreateTraits() and returning his
77 // own traits object) or which is GUI/console dependent as then wxAppTraits
78 // allows us to abstract the differences behind the common façade
79 wxAppTraits *GetTraits();
81 // process all events in the wxPendingEvents list -- it is necessary to
82 // call this function to process posted events. This happens during each
83 // event loop iteration.
84 virtual void ProcessPendingEvents();
86 // process all currently pending events right now
88 // it is an error to call Yield() recursively unless the value of
89 // onlyIfNeeded is True
91 // WARNING: this function is dangerous as it can lead to unexpected
92 // reentrancies (i.e. when called from an event handler it
93 // may result in calling the same event handler again), use
94 // with _extreme_ care or, better, don't use at all!
95 virtual bool Yield(bool onlyIfNeeded = False);
97 // make sure that idle events are sent again
98 virtual void WakeUpIdle();
101 // execute the main GUI loop, the function returns when the loop ends
102 virtual int MainLoop();
104 // exit the main loop thus terminating the application
107 // exit the main GUI loop during the next iteration (i.e. it does not
108 // stop the program immediately!)
109 virtual void ExitMainLoop();
111 // returns True if there are unprocessed events in the event queue
112 virtual bool Pending();
114 // process the first event in the event queue (blocks until an event
115 // apperas if there are none currently)
116 virtual bool Dispatch();
119 // this virtual function is called in the GUI mode when the application
120 // becomes idle and normally just sends wxIdleEvent to all interested
123 // it should return True if more idle events are needed, False if not
124 virtual bool ProcessIdle() ;
126 // Send idle event to window and all subwindows
127 // Returns True if more idle time is requested.
128 virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
130 // Perform standard OnIdle behaviour: call from port's OnIdle
131 void OnIdle(wxIdleEvent& event);
134 // return True if our app has focus
135 virtual bool IsActive() const;
137 // set the "main" top level window
138 void SetTopWindow(wxWindow *win);
140 // return the "main" top level window (if it hadn't been set previously
141 // with SetTopWindow(), will return just some top level window and, if
142 // there are none, will return NULL)
143 virtual wxWindow *GetTopWindow() const;
145 // control the exit behaviour: by default, the program will exit the
146 // main loop (and so, usually, terminate) when the last top-level
147 // program window is deleted. Beware that if you disable this behaviour
148 // (with SetExitOnFrameDelete(False)), you'll have to call
149 // ExitMainLoop() explicitly from somewhere.
150 void SetExitOnFrameDelete(bool flag);
151 bool GetExitOnFrameDelete() const;
154 // Get display mode that is used use. This is only used in framebuffer
155 // wxWin ports (such as wxMGL).
156 virtual wxVideoMode GetDisplayMode() const;
158 // Set display mode to use. This is only used in framebuffer wxWin
159 // ports (such as wxMGL). This method should be called from
161 virtual bool SetDisplayMode(const wxVideoMode& info);
164 // set use of best visual flag (see below)
165 void SetUseBestVisual( bool flag );
166 bool GetUseBestVisual() const;
168 // set/get printing mode: see wxPRINT_XXX constants.
170 // default behaviour is the normal one for Unix: always use PostScript
172 virtual void SetPrintMode(int mode);
173 int GetPrintMode() const;
175 // Get/Set OnAssert behaviour. The following flags may be or'd together:
177 // wxPYAPP_ASSERT_SUPPRESS Don't do anything
178 // wxPYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible
179 // wxPYAPP_ASSERT_DIALOG Display a message dialog
180 // wxPYAPP_ASSERT_LOG Write the assertion info to the wxLog
182 void SetAssertMode(int mode);
185 static bool GetMacSupportPCMenuShortcuts();
186 static long GetMacAboutMenuItemId();
187 static long GetMacPreferencesMenuItemId();
188 static long GetMacExitMenuItemId();
189 static wxString GetMacHelpMenuTitleName();
191 static void SetMacSupportPCMenuShortcuts(bool val);
192 static void SetMacAboutMenuItemId(long val);
193 static void SetMacPreferencesMenuItemId(long val);
194 static void SetMacExitMenuItemId(long val);
195 static void SetMacHelpMenuTitleName(const wxString& val);
197 // For internal use only
198 void _BootstrapApp();
201 // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
202 // wasn't found at all
203 static int GetComCtl32Version();
206 static int GetComCtl32Version()
207 { PyErr_SetNone(PyExc_NotImplementedError); return 0; }
214 //---------------------------------------------------------------------------
217 // Force an exit from main loop
220 // Yield to other apps/messages
222 bool wxYieldIfNeeded();
223 bool wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=False);
225 // Cause the message queue to become empty again
228 // Send an event to be processed later
229 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
231 // This is used to cleanup after wxWindows when Python shuts down.
233 void wxApp_CleanUp() {
238 // Return a reference to the current wxApp object.
240 wxPyApp* wxGetApp() {
241 return (wxPyApp*)wxTheApp;
246 //---------------------------------------------------------------------------
247 // Include some extra wxApp related python code here
249 %pythoncode "_app_ex.py"
251 //---------------------------------------------------------------------------