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