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