]>
Commit | Line | Data |
---|---|---|
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 | |
23 | MustHaveApp(wxToolTip); | |
24 | ||
d14a1e28 RD |
25 | class wxToolTip : public wxObject { |
26 | public: | |
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 |
46 | MustHaveApp(wxCaret); |
47 | ||
d14a1e28 RD |
48 | class wxCaret { |
49 | public: | |
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 |
95 | MustHaveApp(wxBusyCursor); |
96 | ||
d14a1e28 RD |
97 | class wxBusyCursor { |
98 | public: | |
99 | wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR); | |
100 | ~wxBusyCursor(); | |
101 | }; | |
102 | ||
103 | //--------------------------------------------------------------------------- | |
104 | ||
ab1f7d2a RD |
105 | MustHaveApp(wxWindowDisabler); |
106 | ||
d14a1e28 RD |
107 | class wxWindowDisabler { |
108 | public: | |
109 | wxWindowDisabler(wxWindow *winToSkip = NULL); | |
110 | ~wxWindowDisabler(); | |
111 | }; | |
112 | ||
113 | //--------------------------------------------------------------------------- | |
114 | ||
ab1f7d2a RD |
115 | MustHaveApp(wxBusyInfo); |
116 | ||
d14a1e28 RD |
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: | |
823105f4 | 154 | wxFileHistory(int maxFiles = 9, wxWindowID idBase = wxID_FILE1); |
d14a1e28 RD |
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(); | |
1b8c7ba6 | 170 | %Rename(AddFilesToThisMenu, void, AddFilesToMenu(wxMenu* menu)); |
d14a1e28 RD |
171 | |
172 | // Accessors | |
173 | wxString GetHistoryFile(int i) const; | |
174 | ||
175 | int GetCount() const; | |
138bb8ca | 176 | %pythoncode { GetNoHistoryFiles = GetCount } |
d14a1e28 RD |
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 | |
1b8c7ba6 | 195 | %RenameCtor(PreSingleInstanceChecker, wxSingleInstanceChecker()); |
d14a1e28 RD |
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 | // | |
dd9f7fea | 207 | // returns False if initialization failed, it doesn't mean that another |
d14a1e28 RD |
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 | ||
d14a1e28 RD |
218 | %{ |
219 | #ifdef __WXMSW__ | |
220 | #include <wx/msw/private.h> | |
221 | #include <wx/dynload.h> | |
222 | #endif | |
223 | %} | |
224 | ||
225 | ||
226 | %inline %{ | |
227 | ||
32478f52 RD |
228 | bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc |
229 | #if 0 | |
230 | , int method | |
231 | #endif | |
232 | ) | |
d14a1e28 RD |
233 | { |
234 | #ifdef __WXMSW__ | |
32478f52 | 235 | #if 0 |
d14a1e28 RD |
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: | |
32478f52 RD |
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. | |
d14a1e28 RD |
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 ); | |
32478f52 RD |
262 | return true; |
263 | #if 0 | |
d14a1e28 RD |
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); | |
a72f4631 | 282 | static bool s_triedToLoad = false; |
d14a1e28 RD |
283 | static PrintWindow_t pfnPrintWindow = NULL; |
284 | if ( !s_triedToLoad ) | |
285 | { | |
286 | ||
92956ab2 | 287 | s_triedToLoad = true; |
d14a1e28 RD |
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 | { | |
d115ca5e | 297 | //printf("Using PrintWindow\n"); |
d14a1e28 RD |
298 | pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0); |
299 | } | |
300 | else | |
301 | { | |
d115ca5e | 302 | //printf("Using WM_PRINT\n"); |
d14a1e28 | 303 | ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc), |
d115ca5e RD |
304 | PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN | |
305 | PRF_ERASEBKGND | PRF_OWNED ); | |
d14a1e28 RD |
306 | } |
307 | } | |
32478f52 RD |
308 | #endif // 0 |
309 | #else | |
310 | return false; | |
311 | #endif // __WXMSW__ | |
d14a1e28 RD |
312 | } |
313 | ||
314 | %} | |
315 | ||
8f93b075 | 316 | |
214c4fbe RD |
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 | ||
d14a1e28 RD |
367 | //--------------------------------------------------------------------------- |
368 | //--------------------------------------------------------------------------- |