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