]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/misc.i
wxPython 2.1b1 for wxMSW (wxGTK coming soon)
[wxWidgets.git] / utils / wxPython / src / misc.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: misc.i
3 // Purpose: Definitions of miscelaneous functions and classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 7/3/97
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module misc
14
15 %{
16 #include "helpers.h"
17 #include <wx/resource.h>
18 #include <wx/tooltip.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28
29
30 //---------------------------------------------------------------------------
31
32
33 class wxSize {
34 public:
35 long x;
36 long y;
37 %name(width) long x;
38 %name(height)long y;
39
40 wxSize(long w=0, long h=0);
41 ~wxSize();
42 void Set(long w, long h);
43 long GetX();
44 long GetY();
45 long GetWidth();
46 long GetHeight();
47 void SetWidth(long w);
48 void SetHeight(long h);
49
50 %addmethods {
51 PyObject* asTuple() {
52 PyObject* tup = PyTuple_New(2);
53 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
54 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
55 return tup;
56 }
57 }
58 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
59 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
60
61 };
62
63 //---------------------------------------------------------------------------
64
65 class wxRealPoint {
66 public:
67 double x;
68 double y;
69 wxRealPoint(double x=0.0, double y=0.0);
70 ~wxRealPoint();
71 };
72
73 class wxPoint {
74 public:
75 long x;
76 long y;
77 wxPoint(long x=0, long y=0);
78 ~wxPoint();
79
80 %addmethods {
81 void Set(long x, long y) {
82 self->x = x;
83 self->y = y;
84 }
85 PyObject* asTuple() {
86 PyObject* tup = PyTuple_New(2);
87 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
88 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
89 return tup;
90 }
91 }
92 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
93 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
94 };
95
96 //---------------------------------------------------------------------------
97
98 class wxRect {
99 public:
100 wxRect(long x=0, long y=0, long w=0, long h=0);
101 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
102 ~wxRect();
103
104 long GetX();
105 void SetX(long X);
106 long GetY();
107 void SetY(long Y);
108 long GetWidth();
109 void SetWidth(long w);
110 long GetHeight();
111 void SetHeight(long h);
112
113
114 wxPoint GetPosition();
115 wxSize GetSize();
116
117 long GetLeft();
118 long GetTop();
119 long GetBottom();
120 long GetRight();
121
122 long x, y, width, height;
123
124 %addmethods {
125 PyObject* asTuple() {
126 PyObject* tup = PyTuple_New(4);
127 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
128 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
129 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->width));
130 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->height));
131 return tup;
132 }
133 }
134 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
135 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
136 };
137
138
139
140 //---------------------------------------------------------------------------
141 // Dialog Functions
142
143 wxString wxFileSelector(char* message,
144 char* default_path = NULL,
145 char* default_filename = NULL,
146 char* default_extension = NULL,
147 char* wildcard = "*.*",
148 int flags = 0,
149 wxWindow *parent = NULL,
150 int x = -1, int y = -1);
151
152 wxString wxGetTextFromUser(const wxString& message,
153 const wxString& caption = wxPyEmptyStr,
154 const wxString& default_value = wxPyEmptyStr,
155 wxWindow *parent = NULL,
156 int x = -1, int y = -1,
157 bool centre = TRUE);
158
159 // TODO: Need to custom wrap this one...
160 // int wxGetMultipleChoice(char* message, char* caption,
161 // int LCOUNT, char** LIST,
162 // int nsel, int *selection,
163 // wxWindow *parent = NULL, int x = -1, int y = -1,
164 // bool centre = TRUE, int width=150, int height=200);
165
166
167 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
168 int LCOUNT, wxString* LIST,
169 wxWindow *parent = NULL,
170 int x = -1, int y = -1,
171 bool centre = TRUE,
172 int width=150, int height=200);
173
174 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
175 int LCOUNT, wxString* LIST,
176 wxWindow *parent = NULL,
177 int x = -1, int y = -1,
178 bool centre = TRUE,
179 int width=150, int height=200);
180
181
182 int wxMessageBox(const wxString& message,
183 const wxString& caption = wxPyEmptyStr,
184 int style = wxOK | wxCENTRE,
185 wxWindow *parent = NULL,
186 int x = -1, int y = -1);
187
188 //---------------------------------------------------------------------------
189 // GDI Functions
190
191 bool wxColourDisplay();
192 int wxDisplayDepth();
193 void wxSetCursor(wxCursor& cursor);
194
195 //---------------------------------------------------------------------------
196 // Miscellaneous functions
197
198 long wxNewId();
199 void wxRegisterId(long id);
200 %name(NewId) long wxNewId();
201 %name(RegisterId) void wxRegisterId(long id);
202
203 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
204 void wxBell();
205 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
206 void wxEndBusyCursor();
207 long wxExecute(const wxString& command, bool sync = FALSE);
208 #ifdef __WXMSW__
209 wxWindow * wxGetActiveWindow();
210 long wxGetElapsedTime(bool resetTimer = TRUE);
211 long wxGetFreeMemory();
212 #endif
213 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
214 bool wxIsBusy();
215 wxString wxNow();
216 #ifdef __WXMSW__
217 bool wxShell(const wxString& command = wxPyEmptyStr);
218 void wxStartTimer();
219 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
220 #endif
221
222 void wxSleep(int secs);
223 bool wxYield();
224 bool wxSafeYield();
225 void wxEnableTopLevelWindows(bool enable);
226
227 %inline %{
228 char* wxGetResource(char *section, char *entry, char *file = NULL) {
229 char * retval;
230 wxGetResource(section, entry, &retval, file);
231 return retval;
232 }
233 %}
234
235 //---------------------------------------------------------------------------
236 // Resource System
237
238 bool wxResourceAddIdentifier(char *name, int value);
239 void wxResourceClear(void);
240 wxBitmap wxResourceCreateBitmap(char *resource);
241 wxIcon wxResourceCreateIcon(char *resource);
242 wxMenuBar * wxResourceCreateMenuBar(char *resource);
243 int wxResourceGetIdentifier(char *name);
244 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
245 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
246 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
247
248
249
250 //----------------------------------------------------------------------
251
252 class wxPyTimer {
253 public:
254 wxPyTimer(PyObject* notify);
255 ~wxPyTimer();
256 int Interval();
257 void Start(int milliseconds=-1, int oneShot=FALSE);
258 void Stop();
259 };
260
261 //---------------------------------------------------------------------------
262
263 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
264 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
265 enum wxRelationship { wxUnconstrained = 0,
266 wxAsIs,
267 wxPercentOf,
268 wxAbove,
269 wxBelow,
270 wxLeftOf,
271 wxRightOf,
272 wxSameAs,
273 wxAbsolute };
274
275
276 class wxIndividualLayoutConstraint {
277 public:
278 // wxIndividualLayoutConstraint();
279 // ~wxIndividualLayoutConstraint();
280
281 void Above(wxWindow *otherWin, int margin=0);
282 void Absolute(int value);
283 void AsIs();
284 void Below(wxWindow *otherWin, int margin=0);
285 void Unconstrained();
286 void LeftOf(wxWindow *otherWin, int margin=0);
287 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
288 void RightOf(wxWindow *otherWin, int margin=0);
289 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
290 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
291 };
292
293
294 class wxLayoutConstraints {
295 public:
296 wxLayoutConstraints();
297
298 %readonly
299 wxIndividualLayoutConstraint bottom;
300 wxIndividualLayoutConstraint centreX;
301 wxIndividualLayoutConstraint centreY;
302 wxIndividualLayoutConstraint height;
303 wxIndividualLayoutConstraint left;
304 wxIndividualLayoutConstraint right;
305 wxIndividualLayoutConstraint top;
306 wxIndividualLayoutConstraint width;
307 %readwrite
308 }
309
310
311 //---------------------------------------------------------------------------
312 // Regions, etc.
313
314 enum wxRegionContain {
315 wxOutRegion, wxPartRegion, wxInRegion
316 };
317
318
319 class wxRegion {
320 public:
321 wxRegion();
322 ~wxRegion();
323
324 void Clear();
325 wxRegionContain Contains(long x, long y);
326 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
327 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
328
329 wxRect GetBox();
330 bool Intersect(const wxRect& rect);
331 #ifdef __WXMSW__
332 bool IsEmpty();
333 #endif
334 bool Subtract(const wxRect& rect);
335 bool Union(const wxRect& rect);
336 bool Xor(const wxRect& rect);
337 };
338
339
340
341 class wxRegionIterator {
342 public:
343 wxRegionIterator(const wxRegion& region);
344 ~wxRegionIterator();
345
346 long GetX();
347 long GetY();
348 long GetW();
349 long GetWidth();
350 long GetH();
351 long GetHeight();
352 wxRect GetRect();
353 bool HaveRects();
354 void Reset();
355
356 %addmethods {
357 void Next() {
358 (*self) ++;
359 }
360 };
361 };
362
363
364
365 //---------------------------------------------------------------------------
366 // Accelerator Entry and Table
367
368 class wxAcceleratorEntry {
369 public:
370 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
371 //~wxAcceleratorEntry(); *** ?
372
373 void Set(int flags, int keyCode, int Cmd);
374 int GetFlags();
375 int GetKeyCode();
376 int GetCommand();
377 };
378
379
380 class wxAcceleratorTable {
381 public:
382 // Can also accept a list of 3-tuples
383 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
384 // ~wxAcceleratorEntry(); *** ?
385
386 };
387
388 //---------------------------------------------------------------------------