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