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