]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_misc.i
reSWIGGed
[wxWidgets.git] / wxPython / src / _misc.i
CommitLineData
d14a1e28
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: _misc.i
3// Purpose: SWIG interface definitions for lots of little stuff that
4// don't deserve their own file. ;-)
5//
6// Author: Robin Dunn
7//
8// Created: 18-June-1999
9// RCS-ID: $Id$
10// Copyright: (c) 2003 by Total Control Software
11// Licence: wxWindows license
12/////////////////////////////////////////////////////////////////////////////
13
14// Not a %module
15
16
17//---------------------------------------------------------------------------
18%newgroup
19
20
f87da722 21#ifndef __WXX11__
ab1f7d2a
RD
22
23MustHaveApp(wxToolTip);
24
d14a1e28
RD
25class wxToolTip : public wxObject {
26public:
214c4fbe 27 %typemap(out) wxToolTip*; // turn off this typemap
d14a1e28 28 wxToolTip(const wxString &tip);
214c4fbe
RD
29 // Turn it back on again
30 %typemap(out) wxToolTip* { $result = wxPyMake_wxObject($1, $owner); }
d14a1e28 31
214c4fbe
RD
32 ~wxToolTip();
33
d14a1e28
RD
34 void SetTip(const wxString& tip);
35 wxString GetTip();
36 // *** Not in the "public" interface void SetWindow(wxWindow *win);
37 wxWindow *GetWindow();
38
39 static void Enable(bool flag);
40 static void SetDelay(long milliseconds);
994453b8
RD
41
42 %property(Tip, GetTip, SetTip, doc="See `GetTip` and `SetTip`");
43 %property(Window, GetWindow, doc="See `GetWindow`");
d14a1e28 44};
f87da722 45#endif
d14a1e28
RD
46
47//---------------------------------------------------------------------------
48
ab1f7d2a
RD
49MustHaveApp(wxCaret);
50
d14a1e28
RD
51class wxCaret {
52public:
53 wxCaret(wxWindow* window, const wxSize& size);
214c4fbe 54 ~wxCaret();
e981e2b5
RD
55
56 %extend {
4b5a79cf 57 %pythonPrepend Destroy "args[0].this.own(False)"
e981e2b5
RD
58 DocStr(Destroy,
59 "Deletes the C++ object this Python object is a proxy for.", "");
60 void Destroy() {
61 delete self;
62 }
63 }
64
d14a1e28
RD
65 bool IsOk();
66 bool IsVisible();
322913ce 67
d14a1e28 68 wxPoint GetPosition();
322913ce
RD
69 DocDeclAName(
70 void, GetPosition(int *OUTPUT, int *OUTPUT),
71 "GetPositionTuple() -> (x,y)",
72 GetPositionTuple);
73
d14a1e28 74 wxSize GetSize();
322913ce
RD
75 DocDeclAName(
76 void, GetSize( int *OUTPUT, int *OUTPUT ),
77 "GetSizeTuple() -> (width, height)",
78 GetSizeTuple);
79
80
d14a1e28 81 wxWindow *GetWindow();
1b8c7ba6 82 %Rename(MoveXY, void, Move(int x, int y));
d14a1e28 83 void Move(const wxPoint& pt);
1b8c7ba6 84 %Rename(SetSizeWH, void, SetSize(int width, int height));
d14a1e28 85 void SetSize(const wxSize& size);
a72f4631 86 void Show(int show = true);
d14a1e28
RD
87 void Hide();
88
322913ce 89 %pythoncode { def __nonzero__(self): return self.IsOk() }
d14a1e28 90
e981e2b5
RD
91 static int GetBlinkTime();
92 static void SetBlinkTime(int milliseconds);
0eae5d09
RD
93
94 %property(Position, GetPosition, doc="See `GetPosition`");
95 %property(Size, GetSize, SetSize, doc="See `GetSize` and `SetSize`");
96 %property(Window, GetWindow, doc="See `GetWindow`");
97
e981e2b5 98};
d14a1e28 99
d14a1e28
RD
100
101//---------------------------------------------------------------------------
102
ab1f7d2a
RD
103MustHaveApp(wxBusyCursor);
104
d14a1e28
RD
105class wxBusyCursor {
106public:
107 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
108 ~wxBusyCursor();
109};
110
111//---------------------------------------------------------------------------
112
ab1f7d2a
RD
113MustHaveApp(wxWindowDisabler);
114
d14a1e28
RD
115class wxWindowDisabler {
116public:
117 wxWindowDisabler(wxWindow *winToSkip = NULL);
118 ~wxWindowDisabler();
119};
120
121//---------------------------------------------------------------------------
122
ab1f7d2a
RD
123MustHaveApp(wxBusyInfo);
124
d14a1e28
RD
125class wxBusyInfo : public wxObject {
126public:
015131a1 127 wxBusyInfo(const wxString& message, wxWindow *parent = NULL);
d14a1e28 128 ~wxBusyInfo();
f6e949df
RD
129
130 %pythoncode { def Destroy(self): pass }
d14a1e28
RD
131};
132
133
134//---------------------------------------------------------------------------
135
136
137// wxStopWatch: measure time intervals with up to 1ms resolution
138class wxStopWatch
139{
140public:
141 // ctor starts the stop watch
142 wxStopWatch();
3ecece7e
RD
143 ~wxStopWatch();
144
d14a1e28
RD
145 // start the stop watch at the moment t0
146 void Start(long t0 = 0);
147
148 // pause the stop watch
149 void Pause();
150
151 // resume it
152 void Resume();
153
154 // get elapsed time since the last Start() in milliseconds
155 long Time() const;
156};
157
158
159
160//---------------------------------------------------------------------------
161
162class wxFileHistory : public wxObject
163{
164public:
823105f4 165 wxFileHistory(int maxFiles = 9, wxWindowID idBase = wxID_FILE1);
d14a1e28
RD
166 ~wxFileHistory();
167
168 // Operations
169 void AddFileToHistory(const wxString& file);
170 void RemoveFileFromHistory(int i);
171 int GetMaxFiles() const;
172 void UseMenu(wxMenu *menu);
173
174 // Remove menu from the list (MDI child may be closing)
175 void RemoveMenu(wxMenu *menu);
176
177 void Load(wxConfigBase& config);
178 void Save(wxConfigBase& config);
179
180 void AddFilesToMenu();
1b8c7ba6 181 %Rename(AddFilesToThisMenu, void, AddFilesToMenu(wxMenu* menu));
d14a1e28
RD
182
183 // Accessors
184 wxString GetHistoryFile(int i) const;
185
186 int GetCount() const;
138bb8ca 187 %pythoncode { GetNoHistoryFiles = GetCount }
d14a1e28 188
42e2bbb9
RD
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`");
d14a1e28
RD
193};
194
195
196//---------------------------------------------------------------------------
197
198%{
199#include <wx/snglinst.h>
200%}
201
202class wxSingleInstanceChecker
203{
204public:
205 // like Create() but no error checking (dangerous!)
206 wxSingleInstanceChecker(const wxString& name,
207 const wxString& path = wxPyEmptyString);
208
209 // default ctor, use Create() after it
1b8c7ba6 210 %RenameCtor(PreSingleInstanceChecker, wxSingleInstanceChecker());
d14a1e28
RD
211
212 ~wxSingleInstanceChecker();
213
214
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
218 //
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())
221 //
dd9f7fea 222 // returns False if initialization failed, it doesn't mean that another
d14a1e28
RD
223 // instance is running - use IsAnotherRunning() to check it
224 bool Create(const wxString& name, const wxString& path = wxPyEmptyString);
225
226 // is another copy of this program already running?
227 bool IsAnotherRunning() const;
228};
229
09c4bfc3
RD
230//---------------------------------------------------------------------------
231%newgroup
232
233// families & sub-families of operating systems
234enum wxOperatingSystemId
235{
236 wxOS_UNKNOWN = 0, // returned on error
237
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,
241
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 |
247 wxOS_WINDOWS_NT |
248 wxOS_WINDOWS_MICRO |
249 wxOS_WINDOWS_CE,
250
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 |
259 wxOS_UNIX_FREEBSD |
260 wxOS_UNIX_OPENBSD |
261 wxOS_UNIX_NETBSD |
262 wxOS_UNIX_SOLARIS |
263 wxOS_UNIX_AIX |
264 wxOS_UNIX_HPUX,
265
266 // 1<<13 and 1<<14 available for other Unix flavours
267
268 wxOS_DOS = 1 << 15, // Microsoft DOS
269 wxOS_OS2 = 1 << 16 // OS/2
270};
271
272// list of wxWidgets ports - some of them can be used with more than
273// a single toolkit.
274enum wxPortId
275{
276 wxPORT_UNKNOWN = 0, // returned on error
277
278 wxPORT_BASE = 1 << 0, // wxBase, no native toolkit used
279
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
a0ef52c0
RD
285 wxPORT_PM = 1 << 6, // wxOS2, using OS/2 Presentation Manager
286 wxPORT_OS2 = wxPORT_PM, // wxOS2, using OS/2 Presentation Manager
09c4bfc3
RD
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
a0ef52c0
RD
290 wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API
291 wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal
09c4bfc3
RD
292};
293
294// architecture of the operating system
295// (regardless of the build environment of wxWidgets library - see
296// wxIsPlatform64bit documentation for more info)
297enum wxArchitecture
298{
299 wxARCH_INVALID = -1, // returned on error
300
301 wxARCH_32, // 32 bit
302 wxARCH_64,
303
304 wxARCH_MAX
305};
306
307
308// endian-ness of the machine
309enum wxEndianness
310{
311 wxENDIAN_INVALID = -1, // returned on error
312
313 wxENDIAN_BIG, // 4321
314 wxENDIAN_LITTLE, // 1234
315 wxENDIAN_PDP, // 3412
316
317 wxENDIAN_MAX
318};
319
320// Information about the toolkit that the app is running under and some basic
321// platform and architecture info
322
323%rename(PlatformInformation) wxPlatformInfo; // wxPython already has a wx.PlatformInfo
324
325class wxPlatformInfo
326{
327public:
328 wxPlatformInfo();
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);
336
337 // default copy ctor, assignment operator and dtor are ok
338
339 bool operator==(const wxPlatformInfo &t) const;
340
341 bool operator!=(const wxPlatformInfo &t) const;
342
343
344// // string -> enum conversions
345// // ---------------------------------
346
347// static wxOperatingSystemId GetOperatingSystemId(const wxString &name);
348// static wxPortId GetPortId(const wxString &portname);
349
350// static wxArchitecture GetArch(const wxString &arch);
351// static wxEndianness GetEndianness(const wxString &end);
352
353// // enum -> string conversions
354// // ---------------------------------
355
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);
360
361// static wxString GetArchName(wxArchitecture arch);
362// static wxString GetEndiannessName(wxEndianness end);
363
364 // getters
365 // -----------------
366
367 int GetOSMajorVersion() const;
368 int GetOSMinorVersion() const;
369
5acb46e0
RD
370 bool CheckOSVersion(int major, int minor) const;
371
09c4bfc3
RD
372 int GetToolkitMajorVersion() const;
373 int GetToolkitMinorVersion() const;
374
5acb46e0
RD
375 bool CheckToolkitVersion(int major, int minor) const;
376
09c4bfc3
RD
377 bool IsUsingUniversalWidgets() const;
378
379 wxOperatingSystemId GetOperatingSystemId() const;
380 wxPortId GetPortId() const;
381 wxArchitecture GetArchitecture() const;
382 wxEndianness GetEndianness() const;
383
384
385 // string getters
386 // -----------------
387
388 wxString GetOperatingSystemFamilyName() const;
389 wxString GetOperatingSystemIdName() const;
390 wxString GetPortIdName() const;
391 wxString GetPortIdShortName() const;
392 wxString GetArchName() const;
393 wxString GetEndiannessName() const;
394
395 // setters
396 // -----------------
397
398 void SetOSVersion(int major, int minor);
399 void SetToolkitVersion(int major, int minor);
400
401 void SetOperatingSystemId(wxOperatingSystemId n);
402 void SetPortId(wxPortId n);
403 void SetArchitecture(wxArchitecture n);
404 void SetEndianness(wxEndianness n);
405
406 // miscellaneous
407 // -----------------
408
409 bool IsOk() const;
7012bb9f
RD
410
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`");
425
09c4bfc3
RD
426};
427
428
429//---------------------------------------------------------------------------
d14a1e28
RD
430//---------------------------------------------------------------------------
431// Experimental...
432
d14a1e28
RD
433%{
434#ifdef __WXMSW__
435#include <wx/msw/private.h>
436#include <wx/dynload.h>
437#endif
438%}
439
440
441%inline %{
442
32478f52
RD
443bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc
444#if 0
445 , int method
446#endif
447 )
d14a1e28
RD
448{
449#ifdef __WXMSW__
32478f52 450#if 0
d14a1e28
RD
451 switch (method)
452 {
453 case 1:
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
457 // not be painted.
458 ::SendMessage(GetHwndOf(window), WM_PAINT, (long)GetHdcOf(dc), 0);
459 break;
460
461 case 2:
32478f52
RD
462#endif
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
469 // works very well.
d14a1e28
RD
470 //
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 );
32478f52
RD
477 return true;
478#if 0
d14a1e28
RD
479 break;
480
481 case 3:
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;
488
489 // fall through
490
491 case 4:
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);
a72f4631 497 static bool s_triedToLoad = false;
d14a1e28
RD
498 static PrintWindow_t pfnPrintWindow = NULL;
499 if ( !s_triedToLoad )
500 {
501
92956ab2 502 s_triedToLoad = true;
d14a1e28
RD
503 wxDynamicLibrary dllUser32(_T("user32.dll"));
504 if ( dllUser32.IsLoaded() )
505 {
506 wxLogNull nolog; // Don't report errors here
507 pfnPrintWindow = (PrintWindow_t)dllUser32.GetSymbol(_T("PrintWindow"));
508 }
509 }
510 if (pfnPrintWindow)
511 {
d115ca5e 512 //printf("Using PrintWindow\n");
d14a1e28
RD
513 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
514 }
515 else
516 {
d115ca5e 517 //printf("Using WM_PRINT\n");
d14a1e28 518 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
d115ca5e
RD
519 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
520 PRF_ERASEBKGND | PRF_OWNED );
d14a1e28
RD
521 }
522 }
32478f52
RD
523#endif // 0
524#else
525 return false;
526#endif // __WXMSW__
d14a1e28
RD
527}
528
529%}
530
8f93b075 531
214c4fbe
RD
532
533#if 0
534%{
535 void t_output_tester1(int* a, int* b, int* c, int* d)
536 {
537 *a = 1234;
538 *b = 2345;
539 *c = 3456;
540 *d = 4567;
541 }
542 PyObject* t_output_tester2(int* a, int* b, int* c, int* d)
543 {
544 *a = 1234;
545 *b = 2345;
546 *c = 3456;
547 *d = 4567;
548 Py_INCREF(Py_None);
549 return Py_None;
550 }
551 PyObject* t_output_tester3(int* a, int* b, int* c, int* d)
552 {
553 *a = 1234;
554 *b = 2345;
555 *c = 3456;
556 *d = 4567;
557 PyObject* res = PyTuple_New(2);
558 PyTuple_SetItem(res, 0, PyInt_FromLong(1));
559 PyTuple_SetItem(res, 1, PyInt_FromLong(2));
560 return res;
561 }
562 PyObject* t_output_tester4()
563 {
564 PyObject* res = PyTuple_New(2);
565 PyTuple_SetItem(res, 0, PyInt_FromLong(132));
566 PyTuple_SetItem(res, 1, PyInt_FromLong(244));
567 return res;
568 }
569%}
570
571%newobject t_output_tester2;
572%newobject t_output_tester3;
573%newobject t_output_tester4;
574
575void t_output_tester1(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
576PyObject* t_output_tester2(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
577PyObject* t_output_tester3(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
578PyObject* t_output_tester4();
579
580#endif
581
d14a1e28
RD
582//---------------------------------------------------------------------------
583//---------------------------------------------------------------------------