]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_functions.i
Docstring update
[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);
322913ce 55
d14a1e28
RD
56bool wxIsBusy();
57wxString wxNow();
58bool wxShell(const wxString& command = wxPyEmptyString);
59void wxStartTimer();
322913ce
RD
60
61DocDeclA(
62 int, wxGetOsVersion(int *OUTPUT, int *OUTPUT),
63 "GetOsVersion() -> (platform, major, minor)");
64
d14a1e28
RD
65wxString wxGetOsDescription();
66
03d51a2d
RD
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"
daf32463 73// int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters);
03d51a2d 74
d14a1e28 75#if defined(__WXMSW__) || defined(__WXMAC__)
e88df737 76wxMemorySize wxGetFreeMemory();
d14a1e28
RD
77#else
78%inline %{
e88df737 79 wxMemorySize wxGetFreeMemory()
81cfe5e1 80 { wxPyRaiseNotImplemented(); return 0; }
d14a1e28
RD
81%}
82#endif
83
84enum wxShutdownFlags
85{
86 wxSHUTDOWN_POWEROFF, // power off the computer
87 wxSHUTDOWN_REBOOT // shutdown and reboot
88};
89
90// Shutdown or reboot the PC
ab1f7d2a 91MustHaveApp(wxShutdown);
d14a1e28
RD
92bool wxShutdown(wxShutdownFlags wFlags);
93
94
95void wxSleep(int secs);
705b61cc
RD
96void wxMilliSleep(unsigned long milliseconds);
97void wxMicroSleep(unsigned long microseconds);
98%pythoncode { Usleep = MilliSleep }
99
d14a1e28
RD
100void wxEnableTopLevelWindows(bool enable);
101
102wxString wxStripMenuCodes(const wxString& in);
103
104
105wxString wxGetEmailAddress();
106wxString wxGetHostName();
107wxString wxGetFullHostName();
108wxString wxGetUserId();
109wxString wxGetUserName();
110wxString wxGetHomeDir();
111wxString wxGetUserHome(const wxString& user = wxPyEmptyString);
112
113unsigned long wxGetProcessId();
114
115void wxTrap();
116
117
118// Dialog Functions
119
ab1f7d2a 120MustHaveApp(wxFileSelector);
d14a1e28
RD
121wxString 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
ab1f7d2a 134MustHaveApp(wxLoadFileSelector);
d14a1e28
RD
135wxString 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
ab1f7d2a 141MustHaveApp(wxSaveFileSelector);
d14a1e28
RD
142wxString wxSaveFileSelector(const wxString& what,
143 const wxString& extension,
144 const wxString& default_name = wxPyEmptyString,
145 wxWindow *parent = NULL);
146
147
ab1f7d2a 148MustHaveApp(wxDirSelector);
d14a1e28
RD
149wxString 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
ab1f7d2a 155MustHaveApp(wxGetTextFromUser);
d14a1e28
RD
156wxString 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,
a72f4631 161 bool centre = true);
d14a1e28 162
ab1f7d2a 163MustHaveApp(wxGetPasswordFromUser);
d14a1e28
RD
164wxString 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,
a72f4631 175// bool centre = true, int width=150, int height=200);
d14a1e28
RD
176
177
ab1f7d2a 178MustHaveApp(wxGetSingleChoice);
d14a1e28
RD
179wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
180 int choices, wxString* choices_array,
181 wxWindow *parent = NULL,
182 int x = -1, int y = -1,
a72f4631 183 bool centre = true,
d14a1e28
RD
184 int width=150, int height=200);
185
ab1f7d2a 186MustHaveApp(wxGetSingleChoiceIndex);
d14a1e28
RD
187int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
188 int choices, wxString* choices_array,
189 wxWindow *parent = NULL,
190 int x = -1, int y = -1,
a72f4631 191 bool centre = true,
d14a1e28
RD
192 int width=150, int height=200);
193
194
ab1f7d2a 195MustHaveApp(wxMessageBox);
d14a1e28
RD
196int 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
aeee37c3 202// WXWIN_COMPATIBILITY_2_4
2f91e3df 203#if 0
ab1f7d2a 204MustHaveApp(wxGetNumberFromUser);
d14a1e28
RD
205long 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);
02b800ce 212%pythoncode { GetNumberFromUser = wx._deprecated(GetNumberFromUser) }
2f91e3df 213#endif
02b800ce 214
d14a1e28
RD
215// GDI Functions
216
ab1f7d2a 217MustHaveApp(wxColourDisplay);
d14a1e28
RD
218bool wxColourDisplay();
219
ab1f7d2a 220MustHaveApp(wxDisplayDepth);
d14a1e28 221int wxDisplayDepth();
ab1f7d2a
RD
222
223MustHaveApp(wxGetDisplayDepth);
d14a1e28
RD
224int wxGetDisplayDepth();
225
ab1f7d2a 226MustHaveApp(wxDisplaySize);
322913ce
RD
227DocDeclA(
228 void, wxDisplaySize(int* OUTPUT, int* OUTPUT),
229 "DisplaySize() -> (width, height)");
ab1f7d2a
RD
230
231MustHaveApp(wxGetDisplaySize);
d14a1e28
RD
232wxSize wxGetDisplaySize();
233
ab1f7d2a 234MustHaveApp(wxDisplaySizeMM);
322913ce
RD
235DocDeclA(
236 void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT),
237 "DisplaySizeMM() -> (width, height)");
ab1f7d2a
RD
238
239MustHaveApp(wxGetDisplaySizeMM);
d14a1e28
RD
240wxSize wxGetDisplaySizeMM();
241
ab1f7d2a 242MustHaveApp(wxClientDisplayRect);
322913ce
RD
243DocDeclA(
244 void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
245 "ClientDisplayRect() -> (x, y, width, height)");
ab1f7d2a
RD
246
247MustHaveApp(wxGetClientDisplayRect);
d14a1e28
RD
248wxRect wxGetClientDisplayRect();
249
ab1f7d2a
RD
250
251MustHaveApp(wxSetCursor);
d14a1e28
RD
252void wxSetCursor(wxCursor& cursor);
253
254
2327fb3b
RD
255MustHaveApp(wxGetXDisplay);
256DocStr(wxGetXDisplay,
257"Returns a swigified pointer to the X11 display. Returns None on
258other platforms.", "");
259%inline %{
260 void* wxGetXDisplay()
261 {
262#ifdef __WXGTK__
263 return wxGetDisplay();
264#else
265 return NULL;
266#endif
267 }
268%}
269
d14a1e28
RD
270
271// Miscellaneous functions
272
ab1f7d2a 273MustHaveApp(wxBeginBusyCursor);
d14a1e28 274void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
ab1f7d2a 275
095315e2
RD
276
277MustHaveApp(wxGetMousePosition);
278DocDeclStr(
279 wxPoint, wxGetMousePosition(),
280 "Get the current mouse position on the screen.", "");
281
282MustHaveApp(FindWindowAtPointer);
283DocStr(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
ab1f7d2a 294MustHaveApp(wxGetActiveWindow);
095315e2
RD
295DocDeclStr(
296 wxWindow *, wxGetActiveWindow(),
297 "Get the currently active window of this application, or None", "");
298
d14a1e28 299
ab1f7d2a 300MustHaveApp(wxGenericFindWindowAtPoint);
d14a1e28 301wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
ab1f7d2a
RD
302
303MustHaveApp(wxFindWindowAtPoint);
d14a1e28
RD
304wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
305
ab1f7d2a 306MustHaveApp(wxGetTopLevelParent);
d14a1e28
RD
307wxWindow* wxGetTopLevelParent(wxWindow *win);
308
d14a1e28 309
aa2fc802
RD
310DocDeclStr(
311 bool , wxLaunchDefaultBrowser(const wxString& url),
312 "Launches the user's default browser and tells it to open the location
313at ``url``. Returns ``True`` if the application was successfully
314launched.", "");
d14a1e28
RD
315
316
89c876de 317
ab1f7d2a 318MustHaveApp(wxGetKeyState);
ad411ab2
RD
319DocDeclStr(
320 bool , wxGetKeyState(wxKeyCode key),
321 "Get the state of a key (true if pressed or toggled on, false if not.)
322This is generally most useful getting the state of the modifier or
095315e2
RD
323toggle keys. On some platforms those may be the only keys that this
324function is able to detect.
ad411ab2
RD
325", "");
326
57b1892f
RD
327
328
095315e2
RD
329//---------------------------------------------------------------------------
330
331DocStr(wxMouseState,
332"`wx.MouseState` is used to hold information about mouse button and
333modifier key states and is what is returned from `wx.GetMouseState`.",
334"");
335
336class wxMouseState
337{
338public:
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
382DocDeclStr(
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
386pointer in screen coordinants, as well as boolean values indicating
387the up/down status of the mouse buttons and the modifier keys.", "");
388
389
d14a1e28
RD
390//---------------------------------------------------------------------------
391
ab1f7d2a
RD
392MustHaveApp(wxWakeUpMainThread);
393
d14a1e28
RD
394#if defined(__WXMSW__) || defined(__WXMAC__)
395void wxWakeUpMainThread();
396#else
397%inline %{
398 void wxWakeUpMainThread() {}
399%}
400#endif
401
ab1f7d2a
RD
402
403MustHaveApp(wxMutexGuiEnter);
d14a1e28 404void wxMutexGuiEnter();
ab1f7d2a
RD
405
406MustHaveApp(wxMutexGuiLeave);
d14a1e28
RD
407void wxMutexGuiLeave();
408
409
ab1f7d2a 410MustHaveApp(wxMutexGuiLocker);
d14a1e28
RD
411class wxMutexGuiLocker {
412public:
413 wxMutexGuiLocker();
414 ~wxMutexGuiLocker();
415};
416
417
ab1f7d2a 418MustHaveApp(wxThread);
d14a1e28
RD
419%inline %{
420 bool wxThread_IsMain() {
421#ifdef WXP_WITH_THREAD
422 return wxThread::IsMain();
423#else
a72f4631 424 return true;
d14a1e28
RD
425#endif
426 }
427%}
428
aeee37c3
RD
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
d14a1e28
RD
464//---------------------------------------------------------------------------
465//---------------------------------------------------------------------------