]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_functions.i
Include wx/containr.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / wxPython / src / _functions.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _functions.i
3 // Purpose: SWIG interface defs for various functions and such
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 3-July-1997
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 #include <wx/stockitem.h>
18 %}
19
20 //---------------------------------------------------------------------------
21
22 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
23 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
24 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
25
26 //---------------------------------------------------------------------------
27 %newgroup;
28
29
30 long wxNewId();
31 void wxRegisterId(long id);
32 long wxGetCurrentId();
33
34 // Returns true if the ID is in the list of recognized stock actions
35 bool wxIsStockID(wxWindowID id);
36
37 // Returns true of the label is empty or label of a stock button with
38 // given ID
39 bool wxIsStockLabel(wxWindowID id, const wxString& label);
40
41 // Returns label that should be used for given stock UI element (e.g. "&OK"
42 // for wxID_OK):
43 wxString wxGetStockLabel(wxWindowID id,
44 bool withCodes = true,
45 wxString accelerator = wxPyEmptyString);
46
47
48 MustHaveApp(wxBell);
49 void wxBell();
50
51 MustHaveApp(wxEndBusyCursor);
52 void wxEndBusyCursor();
53
54 long wxGetElapsedTime(bool resetTimer = true);
55 %pythoncode { GetElapsedTime = wx._deprecated(GetElapsedTime) }
56
57 bool wxIsBusy();
58 wxString wxNow();
59 bool wxShell(const wxString& command = wxPyEmptyString);
60 void wxStartTimer();
61
62 DocDeclA(
63 int, wxGetOsVersion(int *OUTPUT, int *OUTPUT),
64 "GetOsVersion() -> (platform, major, minor)");
65
66 wxString wxGetOsDescription();
67
68 // TODO:
69 // // Parses the wildCard, returning the number of filters.
70 // // Returns 0 if none or if there's a problem,
71 // // The arrays will contain an equal number of items found before the error.
72 // // wildCard is in the form:
73 // // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
74 // int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters);
75
76 #if defined(__WXMSW__) || defined(__WXMAC__)
77 wxMemorySize wxGetFreeMemory();
78 #else
79 %inline %{
80 wxMemorySize wxGetFreeMemory()
81 { wxPyRaiseNotImplemented(); return 0; }
82 %}
83 #endif
84
85 enum wxShutdownFlags
86 {
87 wxSHUTDOWN_POWEROFF, // power off the computer
88 wxSHUTDOWN_REBOOT // shutdown and reboot
89 };
90
91 // Shutdown or reboot the PC
92 MustHaveApp(wxShutdown);
93 bool wxShutdown(wxShutdownFlags wFlags);
94
95
96 void wxSleep(int secs);
97 void wxMilliSleep(unsigned long milliseconds);
98 void wxMicroSleep(unsigned long microseconds);
99 %pythoncode { Usleep = MilliSleep }
100
101 void wxEnableTopLevelWindows(bool enable);
102
103 wxString wxStripMenuCodes(const wxString& in);
104
105
106 wxString wxGetEmailAddress();
107 wxString wxGetHostName();
108 wxString wxGetFullHostName();
109 wxString wxGetUserId();
110 wxString wxGetUserName();
111 wxString wxGetHomeDir();
112 wxString wxGetUserHome(const wxString& user = wxPyEmptyString);
113
114 unsigned long wxGetProcessId();
115
116 void wxTrap();
117
118
119 // Dialog Functions
120
121 MustHaveApp(wxFileSelector);
122 wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr,
123 const wxString& default_path = wxPyEmptyString,
124 const wxString& default_filename = wxPyEmptyString,
125 const wxString& default_extension = wxPyEmptyString,
126 const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr,
127 int flags = 0,
128 wxWindow *parent = NULL,
129 int x = -1, int y = -1);
130
131 // TODO: wxFileSelectorEx
132
133
134 // Ask for filename to load
135 MustHaveApp(wxLoadFileSelector);
136 wxString wxLoadFileSelector(const wxString& what,
137 const wxString& extension,
138 const wxString& default_name = wxPyEmptyString,
139 wxWindow *parent = NULL);
140
141 // Ask for filename to save
142 MustHaveApp(wxSaveFileSelector);
143 wxString wxSaveFileSelector(const wxString& what,
144 const wxString& extension,
145 const wxString& default_name = wxPyEmptyString,
146 wxWindow *parent = NULL);
147
148
149 MustHaveApp(wxDirSelector);
150 wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr,
151 const wxString& defaultPath = wxPyEmptyString,
152 long style = wxDD_DEFAULT_STYLE,
153 const wxPoint& pos = wxDefaultPosition,
154 wxWindow *parent = NULL);
155
156 MustHaveApp(wxGetTextFromUser);
157 wxString wxGetTextFromUser(const wxString& message,
158 const wxString& caption = wxPyEmptyString,
159 const wxString& default_value = wxPyEmptyString,
160 wxWindow *parent = NULL,
161 int x = -1, int y = -1,
162 bool centre = true);
163
164 MustHaveApp(wxGetPasswordFromUser);
165 wxString wxGetPasswordFromUser(const wxString& message,
166 const wxString& caption = wxPyEmptyString,
167 const wxString& default_value = wxPyEmptyString,
168 wxWindow *parent = NULL);
169
170
171 // TODO: Need to custom wrap this one...
172 // int wxGetMultipleChoice(char* message, char* caption,
173 // int LCOUNT, char** choices,
174 // int nsel, int *selection,
175 // wxWindow *parent = NULL, int x = -1, int y = -1,
176 // bool centre = true, int width=150, int height=200);
177
178
179 MustHaveApp(wxGetSingleChoice);
180 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
181 int choices, wxString* choices_array,
182 wxWindow *parent = NULL,
183 int x = -1, int y = -1,
184 bool centre = true,
185 int width=150, int height=200);
186
187 MustHaveApp(wxGetSingleChoiceIndex);
188 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
189 int choices, wxString* choices_array,
190 wxWindow *parent = NULL,
191 int x = -1, int y = -1,
192 bool centre = true,
193 int width=150, int height=200);
194
195
196 MustHaveApp(wxMessageBox);
197 int wxMessageBox(const wxString& message,
198 const wxString& caption = wxPyEmptyString,
199 int style = wxOK | wxCENTRE,
200 wxWindow *parent = NULL,
201 int x = -1, int y = -1);
202
203 // WXWIN_COMPATIBILITY_2_4
204 #if 0
205 MustHaveApp(wxGetNumberFromUser);
206 long wxGetNumberFromUser(const wxString& message,
207 const wxString& prompt,
208 const wxString& caption,
209 long value,
210 long min = 0, long max = 100,
211 wxWindow *parent = NULL,
212 const wxPoint& pos = wxDefaultPosition);
213 %pythoncode { GetNumberFromUser = wx._deprecated(GetNumberFromUser) }
214 #endif
215
216 // GDI Functions
217
218 MustHaveApp(wxColourDisplay);
219 bool wxColourDisplay();
220
221 MustHaveApp(wxDisplayDepth);
222 int wxDisplayDepth();
223
224 MustHaveApp(wxGetDisplayDepth);
225 int wxGetDisplayDepth();
226
227 MustHaveApp(wxDisplaySize);
228 DocDeclA(
229 void, wxDisplaySize(int* OUTPUT, int* OUTPUT),
230 "DisplaySize() -> (width, height)");
231
232 MustHaveApp(wxGetDisplaySize);
233 wxSize wxGetDisplaySize();
234
235 MustHaveApp(wxDisplaySizeMM);
236 DocDeclA(
237 void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT),
238 "DisplaySizeMM() -> (width, height)");
239
240 MustHaveApp(wxGetDisplaySizeMM);
241 wxSize wxGetDisplaySizeMM();
242
243 MustHaveApp(wxClientDisplayRect);
244 DocDeclA(
245 void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
246 "ClientDisplayRect() -> (x, y, width, height)");
247
248 MustHaveApp(wxGetClientDisplayRect);
249 wxRect wxGetClientDisplayRect();
250
251
252 MustHaveApp(wxSetCursor);
253 void wxSetCursor(wxCursor& cursor);
254
255
256 MustHaveApp(wxGetXDisplay);
257 DocStr(wxGetXDisplay,
258 "Returns a swigified pointer to the X11 display. Returns None on
259 other platforms.", "");
260 %inline %{
261 void* wxGetXDisplay()
262 {
263 #ifdef __WXGTK__
264 return wxGetDisplay();
265 #else
266 return NULL;
267 #endif
268 }
269 %}
270
271
272 // Miscellaneous functions
273
274 MustHaveApp(wxBeginBusyCursor);
275 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
276
277
278 MustHaveApp(wxGetMousePosition);
279 DocDeclStr(
280 wxPoint, wxGetMousePosition(),
281 "Get the current mouse position on the screen.", "");
282
283 MustHaveApp(FindWindowAtPointer);
284 DocStr(FindWindowAtPointer,
285 "Returns the window currently under the mouse pointer, if it belongs to
286 this application. Otherwise it returns None.", "");
287 %inline %{
288 wxWindow* FindWindowAtPointer() {
289 wxPoint unused;
290 return wxFindWindowAtPointer(unused);
291 }
292 %}
293
294
295 MustHaveApp(wxGetActiveWindow);
296 DocDeclStr(
297 wxWindow *, wxGetActiveWindow(),
298 "Get the currently active window of this application, or None", "");
299
300
301 MustHaveApp(wxGenericFindWindowAtPoint);
302 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
303
304 MustHaveApp(wxFindWindowAtPoint);
305 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
306
307 MustHaveApp(wxGetTopLevelParent);
308 wxWindow* wxGetTopLevelParent(wxWindow *win);
309
310
311 DocDeclStr(
312 bool , wxLaunchDefaultBrowser(const wxString& url),
313 "Launches the user's default browser and tells it to open the location
314 at ``url``. Returns ``True`` if the application was successfully
315 launched.", "");
316
317
318
319 MustHaveApp(wxGetKeyState);
320 DocDeclStr(
321 bool , wxGetKeyState(wxKeyCode key),
322 "Get the state of a key (true if pressed or toggled on, false if not.)
323 This is generally most useful getting the state of the modifier or
324 toggle keys. On some platforms those may be the only keys that this
325 function is able to detect.
326 ", "");
327
328
329
330 //---------------------------------------------------------------------------
331
332 DocStr(wxMouseState,
333 "`wx.MouseState` is used to hold information about mouse button and
334 modifier key states and is what is returned from `wx.GetMouseState`.",
335 "");
336
337 class wxMouseState
338 {
339 public:
340 wxMouseState();
341 ~wxMouseState();
342
343 wxCoord GetX();
344 wxCoord GetY();
345
346 bool LeftDown();
347 bool MiddleDown();
348 bool RightDown();
349
350 bool ControlDown();
351 bool ShiftDown();
352 bool AltDown();
353 bool MetaDown();
354 bool CmdDown();
355
356 void SetX(wxCoord x);
357 void SetY(wxCoord y);
358
359 void SetLeftDown(bool down);
360 void SetMiddleDown(bool down);
361 void SetRightDown(bool down);
362
363 void SetControlDown(bool down);
364 void SetShiftDown(bool down);
365 void SetAltDown(bool down);
366 void SetMetaDown(bool down);
367
368 %pythoncode {
369 x = property(GetX, SetX)
370 y = property(GetY, SetY)
371 leftDown = property(LeftDown, SetLeftDown)
372 middleDown = property(MiddleDown, SetMiddleDown)
373 rightDown = property(RightDown, SetRightDown)
374 controlDown = property(ControlDown, SetControlDown)
375 shiftDown = property(ShiftDown, SetShiftDown)
376 altDown = property(AltDown, SetAltDown)
377 metaDown = property(MetaDown, SetMetaDown)
378 cmdDown = property(CmdDown)
379 }
380 };
381
382
383 DocDeclStr(
384 wxMouseState , wxGetMouseState(),
385 "Returns the current state of the mouse. Returns an instance of a
386 `wx.MouseState` object that contains the current position of the mouse
387 pointer in screen coordinants, as well as boolean values indicating
388 the up/down status of the mouse buttons and the modifier keys.", "");
389
390
391 //---------------------------------------------------------------------------
392
393 MustHaveApp(wxWakeUpMainThread);
394
395 #if defined(__WXMSW__) || defined(__WXMAC__)
396 void wxWakeUpMainThread();
397 #else
398 %inline %{
399 void wxWakeUpMainThread() {}
400 %}
401 #endif
402
403
404 MustHaveApp(wxMutexGuiEnter);
405 void wxMutexGuiEnter();
406
407 MustHaveApp(wxMutexGuiLeave);
408 void wxMutexGuiLeave();
409
410
411 MustHaveApp(wxMutexGuiLocker);
412 class wxMutexGuiLocker {
413 public:
414 wxMutexGuiLocker();
415 ~wxMutexGuiLocker();
416 };
417
418
419 MustHaveApp(wxThread);
420 %inline %{
421 bool wxThread_IsMain() {
422 #ifdef WXP_WITH_THREAD
423 return wxThread::IsMain();
424 #else
425 return true;
426 #endif
427 }
428 %}
429
430 //---------------------------------------------------------------------------
431 //---------------------------------------------------------------------------