]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_misc.i
no longer need to lowercase the input ourselves
[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:
27 wxToolTip(const wxString &tip);
28
29 void SetTip(const wxString& tip);
30 wxString GetTip();
31 // *** Not in the "public" interface void SetWindow(wxWindow *win);
32 wxWindow *GetWindow();
33
34 static void Enable(bool flag);
35 static void SetDelay(long milliseconds);
36};
f87da722 37#endif
d14a1e28
RD
38
39//---------------------------------------------------------------------------
40
ab1f7d2a
RD
41MustHaveApp(wxCaret);
42
d14a1e28
RD
43class wxCaret {
44public:
45 wxCaret(wxWindow* window, const wxSize& size);
e981e2b5
RD
46// ~wxCaret(); Window takes ownership
47
48 %extend {
49 DocStr(Destroy,
50 "Deletes the C++ object this Python object is a proxy for.", "");
51 void Destroy() {
52 delete self;
53 }
54 }
55
d14a1e28
RD
56 bool IsOk();
57 bool IsVisible();
322913ce 58
d14a1e28 59 wxPoint GetPosition();
322913ce
RD
60 DocDeclAName(
61 void, GetPosition(int *OUTPUT, int *OUTPUT),
62 "GetPositionTuple() -> (x,y)",
63 GetPositionTuple);
64
d14a1e28 65 wxSize GetSize();
322913ce
RD
66 DocDeclAName(
67 void, GetSize( int *OUTPUT, int *OUTPUT ),
68 "GetSizeTuple() -> (width, height)",
69 GetSizeTuple);
70
71
d14a1e28 72 wxWindow *GetWindow();
1b8c7ba6 73 %Rename(MoveXY, void, Move(int x, int y));
d14a1e28 74 void Move(const wxPoint& pt);
1b8c7ba6 75 %Rename(SetSizeWH, void, SetSize(int width, int height));
d14a1e28 76 void SetSize(const wxSize& size);
a72f4631 77 void Show(int show = true);
d14a1e28
RD
78 void Hide();
79
322913ce 80 %pythoncode { def __nonzero__(self): return self.IsOk() }
d14a1e28 81
e981e2b5
RD
82 static int GetBlinkTime();
83 static void SetBlinkTime(int milliseconds);
84};
d14a1e28 85
d14a1e28
RD
86
87//---------------------------------------------------------------------------
88
ab1f7d2a
RD
89MustHaveApp(wxBusyCursor);
90
d14a1e28
RD
91class wxBusyCursor {
92public:
93 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
94 ~wxBusyCursor();
95};
96
97//---------------------------------------------------------------------------
98
ab1f7d2a
RD
99MustHaveApp(wxWindowDisabler);
100
d14a1e28
RD
101class wxWindowDisabler {
102public:
103 wxWindowDisabler(wxWindow *winToSkip = NULL);
104 ~wxWindowDisabler();
105};
106
107//---------------------------------------------------------------------------
108
ab1f7d2a
RD
109MustHaveApp(wxBusyInfo);
110
d14a1e28
RD
111class wxBusyInfo : public wxObject {
112public:
113 wxBusyInfo(const wxString& message);
114 ~wxBusyInfo();
115};
116
117
118//---------------------------------------------------------------------------
119
120
121// wxStopWatch: measure time intervals with up to 1ms resolution
122class wxStopWatch
123{
124public:
125 // ctor starts the stop watch
126 wxStopWatch();
127
128 // start the stop watch at the moment t0
129 void Start(long t0 = 0);
130
131 // pause the stop watch
132 void Pause();
133
134 // resume it
135 void Resume();
136
137 // get elapsed time since the last Start() in milliseconds
138 long Time() const;
139};
140
141
142
143//---------------------------------------------------------------------------
144
145class wxFileHistory : public wxObject
146{
147public:
823105f4 148 wxFileHistory(int maxFiles = 9, wxWindowID idBase = wxID_FILE1);
d14a1e28
RD
149 ~wxFileHistory();
150
151 // Operations
152 void AddFileToHistory(const wxString& file);
153 void RemoveFileFromHistory(int i);
154 int GetMaxFiles() const;
155 void UseMenu(wxMenu *menu);
156
157 // Remove menu from the list (MDI child may be closing)
158 void RemoveMenu(wxMenu *menu);
159
160 void Load(wxConfigBase& config);
161 void Save(wxConfigBase& config);
162
163 void AddFilesToMenu();
1b8c7ba6 164 %Rename(AddFilesToThisMenu, void, AddFilesToMenu(wxMenu* menu));
d14a1e28
RD
165
166 // Accessors
167 wxString GetHistoryFile(int i) const;
168
169 int GetCount() const;
138bb8ca 170 %pythoncode { GetNoHistoryFiles = GetCount }
d14a1e28
RD
171
172};
173
174
175//---------------------------------------------------------------------------
176
177%{
178#include <wx/snglinst.h>
179%}
180
181class wxSingleInstanceChecker
182{
183public:
184 // like Create() but no error checking (dangerous!)
185 wxSingleInstanceChecker(const wxString& name,
186 const wxString& path = wxPyEmptyString);
187
188 // default ctor, use Create() after it
1b8c7ba6 189 %RenameCtor(PreSingleInstanceChecker, wxSingleInstanceChecker());
d14a1e28
RD
190
191 ~wxSingleInstanceChecker();
192
193
194 // name must be given and be as unique as possible, it is used as the mutex
195 // name under Win32 and the lock file name under Unix -
196 // wxTheApp->GetAppName() may be a good value for this parameter
197 //
198 // path is optional and is ignored under Win32 and used as the directory to
199 // create the lock file in under Unix (default is wxGetHomeDir())
200 //
dd9f7fea 201 // returns False if initialization failed, it doesn't mean that another
d14a1e28
RD
202 // instance is running - use IsAnotherRunning() to check it
203 bool Create(const wxString& name, const wxString& path = wxPyEmptyString);
204
205 // is another copy of this program already running?
206 bool IsAnotherRunning() const;
207};
208
209//---------------------------------------------------------------------------
210// Experimental...
211
d14a1e28
RD
212%{
213#ifdef __WXMSW__
214#include <wx/msw/private.h>
215#include <wx/dynload.h>
216#endif
217%}
218
219
220%inline %{
221
32478f52
RD
222bool wxDrawWindowOnDC(wxWindow* window, const wxDC& dc
223#if 0
224 , int method
225#endif
226 )
d14a1e28
RD
227{
228#ifdef __WXMSW__
32478f52 229#if 0
d14a1e28
RD
230 switch (method)
231 {
232 case 1:
233 // This one only partially works. Appears to be an undocumented
234 // "standard" convention that not all widgets adhear to. For
235 // example, for some widgets backgrounds or non-client areas may
236 // not be painted.
237 ::SendMessage(GetHwndOf(window), WM_PAINT, (long)GetHdcOf(dc), 0);
238 break;
239
240 case 2:
32478f52
RD
241#endif
242 // This one works much better, nearly all widgets and their
243 // children are captured correctly[**]. Prior to the big
244 // background erase changes that Vadim did in 2004-2005 this
245 // method failed badly on XP with Themes activated, most native
246 // widgets draw only partially, if at all. Without themes it
247 // worked just like on Win2k. After those changes this method
248 // works very well.
d14a1e28
RD
249 //
250 // ** For example the radio buttons in a wxRadioBox are not its
251 // children by default, but you can capture it via the panel
252 // instead, or change RADIOBTN_PARENT_IS_RADIOBOX in radiobox.cpp.
253 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
254 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
255 PRF_ERASEBKGND | PRF_OWNED );
32478f52
RD
256 return true;
257#if 0
d14a1e28
RD
258 break;
259
260 case 3:
261 // This one is only defined in the latest SDK and is only
262 // available on XP. MSDN says it is similar to sending WM_PRINT
263 // so I expect that it will work similar to the above. Since it
264 // is avaialble only on XP, it can't be compiled like this and
265 // will have to be loaded dynamically.
266 // //::PrintWindow(GetHwndOf(window), GetHdcOf(dc), 0); //break;
267
268 // fall through
269
270 case 4:
271 // Use PrintWindow if available, or fallback to WM_PRINT
272 // otherwise. Unfortunately using PrintWindow is even worse than
273 // WM_PRINT. For most native widgets nothing is drawn to the dc
274 // at all, with or without Themes.
275 typedef BOOL (WINAPI *PrintWindow_t)(HWND, HDC, UINT);
a72f4631 276 static bool s_triedToLoad = false;
d14a1e28
RD
277 static PrintWindow_t pfnPrintWindow = NULL;
278 if ( !s_triedToLoad )
279 {
280
92956ab2 281 s_triedToLoad = true;
d14a1e28
RD
282 wxDynamicLibrary dllUser32(_T("user32.dll"));
283 if ( dllUser32.IsLoaded() )
284 {
285 wxLogNull nolog; // Don't report errors here
286 pfnPrintWindow = (PrintWindow_t)dllUser32.GetSymbol(_T("PrintWindow"));
287 }
288 }
289 if (pfnPrintWindow)
290 {
d115ca5e 291 //printf("Using PrintWindow\n");
d14a1e28
RD
292 pfnPrintWindow(GetHwndOf(window), GetHdcOf(dc), 0);
293 }
294 else
295 {
d115ca5e 296 //printf("Using WM_PRINT\n");
d14a1e28 297 ::SendMessage(GetHwndOf(window), WM_PRINT, (long)GetHdcOf(dc),
d115ca5e
RD
298 PRF_CLIENT | PRF_NONCLIENT | PRF_CHILDREN |
299 PRF_ERASEBKGND | PRF_OWNED );
d14a1e28
RD
300 }
301 }
32478f52
RD
302#endif // 0
303#else
304 return false;
305#endif // __WXMSW__
d14a1e28
RD
306}
307
308%}
309
8f93b075 310
d14a1e28
RD
311//---------------------------------------------------------------------------
312//---------------------------------------------------------------------------