]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/misc.i
minor additions and bugfixes
[wxWidgets.git] / utils / wxPython / src / misc.i
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
13 %module misc
14
15 %{
16 #include "helpers.h"
17 #include <wx/resource.h>
18 #include <wx/tooltip.h>
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
29
30 //---------------------------------------------------------------------------
31
32
33 class wxSize {
34 public:
35 long x;
36 long y;
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);
43 long GetX();
44 long GetY();
45 long GetWidth();
46 long GetHeight();
47 void SetWidth(long w);
48 void SetHeight(long h);
49
50 %addmethods {
51 PyObject* asTuple() {
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 }
58 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
59 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
60
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();
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())"
86 };
87
88
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 }
101 PyObject* asTuple() {
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 }
108 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
109 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
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;
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));
145 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
146 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
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())"
152 };
153
154
155
156
157 //---------------------------------------------------------------------------
158 // Miscellaneous functions
159
160 long wxNewId();
161 void wxRegisterId(long id);
162 %name(NewId) long wxNewId();
163 %name(RegisterId) void wxRegisterId(long id);
164
165 void wxBell();
166 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
167 void wxEndBusyCursor();
168 long wxExecute(const wxString& command, bool sync = FALSE);
169 long wxGetElapsedTime(bool resetTimer = TRUE);
170 #ifdef __WXMSW__
171 long wxGetFreeMemory();
172 #endif
173 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
174 bool wxIsBusy();
175 wxString wxNow();
176 bool wxShell(const wxString& command = wxPyEmptyStr);
177 void wxStartTimer();
178 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
179
180 void wxSleep(int secs);
181 bool wxYield();
182 bool wxSafeYield();
183 void wxEnableTopLevelWindows(bool enable);
184
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
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);
227 void AsIs();
228 void Below(wxWindow *otherWin, int margin=0);
229 void Unconstrained();
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
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
307 //---------------------------------------------------------------------------
308 // Accelerator Entry and Table
309
310 class wxAcceleratorEntry {
311 public:
312 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
313 ~wxAcceleratorEntry();
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);
326 ~wxAcceleratorTable();
327
328 };
329
330 //---------------------------------------------------------------------------
331 //---------------------------------------------------------------------------
332
333