1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface defs for various functions and such
7 // Created: 3-July-1997
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include <wx/stockitem.h>
20 //---------------------------------------------------------------------------
22 MAKE_CONST_WXSTRING(FileSelectorPromptStr);
23 MAKE_CONST_WXSTRING(FileSelectorDefaultWildcardStr);
24 MAKE_CONST_WXSTRING(DirSelectorPromptStr);
26 //---------------------------------------------------------------------------
31 void wxRegisterId(long id);
32 long wxGetCurrentId();
34 // Returns true if the ID is in the list of recognized stock actions
35 bool wxIsStockID(wxWindowID id);
37 // Returns true of the label is empty or label of a stock button with
39 bool wxIsStockLabel(wxWindowID id, const wxString& label);
41 enum wxStockLabelQueryFlag
45 wxSTOCK_WITH_MNEMONIC = 1,
46 wxSTOCK_WITH_ACCELERATOR = 2
49 // Returns label that should be used for given stock UI element (e.g. "&OK"
51 wxString wxGetStockLabel(wxWindowID id,
52 long flags = wxSTOCK_WITH_MNEMONIC);
58 MustHaveApp(wxEndBusyCursor);
59 void wxEndBusyCursor();
61 long wxGetElapsedTime(bool resetTimer = true);
62 %pythoncode { GetElapsedTime = wx._deprecated(GetElapsedTime) }
66 bool wxShell(const wxString& command = wxPyEmptyString);
71 int, wxGetOsVersion(int *OUTPUT, int *OUTPUT),
72 "GetOsVersion() -> (platform, major, minor)");
74 wxString wxGetOsDescription();
77 // Get platform endianness
78 bool wxIsPlatformLittleEndian();
80 // Get platform architecture
81 bool wxIsPlatform64Bit();
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);
93 %typemap(out) wxMemorySize {
95 $result = PyLong_FromLongLong($1.GetValue());
97 $result = PyInt_FromLong($1);
101 #if defined(__WXMSW__) || defined(__WXMAC__)
102 wxMemorySize wxGetFreeMemory();
105 wxMemorySize wxGetFreeMemory()
106 { wxPyRaiseNotImplemented(); return 0; }
112 wxSHUTDOWN_POWEROFF, // power off the computer
113 wxSHUTDOWN_REBOOT // shutdown and reboot
116 // Shutdown or reboot the PC
117 MustHaveApp(wxShutdown);
118 bool wxShutdown(wxShutdownFlags wFlags);
121 void wxSleep(int secs);
122 void wxMilliSleep(unsigned long milliseconds);
123 void wxMicroSleep(unsigned long microseconds);
124 %pythoncode { Usleep = MilliSleep }
126 void wxEnableTopLevelWindows(bool enable);
128 wxString wxStripMenuCodes(const wxString& in);
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);
139 unsigned long wxGetProcessId();
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,
153 wxWindow *parent = NULL,
154 int x = -1, int y = -1);
156 // TODO: wxFileSelectorEx
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);
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);
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);
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,
189 MustHaveApp(wxGetPasswordFromUser);
190 wxString wxGetPasswordFromUser(const wxString& message,
191 const wxString& caption = wxPyEmptyString,
192 const wxString& default_value = wxPyEmptyString,
193 wxWindow *parent = NULL);
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);
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,
210 int width=150, int height=200);
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,
218 int width=150, int height=200);
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);
228 MustHaveApp(wxGetNumberFromUser);
229 long wxGetNumberFromUser(const wxString& message,
230 const wxString& prompt,
231 const wxString& caption,
233 long min = 0, long max = 100,
234 wxWindow *parent = NULL,
235 const wxPoint& pos = wxDefaultPosition);
239 MustHaveApp(wxColourDisplay);
240 bool wxColourDisplay();
242 MustHaveApp(wxDisplayDepth);
243 int wxDisplayDepth();
245 MustHaveApp(wxGetDisplayDepth);
246 int wxGetDisplayDepth();
248 MustHaveApp(wxDisplaySize);
250 void, wxDisplaySize(int* OUTPUT, int* OUTPUT),
251 "DisplaySize() -> (width, height)");
253 MustHaveApp(wxGetDisplaySize);
254 wxSize wxGetDisplaySize();
256 MustHaveApp(wxDisplaySizeMM);
258 void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT),
259 "DisplaySizeMM() -> (width, height)");
261 MustHaveApp(wxGetDisplaySizeMM);
262 wxSize wxGetDisplaySizeMM();
264 MustHaveApp(wxClientDisplayRect);
266 void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
267 "ClientDisplayRect() -> (x, y, width, height)");
269 MustHaveApp(wxGetClientDisplayRect);
270 wxRect wxGetClientDisplayRect();
273 MustHaveApp(wxSetCursor);
274 void wxSetCursor(wxCursor& cursor);
277 MustHaveApp(wxGetXDisplay);
278 DocStr(wxGetXDisplay,
279 "Returns a swigified pointer to the X11 display. Returns None on
280 other platforms.", "");
282 void* wxGetXDisplay()
285 return wxGetDisplay();
293 // Miscellaneous functions
295 MustHaveApp(wxBeginBusyCursor);
296 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
299 MustHaveApp(wxGetMousePosition);
301 wxPoint, wxGetMousePosition(),
302 "Get the current mouse position on the screen.", "");
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.", "");
309 wxWindow* FindWindowAtPointer() {
311 return wxFindWindowAtPointer(unused);
316 MustHaveApp(wxGetActiveWindow);
318 wxWindow *, wxGetActiveWindow(),
319 "Get the currently active window of this application, or None", "");
322 MustHaveApp(wxGenericFindWindowAtPoint);
323 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
325 MustHaveApp(wxFindWindowAtPoint);
326 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
328 MustHaveApp(wxGetTopLevelParent);
329 wxWindow* wxGetTopLevelParent(wxWindow *win);
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
340 MustHaveApp(wxGetKeyState);
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.
351 //---------------------------------------------------------------------------
354 "`wx.MouseState` is used to hold information about mouse button and
355 modifier key states and is what is returned from `wx.GetMouseState`.",
377 void SetX(wxCoord x);
378 void SetY(wxCoord y);
380 void SetLeftDown(bool down);
381 void SetMiddleDown(bool down);
382 void SetRightDown(bool down);
384 void SetControlDown(bool down);
385 void SetShiftDown(bool down);
386 void SetAltDown(bool down);
387 void SetMetaDown(bool down);
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)
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.", "");
412 //---------------------------------------------------------------------------
414 MustHaveApp(wxWakeUpMainThread);
416 #if defined(__WXMSW__) || defined(__WXMAC__)
417 void wxWakeUpMainThread();
420 void wxWakeUpMainThread() {}
425 MustHaveApp(wxMutexGuiEnter);
426 void wxMutexGuiEnter();
428 MustHaveApp(wxMutexGuiLeave);
429 void wxMutexGuiLeave();
432 MustHaveApp(wxMutexGuiLocker);
433 class wxMutexGuiLocker {
440 MustHaveApp(wxThread);
442 bool wxThread_IsMain() {
443 #ifdef WXP_WITH_THREAD
444 return wxThread::IsMain();
451 //---------------------------------------------------------------------------
452 //---------------------------------------------------------------------------