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 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
86 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
94 wxPoint(long x=0, long y=0);
98 void Set(long x, long y) {
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));
109 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
110 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
113 //---------------------------------------------------------------------------
117 wxRect(int x=0, int y=0, int w=0, int h=0);
118 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
126 void SetWidth(int w);
128 void SetHeight(int h);
131 wxPoint GetPosition();
139 void SetLeft(int left);
140 void SetRight(int right);
141 void SetTop(int top);
142 void SetBottom(int bottom);
144 void Inflate(int dx, int dy);
145 bool Inside(int cx, int cy);
147 int x, y, width, height;
150 PyObject* asTuple() {
151 PyObject* tup = PyTuple_New(4);
152 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
153 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
154 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
155 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
159 wxRect __add__(const wxRect* rect) {
160 if (! rect) return *self;
161 return *self + *rect;
164 int __cmp__(const wxRect* rect) {
165 if (! rect) return 0;
166 return *self == *rect;
170 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
171 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
172 %pragma(python) addtoclass = "
173 # override the __getattr__ made by SWIG
174 def __getattr__(self, name):
176 'x' : miscc.wxRect_x_get,
177 'y' : miscc.wxRect_y_get,
178 'width' : miscc.wxRect_width_get,
179 'height' : miscc.wxRect_height_get,
180 'top' : miscc.wxRect_GetTop,
181 'bottom' : miscc.wxRect_GetBottom,
182 'left' : miscc.wxRect_GetLeft,
183 'right' : miscc.wxRect_GetRight,
188 raise AttributeError,name
191 # and also the __setattr__
192 def __setattr__(self, name, value):
194 'x' : miscc.wxRect_x_set,
195 'y' : miscc.wxRect_y_set,
196 'width' : miscc.wxRect_width_set,
197 'height' : miscc.wxRect_height_set,
198 'top' : miscc.wxRect_SetTop,
199 'bottom' : miscc.wxRect_SetBottom,
200 'left' : miscc.wxRect_SetLeft,
201 'right' : miscc.wxRect_SetRight,
206 self.__dict__[name] = value
215 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
218 wxRect dest(0,0,0,0);
221 reg1.Intersect(reg2);
222 dest = reg1.GetBox();
224 if (dest != wxRect(0,0,0,0)) {
225 bool doSave = wxPyRestoreThread();
226 wxRect* newRect = new wxRect(dest);
227 obj = wxPyConstructObject((void*)newRect, "wxRect");
228 PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
229 wxPySaveThread(doSave);
238 //---------------------------------------------------------------------------
239 // Miscellaneous functions
242 void wxRegisterId(long id);
243 %name(NewId) long wxNewId();
244 %name(RegisterId) void wxRegisterId(long id);
247 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
248 void wxEndBusyCursor();
249 long wxExecute(const wxString& command, int sync = FALSE);
250 long wxGetElapsedTime(bool resetTimer = TRUE);
252 long wxGetFreeMemory();
254 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
257 bool wxShell(const wxString& command = wxPyEmptyStr);
259 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
261 void wxSleep(int secs);
264 void wxEnableTopLevelWindows(bool enable);
267 char* wxGetResource(char *section, char *entry, char *file = NULL) {
269 wxGetResource(section, entry, &retval, file);
274 wxString wxStripMenuCodes(const wxString& in);
276 //----------------------------------------------------------------------
278 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
279 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
280 enum wxRelationship { wxUnconstrained = 0,
291 class wxIndividualLayoutConstraint {
293 // wxIndividualLayoutConstraint();
294 // ~wxIndividualLayoutConstraint();
296 void Above(wxWindow *otherWin, int margin=0);
297 void Absolute(int value);
299 void Below(wxWindow *otherWin, int margin=0);
300 void Unconstrained();
301 void LeftOf(wxWindow *otherWin, int margin=0);
302 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
303 void RightOf(wxWindow *otherWin, int margin=0);
304 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
305 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
309 class wxLayoutConstraints {
311 wxLayoutConstraints();
314 wxIndividualLayoutConstraint bottom;
315 wxIndividualLayoutConstraint centreX;
316 wxIndividualLayoutConstraint centreY;
317 wxIndividualLayoutConstraint height;
318 wxIndividualLayoutConstraint left;
319 wxIndividualLayoutConstraint right;
320 wxIndividualLayoutConstraint top;
321 wxIndividualLayoutConstraint width;
326 //---------------------------------------------------------------------------
329 enum wxRegionContain {
330 wxOutRegion, wxPartRegion, wxInRegion
340 wxRegionContain Contains(long x, long y);
341 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
342 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
343 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
347 bool Intersect(long x, long y, long width, long height);
348 %name(IntersectRect)bool Intersect(const wxRect& rect);
349 %name(IntersectRegion)bool Intersect(const wxRegion& region);
353 bool Union(long x, long y, long width, long height);
354 %name(UnionRect)bool Union(const wxRect& rect);
355 %name(UnionRegion)bool Union(const wxRegion& region);
357 bool Subtract(long x, long y, long width, long height);
358 %name(SubtractRect)bool Subtract(const wxRect& rect);
359 %name(SubtractRegion)bool Subtract(const wxRegion& region);
361 bool Xor(long x, long y, long width, long height);
362 %name(XorRect)bool Xor(const wxRect& rect);
363 %name(XorRegion)bool Xor(const wxRegion& region);
368 class wxRegionIterator {
370 wxRegionIterator(const wxRegion& region);
392 //---------------------------------------------------------------------------
393 // Accelerator Entry and Table
395 class wxAcceleratorEntry {
397 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
398 ~wxAcceleratorEntry();
400 void Set(int flags, int keyCode, int Cmd);
407 class wxAcceleratorTable {
409 // Can also accept a list of 3-tuples
410 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices);
411 ~wxAcceleratorTable();
418 #if 0 // we want to use the definition from the header, not the
419 // one SWIG will generate.
421 extern wxAcceleratorTable wxNullAcceleratorTable;
427 //---------------------------------------------------------------------------
431 wxBusyInfo(const wxString& message);
437 //---------------------------------------------------------------------------