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