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.
31 //---------------------------------------------------------------------------
41 wxSize(long w=0, long h=0);
43 void Set(long w, long h);
48 void SetWidth(long w);
49 void SetHeight(long h);
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));
59 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
60 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
64 //---------------------------------------------------------------------------
70 wxRealPoint(double x=0.0, double y=0.0);
74 void Set(double x, double y) {
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));
85 wxRealPoint __add__(const wxRealPoint* p) {
86 if (! p) return *self;
90 wxRealPoint __sub__(const wxRealPoint* p) {
91 if (! p) return *self;
95 int __cmp__(const wxRealPoint* p) {
100 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
101 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
109 wxPoint(long x=0, long y=0);
113 void Set(long x, long y) {
117 PyObject* asTuple() {
118 PyObject* tup = PyTuple_New(2);
119 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
120 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
124 wxPoint __add__(const wxPoint* p) {
125 if (! p) return *self;
129 wxPoint __sub__(const wxPoint* p) {
130 if (! p) return *self;
134 int __cmp__(const wxPoint* p) {
139 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
140 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
143 //---------------------------------------------------------------------------
147 wxRect(int x=0, int y=0, int w=0, int h=0);
148 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
156 void SetWidth(int w);
158 void SetHeight(int h);
161 wxPoint GetPosition();
169 void SetLeft(int left);
170 void SetRight(int right);
171 void SetTop(int top);
172 void SetBottom(int bottom);
174 void Inflate(int dx, int dy);
175 bool Inside(int cx, int cy);
177 int x, y, width, height;
180 PyObject* asTuple() {
181 PyObject* tup = PyTuple_New(4);
182 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
183 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
184 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
185 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
189 wxRect __add__(const wxRect* rect) {
190 if (! rect) return *self;
191 return *self + *rect;
194 int __cmp__(const wxRect* rect) {
195 if (! rect) return 0;
196 return *self == *rect;
200 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
201 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
202 %pragma(python) addtoclass = "
203 # override the __getattr__ made by SWIG
204 def __getattr__(self, name):
206 'x' : miscc.wxRect_x_get,
207 'y' : miscc.wxRect_y_get,
208 'width' : miscc.wxRect_width_get,
209 'height' : miscc.wxRect_height_get,
210 'top' : miscc.wxRect_GetTop,
211 'bottom' : miscc.wxRect_GetBottom,
212 'left' : miscc.wxRect_GetLeft,
213 'right' : miscc.wxRect_GetRight,
218 raise AttributeError,name
221 # and also the __setattr__
222 def __setattr__(self, name, value):
224 'x' : miscc.wxRect_x_set,
225 'y' : miscc.wxRect_y_set,
226 'width' : miscc.wxRect_width_set,
227 'height' : miscc.wxRect_height_set,
228 'top' : miscc.wxRect_SetTop,
229 'bottom' : miscc.wxRect_SetBottom,
230 'left' : miscc.wxRect_SetLeft,
231 'right' : miscc.wxRect_SetRight,
236 self.__dict__[name] = value
245 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
248 wxRect dest(0,0,0,0);
251 reg1.Intersect(reg2);
252 dest = reg1.GetBox();
254 if (dest != wxRect(0,0,0,0)) {
255 bool doSave = wxPyRestoreThread();
256 wxRect* newRect = new wxRect(dest);
257 obj = wxPyConstructObject((void*)newRect, "wxRect");
258 PyObject* one = PyInt_FromLong(1);
259 PyObject_SetAttrString(obj, "thisown", one);
261 wxPySaveThread(doSave);
270 //---------------------------------------------------------------------------
271 // Miscellaneous functions
274 void wxRegisterId(long id);
275 %name(NewId) long wxNewId();
276 %name(RegisterId) void wxRegisterId(long id);
279 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
280 void wxEndBusyCursor();
282 long wxGetElapsedTime(bool resetTimer = TRUE);
284 long wxGetFreeMemory();
286 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
289 bool wxShell(const wxString& command = wxPyEmptyStr);
291 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
292 wxString wxGetOsDescription();
294 void wxSleep(int secs);
295 void wxUsleep(unsigned long milliseconds);
297 void wxEnableTopLevelWindows(bool enable);
300 char* wxGetResource(char *section, char *entry, char *file = NULL) {
302 wxGetResource(section, entry, &retval, file);
307 wxString wxStripMenuCodes(const wxString& in);
310 wxString wxGetEmailAddress();
311 wxString wxGetHostName();
312 wxString wxGetFullHostName();
313 wxString wxGetUserId();
314 wxString wxGetUserName();
315 wxString wxGetHomeDir();
318 //----------------------------------------------------------------------
320 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
321 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
322 enum wxRelationship { wxUnconstrained = 0,
333 class wxIndividualLayoutConstraint {
335 // wxIndividualLayoutConstraint();
336 // ~wxIndividualLayoutConstraint();
338 void Above(wxWindow *otherWin, int margin=0);
339 void Absolute(int value);
341 void Below(wxWindow *otherWin, int margin=0);
342 void Unconstrained();
343 void LeftOf(wxWindow *otherWin, int margin=0);
344 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
345 void RightOf(wxWindow *otherWin, int margin=0);
346 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
347 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
351 class wxLayoutConstraints {
353 wxLayoutConstraints();
356 wxIndividualLayoutConstraint bottom;
357 wxIndividualLayoutConstraint centreX;
358 wxIndividualLayoutConstraint centreY;
359 wxIndividualLayoutConstraint height;
360 wxIndividualLayoutConstraint left;
361 wxIndividualLayoutConstraint right;
362 wxIndividualLayoutConstraint top;
363 wxIndividualLayoutConstraint width;
368 //---------------------------------------------------------------------------
371 enum wxRegionContain {
372 wxOutRegion, wxPartRegion, wxInRegion
378 wxRegion(long x=0, long y=0, long width=0, long height=0);
382 wxRegionContain Contains(long x, long y);
383 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
384 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
385 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
389 bool Intersect(long x, long y, long width, long height);
390 %name(IntersectRect)bool Intersect(const wxRect& rect);
391 %name(IntersectRegion)bool Intersect(const wxRegion& region);
395 bool Union(long x, long y, long width, long height);
396 %name(UnionRect)bool Union(const wxRect& rect);
397 %name(UnionRegion)bool Union(const wxRegion& region);
399 bool Subtract(long x, long y, long width, long height);
400 %name(SubtractRect)bool Subtract(const wxRect& rect);
401 %name(SubtractRegion)bool Subtract(const wxRegion& region);
403 bool Xor(long x, long y, long width, long height);
404 %name(XorRect)bool Xor(const wxRect& rect);
405 %name(XorRegion)bool Xor(const wxRegion& region);
410 class wxRegionIterator {
412 wxRegionIterator(const wxRegion& region);
434 //---------------------------------------------------------------------------
435 // Accelerator Entry and Table
437 class wxAcceleratorEntry {
439 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
440 ~wxAcceleratorEntry();
442 void Set(int flags, int keyCode, int Cmd);
449 class wxAcceleratorTable {
451 // Can also accept a list of 3-tuples
452 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices);
453 ~wxAcceleratorTable();
457 wxAcceleratorEntry *wxGetAccelFromString(const wxString& label);
461 #if 0 // we want to use the definition from the header, not the
462 // one SWIG will generate.
464 extern wxAcceleratorTable wxNullAcceleratorTable;
470 //---------------------------------------------------------------------------
474 wxBusyInfo(const wxString& message);
478 //---------------------------------------------------------------------------