]> 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 long wxGetFreeMemory();
171 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
172 bool wxIsBusy();
173 wxString wxNow();
174 bool wxShell(const wxString& command = wxPyEmptyStr);
175 void wxStartTimer();
176 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
177
178 void wxSleep(int secs);
179 bool wxYield();
180 bool wxSafeYield();
181 void wxEnableTopLevelWindows(bool enable);
182
183 %inline %{
184 char* wxGetResource(char *section, char *entry, char *file = NULL) {
185 char * retval;
186 wxGetResource(section, entry, &retval, file);
187 return retval;
188 }
189 %}
190
191
192 //----------------------------------------------------------------------
193
194 class wxPyTimer {
195 public:
196 wxPyTimer(PyObject* notify);
197 ~wxPyTimer();
198 int Interval();
199 void Start(int milliseconds=-1, int oneShot=FALSE);
200 void Stop();
201 };
202
203 //---------------------------------------------------------------------------
204
205 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
206 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
207 enum wxRelationship { wxUnconstrained = 0,
208 wxAsIs,
209 wxPercentOf,
210 wxAbove,
211 wxBelow,
212 wxLeftOf,
213 wxRightOf,
214 wxSameAs,
215 wxAbsolute };
216
217
218 class wxIndividualLayoutConstraint {
219 public:
220 // wxIndividualLayoutConstraint();
221 // ~wxIndividualLayoutConstraint();
222
223 void Above(wxWindow *otherWin, int margin=0);
224 void Absolute(int value);
225 void AsIs();
226 void Below(wxWindow *otherWin, int margin=0);
227 void Unconstrained();
228 void LeftOf(wxWindow *otherWin, int margin=0);
229 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
230 void RightOf(wxWindow *otherWin, int margin=0);
231 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
232 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
233 };
234
235
236 class wxLayoutConstraints {
237 public:
238 wxLayoutConstraints();
239
240 %readonly
241 wxIndividualLayoutConstraint bottom;
242 wxIndividualLayoutConstraint centreX;
243 wxIndividualLayoutConstraint centreY;
244 wxIndividualLayoutConstraint height;
245 wxIndividualLayoutConstraint left;
246 wxIndividualLayoutConstraint right;
247 wxIndividualLayoutConstraint top;
248 wxIndividualLayoutConstraint width;
249 %readwrite
250 }
251
252
253 //---------------------------------------------------------------------------
254 // Regions, etc.
255
256 enum wxRegionContain {
257 wxOutRegion, wxPartRegion, wxInRegion
258 };
259
260
261 class wxRegion {
262 public:
263 wxRegion();
264 ~wxRegion();
265
266 void Clear();
267 wxRegionContain Contains(long x, long y);
268 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
269 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
270
271 wxRect GetBox();
272 bool Intersect(const wxRect& rect);
273 bool IsEmpty();
274 bool Subtract(const wxRect& rect);
275 bool Union(const wxRect& rect);
276 bool Xor(const wxRect& rect);
277 };
278
279
280
281 class wxRegionIterator {
282 public:
283 wxRegionIterator(const wxRegion& region);
284 ~wxRegionIterator();
285
286 long GetX();
287 long GetY();
288 long GetW();
289 long GetWidth();
290 long GetH();
291 long GetHeight();
292 wxRect GetRect();
293 bool HaveRects();
294 void Reset();
295
296 %addmethods {
297 void Next() {
298 (*self) ++;
299 }
300 };
301 };
302
303
304
305 //---------------------------------------------------------------------------
306 // Accelerator Entry and Table
307
308 class wxAcceleratorEntry {
309 public:
310 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
311 ~wxAcceleratorEntry();
312
313 void Set(int flags, int keyCode, int Cmd);
314 int GetFlags();
315 int GetKeyCode();
316 int GetCommand();
317 };
318
319
320 class wxAcceleratorTable {
321 public:
322 // Can also accept a list of 3-tuples
323 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
324 ~wxAcceleratorTable();
325
326 };
327
328 //---------------------------------------------------------------------------
329 //---------------------------------------------------------------------------
330
331