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