]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_misc.i
Add wx.menuBar.UpdateMenus
[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 %pythoncode { def Destroy(self): pass }
123 };
124
125
126 //---------------------------------------------------------------------------
127
128
129 // wxStopWatch: measure time intervals with up to 1ms resolution
130 class wxStopWatch
131 {
132 public:
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
153 class wxFileHistory : public wxObject
154 {
155 public:
156 wxFileHistory(int maxFiles = 9, wxWindowID idBase = wxID_FILE1);
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();
172 %Rename(AddFilesToThisMenu, void, AddFilesToMenu(wxMenu* menu));
173
174 // Accessors
175 wxString GetHistoryFile(int i) const;
176
177 int GetCount() const;
178 %pythoncode { GetNoHistoryFiles = GetCount }
179
180 };
181
182
183 //---------------------------------------------------------------------------
184
185 %{
186 #include <wx/snglinst.h>
187 %}
188
189 class wxSingleInstanceChecker
190 {
191 public:
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
197 %RenameCtor(PreSingleInstanceChecker, wxSingleInstanceChecker());
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 //
209 // returns False if initialization failed, it doesn't mean that another
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
220 %{
221 #ifdef __WXMSW__
222 #include <wx/msw/private.h>
223 #include <wx/dynload.h>
224 #endif
225 %}
226
227
228 %inline %{
229
230 bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc
231 #if 0
232 , int method
233 #endif
234 )
235 {
236 #ifdef __WXMSW__
237 #if 0
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:
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.
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 );
264 return true;
265 #if 0
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);
284 static bool s_triedToLoad = false;
285 static PrintWindow_t pfnPrintWindow = NULL;
286 if ( !s_triedToLoad )
287 {
288
289 s_triedToLoad = true;
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 {
299 //printf("Using PrintWindow\n");
300 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
301 }
302 else
303 {
304 //printf("Using WM_PRINT\n");
305 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
306 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
307 PRF_ERASEBKGND | PRF_OWNED );
308 }
309 }
310 #endif // 0
311 #else
312 return false;
313 #endif // __WXMSW__
314 }
315
316 %}
317
318
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
362 void t_output_tester1(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
363 PyObject* t_output_tester2(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
364 PyObject* t_output_tester3(int* OUTPUT, int* OUTPUT, int* OUTPUT, int* OUTPUT);
365 PyObject* t_output_tester4();
366
367 #endif
368
369 //---------------------------------------------------------------------------
370 //---------------------------------------------------------------------------