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