]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_misc.i
c412e3026f3da2aced4e4a1165415bd52c4200d4
[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
144 // start the stop watch at the moment t0
145 void Start(long t0 = 0);
146
147 // pause the stop watch
148 void Pause();
149
150 // resume it
151 void Resume();
152
153 // get elapsed time since the last Start() in milliseconds
154 long Time() const;
155 };
156
157
158
159 //---------------------------------------------------------------------------
160
161 class wxFileHistory : public wxObject
162 {
163 public:
164 wxFileHistory(int maxFiles = 9, wxWindowID idBase = wxID_FILE1);
165 ~wxFileHistory();
166
167 // Operations
168 void AddFileToHistory(const wxString& file);
169 void RemoveFileFromHistory(int i);
170 int GetMaxFiles() const;
171 void UseMenu(wxMenu *menu);
172
173 // Remove menu from the list (MDI child may be closing)
174 void RemoveMenu(wxMenu *menu);
175
176 void Load(wxConfigBase& config);
177 void Save(wxConfigBase& config);
178
179 void AddFilesToMenu();
180 %Rename(AddFilesToThisMenu, void, AddFilesToMenu(wxMenu* menu));
181
182 // Accessors
183 wxString GetHistoryFile(int i) const;
184
185 int GetCount() const;
186 %pythoncode { GetNoHistoryFiles = GetCount }
187
188 %property(Count, GetCount, doc="See `GetCount`");
189 %property(HistoryFile, GetHistoryFile, doc="See `GetHistoryFile`");
190 %property(MaxFiles, GetMaxFiles, doc="See `GetMaxFiles`");
191 %property(NoHistoryFiles, GetNoHistoryFiles, doc="See `GetNoHistoryFiles`");
192 };
193
194
195 //---------------------------------------------------------------------------
196
197 %{
198 #include <wx/snglinst.h>
199 %}
200
201 class wxSingleInstanceChecker
202 {
203 public:
204 // like Create() but no error checking (dangerous!)
205 wxSingleInstanceChecker(const wxString& name,
206 const wxString& path = wxPyEmptyString);
207
208 // default ctor, use Create() after it
209 %RenameCtor(PreSingleInstanceChecker, wxSingleInstanceChecker());
210
211 ~wxSingleInstanceChecker();
212
213
214 // name must be given and be as unique as possible, it is used as the mutex
215 // name under Win32 and the lock file name under Unix -
216 // wxTheApp->GetAppName() may be a good value for this parameter
217 //
218 // path is optional and is ignored under Win32 and used as the directory to
219 // create the lock file in under Unix (default is wxGetHomeDir())
220 //
221 // returns False if initialization failed, it doesn't mean that another
222 // instance is running - use IsAnotherRunning() to check it
223 bool Create(const wxString& name, const wxString& path = wxPyEmptyString);
224
225 // is another copy of this program already running?
226 bool IsAnotherRunning() const;
227 };
228
229 //---------------------------------------------------------------------------
230 %newgroup
231
232 // families & sub-families of operating systems
233 enum wxOperatingSystemId
234 {
235 wxOS_UNKNOWN = 0, // returned on error
236
237 wxOS_MAC_OS = 1 << 0, // Apple Mac OS 8/9/X with Mac paths
238 wxOS_MAC_OSX_DARWIN = 1 << 1, // Apple Mac OS X with Unix paths
239 wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
240
241 wxOS_WINDOWS_9X = 1 << 2, // Windows 9x family (95/98/ME)
242 wxOS_WINDOWS_NT = 1 << 3, // Windows NT family (NT/2000/XP)
243 wxOS_WINDOWS_MICRO = 1 << 4, // MicroWindows
244 wxOS_WINDOWS_CE = 1 << 5, // Windows CE (Window Mobile)
245 wxOS_WINDOWS = wxOS_WINDOWS_9X |
246 wxOS_WINDOWS_NT |
247 wxOS_WINDOWS_MICRO |
248 wxOS_WINDOWS_CE,
249
250 wxOS_UNIX_LINUX = 1 << 6, // Linux
251 wxOS_UNIX_FREEBSD = 1 << 7, // FreeBSD
252 wxOS_UNIX_OPENBSD = 1 << 8, // OpenBSD
253 wxOS_UNIX_NETBSD = 1 << 9, // NetBSD
254 wxOS_UNIX_SOLARIS = 1 << 10, // SunOS
255 wxOS_UNIX_AIX = 1 << 11, // AIX
256 wxOS_UNIX_HPUX = 1 << 12, // HP/UX
257 wxOS_UNIX = wxOS_UNIX_LINUX |
258 wxOS_UNIX_FREEBSD |
259 wxOS_UNIX_OPENBSD |
260 wxOS_UNIX_NETBSD |
261 wxOS_UNIX_SOLARIS |
262 wxOS_UNIX_AIX |
263 wxOS_UNIX_HPUX,
264
265 // 1<<13 and 1<<14 available for other Unix flavours
266
267 wxOS_DOS = 1 << 15, // Microsoft DOS
268 wxOS_OS2 = 1 << 16 // OS/2
269 };
270
271 // list of wxWidgets ports - some of them can be used with more than
272 // a single toolkit.
273 enum wxPortId
274 {
275 wxPORT_UNKNOWN = 0, // returned on error
276
277 wxPORT_BASE = 1 << 0, // wxBase, no native toolkit used
278
279 wxPORT_MSW = 1 << 1, // wxMSW, native toolkit is Windows API
280 wxPORT_MOTIF = 1 << 2, // wxMotif, using [Open]Motif or Lesstif
281 wxPORT_GTK = 1 << 3, // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
282 wxPORT_MGL = 1 << 4, // wxMGL, using wxUniversal
283 wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal
284 wxPORT_PM = 1 << 6, // wxOS2, using OS/2 Presentation Manager
285 wxPORT_OS2 = wxPORT_PM, // wxOS2, using OS/2 Presentation Manager
286 wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API
287 wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
288 wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API
289 wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API
290 wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal
291 };
292
293 // architecture of the operating system
294 // (regardless of the build environment of wxWidgets library - see
295 // wxIsPlatform64bit documentation for more info)
296 enum wxArchitecture
297 {
298 wxARCH_INVALID = -1, // returned on error
299
300 wxARCH_32, // 32 bit
301 wxARCH_64,
302
303 wxARCH_MAX
304 };
305
306
307 // endian-ness of the machine
308 enum wxEndianness
309 {
310 wxENDIAN_INVALID = -1, // returned on error
311
312 wxENDIAN_BIG, // 4321
313 wxENDIAN_LITTLE, // 1234
314 wxENDIAN_PDP, // 3412
315
316 wxENDIAN_MAX
317 };
318
319 // Information about the toolkit that the app is running under and some basic
320 // platform and architecture info
321
322 %rename(PlatformInformation) wxPlatformInfo; // wxPython already has a wx.PlatformInfo
323
324 class wxPlatformInfo
325 {
326 public:
327 wxPlatformInfo();
328 // wxPlatformInfo(wxPortId pid,
329 // int tkMajor = -1, int tkMinor = -1,
330 // wxOperatingSystemId id = wxOS_UNKNOWN,
331 // int osMajor = -1, int osMinor = -1,
332 // wxArchitecture arch = wxARCH_INVALID,
333 // wxEndianness endian = wxENDIAN_INVALID,
334 // bool usingUniversal = false);
335
336 // default copy ctor, assignment operator and dtor are ok
337
338 bool operator==(const wxPlatformInfo &t) const;
339
340 bool operator!=(const wxPlatformInfo &t) const;
341
342
343 // // string -> enum conversions
344 // // ---------------------------------
345
346 // static wxOperatingSystemId GetOperatingSystemId(const wxString &name);
347 // static wxPortId GetPortId(const wxString &portname);
348
349 // static wxArchitecture GetArch(const wxString &arch);
350 // static wxEndianness GetEndianness(const wxString &end);
351
352 // // enum -> string conversions
353 // // ---------------------------------
354
355 // static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
356 // static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
357 // static wxString GetPortIdName(wxPortId port, bool usingUniversal);
358 // static wxString GetPortIdShortName(wxPortId port, bool usingUniversal);
359
360 // static wxString GetArchName(wxArchitecture arch);
361 // static wxString GetEndiannessName(wxEndianness end);
362
363 // getters
364 // -----------------
365
366 int GetOSMajorVersion() const;
367 int GetOSMinorVersion() const;
368
369 bool CheckOSVersion(int major, int minor) const;
370
371 int GetToolkitMajorVersion() const;
372 int GetToolkitMinorVersion() const;
373
374 bool CheckToolkitVersion(int major, int minor) const;
375
376 bool IsUsingUniversalWidgets() const;
377
378 wxOperatingSystemId GetOperatingSystemId() const;
379 wxPortId GetPortId() const;
380 wxArchitecture GetArchitecture() const;
381 wxEndianness GetEndianness() const;
382
383
384 // string getters
385 // -----------------
386
387 wxString GetOperatingSystemFamilyName() const;
388 wxString GetOperatingSystemIdName() const;
389 wxString GetPortIdName() const;
390 wxString GetPortIdShortName() const;
391 wxString GetArchName() const;
392 wxString GetEndiannessName() const;
393
394 // setters
395 // -----------------
396
397 void SetOSVersion(int major, int minor);
398 void SetToolkitVersion(int major, int minor);
399
400 void SetOperatingSystemId(wxOperatingSystemId n);
401 void SetPortId(wxPortId n);
402 void SetArchitecture(wxArchitecture n);
403 void SetEndianness(wxEndianness n);
404
405 // miscellaneous
406 // -----------------
407
408 bool IsOk() const;
409
410 %property(ArchName, GetArchName, doc="See `GetArchName`");
411 %property(Architecture, GetArchitecture, SetArchitecture, doc="See `GetArchitecture` and `SetArchitecture`");
412 %property(Endianness, GetEndianness, SetEndianness, doc="See `GetEndianness` and `SetEndianness`");
413 %property(EndiannessName, GetEndiannessName, doc="See `GetEndiannessName`");
414 %property(OSMajorVersion, GetOSMajorVersion, doc="See `GetOSMajorVersion`");
415 %property(OSMinorVersion, GetOSMinorVersion, doc="See `GetOSMinorVersion`");
416 %property(OperatingSystemFamilyName, GetOperatingSystemFamilyName, doc="See `GetOperatingSystemFamilyName`");
417 %property(OperatingSystemId, GetOperatingSystemId, SetOperatingSystemId, doc="See `GetOperatingSystemId` and `SetOperatingSystemId`");
418 %property(OperatingSystemIdName, GetOperatingSystemIdName, doc="See `GetOperatingSystemIdName`");
419 %property(PortId, GetPortId, SetPortId, doc="See `GetPortId` and `SetPortId`");
420 %property(PortIdName, GetPortIdName, doc="See `GetPortIdName`");
421 %property(PortIdShortName, GetPortIdShortName, doc="See `GetPortIdShortName`");
422 %property(ToolkitMajorVersion, GetToolkitMajorVersion, doc="See `GetToolkitMajorVersion`");
423 %property(ToolkitMinorVersion, GetToolkitMinorVersion, doc="See `GetToolkitMinorVersion`");
424
425 };
426
427
428 //---------------------------------------------------------------------------
429 //---------------------------------------------------------------------------
430 // Experimental...
431
432 %{
433 #ifdef __WXMSW__
434 #include <wx/msw/private.h>
435 #include <wx/dynload.h>
436 #endif
437 %}
438
439
440 %inline %{
441
442 bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc
443 #if 0
444 , int method
445 #endif
446 )
447 {
448 #ifdef __WXMSW__
449 #if 0
450 switch (method)
451 {
452 case 1:
453 // This one only partially works. Appears to be an undocumented
454 // "standard" convention that not all widgets adhear to. For
455 // example, for some widgets backgrounds or non-client areas may
456 // not be painted.
457 ::SendMessage(GetHwndOf(window), WM_PAINT, (long)GetHdcOf(dc), 0);
458 break;
459
460 case 2:
461 #endif
462 // This one works much better, nearly all widgets and their
463 // children are captured correctly[**]. Prior to the big
464 // background erase changes that Vadim did in 2004-2005 this
465 // method failed badly on XP with Themes activated, most native
466 // widgets draw only partially, if at all. Without themes it
467 // worked just like on Win2k. After those changes this method
468 // works very well.
469 //
470 // ** For example the radio buttons in a wxRadioBox are not its
471 // children by default, but you can capture it via the panel
472 // instead, or change RADIOBTN_PARENT_IS_RADIOBOX in radiobox.cpp.
473 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
474 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
475 PRF_ERASEBKGND | PRF_OWNED );
476 return true;
477 #if 0
478 break;
479
480 case 3:
481 // This one is only defined in the latest SDK and is only
482 // available on XP. MSDN says it is similar to sending WM_PRINT
483 // so I expect that it will work similar to the above. Since it
484 // is avaialble only on XP, it can't be compiled like this and
485 // will have to be loaded dynamically.
486 // //::PrintWindow(GetHwndOf(window), GetHdcOf(dc), 0); //break;
487
488 // fall through
489
490 case 4:
491 // Use PrintWindow if available, or fallback to WM_PRINT
492 // otherwise. Unfortunately using PrintWindow is even worse than
493 // WM_PRINT. For most native widgets nothing is drawn to the dc
494 // at all, with or without Themes.
495 typedef BOOL (WINAPI *PrintWindow_t)(HWND, HDC, UINT);
496 static bool s_triedToLoad = false;
497 static PrintWindow_t pfnPrintWindow = NULL;
498 if ( !s_triedToLoad )
499 {
500
501 s_triedToLoad = true;
502 wxDynamicLibrary dllUser32(_T("user32.dll"));
503 if ( dllUser32.IsLoaded() )
504 {
505 wxLogNull nolog; // Don't report errors here
506 pfnPrintWindow = (PrintWindow_t)dllUser32.GetSymbol(_T("PrintWindow"));
507 }
508 }
509 if (pfnPrintWindow)
510 {
511 //printf("Using PrintWindow\n");
512 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
513 }
514 else
515 {
516 //printf("Using WM_PRINT\n");
517 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
518 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
519 PRF_ERASEBKGND | PRF_OWNED );
520 }
521 }
522 #endif // 0
523 #else
524 return false;
525 #endif // __WXMSW__
526 }
527
528 %}
529
530
531
532 #if 0
533 %{
534 void t_output_tester1(int* a, int* b, int* c, int* d)
535 {
536 *a = 1234;
537 *b = 2345;
538 *c = 3456;
539 *d = 4567;
540 }
541 PyObject* t_output_tester2(int* a, int* b, int* c, int* d)
542 {
543 *a = 1234;
544 *b = 2345;
545 *c = 3456;
546 *d = 4567;
547 Py_INCREF(Py_None);
548 return Py_None;
549 }
550 PyObject* t_output_tester3(int* a, int* b, int* c, int* d)
551 {
552 *a = 1234;
553 *b = 2345;
554 *c = 3456;
555 *d = 4567;
556 PyObject* res = PyTuple_New(2);
557 PyTuple_SetItem(res, 0, PyInt_FromLong(1));
558 PyTuple_SetItem(res, 1, PyInt_FromLong(2));
559 return res;
560 }
561 PyObject* t_output_tester4()
562 {
563 PyObject* res = PyTuple_New(2);
564 PyTuple_SetItem(res, 0, PyInt_FromLong(132));
565 PyTuple_SetItem(res, 1, PyInt_FromLong(244));
566 return res;
567 }
568 %}
569
570 %newobject t_output_tester2;
571 %newobject t_output_tester3;
572 %newobject t_output_tester4;
573
574 void t_output_tester1(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
575 PyObject* t_output_tester2(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
576 PyObject* t_output_tester3(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
577 PyObject* t_output_tester4();
578
579 #endif
580
581 //---------------------------------------------------------------------------
582 //---------------------------------------------------------------------------