]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_misc.i
Add wxPyTabArt
[wxWidgets.git] / wxPython / src / _misc.i
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
21 #ifndef __WXX11__
22
23 MustHaveApp(wxToolTip);
24
25 class wxToolTip : public wxObject {
26 public:
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); }
31
32 ~wxToolTip();
33
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);
41
42 %property(Tip, GetTip, SetTip, doc="See `GetTip` and `SetTip`");
43 %property(Window, GetWindow, doc="See `GetWindow`");
44 };
45 #endif
46
47 //---------------------------------------------------------------------------
48
49 MustHaveApp(wxCaret);
50
51 class wxCaret {
52 public:
53 wxCaret(wxWindow* window, const wxSize& size);
54 ~wxCaret();
55
56 %extend {
57 %pythonPrepend Destroy "args[0].this.own(False)"
58 DocStr(Destroy,
59 "Deletes the C++ object this Python object is a proxy for.", "");
60 void Destroy() {
61 delete self;
62 }
63 }
64
65 bool IsOk();
66 bool IsVisible();
67
68 wxPoint GetPosition();
69 DocDeclAName(
70 void, GetPosition(int *OUTPUT, int *OUTPUT),
71 "GetPositionTuple() -> (x,y)",
72 GetPositionTuple);
73
74 wxSize GetSize();
75 DocDeclAName(
76 void, GetSize( int *OUTPUT, int *OUTPUT ),
77 "GetSizeTuple() -> (width, height)",
78 GetSizeTuple);
79
80
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);
87 void Hide();
88
89 %pythoncode { def __nonzero__(self): return self.IsOk() }
90
91 static int GetBlinkTime();
92 static void SetBlinkTime(int milliseconds);
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
98 };
99
100
101 //---------------------------------------------------------------------------
102
103 MustHaveApp(wxBusyCursor);
104
105 class wxBusyCursor {
106 public:
107 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
108 ~wxBusyCursor();
109 };
110
111 //---------------------------------------------------------------------------
112
113 MustHaveApp(wxWindowDisabler);
114
115 class wxWindowDisabler {
116 public:
117 wxWindowDisabler(wxWindow *winToSkip = NULL);
118 ~wxWindowDisabler();
119 };
120
121 //---------------------------------------------------------------------------
122
123 MustHaveApp(wxBusyInfo);
124
125 class wxBusyInfo : public wxObject {
126 public:
127 wxBusyInfo(const wxString& message);
128 ~wxBusyInfo();
129
130 %pythoncode { def Destroy(self): pass }
131 };
132
133
134 //---------------------------------------------------------------------------
135
136
137 // wxStopWatch: measure time intervals with up to 1ms resolution
138 class wxStopWatch
139 {
140 public:
141 // ctor starts the stop watch
142 wxStopWatch();
143 ~wxStopWatch();
144
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
162 class wxFileHistory : public wxObject
163 {
164 public:
165 wxFileHistory(int maxFiles = 9, wxWindowID idBase = wxID_FILE1);
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();
181 %Rename(AddFilesToThisMenu, void, AddFilesToMenu(wxMenu* menu));
182
183 // Accessors
184 wxString GetHistoryFile(int i) const;
185
186 int GetCount() const;
187 %pythoncode { GetNoHistoryFiles = GetCount }
188
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`");
193 };
194
195
196 //---------------------------------------------------------------------------
197
198 %{
199 #include <wx/snglinst.h>
200 %}
201
202 class wxSingleInstanceChecker
203 {
204 public:
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
210 %RenameCtor(PreSingleInstanceChecker, wxSingleInstanceChecker());
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 //
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);
225
226 // is another copy of this program already running?
227 bool IsAnotherRunning() const;
228 };
229
230 //---------------------------------------------------------------------------
231 %newgroup
232
233 // families & sub-families of operating systems
234 enum 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.
274 enum 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
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
292 };
293
294 // architecture of the operating system
295 // (regardless of the build environment of wxWidgets library - see
296 // wxIsPlatform64bit documentation for more info)
297 enum 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
309 enum 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
325 class wxPlatformInfo
326 {
327 public:
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
370 bool CheckOSVersion(int major, int minor) const;
371
372 int GetToolkitMajorVersion() const;
373 int GetToolkitMinorVersion() const;
374
375 bool CheckToolkitVersion(int major, int minor) const;
376
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;
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
426 };
427
428
429 //---------------------------------------------------------------------------
430 //---------------------------------------------------------------------------
431 // Experimental...
432
433 %{
434 #ifdef __WXMSW__
435 #include <wx/msw/private.h>
436 #include <wx/dynload.h>
437 #endif
438 %}
439
440
441 %inline %{
442
443 bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc
444 #if 0
445 , int method
446 #endif
447 )
448 {
449 #ifdef __WXMSW__
450 #if 0
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:
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.
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 );
477 return true;
478 #if 0
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);
497 static bool s_triedToLoad = false;
498 static PrintWindow_t pfnPrintWindow = NULL;
499 if ( !s_triedToLoad )
500 {
501
502 s_triedToLoad = true;
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 {
512 //printf("Using PrintWindow\n");
513 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
514 }
515 else
516 {
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 );
521 }
522 }
523 #endif // 0
524 #else
525 return false;
526 #endif // __WXMSW__
527 }
528
529 %}
530
531
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
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();
579
580 #endif
581
582 //---------------------------------------------------------------------------
583 //---------------------------------------------------------------------------