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