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