]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_app.i
reSWIGged
[wxWidgets.git] / wxPython / src / _app.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _app.i
3 // Purpose: SWIG interface for wxApp
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 9-Aug-2003
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17 // TODOs:
18 //
19 // 1. Provide another app object that allows FilterEvent to be overloaded.
20 // 2. Wrap wxAppTraits and allow wxApp::CreateTraits to be overloaded.
21 //
22 //---------------------------------------------------------------------------
23 %newgroup;
24
25 %{
26 %}
27
28 enum {
29 wxPYAPP_ASSERT_SUPPRESS = 1,
30 wxPYAPP_ASSERT_EXCEPTION = 2,
31 wxPYAPP_ASSERT_DIALOG = 4,
32 wxPYAPP_ASSERT_LOG = 8
33 };
34
35 enum
36 {
37 wxPRINT_WINDOWS = 1,
38 wxPRINT_POSTSCRIPT = 2
39 };
40
41
42
43
44 class wxPyApp : public wxEvtHandler {
45 public:
46
47 %addtofunc wxPyApp
48 "self._setCallbackInfo(self, PyApp)
49 self._setOORInfo(self)";
50
51 %extend {
52 wxPyApp() {
53 wxPythonApp = new wxPyApp();
54 return wxPythonApp;
55 }
56 }
57
58 ~wxPyApp();
59
60 void _setCallbackInfo(PyObject* self, PyObject* _class);
61
62 // set/get the application name
63 wxString GetAppName() const;
64 void SetAppName(const wxString& name);
65
66 // set/get the app class name
67 wxString GetClassName() const;
68 void SetClassName(const wxString& name);
69
70 // set/get the vendor name
71 const wxString& GetVendorName() const;
72 void SetVendorName(const wxString& name);
73
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();
80
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();
85
86 // process all currently pending events right now
87 //
88 // it is an error to call Yield() recursively unless the value of
89 // onlyIfNeeded is True
90 //
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);
96
97 // make sure that idle events are sent again
98 virtual void WakeUpIdle();
99
100
101 // execute the main GUI loop, the function returns when the loop ends
102 virtual int MainLoop();
103
104 // exit the main loop thus terminating the application
105 virtual void Exit();
106
107 // exit the main GUI loop during the next iteration (i.e. it does not
108 // stop the program immediately!)
109 virtual void ExitMainLoop();
110
111 // returns True if there are unprocessed events in the event queue
112 virtual bool Pending();
113
114 // process the first event in the event queue (blocks until an event
115 // apperas if there are none currently)
116 virtual bool Dispatch();
117
118
119 // this virtual function is called in the GUI mode when the application
120 // becomes idle and normally just sends wxIdleEvent to all interested
121 // parties
122 //
123 // it should return True if more idle events are needed, False if not
124 virtual bool ProcessIdle() ;
125
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);
129
130 // Perform standard OnIdle behaviour: call from port's OnIdle
131 void OnIdle(wxIdleEvent& event);
132
133
134 // return True if our app has focus
135 virtual bool IsActive() const;
136
137 // set the "main" top level window
138 void SetTopWindow(wxWindow *win);
139
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;
144
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;
152
153 #if 0
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;
157
158 // Set display mode to use. This is only used in framebuffer wxWin
159 // ports (such as wxMGL). This method should be called from
160 // wxApp::OnInitGui
161 virtual bool SetDisplayMode(const wxVideoMode& info);
162 #endif
163
164 // set use of best visual flag (see below)
165 void SetUseBestVisual( bool flag );
166 bool GetUseBestVisual() const;
167
168 // set/get printing mode: see wxPRINT_XXX constants.
169 //
170 // default behaviour is the normal one for Unix: always use PostScript
171 // printing.
172 virtual void SetPrintMode(int mode);
173 int GetPrintMode() const;
174
175 // Get/Set OnAssert behaviour. The following flags may be or'd together:
176 //
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
181 int GetAssertMode();
182 void SetAssertMode(int mode);
183
184
185 static bool GetMacSupportPCMenuShortcuts();
186 static long GetMacAboutMenuItemId();
187 static long GetMacPreferencesMenuItemId();
188 static long GetMacExitMenuItemId();
189 static wxString GetMacHelpMenuTitleName();
190
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);
196
197 // For internal use only
198 void _BootstrapApp();
199
200 #ifdef __WXMSW__
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();
204 #else
205 %extend {
206 static int GetComCtl32Version()
207 { PyErr_SetNone(PyExc_NotImplementedError); return 0; }
208 }
209 #endif
210 };
211
212
213
214 //---------------------------------------------------------------------------
215 %newgroup;
216
217 // Force an exit from main loop
218 void wxExit();
219
220 // Yield to other apps/messages
221 bool wxYield();
222 bool wxYieldIfNeeded();
223 bool wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=False);
224
225 // Cause the message queue to become empty again
226 void wxWakeUpIdle();
227
228 // Send an event to be processed later
229 void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
230
231 // This is used to cleanup after wxWindows when Python shuts down.
232 %inline %{
233 void wxApp_CleanUp() {
234 __wxPyCleanup();
235 }
236 %}
237
238 // Return a reference to the current wxApp object.
239 %inline %{
240 wxPyApp* wxGetApp() {
241 return (wxPyApp*)wxTheApp;
242 }
243 %}
244
245
246 //---------------------------------------------------------------------------
247 // Include some extra wxApp related python code here
248
249 %pythoncode "_app_ex.py"
250
251 //---------------------------------------------------------------------------
252