]>
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 | |
d14a1e28 | 117 | #if defined(__WXMSW__) || defined(__WXMAC__) |
e88df737 | 118 | wxMemorySize wxGetFreeMemory(); |
d14a1e28 RD |
119 | #else |
120 | %inline %{ | |
e88df737 | 121 | wxMemorySize wxGetFreeMemory() |
81cfe5e1 | 122 | { wxPyRaiseNotImplemented(); return 0; } |
d14a1e28 RD |
123 | %} |
124 | #endif | |
125 | ||
126 | enum wxShutdownFlags | |
127 | { | |
128 | wxSHUTDOWN_POWEROFF, // power off the computer | |
129 | wxSHUTDOWN_REBOOT // shutdown and reboot | |
130 | }; | |
131 | ||
132 | // Shutdown or reboot the PC | |
ab1f7d2a | 133 | MustHaveApp(wxShutdown); |
d14a1e28 RD |
134 | bool wxShutdown(wxShutdownFlags wFlags); |
135 | ||
136 | ||
137 | void wxSleep(int secs); | |
705b61cc RD |
138 | void wxMilliSleep(unsigned long milliseconds); |
139 | void wxMicroSleep(unsigned long microseconds); | |
140 | %pythoncode { Usleep = MilliSleep } | |
141 | ||
d14a1e28 RD |
142 | void wxEnableTopLevelWindows(bool enable); |
143 | ||
144 | wxString wxStripMenuCodes(const wxString& in); | |
145 | ||
146 | ||
147 | wxString wxGetEmailAddress(); | |
148 | wxString wxGetHostName(); | |
149 | wxString wxGetFullHostName(); | |
150 | wxString wxGetUserId(); | |
151 | wxString wxGetUserName(); | |
152 | wxString wxGetHomeDir(); | |
153 | wxString wxGetUserHome(const wxString& user = wxPyEmptyString); | |
154 | ||
155 | unsigned long wxGetProcessId(); | |
156 | ||
157 | void wxTrap(); | |
158 | ||
159 | ||
160 | // Dialog Functions | |
161 | ||
ab1f7d2a | 162 | MustHaveApp(wxFileSelector); |
d14a1e28 RD |
163 | wxString wxFileSelector(const wxString& message = wxPyFileSelectorPromptStr, |
164 | const wxString& default_path = wxPyEmptyString, | |
165 | const wxString& default_filename = wxPyEmptyString, | |
166 | const wxString& default_extension = wxPyEmptyString, | |
167 | const wxString& wildcard = wxPyFileSelectorDefaultWildcardStr, | |
168 | int flags = 0, | |
169 | wxWindow *parent = NULL, | |
170 | int x = -1, int y = -1); | |
171 | ||
172 | // TODO: wxFileSelectorEx | |
173 | ||
174 | ||
175 | // Ask for filename to load | |
ab1f7d2a | 176 | MustHaveApp(wxLoadFileSelector); |
d14a1e28 RD |
177 | wxString wxLoadFileSelector(const wxString& what, |
178 | const wxString& extension, | |
179 | const wxString& default_name = wxPyEmptyString, | |
180 | wxWindow *parent = NULL); | |
181 | ||
182 | // Ask for filename to save | |
ab1f7d2a | 183 | MustHaveApp(wxSaveFileSelector); |
d14a1e28 RD |
184 | wxString wxSaveFileSelector(const wxString& what, |
185 | const wxString& extension, | |
186 | const wxString& default_name = wxPyEmptyString, | |
187 | wxWindow *parent = NULL); | |
188 | ||
189 | ||
ab1f7d2a | 190 | MustHaveApp(wxDirSelector); |
d14a1e28 RD |
191 | wxString wxDirSelector(const wxString& message = wxPyDirSelectorPromptStr, |
192 | const wxString& defaultPath = wxPyEmptyString, | |
193 | long style = wxDD_DEFAULT_STYLE, | |
194 | const wxPoint& pos = wxDefaultPosition, | |
195 | wxWindow *parent = NULL); | |
196 | ||
ab1f7d2a | 197 | MustHaveApp(wxGetTextFromUser); |
d14a1e28 RD |
198 | wxString wxGetTextFromUser(const wxString& message, |
199 | const wxString& caption = wxPyEmptyString, | |
200 | const wxString& default_value = wxPyEmptyString, | |
201 | wxWindow *parent = NULL, | |
202 | int x = -1, int y = -1, | |
a72f4631 | 203 | bool centre = true); |
d14a1e28 | 204 | |
ab1f7d2a | 205 | MustHaveApp(wxGetPasswordFromUser); |
d14a1e28 RD |
206 | wxString wxGetPasswordFromUser(const wxString& message, |
207 | const wxString& caption = wxPyEmptyString, | |
208 | const wxString& default_value = wxPyEmptyString, | |
209 | wxWindow *parent = NULL); | |
210 | ||
211 | ||
212 | // TODO: Need to custom wrap this one... | |
213 | // int wxGetMultipleChoice(char* message, char* caption, | |
214 | // int LCOUNT, char** choices, | |
215 | // int nsel, int *selection, | |
216 | // wxWindow *parent = NULL, int x = -1, int y = -1, | |
a72f4631 | 217 | // bool centre = true, int width=150, int height=200); |
d14a1e28 RD |
218 | |
219 | ||
ab1f7d2a | 220 | MustHaveApp(wxGetSingleChoice); |
d14a1e28 RD |
221 | wxString wxGetSingleChoice(const wxString& message, const wxString& caption, |
222 | int choices, wxString* choices_array, | |
223 | wxWindow *parent = NULL, | |
224 | int x = -1, int y = -1, | |
a72f4631 | 225 | bool centre = true, |
d14a1e28 RD |
226 | int width=150, int height=200); |
227 | ||
ab1f7d2a | 228 | MustHaveApp(wxGetSingleChoiceIndex); |
d14a1e28 RD |
229 | int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption, |
230 | int choices, wxString* choices_array, | |
231 | wxWindow *parent = NULL, | |
232 | int x = -1, int y = -1, | |
a72f4631 | 233 | bool centre = true, |
d14a1e28 RD |
234 | int width=150, int height=200); |
235 | ||
236 | ||
ab1f7d2a | 237 | MustHaveApp(wxMessageBox); |
d14a1e28 RD |
238 | int wxMessageBox(const wxString& message, |
239 | const wxString& caption = wxPyEmptyString, | |
240 | int style = wxOK | wxCENTRE, | |
241 | wxWindow *parent = NULL, | |
242 | int x = -1, int y = -1); | |
243 | ||
ab1f7d2a | 244 | MustHaveApp(wxGetNumberFromUser); |
d14a1e28 RD |
245 | long wxGetNumberFromUser(const wxString& message, |
246 | const wxString& prompt, | |
247 | const wxString& caption, | |
248 | long value, | |
249 | long min = 0, long max = 100, | |
250 | wxWindow *parent = NULL, | |
251 | const wxPoint& pos = wxDefaultPosition); | |
02b800ce | 252 | |
d14a1e28 RD |
253 | // GDI Functions |
254 | ||
ab1f7d2a | 255 | MustHaveApp(wxColourDisplay); |
d14a1e28 RD |
256 | bool wxColourDisplay(); |
257 | ||
ab1f7d2a | 258 | MustHaveApp(wxDisplayDepth); |
d14a1e28 | 259 | int wxDisplayDepth(); |
ab1f7d2a RD |
260 | |
261 | MustHaveApp(wxGetDisplayDepth); | |
d14a1e28 RD |
262 | int wxGetDisplayDepth(); |
263 | ||
ab1f7d2a | 264 | MustHaveApp(wxDisplaySize); |
322913ce RD |
265 | DocDeclA( |
266 | void, wxDisplaySize(int* OUTPUT, int* OUTPUT), | |
267 | "DisplaySize() -> (width, height)"); | |
ab1f7d2a RD |
268 | |
269 | MustHaveApp(wxGetDisplaySize); | |
d14a1e28 RD |
270 | wxSize wxGetDisplaySize(); |
271 | ||
ab1f7d2a | 272 | MustHaveApp(wxDisplaySizeMM); |
322913ce RD |
273 | DocDeclA( |
274 | void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT), | |
275 | "DisplaySizeMM() -> (width, height)"); | |
ab1f7d2a RD |
276 | |
277 | MustHaveApp(wxGetDisplaySizeMM); | |
d14a1e28 RD |
278 | wxSize wxGetDisplaySizeMM(); |
279 | ||
ab1f7d2a | 280 | MustHaveApp(wxClientDisplayRect); |
322913ce RD |
281 | DocDeclA( |
282 | void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT), | |
283 | "ClientDisplayRect() -> (x, y, width, height)"); | |
ab1f7d2a RD |
284 | |
285 | MustHaveApp(wxGetClientDisplayRect); | |
d14a1e28 RD |
286 | wxRect wxGetClientDisplayRect(); |
287 | ||
ab1f7d2a RD |
288 | |
289 | MustHaveApp(wxSetCursor); | |
d14a1e28 RD |
290 | void wxSetCursor(wxCursor& cursor); |
291 | ||
292 | ||
2327fb3b RD |
293 | MustHaveApp(wxGetXDisplay); |
294 | DocStr(wxGetXDisplay, | |
295 | "Returns a swigified pointer to the X11 display. Returns None on | |
296 | other platforms.", ""); | |
297 | %inline %{ | |
298 | void* wxGetXDisplay() | |
299 | { | |
300 | #ifdef __WXGTK__ | |
301 | return wxGetDisplay(); | |
302 | #else | |
303 | return NULL; | |
304 | #endif | |
305 | } | |
306 | %} | |
307 | ||
d14a1e28 RD |
308 | |
309 | // Miscellaneous functions | |
310 | ||
ab1f7d2a | 311 | MustHaveApp(wxBeginBusyCursor); |
d14a1e28 | 312 | void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); |
ab1f7d2a | 313 | |
095315e2 RD |
314 | |
315 | MustHaveApp(wxGetMousePosition); | |
316 | DocDeclStr( | |
317 | wxPoint, wxGetMousePosition(), | |
318 | "Get the current mouse position on the screen.", ""); | |
319 | ||
320 | MustHaveApp(FindWindowAtPointer); | |
321 | DocStr(FindWindowAtPointer, | |
322 | "Returns the window currently under the mouse pointer, if it belongs to | |
323 | this application. Otherwise it returns None.", ""); | |
324 | %inline %{ | |
325 | wxWindow* FindWindowAtPointer() { | |
326 | wxPoint unused; | |
327 | return wxFindWindowAtPointer(unused); | |
328 | } | |
329 | %} | |
330 | ||
331 | ||
ab1f7d2a | 332 | MustHaveApp(wxGetActiveWindow); |
095315e2 RD |
333 | DocDeclStr( |
334 | wxWindow *, wxGetActiveWindow(), | |
335 | "Get the currently active window of this application, or None", ""); | |
336 | ||
d14a1e28 | 337 | |
ab1f7d2a | 338 | MustHaveApp(wxGenericFindWindowAtPoint); |
d14a1e28 | 339 | wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); |
ab1f7d2a RD |
340 | |
341 | MustHaveApp(wxFindWindowAtPoint); | |
d14a1e28 RD |
342 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt); |
343 | ||
ab1f7d2a | 344 | MustHaveApp(wxGetTopLevelParent); |
d14a1e28 RD |
345 | wxWindow* wxGetTopLevelParent(wxWindow *win); |
346 | ||
d14a1e28 | 347 | |
aa2fc802 RD |
348 | DocDeclStr( |
349 | bool , wxLaunchDefaultBrowser(const wxString& url), | |
350 | "Launches the user's default browser and tells it to open the location | |
351 | at ``url``. Returns ``True`` if the application was successfully | |
352 | launched.", ""); | |
d14a1e28 RD |
353 | |
354 | ||
89c876de | 355 | |
ab1f7d2a | 356 | MustHaveApp(wxGetKeyState); |
ad411ab2 RD |
357 | DocDeclStr( |
358 | bool , wxGetKeyState(wxKeyCode key), | |
359 | "Get the state of a key (true if pressed or toggled on, false if not.) | |
360 | This is generally most useful getting the state of the modifier or | |
095315e2 RD |
361 | toggle keys. On some platforms those may be the only keys that this |
362 | function is able to detect. | |
ad411ab2 RD |
363 | ", ""); |
364 | ||
57b1892f RD |
365 | |
366 | ||
095315e2 RD |
367 | //--------------------------------------------------------------------------- |
368 | ||
369 | DocStr(wxMouseState, | |
370 | "`wx.MouseState` is used to hold information about mouse button and | |
371 | modifier key states and is what is returned from `wx.GetMouseState`.", | |
372 | ""); | |
373 | ||
374 | class wxMouseState | |
375 | { | |
376 | public: | |
377 | wxMouseState(); | |
378 | ~wxMouseState(); | |
379 | ||
380 | wxCoord GetX(); | |
381 | wxCoord GetY(); | |
382 | ||
383 | bool LeftDown(); | |
384 | bool MiddleDown(); | |
385 | bool RightDown(); | |
386 | ||
387 | bool ControlDown(); | |
388 | bool ShiftDown(); | |
389 | bool AltDown(); | |
390 | bool MetaDown(); | |
391 | bool CmdDown(); | |
392 | ||
393 | void SetX(wxCoord x); | |
394 | void SetY(wxCoord y); | |
395 | ||
396 | void SetLeftDown(bool down); | |
397 | void SetMiddleDown(bool down); | |
398 | void SetRightDown(bool down); | |
399 | ||
400 | void SetControlDown(bool down); | |
401 | void SetShiftDown(bool down); | |
402 | void SetAltDown(bool down); | |
403 | void SetMetaDown(bool down); | |
404 | ||
405 | %pythoncode { | |
406 | x = property(GetX, SetX) | |
407 | y = property(GetY, SetY) | |
408 | leftDown = property(LeftDown, SetLeftDown) | |
409 | middleDown = property(MiddleDown, SetMiddleDown) | |
410 | rightDown = property(RightDown, SetRightDown) | |
411 | controlDown = property(ControlDown, SetControlDown) | |
412 | shiftDown = property(ShiftDown, SetShiftDown) | |
413 | altDown = property(AltDown, SetAltDown) | |
414 | metaDown = property(MetaDown, SetMetaDown) | |
415 | cmdDown = property(CmdDown) | |
416 | } | |
417 | }; | |
418 | ||
419 | ||
420 | DocDeclStr( | |
421 | wxMouseState , wxGetMouseState(), | |
422 | "Returns the current state of the mouse. Returns an instance of a | |
423 | `wx.MouseState` object that contains the current position of the mouse | |
424 | pointer in screen coordinants, as well as boolean values indicating | |
425 | the up/down status of the mouse buttons and the modifier keys.", ""); | |
426 | ||
427 | ||
d14a1e28 RD |
428 | //--------------------------------------------------------------------------- |
429 | ||
ab1f7d2a RD |
430 | MustHaveApp(wxWakeUpMainThread); |
431 | ||
d14a1e28 RD |
432 | #if defined(__WXMSW__) || defined(__WXMAC__) |
433 | void wxWakeUpMainThread(); | |
434 | #else | |
435 | %inline %{ | |
436 | void wxWakeUpMainThread() {} | |
437 | %} | |
438 | #endif | |
439 | ||
ab1f7d2a RD |
440 | |
441 | MustHaveApp(wxMutexGuiEnter); | |
d14a1e28 | 442 | void wxMutexGuiEnter(); |
ab1f7d2a RD |
443 | |
444 | MustHaveApp(wxMutexGuiLeave); | |
d14a1e28 RD |
445 | void wxMutexGuiLeave(); |
446 | ||
447 | ||
ab1f7d2a | 448 | MustHaveApp(wxMutexGuiLocker); |
d14a1e28 RD |
449 | class wxMutexGuiLocker { |
450 | public: | |
451 | wxMutexGuiLocker(); | |
452 | ~wxMutexGuiLocker(); | |
453 | }; | |
454 | ||
455 | ||
ab1f7d2a | 456 | MustHaveApp(wxThread); |
d14a1e28 RD |
457 | %inline %{ |
458 | bool wxThread_IsMain() { | |
459 | #ifdef WXP_WITH_THREAD | |
460 | return wxThread::IsMain(); | |
461 | #else | |
a72f4631 | 462 | return true; |
d14a1e28 RD |
463 | #endif |
464 | } | |
465 | %} | |
466 | ||
467 | //--------------------------------------------------------------------------- | |
468 | //--------------------------------------------------------------------------- |