]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | %{ | |
17 | #include <wx/stockitem.h> | |
18 | %} | |
19 | ||
20 | //--------------------------------------------------------------------------- | |
21 | ||
22 | MAKE_CONST_WXSTRING(FileSelectorPromptStr); | |
23 | MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr); | |
24 | MAKE_CONST_WXSTRING(DirSelectorPromptStr); | |
25 | ||
26 | //--------------------------------------------------------------------------- | |
27 | %newgroup; | |
28 | ||
29 | ||
30 | long wxNewId(); | |
31 | void wxRegisterId(long id); | |
32 | long wxGetCurrentId(); | |
33 | ||
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): | |
43 | wxString wxGetStockLabel(wxWindowID id, | |
44 | bool withCodes = true, | |
45 | wxString accelerator = wxPyEmptyString); | |
46 | ||
47 | ||
48 | MustHaveApp(wxBell); | |
49 | void wxBell(); | |
50 | ||
51 | MustHaveApp(wxEndBusyCursor); | |
52 | void wxEndBusyCursor(); | |
53 | ||
54 | long wxGetElapsedTime(bool resetTimer = true); | |
55 | ||
56 | bool wxIsBusy(); | |
57 | wxString wxNow(); | |
58 | bool wxShell(const wxString& command = wxPyEmptyString); | |
59 | void wxStartTimer(); | |
60 | ||
61 | DocDeclA( | |
62 | int, wxGetOsVersion(int *OUTPUT, int *OUTPUT), | |
63 | "GetOsVersion() -> (platform, major, minor)"); | |
64 | ||
65 | wxString wxGetOsDescription(); | |
66 | ||
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" | |
73 | // int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters); | |
74 | ||
75 | #if defined(__WXMSW__) || defined(__WXMAC__) | |
76 | wxMemorySize wxGetFreeMemory(); | |
77 | #else | |
78 | %inline %{ | |
79 | wxMemorySize wxGetFreeMemory() | |
80 | { wxPyRaiseNotImplemented(); return 0; } | |
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 | |
91 | MustHaveApp(wxShutdown); | |
92 | bool wxShutdown(wxShutdownFlags wFlags); | |
93 | ||
94 | ||
95 | void wxSleep(int secs); | |
96 | void wxMilliSleep(unsigned long milliseconds); | |
97 | void wxMicroSleep(unsigned long microseconds); | |
98 | %pythoncode { Usleep = MilliSleep } | |
99 | ||
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 | ||
120 | MustHaveApp(wxFileSelector); | |
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 | |
134 | MustHaveApp(wxLoadFileSelector); | |
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 | |
141 | MustHaveApp(wxSaveFileSelector); | |
142 | wxString wxSaveFileSelector(const wxString& what, | |
143 | const wxString& extension, | |
144 | const wxString& default_name = wxPyEmptyString, | |
145 | wxWindow *parent = NULL); | |
146 | ||
147 | ||
148 | MustHaveApp(wxDirSelector); | |
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 | ||
155 | MustHaveApp(wxGetTextFromUser); | |
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, | |
161 | bool centre = true); | |
162 | ||
163 | MustHaveApp(wxGetPasswordFromUser); | |
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, | |
175 | // bool centre = true, int width=150, int height=200); | |
176 | ||
177 | ||
178 | MustHaveApp(wxGetSingleChoice); | |
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, | |
183 | bool centre = true, | |
184 | int width=150, int height=200); | |
185 | ||
186 | MustHaveApp(wxGetSingleChoiceIndex); | |
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, | |
191 | bool centre = true, | |
192 | int width=150, int height=200); | |
193 | ||
194 | ||
195 | MustHaveApp(wxMessageBox); | |
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 | ||
202 | // WXWIN_COMPATIBILITY_2_4 | |
203 | #if 0 | |
204 | MustHaveApp(wxGetNumberFromUser); | |
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); | |
212 | %pythoncode { GetNumberFromUser = wx._deprecated(GetNumberFromUser) } | |
213 | #endif | |
214 | ||
215 | // GDI Functions | |
216 | ||
217 | MustHaveApp(wxColourDisplay); | |
218 | bool wxColourDisplay(); | |
219 | ||
220 | MustHaveApp(wxDisplayDepth); | |
221 | int wxDisplayDepth(); | |
222 | ||
223 | MustHaveApp(wxGetDisplayDepth); | |
224 | int wxGetDisplayDepth(); | |
225 | ||
226 | MustHaveApp(wxDisplaySize); | |
227 | DocDeclA( | |
228 | void, wxDisplaySize(int* OUTPUT, int* OUTPUT), | |
229 | "DisplaySize() -> (width, height)"); | |
230 | ||
231 | MustHaveApp(wxGetDisplaySize); | |
232 | wxSize wxGetDisplaySize(); | |
233 | ||
234 | MustHaveApp(wxDisplaySizeMM); | |
235 | DocDeclA( | |
236 | void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT), | |
237 | "DisplaySizeMM() -> (width, height)"); | |
238 | ||
239 | MustHaveApp(wxGetDisplaySizeMM); | |
240 | wxSize wxGetDisplaySizeMM(); | |
241 | ||
242 | MustHaveApp(wxClientDisplayRect); | |
243 | DocDeclA( | |
244 | void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT), | |
245 | "ClientDisplayRect() -> (x, y, width, height)"); | |
246 | ||
247 | MustHaveApp(wxGetClientDisplayRect); | |
248 | wxRect wxGetClientDisplayRect(); | |
249 | ||
250 | ||
251 | MustHaveApp(wxSetCursor); | |
252 | void wxSetCursor(wxCursor& cursor); | |
253 | ||
254 | ||
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 | ||
270 | ||
271 | // Miscellaneous functions | |
272 | ||
273 | MustHaveApp(wxBeginBusyCursor); | |
274 | void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); | |
275 | ||
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 | ||
294 | MustHaveApp(wxGetActiveWindow); | |
295 | DocDeclStr( | |
296 | wxWindow *, wxGetActiveWindow(), | |
297 | "Get the currently active window of this application, or None", ""); | |
298 | ||
299 | ||
300 | MustHaveApp(wxGenericFindWindowAtPoint); | |
301 | wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); | |
302 | ||
303 | MustHaveApp(wxFindWindowAtPoint); | |
304 | wxWindow* wxFindWindowAtPoint(const wxPoint& pt); | |
305 | ||
306 | MustHaveApp(wxGetTopLevelParent); | |
307 | wxWindow* wxGetTopLevelParent(wxWindow *win); | |
308 | ||
309 | ||
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.", ""); | |
315 | ||
316 | ||
317 | ||
318 | MustHaveApp(wxGetKeyState); | |
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 | |
323 | toggle keys. On some platforms those may be the only keys that this | |
324 | function is able to detect. | |
325 | ", ""); | |
326 | ||
327 | ||
328 | ||
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 | ||
390 | //--------------------------------------------------------------------------- | |
391 | ||
392 | MustHaveApp(wxWakeUpMainThread); | |
393 | ||
394 | #if defined(__WXMSW__) || defined(__WXMAC__) | |
395 | void wxWakeUpMainThread(); | |
396 | #else | |
397 | %inline %{ | |
398 | void wxWakeUpMainThread() {} | |
399 | %} | |
400 | #endif | |
401 | ||
402 | ||
403 | MustHaveApp(wxMutexGuiEnter); | |
404 | void wxMutexGuiEnter(); | |
405 | ||
406 | MustHaveApp(wxMutexGuiLeave); | |
407 | void wxMutexGuiLeave(); | |
408 | ||
409 | ||
410 | MustHaveApp(wxMutexGuiLocker); | |
411 | class wxMutexGuiLocker { | |
412 | public: | |
413 | wxMutexGuiLocker(); | |
414 | ~wxMutexGuiLocker(); | |
415 | }; | |
416 | ||
417 | ||
418 | MustHaveApp(wxThread); | |
419 | %inline %{ | |
420 | bool wxThread_IsMain() { | |
421 | #ifdef WXP_WITH_THREAD | |
422 | return wxThread::IsMain(); | |
423 | #else | |
424 | return true; | |
425 | #endif | |
426 | } | |
427 | %} | |
428 | ||
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 | ||
464 | //--------------------------------------------------------------------------- | |
465 | //--------------------------------------------------------------------------- |