]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_misc.i
Added wrappers for wxAUI
[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
217//---------------------------------------------------------------------------
218// Experimental...
219
d14a1e28
RD
220%{
221#ifdef __WXMSW__
222#include <wx/msw/private.h>
223#include <wx/dynload.h>
224#endif
225%}
226
227
228%inline %{
229
32478f52
RD
230bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc
231#if 0
232 , int method
233#endif
234 )
d14a1e28
RD
235{
236#ifdef __WXMSW__
32478f52 237#if 0
d14a1e28
RD
238 switch (method)
239 {
240 case 1:
241 // This one only partially works. Appears to be an undocumented
242 // "standard" convention that not all widgets adhear to. For
243 // example, for some widgets backgrounds or non-client areas may
244 // not be painted.
245 ::SendMessage(GetHwndOf(window), WM_PAINT, (long)GetHdcOf(dc), 0);
246 break;
247
248 case 2:
32478f52
RD
249#endif
250 // This one works much better, nearly all widgets and their
251 // children are captured correctly[**]. Prior to the big
252 // background erase changes that Vadim did in 2004-2005 this
253 // method failed badly on XP with Themes activated, most native
254 // widgets draw only partially, if at all. Without themes it
255 // worked just like on Win2k. After those changes this method
256 // works very well.
d14a1e28
RD
257 //
258 // ** For example the radio buttons in a wxRadioBox are not its
259 // children by default, but you can capture it via the panel
260 // instead, or change RADIOBTN_PARENT_IS_RADIOBOX in radiobox.cpp.
261 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
262 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
263 PRF_ERASEBKGND | PRF_OWNED );
32478f52
RD
264 return true;
265#if 0
d14a1e28
RD
266 break;
267
268 case 3:
269 // This one is only defined in the latest SDK and is only
270 // available on XP. MSDN says it is similar to sending WM_PRINT
271 // so I expect that it will work similar to the above. Since it
272 // is avaialble only on XP, it can't be compiled like this and
273 // will have to be loaded dynamically.
274 // //::PrintWindow(GetHwndOf(window), GetHdcOf(dc), 0); //break;
275
276 // fall through
277
278 case 4:
279 // Use PrintWindow if available, or fallback to WM_PRINT
280 // otherwise. Unfortunately using PrintWindow is even worse than
281 // WM_PRINT. For most native widgets nothing is drawn to the dc
282 // at all, with or without Themes.
283 typedef BOOL (WINAPI *PrintWindow_t)(HWND, HDC, UINT);
a72f4631 284 static bool s_triedToLoad = false;
d14a1e28
RD
285 static PrintWindow_t pfnPrintWindow = NULL;
286 if ( !s_triedToLoad )
287 {
288
92956ab2 289 s_triedToLoad = true;
d14a1e28
RD
290 wxDynamicLibrary dllUser32(_T("user32.dll"));
291 if ( dllUser32.IsLoaded() )
292 {
293 wxLogNull nolog; // Don't report errors here
294 pfnPrintWindow = (PrintWindow_t)dllUser32.GetSymbol(_T("PrintWindow"));
295 }
296 }
297 if (pfnPrintWindow)
298 {
d115ca5e 299 //printf("Using PrintWindow\n");
d14a1e28
RD
300 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
301 }
302 else
303 {
d115ca5e 304 //printf("Using WM_PRINT\n");
d14a1e28 305 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
d115ca5e
RD
306 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
307 PRF_ERASEBKGND | PRF_OWNED );
d14a1e28
RD
308 }
309 }
32478f52
RD
310#endif // 0
311#else
312 return false;
313#endif // __WXMSW__
d14a1e28
RD
314}
315
316%}
317
8f93b075 318
214c4fbe
RD
319
320#if 0
321%{
322 void t_output_tester1(int* a, int* b, int* c, int* d)
323 {
324 *a = 1234;
325 *b = 2345;
326 *c = 3456;
327 *d = 4567;
328 }
329 PyObject* t_output_tester2(int* a, int* b, int* c, int* d)
330 {
331 *a = 1234;
332 *b = 2345;
333 *c = 3456;
334 *d = 4567;
335 Py_INCREF(Py_None);
336 return Py_None;
337 }
338 PyObject* t_output_tester3(int* a, int* b, int* c, int* d)
339 {
340 *a = 1234;
341 *b = 2345;
342 *c = 3456;
343 *d = 4567;
344 PyObject* res = PyTuple_New(2);
345 PyTuple_SetItem(res, 0, PyInt_FromLong(1));
346 PyTuple_SetItem(res, 1, PyInt_FromLong(2));
347 return res;
348 }
349 PyObject* t_output_tester4()
350 {
351 PyObject* res = PyTuple_New(2);
352 PyTuple_SetItem(res, 0, PyInt_FromLong(132));
353 PyTuple_SetItem(res, 1, PyInt_FromLong(244));
354 return res;
355 }
356%}
357
358%newobject t_output_tester2;
359%newobject t_output_tester3;
360%newobject t_output_tester4;
361
362void t_output_tester1(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
363PyObject* t_output_tester2(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
364PyObject* t_output_tester3(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
365PyObject* t_output_tester4();
366
367#endif
368
d14a1e28
RD
369//---------------------------------------------------------------------------
370//---------------------------------------------------------------------------