]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_functions.i
wxAUI: Support serialization of individual PaneInfo structures
[wxWidgets.git] / wxPython / src / _functions.i
CommitLineData
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
22MAKE_CONST_WXSTRING(FileSelectorPromptStr);
23MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
24MAKE_CONST_WXSTRING(DirSelectorPromptStr);
d14a1e28
RD
25
26//---------------------------------------------------------------------------
27%newgroup;
28
29
30long wxNewId();
31void wxRegisterId(long id);
32long wxGetCurrentId();
33
1e140719
RD
34// Returns true if the ID is in the list of recognized stock actions
35bool wxIsStockID(wxWindowID id);
36
37// Returns true of the label is empty or label of a stock button with
38// given ID
39bool 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
43wxString wxGetStockLabel(wxWindowID id,
44 bool withCodes = true,
45 wxString accelerator = wxPyEmptyString);
1e140719
RD
46
47
ab1f7d2a 48MustHaveApp(wxBell);
d14a1e28 49void wxBell();
ab1f7d2a
RD
50
51MustHaveApp(wxEndBusyCursor);
d14a1e28
RD
52void wxEndBusyCursor();
53
a72f4631 54long wxGetElapsedTime(bool resetTimer = true);
15648073
RD
55%pythoncode { GetElapsedTime = wx._deprecated(GetElapsedTime) }
56
d14a1e28
RD
57bool wxIsBusy();
58wxString wxNow();
59bool wxShell(const wxString& command = wxPyEmptyString);
60void wxStartTimer();
322913ce 61
cbb4b39d
RD
62
63
64enum
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
322913ce
RD
103DocDeclA(
104 int, wxGetOsVersion(int *OUTPUT, int *OUTPUT),
105 "GetOsVersion() -> (platform, major, minor)");
106
d14a1e28
RD
107wxString wxGetOsDescription();
108
03d51a2d
RD
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"
daf32463 115// int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters);
03d51a2d 116
941afb6b
RD
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
d14a1e28 126#if defined(__WXMSW__) || defined(__WXMAC__)
e88df737 127wxMemorySize wxGetFreeMemory();
d14a1e28
RD
128#else
129%inline %{
e88df737 130 wxMemorySize wxGetFreeMemory()
81cfe5e1 131 { wxPyRaiseNotImplemented(); return 0; }
d14a1e28
RD
132%}
133#endif
134
135enum wxShutdownFlags
136{
137 wxSHUTDOWN_POWEROFF, // power off the computer
138 wxSHUTDOWN_REBOOT // shutdown and reboot
139};
140
141// Shutdown or reboot the PC
ab1f7d2a 142MustHaveApp(wxShutdown);
d14a1e28
RD
143bool wxShutdown(wxShutdownFlags wFlags);
144
145
146void wxSleep(int secs);
705b61cc
RD
147void wxMilliSleep(unsigned long milliseconds);
148void wxMicroSleep(unsigned long microseconds);
149%pythoncode { Usleep = MilliSleep }
150
d14a1e28
RD
151void wxEnableTopLevelWindows(bool enable);
152
153wxString wxStripMenuCodes(const wxString& in);
154
155
156wxString wxGetEmailAddress();
157wxString wxGetHostName();
158wxString wxGetFullHostName();
159wxString wxGetUserId();
160wxString wxGetUserName();
161wxString wxGetHomeDir();
162wxString wxGetUserHome(const wxString& user = wxPyEmptyString);
163
164unsigned long wxGetProcessId();
165
166void wxTrap();
167
168
169// Dialog Functions
170
ab1f7d2a 171MustHaveApp(wxFileSelector);
d14a1e28
RD
172wxString 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
ab1f7d2a 185MustHaveApp(wxLoadFileSelector);
d14a1e28
RD
186wxString 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
ab1f7d2a 192MustHaveApp(wxSaveFileSelector);
d14a1e28
RD
193wxString wxSaveFileSelector(const wxString& what,
194 const wxString& extension,
195 const wxString& default_name = wxPyEmptyString,
196 wxWindow *parent = NULL);
197
198
ab1f7d2a 199MustHaveApp(wxDirSelector);
d14a1e28
RD
200wxString 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
ab1f7d2a 206MustHaveApp(wxGetTextFromUser);
d14a1e28
RD
207wxString 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,
a72f4631 212 bool centre = true);
d14a1e28 213
ab1f7d2a 214MustHaveApp(wxGetPasswordFromUser);
d14a1e28
RD
215wxString 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,
a72f4631 226// bool centre = true, int width=150, int height=200);
d14a1e28
RD
227
228
ab1f7d2a 229MustHaveApp(wxGetSingleChoice);
d14a1e28
RD
230wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
231 int choices, wxString* choices_array,
232 wxWindow *parent = NULL,
233 int x = -1, int y = -1,
a72f4631 234 bool centre = true,
d14a1e28
RD
235 int width=150, int height=200);
236
ab1f7d2a 237MustHaveApp(wxGetSingleChoiceIndex);
d14a1e28
RD
238int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
239 int choices, wxString* choices_array,
240 wxWindow *parent = NULL,
241 int x = -1, int y = -1,
a72f4631 242 bool centre = true,
d14a1e28
RD
243 int width=150, int height=200);
244
245
ab1f7d2a 246MustHaveApp(wxMessageBox);
d14a1e28
RD
247int 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
ab1f7d2a 253MustHaveApp(wxGetNumberFromUser);
d14a1e28
RD
254long 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);
02b800ce 261
d14a1e28
RD
262// GDI Functions
263
ab1f7d2a 264MustHaveApp(wxColourDisplay);
d14a1e28
RD
265bool wxColourDisplay();
266
ab1f7d2a 267MustHaveApp(wxDisplayDepth);
d14a1e28 268int wxDisplayDepth();
ab1f7d2a
RD
269
270MustHaveApp(wxGetDisplayDepth);
d14a1e28
RD
271int wxGetDisplayDepth();
272
ab1f7d2a 273MustHaveApp(wxDisplaySize);
322913ce
RD
274DocDeclA(
275 void, wxDisplaySize(int* OUTPUT, int* OUTPUT),
276 "DisplaySize() -> (width, height)");
ab1f7d2a
RD
277
278MustHaveApp(wxGetDisplaySize);
d14a1e28
RD
279wxSize wxGetDisplaySize();
280
ab1f7d2a 281MustHaveApp(wxDisplaySizeMM);
322913ce
RD
282DocDeclA(
283 void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT),
284 "DisplaySizeMM() -> (width, height)");
ab1f7d2a
RD
285
286MustHaveApp(wxGetDisplaySizeMM);
d14a1e28
RD
287wxSize wxGetDisplaySizeMM();
288
ab1f7d2a 289MustHaveApp(wxClientDisplayRect);
322913ce
RD
290DocDeclA(
291 void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
292 "ClientDisplayRect() -> (x, y, width, height)");
ab1f7d2a
RD
293
294MustHaveApp(wxGetClientDisplayRect);
d14a1e28
RD
295wxRect wxGetClientDisplayRect();
296
ab1f7d2a
RD
297
298MustHaveApp(wxSetCursor);
d14a1e28
RD
299void wxSetCursor(wxCursor& cursor);
300
301
2327fb3b
RD
302MustHaveApp(wxGetXDisplay);
303DocStr(wxGetXDisplay,
304"Returns a swigified pointer to the X11 display. Returns None on
305other platforms.", "");
306%inline %{
307 void* wxGetXDisplay()
308 {
309#ifdef __WXGTK__
310 return wxGetDisplay();
311#else
312 return NULL;
313#endif
314 }
315%}
316
d14a1e28
RD
317
318// Miscellaneous functions
319
ab1f7d2a 320MustHaveApp(wxBeginBusyCursor);
d14a1e28 321void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
ab1f7d2a 322
095315e2
RD
323
324MustHaveApp(wxGetMousePosition);
325DocDeclStr(
326 wxPoint, wxGetMousePosition(),
327 "Get the current mouse position on the screen.", "");
328
329MustHaveApp(FindWindowAtPointer);
330DocStr(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
ab1f7d2a 341MustHaveApp(wxGetActiveWindow);
095315e2
RD
342DocDeclStr(
343 wxWindow *, wxGetActiveWindow(),
344 "Get the currently active window of this application, or None", "");
345
d14a1e28 346
ab1f7d2a 347MustHaveApp(wxGenericFindWindowAtPoint);
d14a1e28 348wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
ab1f7d2a
RD
349
350MustHaveApp(wxFindWindowAtPoint);
d14a1e28
RD
351wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
352
ab1f7d2a 353MustHaveApp(wxGetTopLevelParent);
d14a1e28
RD
354wxWindow* wxGetTopLevelParent(wxWindow *win);
355
d14a1e28 356
aa2fc802
RD
357DocDeclStr(
358 bool , wxLaunchDefaultBrowser(const wxString& url),
359 "Launches the user's default browser and tells it to open the location
360at ``url``. Returns ``True`` if the application was successfully
361launched.", "");
d14a1e28
RD
362
363
89c876de 364
ab1f7d2a 365MustHaveApp(wxGetKeyState);
ad411ab2
RD
366DocDeclStr(
367 bool , wxGetKeyState(wxKeyCode key),
368 "Get the state of a key (true if pressed or toggled on, false if not.)
369This is generally most useful getting the state of the modifier or
095315e2
RD
370toggle keys. On some platforms those may be the only keys that this
371function is able to detect.
ad411ab2
RD
372", "");
373
57b1892f
RD
374
375
095315e2
RD
376//---------------------------------------------------------------------------
377
378DocStr(wxMouseState,
379"`wx.MouseState` is used to hold information about mouse button and
380modifier key states and is what is returned from `wx.GetMouseState`.",
381"");
382
383class wxMouseState
384{
385public:
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
429DocDeclStr(
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
433pointer in screen coordinants, as well as boolean values indicating
434the up/down status of the mouse buttons and the modifier keys.", "");
435
436
d14a1e28
RD
437//---------------------------------------------------------------------------
438
ab1f7d2a
RD
439MustHaveApp(wxWakeUpMainThread);
440
d14a1e28
RD
441#if defined(__WXMSW__) || defined(__WXMAC__)
442void wxWakeUpMainThread();
443#else
444%inline %{
445 void wxWakeUpMainThread() {}
446%}
447#endif
448
ab1f7d2a
RD
449
450MustHaveApp(wxMutexGuiEnter);
d14a1e28 451void wxMutexGuiEnter();
ab1f7d2a
RD
452
453MustHaveApp(wxMutexGuiLeave);
d14a1e28
RD
454void wxMutexGuiLeave();
455
456
ab1f7d2a 457MustHaveApp(wxMutexGuiLocker);
d14a1e28
RD
458class wxMutexGuiLocker {
459public:
460 wxMutexGuiLocker();
461 ~wxMutexGuiLocker();
462};
463
464
ab1f7d2a 465MustHaveApp(wxThread);
d14a1e28
RD
466%inline %{
467 bool wxThread_IsMain() {
468#ifdef WXP_WITH_THREAD
469 return wxThread::IsMain();
470#else
a72f4631 471 return true;
d14a1e28
RD
472#endif
473 }
474%}
475
476//---------------------------------------------------------------------------
477//---------------------------------------------------------------------------