1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Definitions of miscelaneous functions and classes
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 #include <wx/resource.h>
18 #include <wx/tooltip.h>
19 #include <wx/busyinfo.h>
22 //----------------------------------------------------------------------
25 %include my_typemaps.i
27 // Import some definitions of other classes, etc.
32 static wxString wxPyEmptyStr("");
35 //---------------------------------------------------------------------------
45 wxSize(long w=0, long h=0);
47 void Set(long w, long h);
52 void SetWidth(long w);
53 void SetHeight(long h);
57 PyObject* tup = PyTuple_New(2);
58 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
59 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
64 %pragma(python) addtoclass = "
65 def __str__(self): return str(self.asTuple())
66 def __repr__(self): return str(self.asTuple())
67 def __len__(self): return len(self.asTuple())
68 def __getitem__(self, index): return self.asTuple()[index]
69 def __setitem__(self, index, val):
70 if index == 0: self.width = val
71 elif index == 1: self.height = val
72 else: raise IndexError
77 //---------------------------------------------------------------------------
83 wxRealPoint(double x=0.0, double y=0.0);
87 void Set(double x, double y) {
92 PyObject* tup = PyTuple_New(2);
93 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
94 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
98 wxRealPoint __add__(const wxRealPoint* p) {
99 if (! p) return *self;
103 wxRealPoint __sub__(const wxRealPoint* p) {
104 if (! p) return *self;
108 int __cmp__(const wxRealPoint* p) {
113 %pragma(python) addtoclass = "
114 def __str__(self): return str(self.asTuple())
115 def __repr__(self): return str(self.asTuple())
116 def __len__(self): return len(self.asTuple())
117 def __getitem__(self, index): return self.asTuple()[index]
118 def __setitem__(self, index, val):
119 if index == 0: self.width = val
120 elif index == 1: self.height = val
121 else: raise IndexError
130 wxPoint(long x=0, long y=0);
134 void Set(long x, long y) {
138 PyObject* asTuple() {
139 PyObject* tup = PyTuple_New(2);
140 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
141 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
145 wxPoint __add__(const wxPoint* p) {
146 if (! p) return *self;
150 wxPoint __sub__(const wxPoint* p) {
151 if (! p) return *self;
155 int __cmp__(const wxPoint* p) {
160 %pragma(python) addtoclass = "
161 def __str__(self): return str(self.asTuple())
162 def __repr__(self): return str(self.asTuple())
163 def __len__(self): return len(self.asTuple())
164 def __getitem__(self, index): return self.asTuple()[index]
165 def __setitem__(self, index, val):
166 if index == 0: self.x = val
167 elif index == 1: self.y = val
168 else: raise IndexError
172 //---------------------------------------------------------------------------
176 wxRect(int x=0, int y=0, int w=0, int h=0);
177 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
185 void SetWidth(int w);
187 void SetHeight(int h);
190 wxPoint GetPosition();
198 void SetLeft(int left);
199 void SetRight(int right);
200 void SetTop(int top);
201 void SetBottom(int bottom);
203 void Inflate(int dx, int dy);
204 bool Inside(int cx, int cy);
206 int x, y, width, height;
209 PyObject* asTuple() {
210 PyObject* tup = PyTuple_New(4);
211 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
212 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
213 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
214 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
218 wxRect __add__(const wxRect* rect) {
219 if (! rect) return *self;
220 return *self + *rect;
223 int __cmp__(const wxRect* rect) {
224 if (! rect) return 0;
225 return *self == *rect;
229 %pragma(python) addtoclass = "
230 def __str__(self): return str(self.asTuple())
231 def __repr__(self): return str(self.asTuple())
232 def __len__(self): return len(self.asTuple())
233 def __getitem__(self, index): return self.asTuple()[index]
234 def __setitem__(self, index, val):
235 if index == 0: self.x = val
236 elif index == 1: self.y = val
237 elif index == 2: self.width = val
238 elif index == 3: self.height = val
239 else: raise IndexError
241 # override the __getattr__ made by SWIG
242 def __getattr__(self, name):
244 'x' : miscc.wxRect_x_get,
245 'y' : miscc.wxRect_y_get,
246 'width' : miscc.wxRect_width_get,
247 'height' : miscc.wxRect_height_get,
248 'top' : miscc.wxRect_GetTop,
249 'bottom' : miscc.wxRect_GetBottom,
250 'left' : miscc.wxRect_GetLeft,
251 'right' : miscc.wxRect_GetRight,
256 raise AttributeError,name
259 # and also the __setattr__
260 def __setattr__(self, name, value):
262 'x' : miscc.wxRect_x_set,
263 'y' : miscc.wxRect_y_set,
264 'width' : miscc.wxRect_width_set,
265 'height' : miscc.wxRect_height_set,
266 'top' : miscc.wxRect_SetTop,
267 'bottom' : miscc.wxRect_SetBottom,
268 'left' : miscc.wxRect_SetLeft,
269 'right' : miscc.wxRect_SetRight,
274 self.__dict__[name] = value
283 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
286 wxRect dest(0,0,0,0);
289 reg1.Intersect(reg2);
290 dest = reg1.GetBox();
292 if (dest != wxRect(0,0,0,0)) {
293 bool doSave = wxPyRestoreThread();
294 wxRect* newRect = new wxRect(dest);
295 obj = wxPyConstructObject((void*)newRect, "wxRect");
296 PyObject* one = PyInt_FromLong(1);
297 PyObject_SetAttrString(obj, "thisown", one);
299 wxPySaveThread(doSave);
308 //---------------------------------------------------------------------------
309 // Miscellaneous functions
312 void wxRegisterId(long id);
313 %name(NewId) long wxNewId();
314 %name(RegisterId) void wxRegisterId(long id);
315 long wxGetCurrentId();
318 void wxEndBusyCursor();
320 long wxGetElapsedTime(bool resetTimer = TRUE);
322 long wxGetFreeMemory();
324 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
327 bool wxShell(const wxString& command = wxPyEmptyStr);
329 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
330 wxString wxGetOsDescription();
332 void wxSleep(int secs);
333 void wxUsleep(unsigned long milliseconds);
335 bool wxYieldIfNeeded();
336 void wxEnableTopLevelWindows(bool enable);
339 char* wxGetResource(char *section, char *entry, char *file = NULL) {
341 wxGetResource(section, entry, &retval, file);
346 wxString wxStripMenuCodes(const wxString& in);
349 wxString wxGetEmailAddress();
350 wxString wxGetHostName();
351 wxString wxGetFullHostName();
352 wxString wxGetUserId();
353 wxString wxGetUserName();
354 wxString wxGetHomeDir();
357 //----------------------------------------------------------------------
359 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
360 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
361 enum wxRelationship { wxUnconstrained = 0,
372 class wxIndividualLayoutConstraint {
374 // wxIndividualLayoutConstraint();
375 // ~wxIndividualLayoutConstraint();
377 void Above(wxWindow *otherWin, int margin=0);
378 void Absolute(int value);
380 void Below(wxWindow *otherWin, int margin=0);
381 void Unconstrained();
382 void LeftOf(wxWindow *otherWin, int margin=0);
383 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
384 void RightOf(wxWindow *otherWin, int margin=0);
385 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
386 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
390 class wxLayoutConstraints {
392 wxLayoutConstraints();
395 wxIndividualLayoutConstraint bottom;
396 wxIndividualLayoutConstraint centreX;
397 wxIndividualLayoutConstraint centreY;
398 wxIndividualLayoutConstraint height;
399 wxIndividualLayoutConstraint left;
400 wxIndividualLayoutConstraint right;
401 wxIndividualLayoutConstraint top;
402 wxIndividualLayoutConstraint width;
407 //---------------------------------------------------------------------------
410 enum wxRegionContain {
411 wxOutRegion, wxPartRegion, wxInRegion
417 wxRegion(long x=0, long y=0, long width=0, long height=0);
421 wxRegionContain Contains(long x, long y);
422 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
423 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
424 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
428 bool Intersect(long x, long y, long width, long height);
429 %name(IntersectRect)bool Intersect(const wxRect& rect);
430 %name(IntersectRegion)bool Intersect(const wxRegion& region);
434 bool Union(long x, long y, long width, long height);
435 %name(UnionRect)bool Union(const wxRect& rect);
436 %name(UnionRegion)bool Union(const wxRegion& region);
438 bool Subtract(long x, long y, long width, long height);
439 %name(SubtractRect)bool Subtract(const wxRect& rect);
440 %name(SubtractRegion)bool Subtract(const wxRegion& region);
442 bool Xor(long x, long y, long width, long height);
443 %name(XorRect)bool Xor(const wxRect& rect);
444 %name(XorRegion)bool Xor(const wxRegion& region);
449 class wxRegionIterator {
451 wxRegionIterator(const wxRegion& region);
473 //---------------------------------------------------------------------------
474 // Accelerator Entry and Table
476 class wxAcceleratorEntry {
478 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
479 ~wxAcceleratorEntry();
481 void Set(int flags, int keyCode, int Cmd);
488 class wxAcceleratorTable {
490 // Can also accept a list of 3-tuples
491 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices);
492 ~wxAcceleratorTable();
496 wxAcceleratorEntry *wxGetAccelFromString(const wxString& label);
500 #if 0 // we want to use the definition from the header, not the
501 // one SWIG will generate.
503 extern wxAcceleratorTable wxNullAcceleratorTable;
509 //---------------------------------------------------------------------------
513 wxBusyInfo(const wxString& message);
517 //---------------------------------------------------------------------------