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