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