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);
145 int x, y, width, height;
148 PyObject* asTuple() {
149 PyObject* tup = PyTuple_New(4);
150 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
151 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
152 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
153 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
157 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
158 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
159 %pragma(python) addtoclass = "
160 # override the __getattr__ made by SWIG
161 def __getattr__(self, name):
163 'x' : miscc.wxRect_x_get,
164 'y' : miscc.wxRect_y_get,
165 'width' : miscc.wxRect_width_get,
166 'height' : miscc.wxRect_height_get,
167 'top' : miscc.wxRect_GetTop,
168 'bottom' : miscc.wxRect_GetBottom,
169 'left' : miscc.wxRect_GetLeft,
170 'right' : miscc.wxRect_GetRight,
175 raise AttributeError,name
178 # and also the __setattr__
179 def __setattr__(self, name, value):
181 'x' : miscc.wxRect_x_set,
182 'y' : miscc.wxRect_y_set,
183 'width' : miscc.wxRect_width_set,
184 'height' : miscc.wxRect_height_set,
185 'top' : miscc.wxRect_SetTop,
186 'bottom' : miscc.wxRect_SetBottom,
187 'left' : miscc.wxRect_SetLeft,
188 'right' : miscc.wxRect_SetRight,
193 self.__dict__[name] = value
202 // bool wxIntersectRect(wxRect* dest, wxRect* r1, wxRect* r2) {
203 // wxRegion reg1(*r1);
204 // wxRegion reg2(*r2);
206 // *dest = wxRect(0,0,0,0);
207 // success = reg1.Intersect(reg2);
209 // *dest = reg1.GetBox();
210 // return *dest != wxRect(0,0,0,0);
218 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
221 wxRect dest(0,0,0,0);
224 reg1.Intersect(reg2);
225 dest = reg1.GetBox();
227 if (dest != wxRect(0,0,0,0)) {
228 bool doSave = wxPyRestoreThread();
229 wxRect* newRect = new wxRect(dest);
230 obj = wxPyConstructObject((void*)newRect, "wxRect");
231 PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
232 wxPySaveThread(doSave);
241 //---------------------------------------------------------------------------
242 // Miscellaneous functions
245 void wxRegisterId(long id);
246 %name(NewId) long wxNewId();
247 %name(RegisterId) void wxRegisterId(long id);
250 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
251 void wxEndBusyCursor();
252 long wxExecute(const wxString& command, int sync = FALSE);
253 long wxGetElapsedTime(bool resetTimer = TRUE);
255 long wxGetFreeMemory();
257 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
260 bool wxShell(const wxString& command = wxPyEmptyStr);
262 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
264 void wxSleep(int secs);
267 void wxEnableTopLevelWindows(bool enable);
270 char* wxGetResource(char *section, char *entry, char *file = NULL) {
272 wxGetResource(section, entry, &retval, file);
277 wxString wxStripMenuCodes(const wxString& in);
279 //----------------------------------------------------------------------
283 wxPyTimer(PyObject* notify);
287 void Start(int milliseconds=-1, int oneShot=FALSE);
291 //---------------------------------------------------------------------------
293 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
294 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
295 enum wxRelationship { wxUnconstrained = 0,
306 class wxIndividualLayoutConstraint {
308 // wxIndividualLayoutConstraint();
309 // ~wxIndividualLayoutConstraint();
311 void Above(wxWindow *otherWin, int margin=0);
312 void Absolute(int value);
314 void Below(wxWindow *otherWin, int margin=0);
315 void Unconstrained();
316 void LeftOf(wxWindow *otherWin, int margin=0);
317 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
318 void RightOf(wxWindow *otherWin, int margin=0);
319 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
320 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
324 class wxLayoutConstraints {
326 wxLayoutConstraints();
329 wxIndividualLayoutConstraint bottom;
330 wxIndividualLayoutConstraint centreX;
331 wxIndividualLayoutConstraint centreY;
332 wxIndividualLayoutConstraint height;
333 wxIndividualLayoutConstraint left;
334 wxIndividualLayoutConstraint right;
335 wxIndividualLayoutConstraint top;
336 wxIndividualLayoutConstraint width;
341 //---------------------------------------------------------------------------
344 enum wxRegionContain {
345 wxOutRegion, wxPartRegion, wxInRegion
355 wxRegionContain Contains(long x, long y);
356 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
357 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
358 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
362 bool Intersect(long x, long y, long width, long height);
363 %name(IntersectRect)bool Intersect(const wxRect& rect);
364 %name(IntersectRegion)bool Intersect(const wxRegion& region);
368 bool Union(long x, long y, long width, long height);
369 %name(UnionRect)bool Union(const wxRect& rect);
370 %name(UnionRegion)bool Union(const wxRegion& region);
372 bool Subtract(long x, long y, long width, long height);
373 %name(SubtractRect)bool Subtract(const wxRect& rect);
374 %name(SubtractRegion)bool Subtract(const wxRegion& region);
376 bool Xor(long x, long y, long width, long height);
377 %name(XorRect)bool Xor(const wxRect& rect);
378 %name(XorRegion)bool Xor(const wxRegion& region);
383 class wxRegionIterator {
385 wxRegionIterator(const wxRegion& region);
407 //---------------------------------------------------------------------------
408 // Accelerator Entry and Table
410 class wxAcceleratorEntry {
412 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
413 ~wxAcceleratorEntry();
415 void Set(int flags, int keyCode, int Cmd);
422 class wxAcceleratorTable {
424 // Can also accept a list of 3-tuples
425 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices);
426 ~wxAcceleratorTable();
430 //---------------------------------------------------------------------------
434 wxBusyInfo(const wxString& message);
440 //---------------------------------------------------------------------------