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