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));
63 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
64 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
68 //---------------------------------------------------------------------------
74 wxRealPoint(double x=0.0, double y=0.0);
78 void Set(double x, double y) {
83 PyObject* tup = PyTuple_New(2);
84 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
85 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
89 wxRealPoint __add__(const wxRealPoint* p) {
90 if (! p) return *self;
94 wxRealPoint __sub__(const wxRealPoint* p) {
95 if (! p) return *self;
99 int __cmp__(const wxRealPoint* p) {
104 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
105 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
113 wxPoint(long x=0, long y=0);
117 void Set(long x, long y) {
121 PyObject* asTuple() {
122 PyObject* tup = PyTuple_New(2);
123 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
124 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
128 wxPoint __add__(const wxPoint* p) {
129 if (! p) return *self;
133 wxPoint __sub__(const wxPoint* p) {
134 if (! p) return *self;
138 int __cmp__(const wxPoint* p) {
143 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
144 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
147 //---------------------------------------------------------------------------
151 wxRect(int x=0, int y=0, int w=0, int h=0);
152 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
160 void SetWidth(int w);
162 void SetHeight(int h);
165 wxPoint GetPosition();
173 void SetLeft(int left);
174 void SetRight(int right);
175 void SetTop(int top);
176 void SetBottom(int bottom);
178 void Inflate(int dx, int dy);
179 bool Inside(int cx, int cy);
181 int x, y, width, height;
184 PyObject* asTuple() {
185 PyObject* tup = PyTuple_New(4);
186 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
187 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
188 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
189 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
193 wxRect __add__(const wxRect* rect) {
194 if (! rect) return *self;
195 return *self + *rect;
198 int __cmp__(const wxRect* rect) {
199 if (! rect) return 0;
200 return *self == *rect;
204 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
205 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
206 %pragma(python) addtoclass = "
207 # override the __getattr__ made by SWIG
208 def __getattr__(self, name):
210 'x' : miscc.wxRect_x_get,
211 'y' : miscc.wxRect_y_get,
212 'width' : miscc.wxRect_width_get,
213 'height' : miscc.wxRect_height_get,
214 'top' : miscc.wxRect_GetTop,
215 'bottom' : miscc.wxRect_GetBottom,
216 'left' : miscc.wxRect_GetLeft,
217 'right' : miscc.wxRect_GetRight,
222 raise AttributeError,name
225 # and also the __setattr__
226 def __setattr__(self, name, value):
228 'x' : miscc.wxRect_x_set,
229 'y' : miscc.wxRect_y_set,
230 'width' : miscc.wxRect_width_set,
231 'height' : miscc.wxRect_height_set,
232 'top' : miscc.wxRect_SetTop,
233 'bottom' : miscc.wxRect_SetBottom,
234 'left' : miscc.wxRect_SetLeft,
235 'right' : miscc.wxRect_SetRight,
240 self.__dict__[name] = value
249 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
252 wxRect dest(0,0,0,0);
255 reg1.Intersect(reg2);
256 dest = reg1.GetBox();
258 if (dest != wxRect(0,0,0,0)) {
259 bool doSave = wxPyRestoreThread();
260 wxRect* newRect = new wxRect(dest);
261 obj = wxPyConstructObject((void*)newRect, "wxRect");
262 PyObject* one = PyInt_FromLong(1);
263 PyObject_SetAttrString(obj, "thisown", one);
265 wxPySaveThread(doSave);
274 //---------------------------------------------------------------------------
275 // Miscellaneous functions
278 void wxRegisterId(long id);
279 %name(NewId) long wxNewId();
280 %name(RegisterId) void wxRegisterId(long id);
283 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
284 void wxEndBusyCursor();
286 long wxGetElapsedTime(bool resetTimer = TRUE);
288 long wxGetFreeMemory();
290 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
293 bool wxShell(const wxString& command = wxPyEmptyStr);
295 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
296 wxString wxGetOsDescription();
298 void wxSleep(int secs);
299 void wxUsleep(unsigned long milliseconds);
301 void wxEnableTopLevelWindows(bool enable);
304 char* wxGetResource(char *section, char *entry, char *file = NULL) {
306 wxGetResource(section, entry, &retval, file);
311 wxString wxStripMenuCodes(const wxString& in);
314 wxString wxGetEmailAddress();
315 wxString wxGetHostName();
316 wxString wxGetFullHostName();
317 wxString wxGetUserId();
318 wxString wxGetUserName();
319 wxString wxGetHomeDir();
322 //----------------------------------------------------------------------
324 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
325 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
326 enum wxRelationship { wxUnconstrained = 0,
337 class wxIndividualLayoutConstraint {
339 // wxIndividualLayoutConstraint();
340 // ~wxIndividualLayoutConstraint();
342 void Above(wxWindow *otherWin, int margin=0);
343 void Absolute(int value);
345 void Below(wxWindow *otherWin, int margin=0);
346 void Unconstrained();
347 void LeftOf(wxWindow *otherWin, int margin=0);
348 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
349 void RightOf(wxWindow *otherWin, int margin=0);
350 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
351 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
355 class wxLayoutConstraints {
357 wxLayoutConstraints();
360 wxIndividualLayoutConstraint bottom;
361 wxIndividualLayoutConstraint centreX;
362 wxIndividualLayoutConstraint centreY;
363 wxIndividualLayoutConstraint height;
364 wxIndividualLayoutConstraint left;
365 wxIndividualLayoutConstraint right;
366 wxIndividualLayoutConstraint top;
367 wxIndividualLayoutConstraint width;
372 //---------------------------------------------------------------------------
375 enum wxRegionContain {
376 wxOutRegion, wxPartRegion, wxInRegion
382 wxRegion(long x=0, long y=0, long width=0, long height=0);
386 wxRegionContain Contains(long x, long y);
387 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
388 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
389 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
393 bool Intersect(long x, long y, long width, long height);
394 %name(IntersectRect)bool Intersect(const wxRect& rect);
395 %name(IntersectRegion)bool Intersect(const wxRegion& region);
399 bool Union(long x, long y, long width, long height);
400 %name(UnionRect)bool Union(const wxRect& rect);
401 %name(UnionRegion)bool Union(const wxRegion& region);
403 bool Subtract(long x, long y, long width, long height);
404 %name(SubtractRect)bool Subtract(const wxRect& rect);
405 %name(SubtractRegion)bool Subtract(const wxRegion& region);
407 bool Xor(long x, long y, long width, long height);
408 %name(XorRect)bool Xor(const wxRect& rect);
409 %name(XorRegion)bool Xor(const wxRegion& region);
414 class wxRegionIterator {
416 wxRegionIterator(const wxRegion& region);
438 //---------------------------------------------------------------------------
439 // Accelerator Entry and Table
441 class wxAcceleratorEntry {
443 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
444 ~wxAcceleratorEntry();
446 void Set(int flags, int keyCode, int Cmd);
453 class wxAcceleratorTable {
455 // Can also accept a list of 3-tuples
456 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices);
457 ~wxAcceleratorTable();
461 wxAcceleratorEntry *wxGetAccelFromString(const wxString& label);
465 #if 0 // we want to use the definition from the header, not the
466 // one SWIG will generate.
468 extern wxAcceleratorTable wxNullAcceleratorTable;
474 //---------------------------------------------------------------------------
478 wxBusyInfo(const wxString& message);
482 //---------------------------------------------------------------------------