]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: misc.i | |
3 | // Purpose: Definitions of miscelaneous functions and classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7/3/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
03e9bead | 13 | %module misc |
7bf85405 | 14 | |
03e9bead | 15 | %{ |
7bf85405 RD |
16 | #include "helpers.h" |
17 | #include <wx/resource.h> | |
af309447 | 18 | #include <wx/tooltip.h> |
2abc0a0f | 19 | #include <wx/busyinfo.h> |
7bf85405 RD |
20 | %} |
21 | ||
22 | //---------------------------------------------------------------------- | |
23 | ||
24 | %include typemaps.i | |
25 | %include my_typemaps.i | |
26 | ||
27 | // Import some definitions of other classes, etc. | |
28 | %import _defs.i | |
29 | ||
7bf85405 | 30 | |
bb0054cd | 31 | //--------------------------------------------------------------------------- |
7bf85405 RD |
32 | |
33 | ||
34 | class wxSize { | |
35 | public: | |
af309447 RD |
36 | long x; |
37 | long y; | |
7bf85405 RD |
38 | %name(width) long x; |
39 | %name(height)long y; | |
40 | ||
41 | wxSize(long w=0, long h=0); | |
42 | ~wxSize(); | |
43 | void Set(long w, long h); | |
af309447 RD |
44 | long GetX(); |
45 | long GetY(); | |
bb0054cd RD |
46 | long GetWidth(); |
47 | long GetHeight(); | |
48 | void SetWidth(long w); | |
49 | void SetHeight(long h); | |
7bf85405 RD |
50 | |
51 | %addmethods { | |
af309447 | 52 | PyObject* asTuple() { |
7bf85405 RD |
53 | PyObject* tup = PyTuple_New(2); |
54 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
55 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
56 | return tup; | |
57 | } | |
58 | } | |
af309447 RD |
59 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" |
60 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
61 | ||
7bf85405 RD |
62 | }; |
63 | ||
64 | //--------------------------------------------------------------------------- | |
65 | ||
66 | class wxRealPoint { | |
67 | public: | |
68 | double x; | |
69 | double y; | |
70 | wxRealPoint(double x=0.0, double y=0.0); | |
71 | ~wxRealPoint(); | |
efc5f224 RD |
72 | |
73 | %addmethods { | |
74 | void Set(double x, double y) { | |
75 | self->x = x; | |
76 | self->y = y; | |
77 | } | |
78 | PyObject* asTuple() { | |
79 | PyObject* tup = PyTuple_New(2); | |
80 | PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x)); | |
81 | PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y)); | |
82 | return tup; | |
83 | } | |
84 | } | |
85 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" | |
86 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
7bf85405 RD |
87 | }; |
88 | ||
efc5f224 | 89 | |
7bf85405 RD |
90 | class wxPoint { |
91 | public: | |
92 | long x; | |
93 | long y; | |
94 | wxPoint(long x=0, long y=0); | |
95 | ~wxPoint(); | |
96 | ||
97 | %addmethods { | |
98 | void Set(long x, long y) { | |
99 | self->x = x; | |
100 | self->y = y; | |
101 | } | |
af309447 | 102 | PyObject* asTuple() { |
7bf85405 RD |
103 | PyObject* tup = PyTuple_New(2); |
104 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
105 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
106 | return tup; | |
107 | } | |
108 | } | |
af309447 RD |
109 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" |
110 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
7bf85405 RD |
111 | }; |
112 | ||
113 | //--------------------------------------------------------------------------- | |
114 | ||
115 | class wxRect { | |
116 | public: | |
eb715945 RD |
117 | wxRect(int x=0, int y=0, int w=0, int h=0); |
118 | // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size); | |
119 | ~wxRect(); | |
7bf85405 | 120 | |
eb715945 RD |
121 | int GetX(); |
122 | void SetX(int X); | |
123 | int GetY(); | |
124 | void SetY(int Y); | |
125 | int GetWidth(); | |
126 | void SetWidth(int w); | |
127 | int GetHeight(); | |
128 | void SetHeight(int h); | |
7bf85405 RD |
129 | |
130 | ||
eb715945 RD |
131 | wxPoint GetPosition(); |
132 | wxSize GetSize(); | |
7bf85405 | 133 | |
eb715945 RD |
134 | int GetLeft(); |
135 | int GetTop(); | |
136 | int GetBottom(); | |
137 | int GetRight(); | |
7bf85405 | 138 | |
eb715945 RD |
139 | void SetLeft(int left); |
140 | void SetRight(int right); | |
141 | void SetTop(int top); | |
142 | void SetBottom(int bottom); | |
143 | ||
144 | ||
145 | int x, y, width, height; | |
af309447 RD |
146 | |
147 | %addmethods { | |
148 | PyObject* asTuple() { | |
149 | PyObject* tup = PyTuple_New(4); | |
150 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
151 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
f0261a72 RD |
152 | PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width)); |
153 | PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height)); | |
af309447 RD |
154 | return tup; |
155 | } | |
156 | } | |
157 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" | |
158 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
7bf85405 RD |
159 | }; |
160 | ||
161 | ||
eb715945 RD |
162 | // %inline %{ |
163 | // bool wxIntersectRect(wxRect* dest, wxRect* r1, wxRect* r2) { | |
164 | // wxRegion reg1(*r1); | |
165 | // wxRegion reg2(*r2); | |
166 | // bool success; | |
167 | // *dest = wxRect(0,0,0,0); | |
168 | // success = reg1.Intersect(reg2); | |
169 | // if (success) { | |
170 | // *dest = reg1.GetBox(); | |
171 | // return *dest != wxRect(0,0,0,0); | |
172 | // } | |
173 | // return FALSE; | |
174 | // } | |
175 | // %} | |
176 | ||
177 | ||
178 | %inline %{ | |
179 | PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) { | |
180 | wxRegion reg1(*r1); | |
181 | wxRegion reg2(*r2); | |
182 | wxRect dest(0,0,0,0); | |
183 | PyObject* obj; | |
184 | ||
185 | reg1.Intersect(reg2); | |
186 | dest = reg1.GetBox(); | |
187 | ||
188 | if (dest != wxRect(0,0,0,0)) { | |
189 | bool doSave = wxPyRestoreThread(); | |
190 | wxRect* newRect = new wxRect(dest); | |
191 | obj = wxPyConstructObject((void*)newRect, "wxRect"); | |
192 | PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1)); | |
193 | wxPySaveThread(doSave); | |
194 | return obj; | |
195 | } | |
196 | Py_INCREF(Py_None); | |
197 | return Py_None; | |
198 | } | |
199 | %} | |
7bf85405 | 200 | |
7bf85405 RD |
201 | |
202 | //--------------------------------------------------------------------------- | |
203 | // Miscellaneous functions | |
204 | ||
cf694132 RD |
205 | long wxNewId(); |
206 | void wxRegisterId(long id); | |
207 | %name(NewId) long wxNewId(); | |
208 | %name(RegisterId) void wxRegisterId(long id); | |
209 | ||
7bf85405 RD |
210 | void wxBell(); |
211 | void wxDisplaySize(int *OUTPUT, int *OUTPUT); | |
212 | void wxEndBusyCursor(); | |
eb715945 | 213 | long wxExecute(const wxString& command, int sync = FALSE); |
7bf85405 | 214 | long wxGetElapsedTime(bool resetTimer = TRUE); |
bc29c5e0 | 215 | #ifdef __WXMSW__ |
7bf85405 | 216 | long wxGetFreeMemory(); |
bc29c5e0 | 217 | #endif |
7bf85405 RD |
218 | void wxGetMousePosition(int* OUTPUT, int* OUTPUT); |
219 | bool wxIsBusy(); | |
220 | wxString wxNow(); | |
fb5e0af0 | 221 | bool wxShell(const wxString& command = wxPyEmptyStr); |
7bf85405 | 222 | void wxStartTimer(); |
fb5e0af0 | 223 | int wxGetOsVersion(int *OUTPUT, int *OUTPUT); |
fb5e0af0 | 224 | |
bb0054cd | 225 | void wxSleep(int secs); |
7bf85405 | 226 | bool wxYield(); |
cf694132 | 227 | bool wxSafeYield(); |
bb0054cd | 228 | void wxEnableTopLevelWindows(bool enable); |
7bf85405 | 229 | |
7bf85405 RD |
230 | %inline %{ |
231 | char* wxGetResource(char *section, char *entry, char *file = NULL) { | |
232 | char * retval; | |
233 | wxGetResource(section, entry, &retval, file); | |
234 | return retval; | |
235 | } | |
236 | %} | |
237 | ||
694759cf | 238 | wxString wxStripMenuCodes(const wxString& in); |
7bf85405 RD |
239 | |
240 | //---------------------------------------------------------------------- | |
241 | ||
242 | class wxPyTimer { | |
243 | public: | |
244 | wxPyTimer(PyObject* notify); | |
245 | ~wxPyTimer(); | |
694759cf RD |
246 | int GetInterval(); |
247 | bool IsOneShot(); | |
7bf85405 RD |
248 | void Start(int milliseconds=-1, int oneShot=FALSE); |
249 | void Stop(); | |
250 | }; | |
251 | ||
252 | //--------------------------------------------------------------------------- | |
253 | ||
254 | enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight, | |
255 | wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY }; | |
256 | enum wxRelationship { wxUnconstrained = 0, | |
257 | wxAsIs, | |
258 | wxPercentOf, | |
259 | wxAbove, | |
260 | wxBelow, | |
261 | wxLeftOf, | |
262 | wxRightOf, | |
263 | wxSameAs, | |
264 | wxAbsolute }; | |
265 | ||
266 | ||
267 | class wxIndividualLayoutConstraint { | |
268 | public: | |
269 | // wxIndividualLayoutConstraint(); | |
270 | // ~wxIndividualLayoutConstraint(); | |
271 | ||
272 | void Above(wxWindow *otherWin, int margin=0); | |
273 | void Absolute(int value); | |
08127323 | 274 | void AsIs(); |
7bf85405 | 275 | void Below(wxWindow *otherWin, int margin=0); |
08127323 | 276 | void Unconstrained(); |
7bf85405 RD |
277 | void LeftOf(wxWindow *otherWin, int margin=0); |
278 | void PercentOf(wxWindow *otherWin, wxEdge edge, int percent); | |
279 | void RightOf(wxWindow *otherWin, int margin=0); | |
280 | void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0); | |
281 | void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0); | |
282 | }; | |
283 | ||
284 | ||
285 | class wxLayoutConstraints { | |
286 | public: | |
287 | wxLayoutConstraints(); | |
288 | ||
289 | %readonly | |
290 | wxIndividualLayoutConstraint bottom; | |
291 | wxIndividualLayoutConstraint centreX; | |
292 | wxIndividualLayoutConstraint centreY; | |
293 | wxIndividualLayoutConstraint height; | |
294 | wxIndividualLayoutConstraint left; | |
295 | wxIndividualLayoutConstraint right; | |
296 | wxIndividualLayoutConstraint top; | |
297 | wxIndividualLayoutConstraint width; | |
298 | %readwrite | |
299 | } | |
300 | ||
301 | ||
b639c3c5 RD |
302 | //--------------------------------------------------------------------------- |
303 | // Regions, etc. | |
304 | ||
305 | enum wxRegionContain { | |
306 | wxOutRegion, wxPartRegion, wxInRegion | |
307 | }; | |
308 | ||
309 | ||
310 | class wxRegion { | |
311 | public: | |
312 | wxRegion(); | |
313 | ~wxRegion(); | |
314 | ||
315 | void Clear(); | |
316 | wxRegionContain Contains(long x, long y); | |
317 | %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt); | |
318 | %name(ContainsRect)wxRegionContain Contains(const wxRect& rect); | |
eb715945 | 319 | %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h); |
b639c3c5 RD |
320 | |
321 | wxRect GetBox(); | |
eb715945 RD |
322 | |
323 | bool Intersect(long x, long y, long width, long height); | |
324 | %name(IntersectRect)bool Intersect(const wxRect& rect); | |
325 | %name(IntersectRegion)bool Intersect(const wxRegion& region); | |
326 | ||
b639c3c5 | 327 | bool IsEmpty(); |
eb715945 RD |
328 | |
329 | bool Union(long x, long y, long width, long height); | |
330 | %name(UnionRect)bool Union(const wxRect& rect); | |
331 | %name(UnionRegion)bool Union(const wxRegion& region); | |
332 | ||
333 | bool Subtract(long x, long y, long width, long height); | |
334 | %name(SubtractRect)bool Subtract(const wxRect& rect); | |
335 | %name(SubtractRegion)bool Subtract(const wxRegion& region); | |
336 | ||
337 | bool Xor(long x, long y, long width, long height); | |
338 | %name(XorRect)bool Xor(const wxRect& rect); | |
339 | %name(XorRegion)bool Xor(const wxRegion& region); | |
b639c3c5 RD |
340 | }; |
341 | ||
342 | ||
343 | ||
344 | class wxRegionIterator { | |
345 | public: | |
346 | wxRegionIterator(const wxRegion& region); | |
347 | ~wxRegionIterator(); | |
348 | ||
349 | long GetX(); | |
350 | long GetY(); | |
351 | long GetW(); | |
352 | long GetWidth(); | |
353 | long GetH(); | |
354 | long GetHeight(); | |
355 | wxRect GetRect(); | |
356 | bool HaveRects(); | |
357 | void Reset(); | |
358 | ||
359 | %addmethods { | |
360 | void Next() { | |
361 | (*self) ++; | |
362 | } | |
363 | }; | |
364 | }; | |
365 | ||
366 | ||
367 | ||
7bf85405 RD |
368 | //--------------------------------------------------------------------------- |
369 | // Accelerator Entry and Table | |
370 | ||
371 | class wxAcceleratorEntry { | |
372 | public: | |
373 | wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0); | |
2f90df85 | 374 | ~wxAcceleratorEntry(); |
7bf85405 RD |
375 | |
376 | void Set(int flags, int keyCode, int Cmd); | |
377 | int GetFlags(); | |
378 | int GetKeyCode(); | |
379 | int GetCommand(); | |
380 | }; | |
381 | ||
382 | ||
383 | class wxAcceleratorTable { | |
384 | public: | |
385 | // Can also accept a list of 3-tuples | |
386 | wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST); | |
2f90df85 | 387 | ~wxAcceleratorTable(); |
7bf85405 RD |
388 | |
389 | }; | |
faf3cb35 | 390 | |
8bf5d46e | 391 | //--------------------------------------------------------------------------- |
2abc0a0f RD |
392 | |
393 | class wxBusyInfo { | |
394 | public: | |
395 | wxBusyInfo(const wxString& message); | |
396 | ~wxBusyInfo(); | |
397 | }; | |
398 | ||
399 | ||
400 | ||
8bf5d46e RD |
401 | //--------------------------------------------------------------------------- |
402 | ||
403 |