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);
 
  55 enum wxStockHelpStringClient
 
  57     wxSTOCK_MENU        // help string to use for menu items
 
  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);
 
  70 MustHaveApp(wxEndBusyCursor);
 
  71 void wxEndBusyCursor();
 
  73 long wxGetElapsedTime(bool resetTimer = true);
 
  74 %pythoncode { GetElapsedTime = wx._deprecated(GetElapsedTime) }
 
  78 bool wxShell(const wxString& command = wxPyEmptyString);
 
  83     int, wxGetOsVersion(int *OUTPUT, int *OUTPUT),
 
  84     "GetOsVersion() -> (platform, major, minor)");
 
  86 wxString wxGetOsDescription();
 
  89 // Get platform endianness
 
  90 bool wxIsPlatformLittleEndian();
 
  92 // Get platform architecture
 
  93 bool wxIsPlatform64Bit();
 
  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);
 
 105 %typemap(out) wxMemorySize {
 
 107          $result = PyLong_FromLongLong($1.GetValue());
 
 109          $result = PyInt_FromLong($1);
 
 113 #if defined(__WXMSW__) || defined(__WXMAC__)
 
 114 wxMemorySize wxGetFreeMemory();
 
 117     wxMemorySize wxGetFreeMemory()
 
 118         { wxPyRaiseNotImplemented(); return 0; }
 
 124     wxSHUTDOWN_POWEROFF,    // power off the computer
 
 125     wxSHUTDOWN_REBOOT       // shutdown and reboot
 
 128 // Shutdown or reboot the PC
 
 129 MustHaveApp(wxShutdown);
 
 130 bool wxShutdown(wxShutdownFlags wFlags);
 
 133 void wxSleep(int secs);
 
 134 void wxMilliSleep(unsigned long milliseconds);
 
 135 void wxMicroSleep(unsigned long microseconds);
 
 136 %pythoncode { Usleep = MilliSleep }
 
 138 void wxEnableTopLevelWindows(bool enable);
 
 140 wxString wxStripMenuCodes(const wxString& in);
 
 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);
 
 151 unsigned long wxGetProcessId();
 
 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,
 
 165                         wxWindow *parent = NULL,
 
 166                         int x = -1, int y = -1);
 
 168 // TODO: wxFileSelectorEx
 
 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);
 
 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);
 
 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);
 
 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,
 
 201 MustHaveApp(wxGetPasswordFromUser);
 
 202 wxString wxGetPasswordFromUser(const wxString& message,
 
 203                                const wxString& caption = wxPyEmptyString,
 
 204                                const wxString& default_value = wxPyEmptyString,
 
 205                                wxWindow *parent = NULL);
 
 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);
 
 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,
 
 222                            int width=150, int height=200);
 
 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,
 
 230                            int width=150, int height=200);
 
 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);
 
 240 MustHaveApp(wxGetNumberFromUser);
 
 241 long wxGetNumberFromUser(const wxString& message,
 
 242                          const wxString& prompt,
 
 243                          const wxString& caption,
 
 245                          long min = 0, long max = 100,
 
 246                          wxWindow *parent = NULL,
 
 247                          const wxPoint& pos = wxDefaultPosition);
 
 251 MustHaveApp(wxColourDisplay);
 
 252 bool wxColourDisplay();
 
 254 MustHaveApp(wxDisplayDepth);
 
 255 int wxDisplayDepth();
 
 257 MustHaveApp(wxGetDisplayDepth);
 
 258 int wxGetDisplayDepth();
 
 260 MustHaveApp(wxDisplaySize);
 
 262     void, wxDisplaySize(int* OUTPUT, int* OUTPUT),
 
 263     "DisplaySize() -> (width, height)");
 
 265 MustHaveApp(wxGetDisplaySize);
 
 266 wxSize wxGetDisplaySize();
 
 268 MustHaveApp(wxDisplaySizeMM);
 
 270     void, wxDisplaySizeMM(int* OUTPUT, int* OUTPUT),
 
 271     "DisplaySizeMM() -> (width, height)");
 
 273 MustHaveApp(wxGetDisplaySizeMM);
 
 274 wxSize wxGetDisplaySizeMM();
 
 276 MustHaveApp(wxClientDisplayRect);
 
 278     void, wxClientDisplayRect(int *OUTPUT, int *OUTPUT, int *OUTPUT, int *OUTPUT),
 
 279     "ClientDisplayRect() -> (x, y, width, height)");
 
 281 MustHaveApp(wxGetClientDisplayRect);
 
 282 wxRect wxGetClientDisplayRect();
 
 285 MustHaveApp(wxSetCursor);
 
 286 void wxSetCursor(wxCursor& cursor);
 
 289 MustHaveApp(wxGetXDisplay);
 
 290 DocStr(wxGetXDisplay,
 
 291 "Returns a swigified pointer to the X11 display.  Returns None on
 
 292 other platforms.", "");
 
 294     void* wxGetXDisplay()
 
 297         return wxGetDisplay();
 
 305 // Miscellaneous functions
 
 307 MustHaveApp(wxBeginBusyCursor);
 
 308 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
 
 311 MustHaveApp(wxGetMousePosition);
 
 313     wxPoint, wxGetMousePosition(),
 
 314     "Get the current mouse position on the screen.", "");
 
 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.", "");
 
 321     wxWindow* FindWindowAtPointer() {
 
 323         return wxFindWindowAtPointer(unused);
 
 328 MustHaveApp(wxGetActiveWindow);
 
 330     wxWindow *, wxGetActiveWindow(),
 
 331     "Get the currently active window of this application, or None", "");
 
 334 MustHaveApp(wxGenericFindWindowAtPoint);
 
 335 wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
 
 337 MustHaveApp(wxFindWindowAtPoint);
 
 338 wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
 
 340 MustHaveApp(wxGetTopLevelParent);
 
 341 wxWindow* wxGetTopLevelParent(wxWindow *win);
 
 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
 
 352 MustHaveApp(wxGetKeyState);
 
 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.
 
 363 //---------------------------------------------------------------------------
 
 366 "`wx.MouseState` is used to hold information about mouse button and
 
 367 modifier key states and is what is returned from `wx.GetMouseState`.",
 
 389     void        SetX(wxCoord x);
 
 390     void        SetY(wxCoord y);
 
 392     void        SetLeftDown(bool down);
 
 393     void        SetMiddleDown(bool down);
 
 394     void        SetRightDown(bool down);
 
 396     void        SetControlDown(bool down);
 
 397     void        SetShiftDown(bool down);
 
 398     void        SetAltDown(bool down);
 
 399     void        SetMetaDown(bool down);
 
 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)
 
 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.", "");
 
 424 //---------------------------------------------------------------------------
 
 426 MustHaveApp(wxWakeUpMainThread);
 
 428 #if defined(__WXMSW__) || defined(__WXMAC__)
 
 429 void wxWakeUpMainThread();
 
 432     void wxWakeUpMainThread() {}
 
 437 MustHaveApp(wxMutexGuiEnter);
 
 438 void wxMutexGuiEnter();
 
 440 MustHaveApp(wxMutexGuiLeave);
 
 441 void wxMutexGuiLeave();
 
 444 MustHaveApp(wxMutexGuiLocker);
 
 445 class wxMutexGuiLocker  {
 
 452 MustHaveApp(wxThread);
 
 454     bool wxThread_IsMain() {
 
 455 #ifdef WXP_WITH_THREAD
 
 456         return wxThread::IsMain();
 
 463 //---------------------------------------------------------------------------
 
 464 //---------------------------------------------------------------------------