1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface definitions for lots of little stuff that
 
   4 //              don't deserve their own file.  ;-)
 
   8 // Created:     18-June-1999
 
  10 // Copyright:   (c) 2003 by Total Control Software
 
  11 // Licence:     wxWindows license
 
  12 /////////////////////////////////////////////////////////////////////////////
 
  17 //---------------------------------------------------------------------------
 
  23 MustHaveApp(wxToolTip);
 
  25 class wxToolTip : public wxObject {
 
  27     %typemap(out) wxToolTip*;    // turn off this typemap
 
  28     wxToolTip(const wxString &tip);
 
  29     // Turn it back on again
 
  30     %typemap(out) wxToolTip* { $result = wxPyMake_wxObject($1, $owner); }
 
  34     void SetTip(const wxString& tip);
 
  36     // *** Not in the "public" interface void SetWindow(wxWindow *win);
 
  37     wxWindow *GetWindow();
 
  39     static void Enable(bool flag);
 
  40     static void SetDelay(long milliseconds);
 
  42     %property(Tip, GetTip, SetTip, doc="See `GetTip` and `SetTip`");
 
  43     %property(Window, GetWindow, doc="See `GetWindow`");
 
  47 //---------------------------------------------------------------------------
 
  53     wxCaret(wxWindow* window, const wxSize& size);
 
  57         %pythonPrepend Destroy "args[0].this.own(False)"
 
  59                "Deletes the C++ object this Python object is a proxy for.", "");
 
  68     wxPoint GetPosition();
 
  70         void, GetPosition(int *OUTPUT, int *OUTPUT),
 
  71         "GetPositionTuple() -> (x,y)",
 
  76         void, GetSize( int *OUTPUT, int *OUTPUT ),
 
  77         "GetSizeTuple() -> (width, height)",
 
  81     wxWindow *GetWindow();
 
  82     %Rename(MoveXY, void, Move(int x, int y));
 
  83     void Move(const wxPoint& pt);
 
  84     %Rename(SetSizeWH,  void, SetSize(int width, int height));
 
  85     void SetSize(const wxSize& size);
 
  86     void Show(int show = true);
 
  89     %pythoncode { def __nonzero__(self): return self.IsOk() }
 
  91     static int GetBlinkTime();
 
  92     static void SetBlinkTime(int milliseconds);
 
  94     %property(Position, GetPosition, doc="See `GetPosition`");
 
  95     %property(Size, GetSize, SetSize, doc="See `GetSize` and `SetSize`");
 
  96     %property(Window, GetWindow, doc="See `GetWindow`");
 
 101 //---------------------------------------------------------------------------
 
 103 MustHaveApp(wxBusyCursor);
 
 107     wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
 
 111 //---------------------------------------------------------------------------
 
 113 MustHaveApp(wxWindowDisabler);
 
 115 class wxWindowDisabler {
 
 117     wxWindowDisabler(wxWindow *winToSkip = NULL);
 
 121 //---------------------------------------------------------------------------
 
 123 MustHaveApp(wxBusyInfo);
 
 125 class wxBusyInfo : public wxObject {
 
 127     wxBusyInfo(const wxString& message);
 
 130     %pythoncode { def Destroy(self): pass }
 
 134 //---------------------------------------------------------------------------
 
 137 // wxStopWatch: measure time intervals with up to 1ms resolution
 
 141     // ctor starts the stop watch
 
 145     // start the stop watch at the moment t0
 
 146     void Start(long t0 = 0);
 
 148     // pause the stop watch
 
 154     // get elapsed time since the last Start() in milliseconds
 
 160 //---------------------------------------------------------------------------
 
 162 class wxFileHistory : public wxObject
 
 165     wxFileHistory(int maxFiles = 9, wxWindowID idBase = wxID_FILE1);
 
 169     void AddFileToHistory(const wxString& file);
 
 170     void RemoveFileFromHistory(int i);
 
 171     int GetMaxFiles() const;
 
 172     void UseMenu(wxMenu *menu);
 
 174     // Remove menu from the list (MDI child may be closing)
 
 175     void RemoveMenu(wxMenu *menu);
 
 177     void Load(wxConfigBase& config);
 
 178     void Save(wxConfigBase& config);
 
 180     void AddFilesToMenu();
 
 181     %Rename(AddFilesToThisMenu, void, AddFilesToMenu(wxMenu* menu));
 
 184     wxString GetHistoryFile(int i) const;
 
 186     int GetCount() const;
 
 187     %pythoncode { GetNoHistoryFiles = GetCount }
 
 189     %property(Count, GetCount, doc="See `GetCount`");
 
 190     %property(HistoryFile, GetHistoryFile, doc="See `GetHistoryFile`");
 
 191     %property(MaxFiles, GetMaxFiles, doc="See `GetMaxFiles`");
 
 192     %property(NoHistoryFiles, GetNoHistoryFiles, doc="See `GetNoHistoryFiles`");
 
 196 //---------------------------------------------------------------------------
 
 199 #include <wx/snglinst.h>
 
 202 class wxSingleInstanceChecker
 
 205     // like Create() but no error checking (dangerous!)
 
 206     wxSingleInstanceChecker(const wxString& name,
 
 207                             const wxString& path = wxPyEmptyString);
 
 209     // default ctor, use Create() after it
 
 210     %RenameCtor(PreSingleInstanceChecker,  wxSingleInstanceChecker());
 
 212     ~wxSingleInstanceChecker();
 
 215     // name must be given and be as unique as possible, it is used as the mutex
 
 216     // name under Win32 and the lock file name under Unix -
 
 217     // wxTheApp->GetAppName() may be a good value for this parameter
 
 219     // path is optional and is ignored under Win32 and used as the directory to
 
 220     // create the lock file in under Unix (default is wxGetHomeDir())
 
 222     // returns False if initialization failed, it doesn't mean that another
 
 223     // instance is running - use IsAnotherRunning() to check it
 
 224     bool Create(const wxString& name, const wxString& path = wxPyEmptyString);
 
 226     // is another copy of this program already running?
 
 227     bool IsAnotherRunning() const;
 
 230 //---------------------------------------------------------------------------
 
 233 // families & sub-families of operating systems
 
 234 enum wxOperatingSystemId
 
 236     wxOS_UNKNOWN = 0,                 // returned on error
 
 238     wxOS_MAC_OS         = 1 << 0,     // Apple Mac OS 8/9/X with Mac paths
 
 239     wxOS_MAC_OSX_DARWIN = 1 << 1,     // Apple Mac OS X with Unix paths
 
 240     wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
 
 242     wxOS_WINDOWS_9X     = 1 << 2,     // Windows 9x family (95/98/ME)
 
 243     wxOS_WINDOWS_NT     = 1 << 3,     // Windows NT family (NT/2000/XP)
 
 244     wxOS_WINDOWS_MICRO  = 1 << 4,     // MicroWindows
 
 245     wxOS_WINDOWS_CE     = 1 << 5,     // Windows CE (Window Mobile)
 
 246     wxOS_WINDOWS = wxOS_WINDOWS_9X      |
 
 251     wxOS_UNIX_LINUX     = 1 << 6,       // Linux
 
 252     wxOS_UNIX_FREEBSD   = 1 << 7,       // FreeBSD
 
 253     wxOS_UNIX_OPENBSD   = 1 << 8,       // OpenBSD
 
 254     wxOS_UNIX_NETBSD    = 1 << 9,       // NetBSD
 
 255     wxOS_UNIX_SOLARIS   = 1 << 10,      // SunOS
 
 256     wxOS_UNIX_AIX       = 1 << 11,      // AIX
 
 257     wxOS_UNIX_HPUX      = 1 << 12,      // HP/UX
 
 258     wxOS_UNIX = wxOS_UNIX_LINUX     |
 
 266     // 1<<13 and 1<<14 available for other Unix flavours
 
 268     wxOS_DOS            = 1 << 15,      // Microsoft DOS
 
 269     wxOS_OS2            = 1 << 16       // OS/2
 
 272 // list of wxWidgets ports - some of them can be used with more than
 
 276     wxPORT_UNKNOWN  = 0,            // returned on error
 
 278     wxPORT_BASE     = 1 << 0,       // wxBase, no native toolkit used
 
 280     wxPORT_MSW      = 1 << 1,       // wxMSW, native toolkit is Windows API
 
 281     wxPORT_MOTIF    = 1 << 2,       // wxMotif, using [Open]Motif or Lesstif
 
 282     wxPORT_GTK      = 1 << 3,       // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
 
 283     wxPORT_MGL      = 1 << 4,       // wxMGL, using wxUniversal
 
 284     wxPORT_X11      = 1 << 5,       // wxX11, using wxUniversal
 
 285     wxPORT_PM       = 1 << 6,       // wxOS2, using OS/2 Presentation Manager
 
 286     wxPORT_OS2      = wxPORT_PM,    // wxOS2, using OS/2 Presentation Manager
 
 287     wxPORT_MAC      = 1 << 7,       // wxMac, using Carbon or Classic Mac API
 
 288     wxPORT_COCOA    = 1 << 8,       // wxCocoa, using Cocoa NextStep/Mac API
 
 289     wxPORT_WINCE    = 1 << 9,       // wxWinCE, toolkit is WinCE SDK API
 
 290     wxPORT_PALMOS   = 1 << 10,       // wxPalmOS, toolkit is PalmOS API
 
 291     wxPORT_DFB      = 1 << 11       // wxDFB, using wxUniversal
 
 294 // architecture of the operating system
 
 295 // (regardless of the build environment of wxWidgets library - see
 
 296 // wxIsPlatform64bit documentation for more info)
 
 299     wxARCH_INVALID = -1,        // returned on error
 
 308 // endian-ness of the machine
 
 311     wxENDIAN_INVALID = -1,      // returned on error
 
 313     wxENDIAN_BIG,               // 4321
 
 314     wxENDIAN_LITTLE,            // 1234
 
 315     wxENDIAN_PDP,               // 3412
 
 320 // Information about the toolkit that the app is running under and some basic
 
 321 // platform and architecture info
 
 323 %rename(PlatformInformation) wxPlatformInfo; // wxPython already has a wx.PlatformInfo
 
 329 //     wxPlatformInfo(wxPortId pid,
 
 330 //                    int tkMajor = -1, int tkMinor = -1,
 
 331 //                    wxOperatingSystemId id = wxOS_UNKNOWN,
 
 332 //                    int osMajor = -1, int osMinor = -1,
 
 333 //                    wxArchitecture arch = wxARCH_INVALID,
 
 334 //                    wxEndianness endian = wxENDIAN_INVALID,
 
 335 //                    bool usingUniversal = false);
 
 337     // default copy ctor, assignment operator and dtor are ok
 
 339     bool operator==(const wxPlatformInfo &t) const;
 
 341     bool operator!=(const wxPlatformInfo &t) const;
 
 344 //     // string -> enum conversions
 
 345 //     // ---------------------------------
 
 347 //     static wxOperatingSystemId GetOperatingSystemId(const wxString &name);
 
 348 //     static wxPortId GetPortId(const wxString &portname);
 
 350 //     static wxArchitecture GetArch(const wxString &arch);
 
 351 //     static wxEndianness GetEndianness(const wxString &end);
 
 353 //     // enum -> string conversions
 
 354 //     // ---------------------------------
 
 356 //     static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
 
 357 //     static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
 
 358 //     static wxString GetPortIdName(wxPortId port, bool usingUniversal);
 
 359 //     static wxString GetPortIdShortName(wxPortId port, bool usingUniversal);
 
 361 //     static wxString GetArchName(wxArchitecture arch);
 
 362 //     static wxString GetEndiannessName(wxEndianness end);
 
 367     int GetOSMajorVersion() const;
 
 368     int GetOSMinorVersion() const;
 
 370     bool CheckOSVersion(int major, int minor) const;
 
 372     int GetToolkitMajorVersion() const;
 
 373     int GetToolkitMinorVersion() const;
 
 375     bool CheckToolkitVersion(int major, int minor) const;
 
 377     bool IsUsingUniversalWidgets() const;
 
 379     wxOperatingSystemId GetOperatingSystemId() const;
 
 380     wxPortId GetPortId() const;
 
 381     wxArchitecture GetArchitecture() const;
 
 382     wxEndianness GetEndianness() const;
 
 388     wxString GetOperatingSystemFamilyName() const;
 
 389     wxString GetOperatingSystemIdName() const;
 
 390     wxString GetPortIdName() const;
 
 391     wxString GetPortIdShortName() const;
 
 392     wxString GetArchName() const;
 
 393     wxString GetEndiannessName() const;
 
 398     void SetOSVersion(int major, int minor);
 
 399     void SetToolkitVersion(int major, int minor);
 
 401     void SetOperatingSystemId(wxOperatingSystemId n);
 
 402     void SetPortId(wxPortId n);
 
 403     void SetArchitecture(wxArchitecture n);
 
 404     void SetEndianness(wxEndianness n);
 
 411     %property(ArchName, GetArchName, doc="See `GetArchName`");
 
 412     %property(Architecture, GetArchitecture, SetArchitecture, doc="See `GetArchitecture` and `SetArchitecture`");
 
 413     %property(Endianness, GetEndianness, SetEndianness, doc="See `GetEndianness` and `SetEndianness`");
 
 414     %property(EndiannessName, GetEndiannessName, doc="See `GetEndiannessName`");
 
 415     %property(OSMajorVersion, GetOSMajorVersion, doc="See `GetOSMajorVersion`");
 
 416     %property(OSMinorVersion, GetOSMinorVersion, doc="See `GetOSMinorVersion`");
 
 417     %property(OperatingSystemFamilyName, GetOperatingSystemFamilyName, doc="See `GetOperatingSystemFamilyName`");
 
 418     %property(OperatingSystemId, GetOperatingSystemId, SetOperatingSystemId, doc="See `GetOperatingSystemId` and `SetOperatingSystemId`");
 
 419     %property(OperatingSystemIdName, GetOperatingSystemIdName, doc="See `GetOperatingSystemIdName`");
 
 420     %property(PortId, GetPortId, SetPortId, doc="See `GetPortId` and `SetPortId`");
 
 421     %property(PortIdName, GetPortIdName, doc="See `GetPortIdName`");
 
 422     %property(PortIdShortName, GetPortIdShortName, doc="See `GetPortIdShortName`");
 
 423     %property(ToolkitMajorVersion, GetToolkitMajorVersion, doc="See `GetToolkitMajorVersion`");
 
 424     %property(ToolkitMinorVersion, GetToolkitMinorVersion, doc="See `GetToolkitMinorVersion`");
 
 429 //---------------------------------------------------------------------------
 
 430 //---------------------------------------------------------------------------
 
 435 #include <wx/msw/private.h>
 
 436 #include <wx/dynload.h>
 
 443 bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc
 
 454             // This one only partially works.  Appears to be an undocumented
 
 455             // "standard" convention that not all widgets adhear to.  For
 
 456             // example, for some widgets backgrounds or non-client areas may
 
 458             ::SendMessage(GetHwndOf(window), WM_PAINT, (long)GetHdcOf(dc), 0);
 
 463             // This one works much better, nearly all widgets and their
 
 464             // children are captured correctly[**].  Prior to the big
 
 465             // background erase changes that Vadim did in 2004-2005 this
 
 466             // method failed badly on XP with Themes activated, most native
 
 467             // widgets draw only partially, if at all.  Without themes it
 
 468             // worked just like on Win2k.  After those changes this method
 
 471             // ** For example the radio buttons in a wxRadioBox are not its
 
 472             // children by default, but you can capture it via the panel
 
 473             // instead, or change RADIOBTN_PARENT_IS_RADIOBOX in radiobox.cpp.
 
 474             ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
 
 475                           PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
 
 476                           PRF_ERASEBKGND | PRF_OWNED );
 
 482             // This one is only defined in the latest SDK and is only
 
 483             // available on XP.  MSDN says it is similar to sending WM_PRINT
 
 484             // so I expect that it will work similar to the above.  Since it
 
 485             // is avaialble only on XP, it can't be compiled like this and
 
 486             // will have to be loaded dynamically.
 
 487             // //::PrintWindow(GetHwndOf(window), GetHdcOf(dc), 0); //break;
 
 492             // Use PrintWindow if available, or fallback to WM_PRINT
 
 493             // otherwise.  Unfortunately using PrintWindow is even worse than
 
 494             // WM_PRINT.  For most native widgets nothing is drawn to the dc
 
 495             // at all, with or without Themes.
 
 496             typedef BOOL (WINAPI *PrintWindow_t)(HWND, HDC, UINT);
 
 497             static bool s_triedToLoad = false;
 
 498             static PrintWindow_t pfnPrintWindow = NULL;
 
 499             if ( !s_triedToLoad )
 
 502                 s_triedToLoad = true;
 
 503                 wxDynamicLibrary dllUser32(_T("user32.dll"));
 
 504                 if ( dllUser32.IsLoaded() )
 
 506                     wxLogNull nolog;  // Don't report errors here
 
 507                     pfnPrintWindow = (PrintWindow_t)dllUser32.GetSymbol(_T("PrintWindow"));
 
 512                 //printf("Using PrintWindow\n");
 
 513                 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
 
 517                 //printf("Using WM_PRINT\n");
 
 518                 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
 
 519                               PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
 
 520                               PRF_ERASEBKGND | PRF_OWNED );
 
 535     void t_output_tester1(int* a, int* b, int* c, int* d)
 
 542     PyObject* t_output_tester2(int* a, int* b, int* c, int* d)
 
 551     PyObject* t_output_tester3(int* a, int* b, int* c, int* d)
 
 557         PyObject* res = PyTuple_New(2);
 
 558         PyTuple_SetItem(res, 0, PyInt_FromLong(1));
 
 559         PyTuple_SetItem(res, 1, PyInt_FromLong(2));
 
 562     PyObject* t_output_tester4()
 
 564         PyObject* res = PyTuple_New(2);
 
 565         PyTuple_SetItem(res, 0, PyInt_FromLong(132));
 
 566         PyTuple_SetItem(res, 1, PyInt_FromLong(244));
 
 571 %newobject t_output_tester2;
 
 572 %newobject t_output_tester3;
 
 573 %newobject t_output_tester4;
 
 575 void      t_output_tester1(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
 
 576 PyObject* t_output_tester2(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
 
 577 PyObject* t_output_tester3(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
 
 578 PyObject* t_output_tester4();
 
 582 //---------------------------------------------------------------------------
 
 583 //---------------------------------------------------------------------------