]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
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 | ||
1e140719 RD |
16 | %{ |
17 | #include <wx/stockitem.h> | |
18 | %} | |
19 | ||
d14a1e28 RD |
20 | //--------------------------------------------------------------------------- |
21 | ||
b2dc1044 RD |
22 | MAKE_CONST_WXSTRING(FileSelectorPromptStr); |
23 | MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr); | |
24 | MAKE_CONST_WXSTRING(DirSelectorPromptStr); | |
d14a1e28 RD |
25 | |
26 | //--------------------------------------------------------------------------- | |
27 | %newgroup; | |
28 | ||
29 | ||
30 | long wxNewId(); | |
31 | void wxRegisterId(long id); | |
32 | long wxGetCurrentId(); | |
33 | ||
1e140719 RD |
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): | |
8815349a RD |
43 | wxString wxGetStockLabel(wxWindowID id, |
44 | bool withCodes = true, | |
45 | wxString accelerator = wxPyEmptyString); | |
1e140719 RD |
46 | |
47 | ||
ab1f7d2a | 48 | MustHaveApp(wxBell); |
d14a1e28 | 49 | void wxBell(); |
ab1f7d2a RD |
50 | |
51 | MustHaveApp(wxEndBusyCursor); | |
d14a1e28 RD |
52 | void wxEndBusyCursor(); |
53 | ||
a72f4631 | 54 | long wxGetElapsedTime(bool resetTimer = true); |
15648073 RD |
55 | %pythoncode { GetElapsedTime = wx._deprecated(GetElapsedTime) } |
56 | ||
d14a1e28 RD |
57 | bool wxIsBusy(); |
58 | wxString wxNow(); | |
59 | bool wxShell(const wxString& command = wxPyEmptyString); | |
60 | void wxStartTimer(); | |
322913ce | 61 | |
cbb4b39d RD |
62 | |
63 | ||
64 | enum | |
65 | { | |
66 | wxUNKNOWN_PLATFORM, | |
67 | wxCURSES, /* Text-only CURSES */ | |
68 | wxXVIEW_X, /* Sun's XView OpenLOOK toolkit */ | |
69 | wxMOTIF_X, /* OSF Motif 1.x.x */ | |
70 | wxCOSE_X, /* OSF Common Desktop Environment */ | |
71 | wxNEXTSTEP, /* NeXTStep */ | |
72 | wxMAC, /* Apple Mac OS 8/9/X with Mac paths */ | |
73 | wxMAC_DARWIN, /* Apple Mac OS X with Unix paths */ | |
74 | wxBEOS, /* BeOS */ | |
75 | wxGTK, /* GTK on X */ | |
76 | wxGTK_WIN32, /* GTK on Win32 */ | |
77 | wxGTK_OS2, /* GTK on OS/2 */ | |
78 | wxGTK_BEOS, /* GTK on BeOS */ | |
79 | wxGEOS, /* GEOS */ | |
80 | wxOS2_PM, /* OS/2 Workplace */ | |
81 | wxWINDOWS, /* Windows or WfW */ | |
82 | wxMICROWINDOWS, /* MicroWindows */ | |
83 | wxPENWINDOWS, /* Windows for Pen Computing */ | |
84 | wxWINDOWS_NT, /* Windows NT */ | |
85 | wxWIN32S, /* Windows 32S API */ | |
86 | wxWIN95, /* Windows 95 */ | |
87 | wxWIN386, /* Watcom 32-bit supervisor modus */ | |
88 | wxWINDOWS_CE, /* Windows CE (generic) */ | |
89 | wxWINDOWS_POCKETPC, /* Windows CE PocketPC */ | |
90 | wxWINDOWS_SMARTPHONE, /* Windows CE Smartphone */ | |
91 | wxMGL_UNIX, /* MGL with direct hardware access */ | |
92 | wxMGL_X, /* MGL on X */ | |
93 | wxMGL_WIN32, /* MGL on Win32 */ | |
94 | wxMGL_OS2, /* MGL on OS/2 */ | |
95 | wxMGL_DOS, /* MGL on MS-DOS */ | |
96 | wxWINDOWS_OS2, /* Native OS/2 PM */ | |
97 | wxUNIX, /* wxBase under Unix */ | |
98 | wxX11, /* Plain X11 and Universal widgets */ | |
99 | wxPALMOS, /* PalmOS */ | |
100 | wxDOS /* wxBase under MS-DOS */ | |
101 | }; | |
102 | ||
322913ce RD |
103 | DocDeclA( |
104 | int, wxGetOsVersion(int *OUTPUT, int *OUTPUT), | |
105 | "GetOsVersion() -> (platform, major, minor)"); | |
106 | ||
d14a1e28 RD |
107 | wxString wxGetOsDescription(); |
108 | ||
03d51a2d RD |
109 | // TODO: |
110 | // // Parses the wildCard, returning the number of filters. | |
111 | // // Returns 0 if none or if there's a problem, | |
112 | // // The arrays will contain an equal number of items found before the error. | |
113 | // // wildCard is in the form: | |
114 | // // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png" | |
daf32463 | 115 | // int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters); |
03d51a2d | 116 | |
941afb6b RD |
117 | |
118 | %typemap(out) wxMemorySize { | |
119 | %#if wxUSE_LONGLONG | |
120 | $result = PyLong_FromLongLong($1.GetValue()); | |
121 | %#else | |
122 | $result = PyInt_FromLong($1); | |
123 | %#endif | |
124 | } | |
125 | ||
d14a1e28 | 126 | #if defined(__WXMSW__) || defined(__WXMAC__) |
e88df737 | 127 | wxMemorySize wxGetFreeMemory(); |
d14a1e28 RD |
128 | #else |
129 | %inline %{ | |
e88df737 | 130 | wxMemorySize wxGetFreeMemory() |
81cfe5e1 | 131 | { wxPyRaiseNotImplemented(); return 0; } |
d14a1e28 RD |
132 | %} |
133 | #endif | |
134 | ||
135 | enum wxShutdownFlags | |
136 | { | |
137 | wxSHUTDOWN_POWEROFF, // power off the computer | |
138 | wxSHUTDOWN_REBOOT // shutdown and reboot | |
139 | }; | |
140 | ||
141 | // Shutdown or reboot the PC | |
ab1f7d2a | 142 | MustHaveApp(wxShutdown); |
d14a1e28 RD |
143 | bool wxShutdown(wxShutdownFlags wFlags); |
144 | ||
145 | ||
146 | void wxSleep(int secs); | |
705b61cc RD |
147 | void wxMilliSleep(unsigned long milliseconds); |
148 | void wxMicroSleep(unsigned long microseconds); | |
149 | %pythoncode { Usleep = MilliSleep } | |
150 | ||
d14a1e28 RD |
151 | void wxEnableTopLevelWindows(bool enable); |
152 | ||
153 | wxString wxStripMenuCodes(const wxString& in); | |
154 | ||
155 | ||
156 | wxString wxGetEmailAddress(); | |
157 | wxString wxGetHostName(); | |
158 | wxString wxGetFullHostName(); | |
159 | wxString wxGetUserId(); | |
160 | wxString wxGetUserName(); | |
161 | wxString wxGetHomeDir(); | |
162 | wxString wxGetUserHome(const wxString& user = wxPyEmptyString); | |
163 | ||
164 | unsigned long wxGetProcessId(); | |
165 | ||
166 | void wxTrap(); | |
167 | ||
168 | ||
169 | // Dialog Functions | |
170 | ||
ab1f7d2a | 171 | MustHaveApp(wxFileSelector); |
d14a1e28 RD |
172 | wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr, |
173 | const wxString& default_path = wxPyEmptyString, | |
174 | const wxString& default_filename = wxPyEmptyString, | |
175 | const wxString& default_extension = wxPyEmptyString, | |
176 | const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr, | |
177 | int flags = 0, | |
178 | wxWindow *parent = NULL, | |
179 | int x = -1, int y = -1); | |
180 | ||
181 | // TODO: wxFileSelectorEx | |
182 | ||
183 | ||
184 | // Ask for filename to load | |
ab1f7d2a | 185 | MustHaveApp(wxLoadFileSelector); |
d14a1e28 RD |
186 | wxString wxLoadFileSelector(const wxString& what, |
187 | const wxString& extension, | |
188 | const wxString& default_name = wxPyEmptyString, | |
189 | wxWindow *parent = NULL); | |
190 | ||
191 | // Ask for filename to save | |
ab1f7d2a | 192 | MustHaveApp(wxSaveFileSelector); |
d14a1e28 RD |
193 | wxString wxSaveFileSelector(const wxString& what, |
194 | const wxString& extension, | |
195 | const wxString& default_name = wxPyEmptyString, | |
196 | wxWindow *parent = NULL); | |
197 | ||
198 | ||
ab1f7d2a | 199 | MustHaveApp(wxDirSelector); |
d14a1e28 RD |
200 | wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr, |
201 | const wxString& defaultPath = wxPyEmptyString, | |
202 | long style = wxDD_DEFAULT_STYLE, | |
203 | const wxPoint& pos = wxDefaultPosition, | |
204 | wxWindow *parent = NULL); | |
205 | ||
ab1f7d2a | 206 | MustHaveApp(wxGetTextFromUser); |
d14a1e28 RD |
207 | wxString wxGetTextFromUser(const wxString& message, |
208 | const wxString& caption = wxPyEmptyString, | |
209 | const wxString& default_value = wxPyEmptyString, | |
210 | wxWindow *parent = NULL, | |
211 | int x = -1, int y = -1, | |
a72f4631 | 212 | bool centre = true); |
d14a1e28 | 213 | |
ab1f7d2a | 214 | MustHaveApp(wxGetPasswordFromUser); |
d14a1e28 RD |
215 | wxString wxGetPasswordFromUser(const wxString& message, |
216 | const wxString& caption = wxPyEmptyString, | |
217 | const wxString& default_value = wxPyEmptyString, | |
218 | wxWindow *parent = NULL); | |
219 | ||
220 | ||
221 | // TODO: Need to custom wrap this one... | |
222 | // int wxGetMultipleChoice(char* message, char* caption, | |
223 | // int LCOUNT, char** choices, | |
224 | // int nsel, int *selection, | |
225 | // wxWindow *parent = NULL, int x = -1, int y = -1, | |
a72f4631 | 226 | // bool centre = true, int width=150, int height=200); |
d14a1e28 RD |
227 | |
228 | ||
ab1f7d2a | 229 | MustHaveApp(wxGetSingleChoice); |
d14a1e28 RD |
230 | wxString wxGetSingleChoice(const wxString& message, const wxString& caption, |
231 | int choices, wxString* choices_array, | |
232 | wxWindow *parent = NULL, | |
233 | int x = -1, int y = -1, | |
a72f4631 | 234 | bool centre = true, |
d14a1e28 RD |
235 | int width=150, int height=200); |
236 | ||
ab1f7d2a | 237 | MustHaveApp(wxGetSingleChoiceIndex); |
d14a1e28 RD |
238 | int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, |
239 | int choices, wxString* choices_array, | |
240 | wxWindow *parent = NULL, | |
241 | int x = -1, int y = -1, | |
a72f4631 | 242 | bool centre = true, |
d14a1e28 RD |
243 | int width=150, int height=200); |
244 | ||
245 | ||
ab1f7d2a | 246 | MustHaveApp(wxMessageBox); |
d14a1e28 RD |
247 | int wxMessageBox(const wxString& message, |
248 | const wxString& caption = wxPyEmptyString, | |
249 | int style = wxOK | wxCENTRE, | |
250 | wxWindow *parent = NULL, | |
251 | int x = -1, int y = -1); | |
252 | ||
ab1f7d2a | 253 | MustHaveApp(wxGetNumberFromUser); |
d14a1e28 RD |
254 | long wxGetNumberFromUser(const wxString& message, |
255 | const wxString& prompt, | |
256 | const wxString& caption, | |
257 | long value, | |
258 | long min = 0, long max = 100, | |
259 | wxWindow *parent = NULL, | |
260 | const wxPoint& pos = wxDefaultPosition); | |
02b800ce | 261 | |
d14a1e28 RD |
262 | // GDI Functions |
263 | ||
ab1f7d2a | 264 | MustHaveApp(wxColourDisplay); |
d14a1e28 RD |
265 | bool wxColourDisplay(); |
266 | ||
ab1f7d2a | 267 | MustHaveApp(wxDisplayDepth); |
d14a1e28 | 268 | int wxDisplayDepth(); |
ab1f7d2a RD |
269 | |
270 | MustHaveApp(wxGetDisplayDepth); | |
d14a1e28 RD |
271 | int wxGetDisplayDepth(); |
272 | ||
ab1f7d2a | 273 | MustHaveApp(wxDisplaySize); |
322913ce RD |
274 | DocDeclA( |
275 | void, wxDisplaySize(int* OUTPUT, int* OUTPUT), | |
276 | "DisplaySize() -> (width, height)"); | |
ab1f7d2a RD |
277 | |
278 | MustHaveApp(wxGetDisplaySize); | |
d14a1e28 RD |
279 | wxSize wxGetDisplaySize(); |
280 | ||
ab1f7d2a | 281 | MustHaveApp(wxDisplaySizeMM); |
322913ce RD |
282 | DocDeclA( |
283 | void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT), | |
284 | "DisplaySizeMM() -> (width, height)"); | |
ab1f7d2a RD |
285 | |
286 | MustHaveApp(wxGetDisplaySizeMM); | |
d14a1e28 RD |
287 | wxSize wxGetDisplaySizeMM(); |
288 | ||
ab1f7d2a | 289 | MustHaveApp(wxClientDisplayRect); |
322913ce RD |
290 | DocDeclA( |
291 | void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT), | |
292 | "ClientDisplayRect() -> (x, y, width, height)"); | |
ab1f7d2a RD |
293 | |
294 | MustHaveApp(wxGetClientDisplayRect); | |
d14a1e28 RD |
295 | wxRect wxGetClientDisplayRect(); |
296 | ||
ab1f7d2a RD |
297 | |
298 | MustHaveApp(wxSetCursor); | |
d14a1e28 RD |
299 | void wxSetCursor(wxCursor& cursor); |
300 | ||
301 | ||
2327fb3b RD |
302 | MustHaveApp(wxGetXDisplay); |
303 | DocStr(wxGetXDisplay, | |
304 | "Returns a swigified pointer to the X11 display. Returns None on | |
305 | other platforms.", ""); | |
306 | %inline %{ | |
307 | void* wxGetXDisplay() | |
308 | { | |
309 | #ifdef __WXGTK__ | |
310 | return wxGetDisplay(); | |
311 | #else | |
312 | return NULL; | |
313 | #endif | |
314 | } | |
315 | %} | |
316 | ||
d14a1e28 RD |
317 | |
318 | // Miscellaneous functions | |
319 | ||
ab1f7d2a | 320 | MustHaveApp(wxBeginBusyCursor); |
d14a1e28 | 321 | void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); |
ab1f7d2a | 322 | |
095315e2 RD |
323 | |
324 | MustHaveApp(wxGetMousePosition); | |
325 | DocDeclStr( | |
326 | wxPoint, wxGetMousePosition(), | |
327 | "Get the current mouse position on the screen.", ""); | |
328 | ||
329 | MustHaveApp(FindWindowAtPointer); | |
330 | DocStr(FindWindowAtPointer, | |
331 | "Returns the window currently under the mouse pointer, if it belongs to | |
332 | this application. Otherwise it returns None.", ""); | |
333 | %inline %{ | |
334 | wxWindow* FindWindowAtPointer() { | |
335 | wxPoint unused; | |
336 | return wxFindWindowAtPointer(unused); | |
337 | } | |
338 | %} | |
339 | ||
340 | ||
ab1f7d2a | 341 | MustHaveApp(wxGetActiveWindow); |
095315e2 RD |
342 | DocDeclStr( |
343 | wxWindow *, wxGetActiveWindow(), | |
344 | "Get the currently active window of this application, or None", ""); | |
345 | ||
d14a1e28 | 346 | |
ab1f7d2a | 347 | MustHaveApp(wxGenericFindWindowAtPoint); |
d14a1e28 | 348 | wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); |
ab1f7d2a RD |
349 | |
350 | MustHaveApp(wxFindWindowAtPoint); | |
d14a1e28 RD |
351 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt); |
352 | ||
ab1f7d2a | 353 | MustHaveApp(wxGetTopLevelParent); |
d14a1e28 RD |
354 | wxWindow* wxGetTopLevelParent(wxWindow *win); |
355 | ||
d14a1e28 | 356 | |
aa2fc802 RD |
357 | DocDeclStr( |
358 | bool , wxLaunchDefaultBrowser(const wxString& url), | |
359 | "Launches the user's default browser and tells it to open the location | |
360 | at ``url``. Returns ``True`` if the application was successfully | |
361 | launched.", ""); | |
d14a1e28 RD |
362 | |
363 | ||
89c876de | 364 | |
ab1f7d2a | 365 | MustHaveApp(wxGetKeyState); |
ad411ab2 RD |
366 | DocDeclStr( |
367 | bool , wxGetKeyState(wxKeyCode key), | |
368 | "Get the state of a key (true if pressed or toggled on, false if not.) | |
369 | This is generally most useful getting the state of the modifier or | |
095315e2 RD |
370 | toggle keys. On some platforms those may be the only keys that this |
371 | function is able to detect. | |
ad411ab2 RD |
372 | ", ""); |
373 | ||
57b1892f RD |
374 | |
375 | ||
095315e2 RD |
376 | //--------------------------------------------------------------------------- |
377 | ||
378 | DocStr(wxMouseState, | |
379 | "`wx.MouseState` is used to hold information about mouse button and | |
380 | modifier key states and is what is returned from `wx.GetMouseState`.", | |
381 | ""); | |
382 | ||
383 | class wxMouseState | |
384 | { | |
385 | public: | |
386 | wxMouseState(); | |
387 | ~wxMouseState(); | |
388 | ||
389 | wxCoord GetX(); | |
390 | wxCoord GetY(); | |
391 | ||
392 | bool LeftDown(); | |
393 | bool MiddleDown(); | |
394 | bool RightDown(); | |
395 | ||
396 | bool ControlDown(); | |
397 | bool ShiftDown(); | |
398 | bool AltDown(); | |
399 | bool MetaDown(); | |
400 | bool CmdDown(); | |
401 | ||
402 | void SetX(wxCoord x); | |
403 | void SetY(wxCoord y); | |
404 | ||
405 | void SetLeftDown(bool down); | |
406 | void SetMiddleDown(bool down); | |
407 | void SetRightDown(bool down); | |
408 | ||
409 | void SetControlDown(bool down); | |
410 | void SetShiftDown(bool down); | |
411 | void SetAltDown(bool down); | |
412 | void SetMetaDown(bool down); | |
413 | ||
414 | %pythoncode { | |
415 | x = property(GetX, SetX) | |
416 | y = property(GetY, SetY) | |
417 | leftDown = property(LeftDown, SetLeftDown) | |
418 | middleDown = property(MiddleDown, SetMiddleDown) | |
419 | rightDown = property(RightDown, SetRightDown) | |
420 | controlDown = property(ControlDown, SetControlDown) | |
421 | shiftDown = property(ShiftDown, SetShiftDown) | |
422 | altDown = property(AltDown, SetAltDown) | |
423 | metaDown = property(MetaDown, SetMetaDown) | |
424 | cmdDown = property(CmdDown) | |
425 | } | |
426 | }; | |
427 | ||
428 | ||
429 | DocDeclStr( | |
430 | wxMouseState , wxGetMouseState(), | |
431 | "Returns the current state of the mouse. Returns an instance of a | |
432 | `wx.MouseState` object that contains the current position of the mouse | |
433 | pointer in screen coordinants, as well as boolean values indicating | |
434 | the up/down status of the mouse buttons and the modifier keys.", ""); | |
435 | ||
436 | ||
d14a1e28 RD |
437 | //--------------------------------------------------------------------------- |
438 | ||
ab1f7d2a RD |
439 | MustHaveApp(wxWakeUpMainThread); |
440 | ||
d14a1e28 RD |
441 | #if defined(__WXMSW__) || defined(__WXMAC__) |
442 | void wxWakeUpMainThread(); | |
443 | #else | |
444 | %inline %{ | |
445 | void wxWakeUpMainThread() {} | |
446 | %} | |
447 | #endif | |
448 | ||
ab1f7d2a RD |
449 | |
450 | MustHaveApp(wxMutexGuiEnter); | |
d14a1e28 | 451 | void wxMutexGuiEnter(); |
ab1f7d2a RD |
452 | |
453 | MustHaveApp(wxMutexGuiLeave); | |
d14a1e28 RD |
454 | void wxMutexGuiLeave(); |
455 | ||
456 | ||
ab1f7d2a | 457 | MustHaveApp(wxMutexGuiLocker); |
d14a1e28 RD |
458 | class wxMutexGuiLocker { |
459 | public: | |
460 | wxMutexGuiLocker(); | |
461 | ~wxMutexGuiLocker(); | |
462 | }; | |
463 | ||
464 | ||
ab1f7d2a | 465 | MustHaveApp(wxThread); |
d14a1e28 RD |
466 | %inline %{ |
467 | bool wxThread_IsMain() { | |
468 | #ifdef WXP_WITH_THREAD | |
469 | return wxThread::IsMain(); | |
470 | #else | |
a72f4631 | 471 | return true; |
d14a1e28 RD |
472 | #endif |
473 | } | |
474 | %} | |
475 | ||
476 | //--------------------------------------------------------------------------- | |
477 | //--------------------------------------------------------------------------- |