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