]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_functions.i
save a reference to the bitmap so it doesn't get destroyed before the
[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 enum 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".
61 wxString wxGetStockHelpString(wxWindowID id,
62 wxStockHelpStringClient client = wxSTOCK_MENU);
63
64
65
66
67 MustHaveApp(wxBell);
68 void wxBell();
69
70 MustHaveApp(wxEndBusyCursor);
71 void wxEndBusyCursor();
72
73 long wxGetElapsedTime(bool resetTimer = true);
74 %pythoncode { GetElapsedTime = wx._deprecated(GetElapsedTime) }
75
76 bool wxIsBusy();
77 wxString wxNow();
78 bool wxShell(const wxString& command = wxPyEmptyString);
79 void wxStartTimer();
80
81
82 DocDeclA(
83 int, wxGetOsVersion(int *OUTPUT, int *OUTPUT),
84 "GetOsVersion() -> (platform, major, minor)");
85
86 wxString wxGetOsDescription();
87
88
89 // Get platform endianness
90 bool wxIsPlatformLittleEndian();
91
92 // Get platform architecture
93 bool wxIsPlatform64Bit();
94
95
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"
102 // int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters);
103
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
113 #if defined(__WXMSW__) || defined(__WXMAC__)
114 wxMemorySize wxGetFreeMemory();
115 #else
116 %inline %{
117 wxMemorySize wxGetFreeMemory()
118 { wxPyRaiseNotImplemented(); return 0; }
119 %}
120 #endif
121
122 enum wxShutdownFlags
123 {
124 wxSHUTDOWN_POWEROFF, // power off the computer
125 wxSHUTDOWN_REBOOT // shutdown and reboot
126 };
127
128 // Shutdown or reboot the PC
129 MustHaveApp(wxShutdown);
130 bool wxShutdown(wxShutdownFlags wFlags);
131
132
133 void wxSleep(int secs);
134 void wxMilliSleep(unsigned long milliseconds);
135 void wxMicroSleep(unsigned long microseconds);
136 %pythoncode { Usleep = MilliSleep }
137
138 void wxEnableTopLevelWindows(bool enable);
139
140 wxString wxStripMenuCodes(const wxString& in);
141
142
143 wxString wxGetEmailAddress();
144 wxString wxGetHostName();
145 wxString wxGetFullHostName();
146 wxString wxGetUserId();
147 wxString wxGetUserName();
148 wxString wxGetHomeDir();
149 wxString wxGetUserHome(const wxString& user = wxPyEmptyString);
150
151 unsigned long wxGetProcessId();
152
153 void wxTrap();
154
155
156 // Dialog Functions
157
158 MustHaveApp(wxFileSelector);
159 wxString 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
172 MustHaveApp(wxLoadFileSelector);
173 wxString 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
179 MustHaveApp(wxSaveFileSelector);
180 wxString wxSaveFileSelector(const wxString& what,
181 const wxString& extension,
182 const wxString& default_name = wxPyEmptyString,
183 wxWindow *parent = NULL);
184
185
186 MustHaveApp(wxDirSelector);
187 wxString 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
193 MustHaveApp(wxGetTextFromUser);
194 wxString 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,
199 bool centre = true);
200
201 MustHaveApp(wxGetPasswordFromUser);
202 wxString 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,
213 // bool centre = true, int width=150, int height=200);
214
215
216 MustHaveApp(wxGetSingleChoice);
217 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
218 int choices, wxString* choices_array,
219 wxWindow *parent = NULL,
220 int x = -1, int y = -1,
221 bool centre = true,
222 int width=150, int height=200);
223
224 MustHaveApp(wxGetSingleChoiceIndex);
225 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
226 int choices, wxString* choices_array,
227 wxWindow *parent = NULL,
228 int x = -1, int y = -1,
229 bool centre = true,
230 int width=150, int height=200);
231
232
233 MustHaveApp(wxMessageBox);
234 int 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
240 MustHaveApp(wxGetNumberFromUser);
241 long 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);
248
249 // GDI Functions
250
251 MustHaveApp(wxColourDisplay);
252 bool wxColourDisplay();
253
254 MustHaveApp(wxDisplayDepth);
255 int wxDisplayDepth();
256
257 MustHaveApp(wxGetDisplayDepth);
258 int wxGetDisplayDepth();
259
260 MustHaveApp(wxDisplaySize);
261 DocDeclA(
262 void, wxDisplaySize(int* OUTPUT, int* OUTPUT),
263 "DisplaySize() -> (width, height)");
264
265 MustHaveApp(wxGetDisplaySize);
266 wxSize wxGetDisplaySize();
267
268 MustHaveApp(wxDisplaySizeMM);
269 DocDeclA(
270 void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT),
271 "DisplaySizeMM() -> (width, height)");
272
273 MustHaveApp(wxGetDisplaySizeMM);
274 wxSize wxGetDisplaySizeMM();
275
276 MustHaveApp(wxClientDisplayRect);
277 DocDeclA(
278 void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
279 "ClientDisplayRect() -> (x, y, width, height)");
280
281 MustHaveApp(wxGetClientDisplayRect);
282 wxRect wxGetClientDisplayRect();
283
284
285 MustHaveApp(wxSetCursor);
286 void wxSetCursor(wxCursor& cursor);
287
288
289 MustHaveApp(wxGetXDisplay);
290 DocStr(wxGetXDisplay,
291 "Returns a swigified pointer to the X11 display. Returns None on
292 other platforms.", "");
293 %inline %{
294 void* wxGetXDisplay()
295 {
296 #ifdef __WXGTK__
297 return wxGetDisplay();
298 #else
299 return NULL;
300 #endif
301 }
302 %}
303
304
305 // Miscellaneous functions
306
307 MustHaveApp(wxBeginBusyCursor);
308 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
309
310
311 MustHaveApp(wxGetMousePosition);
312 DocDeclStr(
313 wxPoint, wxGetMousePosition(),
314 "Get the current mouse position on the screen.", "");
315
316 MustHaveApp(FindWindowAtPointer);
317 DocStr(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
328 MustHaveApp(wxGetActiveWindow);
329 DocDeclStr(
330 wxWindow *, wxGetActiveWindow(),
331 "Get the currently active window of this application, or None", "");
332
333
334 MustHaveApp(wxGenericFindWindowAtPoint);
335 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
336
337 MustHaveApp(wxFindWindowAtPoint);
338 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
339
340 MustHaveApp(wxGetTopLevelParent);
341 wxWindow* wxGetTopLevelParent(wxWindow *win);
342
343
344 DocDeclStr(
345 bool , wxLaunchDefaultBrowser(const wxString& url),
346 "Launches the user's default browser and tells it to open the location
347 at ``url``. Returns ``True`` if the application was successfully
348 launched.", "");
349
350
351
352 MustHaveApp(wxGetKeyState);
353 DocDeclStr(
354 bool , wxGetKeyState(wxKeyCode key),
355 "Get the state of a key (true if pressed or toggled on, false if not.)
356 This is generally most useful getting the state of the modifier or
357 toggle keys. On some platforms those may be the only keys that this
358 function is able to detect.
359 ", "");
360
361
362
363 //---------------------------------------------------------------------------
364
365 DocStr(wxMouseState,
366 "`wx.MouseState` is used to hold information about mouse button and
367 modifier key states and is what is returned from `wx.GetMouseState`.",
368 "");
369
370 class wxMouseState
371 {
372 public:
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
416 DocDeclStr(
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
420 pointer in screen coordinants, as well as boolean values indicating
421 the up/down status of the mouse buttons and the modifier keys.", "");
422
423
424 //---------------------------------------------------------------------------
425
426 MustHaveApp(wxWakeUpMainThread);
427
428 #if defined(__WXMSW__) || defined(__WXMAC__)
429 void wxWakeUpMainThread();
430 #else
431 %inline %{
432 void wxWakeUpMainThread() {}
433 %}
434 #endif
435
436
437 MustHaveApp(wxMutexGuiEnter);
438 void wxMutexGuiEnter();
439
440 MustHaveApp(wxMutexGuiLeave);
441 void wxMutexGuiLeave();
442
443
444 MustHaveApp(wxMutexGuiLocker);
445 class wxMutexGuiLocker {
446 public:
447 wxMutexGuiLocker();
448 ~wxMutexGuiLocker();
449 };
450
451
452 MustHaveApp(wxThread);
453 %inline %{
454 bool wxThread_IsMain() {
455 #ifdef WXP_WITH_THREAD
456 return wxThread::IsMain();
457 #else
458 return true;
459 #endif
460 }
461 %}
462
463 //---------------------------------------------------------------------------
464 //---------------------------------------------------------------------------