]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_misc.i
added obsolescence note
[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 class wxToolTip : public wxObject {
22 public:
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
36 class wxCaret {
37 public:
38 wxCaret(wxWindow* window, const wxSize& size);
39 ~wxCaret();
40
41 bool IsOk();
42 bool IsVisible();
43
44 wxPoint GetPosition();
45 DocDeclAName(
46 void, GetPosition(int *OUTPUT, int *OUTPUT),
47 "GetPositionTuple() -> (x,y)",
48 GetPositionTuple);
49
50 wxSize GetSize();
51 DocDeclAName(
52 void, GetSize( int *OUTPUT, int *OUTPUT ),
53 "GetSizeTuple() -> (width, height)",
54 GetSizeTuple);
55
56
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);
62 void Show(int show = True);
63 void Hide();
64
65 %pythoncode { def __nonzero__(self): return self.IsOk() }
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
80 class wxBusyCursor {
81 public:
82 wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR);
83 ~wxBusyCursor();
84 };
85
86 //---------------------------------------------------------------------------
87
88 class wxWindowDisabler {
89 public:
90 wxWindowDisabler(wxWindow *winToSkip = NULL);
91 ~wxWindowDisabler();
92 };
93
94 //---------------------------------------------------------------------------
95
96 class wxBusyInfo : public wxObject {
97 public:
98 wxBusyInfo(const wxString& message);
99 ~wxBusyInfo();
100 };
101
102
103 //---------------------------------------------------------------------------
104
105
106 // wxStopWatch: measure time intervals with up to 1ms resolution
107 class wxStopWatch
108 {
109 public:
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
130 class wxFileHistory : public wxObject
131 {
132 public:
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
166 class wxSingleInstanceChecker
167 {
168 public:
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 //
186 // returns False if initialization failed, it doesn't mean that another
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
209 void 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);
254 static bool s_triedToLoad = False;
255 static PrintWindow_t pfnPrintWindow = NULL;
256 if ( !s_triedToLoad )
257 {
258
259 s_triedToLoad = True;
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 //---------------------------------------------------------------------------