]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/misc.i
Bug fixes, new tests and demos, new generated source...
[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 #include <wx/busyinfo.h>
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
30
31 //---------------------------------------------------------------------------
32
33
34 class wxSize {
35 public:
36 long x;
37 long y;
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);
44 long GetX();
45 long GetY();
46 long GetWidth();
47 long GetHeight();
48 void SetWidth(long w);
49 void SetHeight(long h);
50
51 %addmethods {
52 PyObject* asTuple() {
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 }
59 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
60 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
61
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();
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())"
87 };
88
89
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 }
102 PyObject* asTuple() {
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 }
109 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
110 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
111 };
112
113 //---------------------------------------------------------------------------
114
115 class wxRect {
116 public:
117 wxRect(long x=0, long y=0, long w=0, long h=0);
118 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
119 ~wxRect();
120
121 long GetX();
122 void SetX(long X);
123 long GetY();
124 void SetY(long Y);
125 long GetWidth();
126 void SetWidth(long w);
127 long GetHeight();
128 void SetHeight(long h);
129
130
131 wxPoint GetPosition();
132 wxSize GetSize();
133
134 long GetLeft();
135 long GetTop();
136 long GetBottom();
137 long GetRight();
138
139 long x, y, width, height;
140
141 %addmethods {
142 PyObject* asTuple() {
143 PyObject* tup = PyTuple_New(4);
144 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
145 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
146 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
147 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
148 return tup;
149 }
150 }
151 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
152 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
153 };
154
155
156
157
158 //---------------------------------------------------------------------------
159 // Miscellaneous functions
160
161 long wxNewId();
162 void wxRegisterId(long id);
163 %name(NewId) long wxNewId();
164 %name(RegisterId) void wxRegisterId(long id);
165
166 void wxBell();
167 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
168 void wxEndBusyCursor();
169 long wxExecute(const wxString& command, bool sync = FALSE);
170 long wxGetElapsedTime(bool resetTimer = TRUE);
171 #ifdef __WXMSW__
172 long wxGetFreeMemory();
173 #endif
174 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
175 bool wxIsBusy();
176 wxString wxNow();
177 bool wxShell(const wxString& command = wxPyEmptyStr);
178 void wxStartTimer();
179 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
180
181 void wxSleep(int secs);
182 bool wxYield();
183 bool wxSafeYield();
184 void wxEnableTopLevelWindows(bool enable);
185
186 %inline %{
187 char* wxGetResource(char *section, char *entry, char *file = NULL) {
188 char * retval;
189 wxGetResource(section, entry, &retval, file);
190 return retval;
191 }
192 %}
193
194 wxString wxStripMenuCodes(const wxString& in);
195
196 //----------------------------------------------------------------------
197
198 class wxPyTimer {
199 public:
200 wxPyTimer(PyObject* notify);
201 ~wxPyTimer();
202 int GetInterval();
203 bool IsOneShot();
204 void Start(int milliseconds=-1, int oneShot=FALSE);
205 void Stop();
206 };
207
208 //---------------------------------------------------------------------------
209
210 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
211 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
212 enum wxRelationship { wxUnconstrained = 0,
213 wxAsIs,
214 wxPercentOf,
215 wxAbove,
216 wxBelow,
217 wxLeftOf,
218 wxRightOf,
219 wxSameAs,
220 wxAbsolute };
221
222
223 class wxIndividualLayoutConstraint {
224 public:
225 // wxIndividualLayoutConstraint();
226 // ~wxIndividualLayoutConstraint();
227
228 void Above(wxWindow *otherWin, int margin=0);
229 void Absolute(int value);
230 void AsIs();
231 void Below(wxWindow *otherWin, int margin=0);
232 void Unconstrained();
233 void LeftOf(wxWindow *otherWin, int margin=0);
234 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
235 void RightOf(wxWindow *otherWin, int margin=0);
236 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
237 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
238 };
239
240
241 class wxLayoutConstraints {
242 public:
243 wxLayoutConstraints();
244
245 %readonly
246 wxIndividualLayoutConstraint bottom;
247 wxIndividualLayoutConstraint centreX;
248 wxIndividualLayoutConstraint centreY;
249 wxIndividualLayoutConstraint height;
250 wxIndividualLayoutConstraint left;
251 wxIndividualLayoutConstraint right;
252 wxIndividualLayoutConstraint top;
253 wxIndividualLayoutConstraint width;
254 %readwrite
255 }
256
257
258 //---------------------------------------------------------------------------
259 // Regions, etc.
260
261 enum wxRegionContain {
262 wxOutRegion, wxPartRegion, wxInRegion
263 };
264
265
266 class wxRegion {
267 public:
268 wxRegion();
269 ~wxRegion();
270
271 void Clear();
272 wxRegionContain Contains(long x, long y);
273 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
274 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
275
276 wxRect GetBox();
277 bool Intersect(const wxRect& rect);
278 bool IsEmpty();
279 bool Subtract(const wxRect& rect);
280 bool Union(const wxRect& rect);
281 bool Xor(const wxRect& rect);
282 };
283
284
285
286 class wxRegionIterator {
287 public:
288 wxRegionIterator(const wxRegion& region);
289 ~wxRegionIterator();
290
291 long GetX();
292 long GetY();
293 long GetW();
294 long GetWidth();
295 long GetH();
296 long GetHeight();
297 wxRect GetRect();
298 bool HaveRects();
299 void Reset();
300
301 %addmethods {
302 void Next() {
303 (*self) ++;
304 }
305 };
306 };
307
308
309
310 //---------------------------------------------------------------------------
311 // Accelerator Entry and Table
312
313 class wxAcceleratorEntry {
314 public:
315 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
316 ~wxAcceleratorEntry();
317
318 void Set(int flags, int keyCode, int Cmd);
319 int GetFlags();
320 int GetKeyCode();
321 int GetCommand();
322 };
323
324
325 class wxAcceleratorTable {
326 public:
327 // Can also accept a list of 3-tuples
328 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
329 ~wxAcceleratorTable();
330
331 };
332
333 //---------------------------------------------------------------------------
334
335 class wxBusyInfo {
336 public:
337 wxBusyInfo(const wxString& message);
338 ~wxBusyInfo();
339 };
340
341
342
343 //---------------------------------------------------------------------------
344
345