]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_misc.i
Applied patch [ 1431955 ] Fixes wxSocket* _Wait/Select
[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
92
93 //---------------------------------------------------------------------------
94
95 MustHaveApp(wxBusyCursor);
96
97 class wxBusyCursor {
98 public:
99 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
100 ~wxBusyCursor();
101 };
102
103 //---------------------------------------------------------------------------
104
105 MustHaveApp(wxWindowDisabler);
106
107 class wxWindowDisabler {
108 public:
109 wxWindowDisabler(wxWindow *winToSkip = NULL);
110 ~wxWindowDisabler();
111 };
112
113 //---------------------------------------------------------------------------
114
115 MustHaveApp(wxBusyInfo);
116
117 class wxBusyInfo : public wxObject {
118 public:
119 wxBusyInfo(const wxString& message);
120 ~wxBusyInfo();
121 };
122
123
124 //---------------------------------------------------------------------------
125
126
127 // wxStopWatch: measure time intervals with up to 1ms resolution
128 class wxStopWatch
129 {
130 public:
131 // ctor starts the stop watch
132 wxStopWatch();
133
134 // start the stop watch at the moment t0
135 void Start(long t0 = 0);
136
137 // pause the stop watch
138 void Pause();
139
140 // resume it
141 void Resume();
142
143 // get elapsed time since the last Start() in milliseconds
144 long Time() const;
145 };
146
147
148
149 //---------------------------------------------------------------------------
150
151 class wxFileHistory : public wxObject
152 {
153 public:
154 wxFileHistory(int maxFiles = 9, wxWindowID idBase = wxID_FILE1);
155 ~wxFileHistory();
156
157 // Operations
158 void AddFileToHistory(const wxString& file);
159 void RemoveFileFromHistory(int i);
160 int GetMaxFiles() const;
161 void UseMenu(wxMenu *menu);
162
163 // Remove menu from the list (MDI child may be closing)
164 void RemoveMenu(wxMenu *menu);
165
166 void Load(wxConfigBase& config);
167 void Save(wxConfigBase& config);
168
169 void AddFilesToMenu();
170 %Rename(AddFilesToThisMenu, void, AddFilesToMenu(wxMenu* menu));
171
172 // Accessors
173 wxString GetHistoryFile(int i) const;
174
175 int GetCount() const;
176 %pythoncode { GetNoHistoryFiles = GetCount }
177
178 };
179
180
181 //---------------------------------------------------------------------------
182
183 %{
184 #include <wx/snglinst.h>
185 %}
186
187 class wxSingleInstanceChecker
188 {
189 public:
190 // like Create() but no error checking (dangerous!)
191 wxSingleInstanceChecker(const wxString& name,
192 const wxString& path = wxPyEmptyString);
193
194 // default ctor, use Create() after it
195 %RenameCtor(PreSingleInstanceChecker, wxSingleInstanceChecker());
196
197 ~wxSingleInstanceChecker();
198
199
200 // name must be given and be as unique as possible, it is used as the mutex
201 // name under Win32 and the lock file name under Unix -
202 // wxTheApp->GetAppName() may be a good value for this parameter
203 //
204 // path is optional and is ignored under Win32 and used as the directory to
205 // create the lock file in under Unix (default is wxGetHomeDir())
206 //
207 // returns False if initialization failed, it doesn't mean that another
208 // instance is running - use IsAnotherRunning() to check it
209 bool Create(const wxString& name, const wxString& path = wxPyEmptyString);
210
211 // is another copy of this program already running?
212 bool IsAnotherRunning() const;
213 };
214
215 //---------------------------------------------------------------------------
216 // Experimental...
217
218 %{
219 #ifdef __WXMSW__
220 #include <wx/msw/private.h>
221 #include <wx/dynload.h>
222 #endif
223 %}
224
225
226 %inline %{
227
228 bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc
229 #if 0
230 , int method
231 #endif
232 )
233 {
234 #ifdef __WXMSW__
235 #if 0
236 switch (method)
237 {
238 case 1:
239 // This one only partially works. Appears to be an undocumented
240 // "standard" convention that not all widgets adhear to. For
241 // example, for some widgets backgrounds or non-client areas may
242 // not be painted.
243 ::SendMessage(GetHwndOf(window), WM_PAINT, (long)GetHdcOf(dc), 0);
244 break;
245
246 case 2:
247 #endif
248 // This one works much better, nearly all widgets and their
249 // children are captured correctly[**]. Prior to the big
250 // background erase changes that Vadim did in 2004-2005 this
251 // method failed badly on XP with Themes activated, most native
252 // widgets draw only partially, if at all. Without themes it
253 // worked just like on Win2k. After those changes this method
254 // works very well.
255 //
256 // ** For example the radio buttons in a wxRadioBox are not its
257 // children by default, but you can capture it via the panel
258 // instead, or change RADIOBTN_PARENT_IS_RADIOBOX in radiobox.cpp.
259 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
260 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
261 PRF_ERASEBKGND | PRF_OWNED );
262 return true;
263 #if 0
264 break;
265
266 case 3:
267 // This one is only defined in the latest SDK and is only
268 // available on XP. MSDN says it is similar to sending WM_PRINT
269 // so I expect that it will work similar to the above. Since it
270 // is avaialble only on XP, it can't be compiled like this and
271 // will have to be loaded dynamically.
272 // //::PrintWindow(GetHwndOf(window), GetHdcOf(dc), 0); //break;
273
274 // fall through
275
276 case 4:
277 // Use PrintWindow if available, or fallback to WM_PRINT
278 // otherwise. Unfortunately using PrintWindow is even worse than
279 // WM_PRINT. For most native widgets nothing is drawn to the dc
280 // at all, with or without Themes.
281 typedef BOOL (WINAPI *PrintWindow_t)(HWND, HDC, UINT);
282 static bool s_triedToLoad = false;
283 static PrintWindow_t pfnPrintWindow = NULL;
284 if ( !s_triedToLoad )
285 {
286
287 s_triedToLoad = true;
288 wxDynamicLibrary dllUser32(_T("user32.dll"));
289 if ( dllUser32.IsLoaded() )
290 {
291 wxLogNull nolog; // Don't report errors here
292 pfnPrintWindow = (PrintWindow_t)dllUser32.GetSymbol(_T("PrintWindow"));
293 }
294 }
295 if (pfnPrintWindow)
296 {
297 //printf("Using PrintWindow\n");
298 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
299 }
300 else
301 {
302 //printf("Using WM_PRINT\n");
303 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
304 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
305 PRF_ERASEBKGND | PRF_OWNED );
306 }
307 }
308 #endif // 0
309 #else
310 return false;
311 #endif // __WXMSW__
312 }
313
314 %}
315
316
317
318 #if 0
319 %{
320 void t_output_tester1(int* a, int* b, int* c, int* d)
321 {
322 *a = 1234;
323 *b = 2345;
324 *c = 3456;
325 *d = 4567;
326 }
327 PyObject* t_output_tester2(int* a, int* b, int* c, int* d)
328 {
329 *a = 1234;
330 *b = 2345;
331 *c = 3456;
332 *d = 4567;
333 Py_INCREF(Py_None);
334 return Py_None;
335 }
336 PyObject* t_output_tester3(int* a, int* b, int* c, int* d)
337 {
338 *a = 1234;
339 *b = 2345;
340 *c = 3456;
341 *d = 4567;
342 PyObject* res = PyTuple_New(2);
343 PyTuple_SetItem(res, 0, PyInt_FromLong(1));
344 PyTuple_SetItem(res, 1, PyInt_FromLong(2));
345 return res;
346 }
347 PyObject* t_output_tester4()
348 {
349 PyObject* res = PyTuple_New(2);
350 PyTuple_SetItem(res, 0, PyInt_FromLong(132));
351 PyTuple_SetItem(res, 1, PyInt_FromLong(244));
352 return res;
353 }
354 %}
355
356 %newobject t_output_tester2;
357 %newobject t_output_tester3;
358 %newobject t_output_tester4;
359
360 void t_output_tester1(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
361 PyObject* t_output_tester2(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
362 PyObject* t_output_tester3(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
363 PyObject* t_output_tester4();
364
365 #endif
366
367 //---------------------------------------------------------------------------
368 //---------------------------------------------------------------------------