]>
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 RD |
61 | |
62 | DocDeclA( | |
63 | int, wxGetOsVersion(int *OUTPUT, int *OUTPUT), | |
64 | "GetOsVersion() -> (platform, major, minor)"); | |
65 | ||
d14a1e28 RD |
66 | wxString wxGetOsDescription(); |
67 | ||
03d51a2d RD |
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" | |
daf32463 | 74 | // int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters); |
03d51a2d | 75 | |
d14a1e28 | 76 | #if defined(__WXMSW__) || defined(__WXMAC__) |
e88df737 | 77 | wxMemorySize wxGetFreeMemory(); |
d14a1e28 RD |
78 | #else |
79 | %inline %{ | |
e88df737 | 80 | wxMemorySize wxGetFreeMemory() |
81cfe5e1 | 81 | { wxPyRaiseNotImplemented(); return 0; } |
d14a1e28 RD |
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 | |
ab1f7d2a | 92 | MustHaveApp(wxShutdown); |
d14a1e28 RD |
93 | bool wxShutdown(wxShutdownFlags wFlags); |
94 | ||
95 | ||
96 | void wxSleep(int secs); | |
705b61cc RD |
97 | void wxMilliSleep(unsigned long milliseconds); |
98 | void wxMicroSleep(unsigned long microseconds); | |
99 | %pythoncode { Usleep = MilliSleep } | |
100 | ||
d14a1e28 RD |
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 | ||
ab1f7d2a | 121 | MustHaveApp(wxFileSelector); |
d14a1e28 RD |
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 | |
ab1f7d2a | 135 | MustHaveApp(wxLoadFileSelector); |
d14a1e28 RD |
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 | |
ab1f7d2a | 142 | MustHaveApp(wxSaveFileSelector); |
d14a1e28 RD |
143 | wxString wxSaveFileSelector(const wxString& what, |
144 | const wxString& extension, | |
145 | const wxString& default_name = wxPyEmptyString, | |
146 | wxWindow *parent = NULL); | |
147 | ||
148 | ||
ab1f7d2a | 149 | MustHaveApp(wxDirSelector); |
d14a1e28 RD |
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 | ||
ab1f7d2a | 156 | MustHaveApp(wxGetTextFromUser); |
d14a1e28 RD |
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, | |
a72f4631 | 162 | bool centre = true); |
d14a1e28 | 163 | |
ab1f7d2a | 164 | MustHaveApp(wxGetPasswordFromUser); |
d14a1e28 RD |
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, | |
a72f4631 | 176 | // bool centre = true, int width=150, int height=200); |
d14a1e28 RD |
177 | |
178 | ||
ab1f7d2a | 179 | MustHaveApp(wxGetSingleChoice); |
d14a1e28 RD |
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, | |
a72f4631 | 184 | bool centre = true, |
d14a1e28 RD |
185 | int width=150, int height=200); |
186 | ||
ab1f7d2a | 187 | MustHaveApp(wxGetSingleChoiceIndex); |
d14a1e28 RD |
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, | |
a72f4631 | 192 | bool centre = true, |
d14a1e28 RD |
193 | int width=150, int height=200); |
194 | ||
195 | ||
ab1f7d2a | 196 | MustHaveApp(wxMessageBox); |
d14a1e28 RD |
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 | ||
aeee37c3 | 203 | // WXWIN_COMPATIBILITY_2_4 |
2f91e3df | 204 | #if 0 |
ab1f7d2a | 205 | MustHaveApp(wxGetNumberFromUser); |
d14a1e28 RD |
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); | |
02b800ce | 213 | %pythoncode { GetNumberFromUser = wx._deprecated(GetNumberFromUser) } |
2f91e3df | 214 | #endif |
02b800ce | 215 | |
d14a1e28 RD |
216 | // GDI Functions |
217 | ||
ab1f7d2a | 218 | MustHaveApp(wxColourDisplay); |
d14a1e28 RD |
219 | bool wxColourDisplay(); |
220 | ||
ab1f7d2a | 221 | MustHaveApp(wxDisplayDepth); |
d14a1e28 | 222 | int wxDisplayDepth(); |
ab1f7d2a RD |
223 | |
224 | MustHaveApp(wxGetDisplayDepth); | |
d14a1e28 RD |
225 | int wxGetDisplayDepth(); |
226 | ||
ab1f7d2a | 227 | MustHaveApp(wxDisplaySize); |
322913ce RD |
228 | DocDeclA( |
229 | void, wxDisplaySize(int* OUTPUT, int* OUTPUT), | |
230 | "DisplaySize() -> (width, height)"); | |
ab1f7d2a RD |
231 | |
232 | MustHaveApp(wxGetDisplaySize); | |
d14a1e28 RD |
233 | wxSize wxGetDisplaySize(); |
234 | ||
ab1f7d2a | 235 | MustHaveApp(wxDisplaySizeMM); |
322913ce RD |
236 | DocDeclA( |
237 | void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT), | |
238 | "DisplaySizeMM() -> (width, height)"); | |
ab1f7d2a RD |
239 | |
240 | MustHaveApp(wxGetDisplaySizeMM); | |
d14a1e28 RD |
241 | wxSize wxGetDisplaySizeMM(); |
242 | ||
ab1f7d2a | 243 | MustHaveApp(wxClientDisplayRect); |
322913ce RD |
244 | DocDeclA( |
245 | void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT), | |
246 | "ClientDisplayRect() -> (x, y, width, height)"); | |
ab1f7d2a RD |
247 | |
248 | MustHaveApp(wxGetClientDisplayRect); | |
d14a1e28 RD |
249 | wxRect wxGetClientDisplayRect(); |
250 | ||
ab1f7d2a RD |
251 | |
252 | MustHaveApp(wxSetCursor); | |
d14a1e28 RD |
253 | void wxSetCursor(wxCursor& cursor); |
254 | ||
255 | ||
2327fb3b RD |
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 | ||
d14a1e28 RD |
271 | |
272 | // Miscellaneous functions | |
273 | ||
ab1f7d2a | 274 | MustHaveApp(wxBeginBusyCursor); |
d14a1e28 | 275 | void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); |
ab1f7d2a | 276 | |
095315e2 RD |
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 | ||
ab1f7d2a | 295 | MustHaveApp(wxGetActiveWindow); |
095315e2 RD |
296 | DocDeclStr( |
297 | wxWindow *, wxGetActiveWindow(), | |
298 | "Get the currently active window of this application, or None", ""); | |
299 | ||
d14a1e28 | 300 | |
ab1f7d2a | 301 | MustHaveApp(wxGenericFindWindowAtPoint); |
d14a1e28 | 302 | wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); |
ab1f7d2a RD |
303 | |
304 | MustHaveApp(wxFindWindowAtPoint); | |
d14a1e28 RD |
305 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt); |
306 | ||
ab1f7d2a | 307 | MustHaveApp(wxGetTopLevelParent); |
d14a1e28 RD |
308 | wxWindow* wxGetTopLevelParent(wxWindow *win); |
309 | ||
d14a1e28 | 310 | |
aa2fc802 RD |
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.", ""); | |
d14a1e28 RD |
316 | |
317 | ||
89c876de | 318 | |
ab1f7d2a | 319 | MustHaveApp(wxGetKeyState); |
ad411ab2 RD |
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 | |
095315e2 RD |
324 | toggle keys. On some platforms those may be the only keys that this |
325 | function is able to detect. | |
ad411ab2 RD |
326 | ", ""); |
327 | ||
57b1892f RD |
328 | |
329 | ||
095315e2 RD |
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 | ||
d14a1e28 RD |
391 | //--------------------------------------------------------------------------- |
392 | ||
ab1f7d2a RD |
393 | MustHaveApp(wxWakeUpMainThread); |
394 | ||
d14a1e28 RD |
395 | #if defined(__WXMSW__) || defined(__WXMAC__) |
396 | void wxWakeUpMainThread(); | |
397 | #else | |
398 | %inline %{ | |
399 | void wxWakeUpMainThread() {} | |
400 | %} | |
401 | #endif | |
402 | ||
ab1f7d2a RD |
403 | |
404 | MustHaveApp(wxMutexGuiEnter); | |
d14a1e28 | 405 | void wxMutexGuiEnter(); |
ab1f7d2a RD |
406 | |
407 | MustHaveApp(wxMutexGuiLeave); | |
d14a1e28 RD |
408 | void wxMutexGuiLeave(); |
409 | ||
410 | ||
ab1f7d2a | 411 | MustHaveApp(wxMutexGuiLocker); |
d14a1e28 RD |
412 | class wxMutexGuiLocker { |
413 | public: | |
414 | wxMutexGuiLocker(); | |
415 | ~wxMutexGuiLocker(); | |
416 | }; | |
417 | ||
418 | ||
ab1f7d2a | 419 | MustHaveApp(wxThread); |
d14a1e28 RD |
420 | %inline %{ |
421 | bool wxThread_IsMain() { | |
422 | #ifdef WXP_WITH_THREAD | |
423 | return wxThread::IsMain(); | |
424 | #else | |
a72f4631 | 425 | return true; |
d14a1e28 RD |
426 | #endif |
427 | } | |
428 | %} | |
429 | ||
aeee37c3 RD |
430 | //--------------------------------------------------------------------------- |
431 | ||
432 | // enum wxPowerType | |
433 | // { | |
434 | // wxPOWER_SOCKET, | |
435 | // wxPOWER_BATTERY, | |
436 | // wxPOWER_UNKNOWN | |
437 | // }; | |
438 | ||
439 | // DocDeclStr( | |
440 | // wxPowerType , wxGetPowerType(), | |
441 | // "Returns the type of power source as one of wx.POWER_SOCKET, | |
442 | // wx.POWER_BATTERY or wx.POWER_UNKNOWN. wx.POWER_UNKNOWN is also the | |
443 | // default on platforms where this feature is not implemented.", ""); | |
444 | ||
445 | ||
446 | // enum wxBatteryState | |
447 | // { | |
448 | // wxBATTERY_NORMAL_STATE, // system is fully usable | |
449 | // wxBATTERY_LOW_STATE, // start to worry | |
450 | // wxBATTERY_CRITICAL_STATE, // save quickly | |
451 | // wxBATTERY_SHUTDOWN_STATE, // too late | |
452 | // wxBATTERY_UNKNOWN_STATE | |
453 | // }; | |
454 | ||
455 | // DocDeclStr( | |
456 | // wxBatteryState , wxGetBatteryState(), | |
457 | // "Returns battery state as one of wx.BATTERY_NORMAL_STATE, | |
458 | // wx.BATTERY_LOW_STATE}, wx.BATTERY_CRITICAL_STATE, | |
459 | // wx.BATTERY_SHUTDOWN_STATE or wx.BATTERY_UNKNOWN_STATE. | |
460 | // wx.BATTERY_UNKNOWN_STATE is also the default on platforms where this | |
461 | // feature is not implemented.", ""); | |
462 | ||
463 | ||
464 | ||
d14a1e28 RD |
465 | //--------------------------------------------------------------------------- |
466 | //--------------------------------------------------------------------------- |