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