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