]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_functions.i
Move the language catalogs install directory on MSW from 'locale' to
[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 // Returns label that should be used for given stock UI element (e.g. "&OK"
42 // for wxID_OK):
43 wxString wxGetStockLabel(wxWindowID id,
44 bool withCodes = true,
45 wxString accelerator = wxPyEmptyString);
46
47
48 MustHaveApp(wxBell);
49 void wxBell();
50
51 MustHaveApp(wxEndBusyCursor);
52 void wxEndBusyCursor();
53
54 long wxGetElapsedTime(bool resetTimer = true);
55 %pythoncode { GetElapsedTime = wx._deprecated(GetElapsedTime) }
56
57 bool wxIsBusy();
58 wxString wxNow();
59 bool wxShell(const wxString& command = wxPyEmptyString);
60 void wxStartTimer();
61
62
63 DocDeclA(
64 int, wxGetOsVersion(int *OUTPUT, int *OUTPUT),
65 "GetOsVersion() -> (platform, major, minor)");
66
67 wxString wxGetOsDescription();
68
69
70 // Get platform endianness
71 bool wxIsPlatformLittleEndian();
72
73 // Get platform architecture
74 bool wxIsPlatform64Bit();
75
76
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"
83 // int wxParseCommonDialogsFilter(const wxString& wildCard, wxArrayString& descriptions, wxArrayString& filters);
84
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
94 #if defined(__WXMSW__) || defined(__WXMAC__)
95 wxMemorySize wxGetFreeMemory();
96 #else
97 %inline %{
98 wxMemorySize wxGetFreeMemory()
99 { wxPyRaiseNotImplemented(); return 0; }
100 %}
101 #endif
102
103 enum wxShutdownFlags
104 {
105 wxSHUTDOWN_POWEROFF, // power off the computer
106 wxSHUTDOWN_REBOOT // shutdown and reboot
107 };
108
109 // Shutdown or reboot the PC
110 MustHaveApp(wxShutdown);
111 bool wxShutdown(wxShutdownFlags wFlags);
112
113
114 void wxSleep(int secs);
115 void wxMilliSleep(unsigned long milliseconds);
116 void wxMicroSleep(unsigned long microseconds);
117 %pythoncode { Usleep = MilliSleep }
118
119 void wxEnableTopLevelWindows(bool enable);
120
121 wxString wxStripMenuCodes(const wxString& in);
122
123
124 wxString wxGetEmailAddress();
125 wxString wxGetHostName();
126 wxString wxGetFullHostName();
127 wxString wxGetUserId();
128 wxString wxGetUserName();
129 wxString wxGetHomeDir();
130 wxString wxGetUserHome(const wxString& user = wxPyEmptyString);
131
132 unsigned long wxGetProcessId();
133
134 void wxTrap();
135
136
137 // Dialog Functions
138
139 MustHaveApp(wxFileSelector);
140 wxString 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
153 MustHaveApp(wxLoadFileSelector);
154 wxString 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
160 MustHaveApp(wxSaveFileSelector);
161 wxString wxSaveFileSelector(const wxString& what,
162 const wxString& extension,
163 const wxString& default_name = wxPyEmptyString,
164 wxWindow *parent = NULL);
165
166
167 MustHaveApp(wxDirSelector);
168 wxString 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
174 MustHaveApp(wxGetTextFromUser);
175 wxString 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,
180 bool centre = true);
181
182 MustHaveApp(wxGetPasswordFromUser);
183 wxString 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,
194 // bool centre = true, int width=150, int height=200);
195
196
197 MustHaveApp(wxGetSingleChoice);
198 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
199 int choices, wxString* choices_array,
200 wxWindow *parent = NULL,
201 int x = -1, int y = -1,
202 bool centre = true,
203 int width=150, int height=200);
204
205 MustHaveApp(wxGetSingleChoiceIndex);
206 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
207 int choices, wxString* choices_array,
208 wxWindow *parent = NULL,
209 int x = -1, int y = -1,
210 bool centre = true,
211 int width=150, int height=200);
212
213
214 MustHaveApp(wxMessageBox);
215 int 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
221 MustHaveApp(wxGetNumberFromUser);
222 long 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);
229
230 // GDI Functions
231
232 MustHaveApp(wxColourDisplay);
233 bool wxColourDisplay();
234
235 MustHaveApp(wxDisplayDepth);
236 int wxDisplayDepth();
237
238 MustHaveApp(wxGetDisplayDepth);
239 int wxGetDisplayDepth();
240
241 MustHaveApp(wxDisplaySize);
242 DocDeclA(
243 void, wxDisplaySize(int* OUTPUT, int* OUTPUT),
244 "DisplaySize() -> (width, height)");
245
246 MustHaveApp(wxGetDisplaySize);
247 wxSize wxGetDisplaySize();
248
249 MustHaveApp(wxDisplaySizeMM);
250 DocDeclA(
251 void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT),
252 "DisplaySizeMM() -> (width, height)");
253
254 MustHaveApp(wxGetDisplaySizeMM);
255 wxSize wxGetDisplaySizeMM();
256
257 MustHaveApp(wxClientDisplayRect);
258 DocDeclA(
259 void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
260 "ClientDisplayRect() -> (x, y, width, height)");
261
262 MustHaveApp(wxGetClientDisplayRect);
263 wxRect wxGetClientDisplayRect();
264
265
266 MustHaveApp(wxSetCursor);
267 void wxSetCursor(wxCursor& cursor);
268
269
270 MustHaveApp(wxGetXDisplay);
271 DocStr(wxGetXDisplay,
272 "Returns a swigified pointer to the X11 display. Returns None on
273 other platforms.", "");
274 %inline %{
275 void* wxGetXDisplay()
276 {
277 #ifdef __WXGTK__
278 return wxGetDisplay();
279 #else
280 return NULL;
281 #endif
282 }
283 %}
284
285
286 // Miscellaneous functions
287
288 MustHaveApp(wxBeginBusyCursor);
289 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
290
291
292 MustHaveApp(wxGetMousePosition);
293 DocDeclStr(
294 wxPoint, wxGetMousePosition(),
295 "Get the current mouse position on the screen.", "");
296
297 MustHaveApp(FindWindowAtPointer);
298 DocStr(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
309 MustHaveApp(wxGetActiveWindow);
310 DocDeclStr(
311 wxWindow *, wxGetActiveWindow(),
312 "Get the currently active window of this application, or None", "");
313
314
315 MustHaveApp(wxGenericFindWindowAtPoint);
316 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
317
318 MustHaveApp(wxFindWindowAtPoint);
319 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
320
321 MustHaveApp(wxGetTopLevelParent);
322 wxWindow* wxGetTopLevelParent(wxWindow *win);
323
324
325 DocDeclStr(
326 bool , wxLaunchDefaultBrowser(const wxString& url),
327 "Launches the user's default browser and tells it to open the location
328 at ``url``. Returns ``True`` if the application was successfully
329 launched.", "");
330
331
332
333 MustHaveApp(wxGetKeyState);
334 DocDeclStr(
335 bool , wxGetKeyState(wxKeyCode key),
336 "Get the state of a key (true if pressed or toggled on, false if not.)
337 This is generally most useful getting the state of the modifier or
338 toggle keys. On some platforms those may be the only keys that this
339 function is able to detect.
340 ", "");
341
342
343
344 //---------------------------------------------------------------------------
345
346 DocStr(wxMouseState,
347 "`wx.MouseState` is used to hold information about mouse button and
348 modifier key states and is what is returned from `wx.GetMouseState`.",
349 "");
350
351 class wxMouseState
352 {
353 public:
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
397 DocDeclStr(
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
401 pointer in screen coordinants, as well as boolean values indicating
402 the up/down status of the mouse buttons and the modifier keys.", "");
403
404
405 //---------------------------------------------------------------------------
406
407 MustHaveApp(wxWakeUpMainThread);
408
409 #if defined(__WXMSW__) || defined(__WXMAC__)
410 void wxWakeUpMainThread();
411 #else
412 %inline %{
413 void wxWakeUpMainThread() {}
414 %}
415 #endif
416
417
418 MustHaveApp(wxMutexGuiEnter);
419 void wxMutexGuiEnter();
420
421 MustHaveApp(wxMutexGuiLeave);
422 void wxMutexGuiLeave();
423
424
425 MustHaveApp(wxMutexGuiLocker);
426 class wxMutexGuiLocker {
427 public:
428 wxMutexGuiLocker();
429 ~wxMutexGuiLocker();
430 };
431
432
433 MustHaveApp(wxThread);
434 %inline %{
435 bool wxThread_IsMain() {
436 #ifdef WXP_WITH_THREAD
437 return wxThread::IsMain();
438 #else
439 return true;
440 #endif
441 }
442 %}
443
444 //---------------------------------------------------------------------------
445 //---------------------------------------------------------------------------