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())"
163 // bool wxIntersectRect(wxRect* dest, wxRect* r1, wxRect* r2) {
164 // wxRegion reg1(*r1);
165 // wxRegion reg2(*r2);
167 // *dest = wxRect(0,0,0,0);
168 // success = reg1.Intersect(reg2);
170 // *dest = reg1.GetBox();
171 // return *dest != wxRect(0,0,0,0);
179 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
182 wxRect dest(0,0,0,0);
185 reg1.Intersect(reg2);
186 dest = reg1.GetBox();
188 if (dest != wxRect(0,0,0,0)) {
189 bool doSave = wxPyRestoreThread();
190 wxRect* newRect = new wxRect(dest);
191 obj = wxPyConstructObject((void*)newRect, "wxRect");
192 PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
193 wxPySaveThread(doSave);
202 //---------------------------------------------------------------------------
203 // Miscellaneous functions
206 void wxRegisterId(long id);
207 %name(NewId) long wxNewId();
208 %name(RegisterId) void wxRegisterId(long id);
211 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
212 void wxEndBusyCursor();
213 long wxExecute(const wxString& command, int sync = FALSE);
214 long wxGetElapsedTime(bool resetTimer = TRUE);
216 long wxGetFreeMemory();
218 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
221 bool wxShell(const wxString& command = wxPyEmptyStr);
223 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
225 void wxSleep(int secs);
228 void wxEnableTopLevelWindows(bool enable);
231 char* wxGetResource(char *section, char *entry, char *file = NULL) {
233 wxGetResource(section, entry, &retval, file);
238 wxString wxStripMenuCodes(const wxString& in);
240 //----------------------------------------------------------------------
244 wxPyTimer(PyObject* notify);
248 void Start(int milliseconds=-1, int oneShot=FALSE);
252 //---------------------------------------------------------------------------
254 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
255 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
256 enum wxRelationship { wxUnconstrained = 0,
267 class wxIndividualLayoutConstraint {
269 // wxIndividualLayoutConstraint();
270 // ~wxIndividualLayoutConstraint();
272 void Above(wxWindow *otherWin, int margin=0);
273 void Absolute(int value);
275 void Below(wxWindow *otherWin, int margin=0);
276 void Unconstrained();
277 void LeftOf(wxWindow *otherWin, int margin=0);
278 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
279 void RightOf(wxWindow *otherWin, int margin=0);
280 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
281 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
285 class wxLayoutConstraints {
287 wxLayoutConstraints();
290 wxIndividualLayoutConstraint bottom;
291 wxIndividualLayoutConstraint centreX;
292 wxIndividualLayoutConstraint centreY;
293 wxIndividualLayoutConstraint height;
294 wxIndividualLayoutConstraint left;
295 wxIndividualLayoutConstraint right;
296 wxIndividualLayoutConstraint top;
297 wxIndividualLayoutConstraint width;
302 //---------------------------------------------------------------------------
305 enum wxRegionContain {
306 wxOutRegion, wxPartRegion, wxInRegion
316 wxRegionContain Contains(long x, long y);
317 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
318 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
319 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
323 bool Intersect(long x, long y, long width, long height);
324 %name(IntersectRect)bool Intersect(const wxRect& rect);
325 %name(IntersectRegion)bool Intersect(const wxRegion& region);
329 bool Union(long x, long y, long width, long height);
330 %name(UnionRect)bool Union(const wxRect& rect);
331 %name(UnionRegion)bool Union(const wxRegion& region);
333 bool Subtract(long x, long y, long width, long height);
334 %name(SubtractRect)bool Subtract(const wxRect& rect);
335 %name(SubtractRegion)bool Subtract(const wxRegion& region);
337 bool Xor(long x, long y, long width, long height);
338 %name(XorRect)bool Xor(const wxRect& rect);
339 %name(XorRegion)bool Xor(const wxRegion& region);
344 class wxRegionIterator {
346 wxRegionIterator(const wxRegion& region);
368 //---------------------------------------------------------------------------
369 // Accelerator Entry and Table
371 class wxAcceleratorEntry {
373 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
374 ~wxAcceleratorEntry();
376 void Set(int flags, int keyCode, int Cmd);
383 class wxAcceleratorTable {
385 // Can also accept a list of 3-tuples
386 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
387 ~wxAcceleratorTable();
391 //---------------------------------------------------------------------------
395 wxBusyInfo(const wxString& message);
401 //---------------------------------------------------------------------------