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> |
7bf85405 RD |
19 | %} |
20 | ||
21 | //---------------------------------------------------------------------- | |
22 | ||
23 | %include typemaps.i | |
24 | %include my_typemaps.i | |
25 | ||
26 | // Import some definitions of other classes, etc. | |
27 | %import _defs.i | |
28 | ||
7bf85405 | 29 | |
bb0054cd | 30 | //--------------------------------------------------------------------------- |
7bf85405 RD |
31 | |
32 | ||
33 | class wxSize { | |
34 | public: | |
af309447 RD |
35 | long x; |
36 | long y; | |
7bf85405 RD |
37 | %name(width) long x; |
38 | %name(height)long y; | |
39 | ||
40 | wxSize(long w=0, long h=0); | |
41 | ~wxSize(); | |
42 | void Set(long w, long h); | |
af309447 RD |
43 | long GetX(); |
44 | long GetY(); | |
bb0054cd RD |
45 | long GetWidth(); |
46 | long GetHeight(); | |
47 | void SetWidth(long w); | |
48 | void SetHeight(long h); | |
7bf85405 RD |
49 | |
50 | %addmethods { | |
af309447 | 51 | PyObject* asTuple() { |
7bf85405 RD |
52 | PyObject* tup = PyTuple_New(2); |
53 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
54 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
55 | return tup; | |
56 | } | |
57 | } | |
af309447 RD |
58 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" |
59 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
60 | ||
7bf85405 RD |
61 | }; |
62 | ||
63 | //--------------------------------------------------------------------------- | |
64 | ||
65 | class wxRealPoint { | |
66 | public: | |
67 | double x; | |
68 | double y; | |
69 | wxRealPoint(double x=0.0, double y=0.0); | |
70 | ~wxRealPoint(); | |
efc5f224 RD |
71 | |
72 | %addmethods { | |
73 | void Set(double x, double y) { | |
74 | self->x = x; | |
75 | self->y = y; | |
76 | } | |
77 | PyObject* asTuple() { | |
78 | PyObject* tup = PyTuple_New(2); | |
79 | PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x)); | |
80 | PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y)); | |
81 | return tup; | |
82 | } | |
83 | } | |
84 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" | |
85 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
7bf85405 RD |
86 | }; |
87 | ||
efc5f224 | 88 | |
7bf85405 RD |
89 | class wxPoint { |
90 | public: | |
91 | long x; | |
92 | long y; | |
93 | wxPoint(long x=0, long y=0); | |
94 | ~wxPoint(); | |
95 | ||
96 | %addmethods { | |
97 | void Set(long x, long y) { | |
98 | self->x = x; | |
99 | self->y = y; | |
100 | } | |
af309447 | 101 | PyObject* asTuple() { |
7bf85405 RD |
102 | PyObject* tup = PyTuple_New(2); |
103 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
104 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
105 | return tup; | |
106 | } | |
107 | } | |
af309447 RD |
108 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" |
109 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
7bf85405 RD |
110 | }; |
111 | ||
112 | //--------------------------------------------------------------------------- | |
113 | ||
114 | class wxRect { | |
115 | public: | |
116 | wxRect(long x=0, long y=0, long w=0, long h=0); | |
117 | // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size); | |
118 | ~wxRect(); | |
119 | ||
120 | long GetX(); | |
121 | void SetX(long X); | |
122 | long GetY(); | |
123 | void SetY(long Y); | |
124 | long GetWidth(); | |
125 | void SetWidth(long w); | |
126 | long GetHeight(); | |
127 | void SetHeight(long h); | |
128 | ||
129 | ||
130 | wxPoint GetPosition(); | |
131 | wxSize GetSize(); | |
132 | ||
133 | long GetLeft(); | |
134 | long GetTop(); | |
135 | long GetBottom(); | |
136 | long GetRight(); | |
137 | ||
138 | long x, y, width, height; | |
af309447 RD |
139 | |
140 | %addmethods { | |
141 | PyObject* asTuple() { | |
142 | PyObject* tup = PyTuple_New(4); | |
143 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
144 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
f0261a72 RD |
145 | PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width)); |
146 | PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height)); | |
af309447 RD |
147 | return tup; |
148 | } | |
149 | } | |
150 | %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())" | |
151 | %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())" | |
7bf85405 RD |
152 | }; |
153 | ||
154 | ||
155 | ||
7bf85405 RD |
156 | |
157 | //--------------------------------------------------------------------------- | |
158 | // Miscellaneous functions | |
159 | ||
cf694132 RD |
160 | long wxNewId(); |
161 | void wxRegisterId(long id); | |
162 | %name(NewId) long wxNewId(); | |
163 | %name(RegisterId) void wxRegisterId(long id); | |
164 | ||
7bf85405 RD |
165 | void wxBell(); |
166 | void wxDisplaySize(int *OUTPUT, int *OUTPUT); | |
167 | void wxEndBusyCursor(); | |
168 | long wxExecute(const wxString& command, bool sync = FALSE); | |
7bf85405 | 169 | long wxGetElapsedTime(bool resetTimer = TRUE); |
bc29c5e0 | 170 | #ifdef __WXMSW__ |
7bf85405 | 171 | long wxGetFreeMemory(); |
bc29c5e0 | 172 | #endif |
7bf85405 RD |
173 | void wxGetMousePosition(int* OUTPUT, int* OUTPUT); |
174 | bool wxIsBusy(); | |
175 | wxString wxNow(); | |
fb5e0af0 | 176 | bool wxShell(const wxString& command = wxPyEmptyStr); |
7bf85405 | 177 | void wxStartTimer(); |
fb5e0af0 | 178 | int wxGetOsVersion(int *OUTPUT, int *OUTPUT); |
fb5e0af0 | 179 | |
bb0054cd | 180 | void wxSleep(int secs); |
7bf85405 | 181 | bool wxYield(); |
cf694132 | 182 | bool wxSafeYield(); |
bb0054cd | 183 | void wxEnableTopLevelWindows(bool enable); |
7bf85405 | 184 | |
7bf85405 RD |
185 | %inline %{ |
186 | char* wxGetResource(char *section, char *entry, char *file = NULL) { | |
187 | char * retval; | |
188 | wxGetResource(section, entry, &retval, file); | |
189 | return retval; | |
190 | } | |
191 | %} | |
192 | ||
7bf85405 RD |
193 | |
194 | //---------------------------------------------------------------------- | |
195 | ||
196 | class wxPyTimer { | |
197 | public: | |
198 | wxPyTimer(PyObject* notify); | |
199 | ~wxPyTimer(); | |
200 | int Interval(); | |
201 | void Start(int milliseconds=-1, int oneShot=FALSE); | |
202 | void Stop(); | |
203 | }; | |
204 | ||
205 | //--------------------------------------------------------------------------- | |
206 | ||
207 | enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight, | |
208 | wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY }; | |
209 | enum wxRelationship { wxUnconstrained = 0, | |
210 | wxAsIs, | |
211 | wxPercentOf, | |
212 | wxAbove, | |
213 | wxBelow, | |
214 | wxLeftOf, | |
215 | wxRightOf, | |
216 | wxSameAs, | |
217 | wxAbsolute }; | |
218 | ||
219 | ||
220 | class wxIndividualLayoutConstraint { | |
221 | public: | |
222 | // wxIndividualLayoutConstraint(); | |
223 | // ~wxIndividualLayoutConstraint(); | |
224 | ||
225 | void Above(wxWindow *otherWin, int margin=0); | |
226 | void Absolute(int value); | |
08127323 | 227 | void AsIs(); |
7bf85405 | 228 | void Below(wxWindow *otherWin, int margin=0); |
08127323 | 229 | void Unconstrained(); |
7bf85405 RD |
230 | void LeftOf(wxWindow *otherWin, int margin=0); |
231 | void PercentOf(wxWindow *otherWin, wxEdge edge, int percent); | |
232 | void RightOf(wxWindow *otherWin, int margin=0); | |
233 | void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0); | |
234 | void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0); | |
235 | }; | |
236 | ||
237 | ||
238 | class wxLayoutConstraints { | |
239 | public: | |
240 | wxLayoutConstraints(); | |
241 | ||
242 | %readonly | |
243 | wxIndividualLayoutConstraint bottom; | |
244 | wxIndividualLayoutConstraint centreX; | |
245 | wxIndividualLayoutConstraint centreY; | |
246 | wxIndividualLayoutConstraint height; | |
247 | wxIndividualLayoutConstraint left; | |
248 | wxIndividualLayoutConstraint right; | |
249 | wxIndividualLayoutConstraint top; | |
250 | wxIndividualLayoutConstraint width; | |
251 | %readwrite | |
252 | } | |
253 | ||
254 | ||
b639c3c5 RD |
255 | //--------------------------------------------------------------------------- |
256 | // Regions, etc. | |
257 | ||
258 | enum wxRegionContain { | |
259 | wxOutRegion, wxPartRegion, wxInRegion | |
260 | }; | |
261 | ||
262 | ||
263 | class wxRegion { | |
264 | public: | |
265 | wxRegion(); | |
266 | ~wxRegion(); | |
267 | ||
268 | void Clear(); | |
269 | wxRegionContain Contains(long x, long y); | |
270 | %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt); | |
271 | %name(ContainsRect)wxRegionContain Contains(const wxRect& rect); | |
272 | ||
273 | wxRect GetBox(); | |
274 | bool Intersect(const wxRect& rect); | |
275 | bool IsEmpty(); | |
276 | bool Subtract(const wxRect& rect); | |
277 | bool Union(const wxRect& rect); | |
278 | bool Xor(const wxRect& rect); | |
279 | }; | |
280 | ||
281 | ||
282 | ||
283 | class wxRegionIterator { | |
284 | public: | |
285 | wxRegionIterator(const wxRegion& region); | |
286 | ~wxRegionIterator(); | |
287 | ||
288 | long GetX(); | |
289 | long GetY(); | |
290 | long GetW(); | |
291 | long GetWidth(); | |
292 | long GetH(); | |
293 | long GetHeight(); | |
294 | wxRect GetRect(); | |
295 | bool HaveRects(); | |
296 | void Reset(); | |
297 | ||
298 | %addmethods { | |
299 | void Next() { | |
300 | (*self) ++; | |
301 | } | |
302 | }; | |
303 | }; | |
304 | ||
305 | ||
306 | ||
7bf85405 RD |
307 | //--------------------------------------------------------------------------- |
308 | // Accelerator Entry and Table | |
309 | ||
310 | class wxAcceleratorEntry { | |
311 | public: | |
312 | wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0); | |
2f90df85 | 313 | ~wxAcceleratorEntry(); |
7bf85405 RD |
314 | |
315 | void Set(int flags, int keyCode, int Cmd); | |
316 | int GetFlags(); | |
317 | int GetKeyCode(); | |
318 | int GetCommand(); | |
319 | }; | |
320 | ||
321 | ||
322 | class wxAcceleratorTable { | |
323 | public: | |
324 | // Can also accept a list of 3-tuples | |
325 | wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST); | |
2f90df85 | 326 | ~wxAcceleratorTable(); |
7bf85405 RD |
327 | |
328 | }; | |
faf3cb35 | 329 | |
8bf5d46e RD |
330 | //--------------------------------------------------------------------------- |
331 | //--------------------------------------------------------------------------- | |
332 | ||
333 |