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