]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/misc.i
wxPython 2.1b1:
[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
160 // TODO: Need to custom wrap this one...
161 // int wxGetMultipleChoice(char* message, char* caption,
162 // int LCOUNT, char** LIST,
163 // int nsel, int *selection,
164 // wxWindow *parent = NULL, int x = -1, int y = -1,
165 // bool centre = TRUE, int width=150, int height=200);
166
167
168 wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
169 int LCOUNT, wxString* LIST,
170 wxWindow *parent = NULL,
171 int x = -1, int y = -1,
172 bool centre = TRUE,
173 int width=150, int height=200);
174
175 int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
176 int LCOUNT, wxString* LIST,
177 wxWindow *parent = NULL,
178 int x = -1, int y = -1,
179 bool centre = TRUE,
180 int width=150, int height=200);
181
182
183 int wxMessageBox(const wxString& message,
184 const wxString& caption = wxPyEmptyStr,
185 int style = wxOK | wxCENTRE,
186 wxWindow *parent = NULL,
187 int x = -1, int y = -1);
188
189 long wxGetNumberFromUser(const wxString& message,
190 const wxString& prompt,
191 const wxString& caption,
192 long value,
193 long min = 0, long max = 100,
194 wxWindow *parent = NULL,
195 const wxPoint& pos = wxPyDefaultPosition);
196
197 //---------------------------------------------------------------------------
198 // GDI Functions
199
200 bool wxColourDisplay();
201 int wxDisplayDepth();
202 void wxSetCursor(wxCursor& cursor);
203
204 //---------------------------------------------------------------------------
205 // Miscellaneous functions
206
207 long wxNewId();
208 void wxRegisterId(long id);
209 %name(NewId) long wxNewId();
210 %name(RegisterId) void wxRegisterId(long id);
211
212 void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
213 void wxBell();
214 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
215 void wxEndBusyCursor();
216 long wxExecute(const wxString& command, bool sync = FALSE);
217 #ifdef __WXMSW__
218 wxWindow * wxGetActiveWindow();
219 long wxGetElapsedTime(bool resetTimer = TRUE);
220 long wxGetFreeMemory();
221 #endif
222 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
223 bool wxIsBusy();
224 wxString wxNow();
225 #ifdef __WXMSW__
226 bool wxShell(const wxString& command = wxPyEmptyStr);
227 void wxStartTimer();
228 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
229 #endif
230
231 void wxSleep(int secs);
232 bool wxYield();
233 bool wxSafeYield();
234 void wxEnableTopLevelWindows(bool enable);
235
236 %inline %{
237 char* wxGetResource(char *section, char *entry, char *file = NULL) {
238 char * retval;
239 wxGetResource(section, entry, &retval, file);
240 return retval;
241 }
242 %}
243
244 //---------------------------------------------------------------------------
245 // Resource System
246
247 bool wxResourceAddIdentifier(char *name, int value);
248 void wxResourceClear(void);
249 wxBitmap wxResourceCreateBitmap(char *resource);
250 wxIcon wxResourceCreateIcon(char *resource);
251 wxMenuBar * wxResourceCreateMenuBar(char *resource);
252 int wxResourceGetIdentifier(char *name);
253 bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
254 bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
255 bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
256
257
258
259 //----------------------------------------------------------------------
260
261 class wxPyTimer {
262 public:
263 wxPyTimer(PyObject* notify);
264 ~wxPyTimer();
265 int Interval();
266 void Start(int milliseconds=-1, int oneShot=FALSE);
267 void Stop();
268 };
269
270 //---------------------------------------------------------------------------
271
272 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
273 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
274 enum wxRelationship { wxUnconstrained = 0,
275 wxAsIs,
276 wxPercentOf,
277 wxAbove,
278 wxBelow,
279 wxLeftOf,
280 wxRightOf,
281 wxSameAs,
282 wxAbsolute };
283
284
285 class wxIndividualLayoutConstraint {
286 public:
287 // wxIndividualLayoutConstraint();
288 // ~wxIndividualLayoutConstraint();
289
290 void Above(wxWindow *otherWin, int margin=0);
291 void Absolute(int value);
292 void AsIs();
293 void Below(wxWindow *otherWin, int margin=0);
294 void Unconstrained();
295 void LeftOf(wxWindow *otherWin, int margin=0);
296 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
297 void RightOf(wxWindow *otherWin, int margin=0);
298 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
299 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
300 };
301
302
303 class wxLayoutConstraints {
304 public:
305 wxLayoutConstraints();
306
307 %readonly
308 wxIndividualLayoutConstraint bottom;
309 wxIndividualLayoutConstraint centreX;
310 wxIndividualLayoutConstraint centreY;
311 wxIndividualLayoutConstraint height;
312 wxIndividualLayoutConstraint left;
313 wxIndividualLayoutConstraint right;
314 wxIndividualLayoutConstraint top;
315 wxIndividualLayoutConstraint width;
316 %readwrite
317 }
318
319
320 //---------------------------------------------------------------------------
321 // Regions, etc.
322
323 enum wxRegionContain {
324 wxOutRegion, wxPartRegion, wxInRegion
325 };
326
327
328 class wxRegion {
329 public:
330 wxRegion();
331 ~wxRegion();
332
333 void Clear();
334 wxRegionContain Contains(long x, long y);
335 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
336 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
337
338 wxRect GetBox();
339 bool Intersect(const wxRect& rect);
340 #ifdef __WXMSW__
341 bool IsEmpty();
342 #endif
343 bool Subtract(const wxRect& rect);
344 bool Union(const wxRect& rect);
345 bool Xor(const wxRect& rect);
346 };
347
348
349
350 class wxRegionIterator {
351 public:
352 wxRegionIterator(const wxRegion& region);
353 ~wxRegionIterator();
354
355 long GetX();
356 long GetY();
357 long GetW();
358 long GetWidth();
359 long GetH();
360 long GetHeight();
361 wxRect GetRect();
362 bool HaveRects();
363 void Reset();
364
365 %addmethods {
366 void Next() {
367 (*self) ++;
368 }
369 };
370 };
371
372
373
374 //---------------------------------------------------------------------------
375 // Accelerator Entry and Table
376
377 class wxAcceleratorEntry {
378 public:
379 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
380 //~wxAcceleratorEntry(); *** ?
381
382 void Set(int flags, int keyCode, int Cmd);
383 int GetFlags();
384 int GetKeyCode();
385 int GetCommand();
386 };
387
388
389 class wxAcceleratorTable {
390 public:
391 // Can also accept a list of 3-tuples
392 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
393 // ~wxAcceleratorEntry(); *** ?
394
395 };
396
397 //---------------------------------------------------------------------------
398
399 enum {
400 wxSYS_WHITE_BRUSH,
401 wxSYS_LTGRAY_BRUSH,
402 wxSYS_GRAY_BRUSH,
403 wxSYS_DKGRAY_BRUSH,
404 wxSYS_BLACK_BRUSH,
405 wxSYS_NULL_BRUSH,
406 wxSYS_HOLLOW_BRUSH,
407 wxSYS_WHITE_PEN,
408 wxSYS_BLACK_PEN,
409 wxSYS_NULL_PEN,
410 wxSYS_OEM_FIXED_FONT,
411 wxSYS_ANSI_FIXED_FONT,
412 wxSYS_ANSI_VAR_FONT,
413 wxSYS_SYSTEM_FONT,
414 wxSYS_DEVICE_DEFAULT_FONT,
415 wxSYS_DEFAULT_PALETTE,
416 wxSYS_SYSTEM_FIXED_FONT,
417 wxSYS_DEFAULT_GUI_FONT,
418
419 wxSYS_COLOUR_SCROLLBAR,
420 wxSYS_COLOUR_BACKGROUND,
421 wxSYS_COLOUR_ACTIVECAPTION,
422 wxSYS_COLOUR_INACTIVECAPTION,
423 wxSYS_COLOUR_MENU,
424 wxSYS_COLOUR_WINDOW,
425 wxSYS_COLOUR_WINDOWFRAME,
426 wxSYS_COLOUR_MENUTEXT,
427 wxSYS_COLOUR_WINDOWTEXT,
428 wxSYS_COLOUR_CAPTIONTEXT,
429 wxSYS_COLOUR_ACTIVEBORDER,
430 wxSYS_COLOUR_INACTIVEBORDER,
431 wxSYS_COLOUR_APPWORKSPACE,
432 wxSYS_COLOUR_HIGHLIGHT,
433 wxSYS_COLOUR_HIGHLIGHTTEXT,
434 wxSYS_COLOUR_BTNFACE,
435 wxSYS_COLOUR_BTNSHADOW,
436 wxSYS_COLOUR_GRAYTEXT,
437 wxSYS_COLOUR_BTNTEXT,
438 wxSYS_COLOUR_INACTIVECAPTIONTEXT,
439 wxSYS_COLOUR_BTNHIGHLIGHT,
440
441 wxSYS_COLOUR_3DDKSHADOW,
442 wxSYS_COLOUR_3DLIGHT,
443 wxSYS_COLOUR_INFOTEXT,
444 wxSYS_COLOUR_INFOBK,
445
446 wxSYS_COLOUR_DESKTOP,
447 wxSYS_COLOUR_3DFACE,
448 wxSYS_COLOUR_3DSHADOW,
449 wxSYS_COLOUR_3DHIGHLIGHT,
450 wxSYS_COLOUR_3DHILIGHT,
451 wxSYS_COLOUR_BTNHILIGHT,
452
453 wxSYS_MOUSE_BUTTONS,
454 wxSYS_BORDER_X,
455 wxSYS_BORDER_Y,
456 wxSYS_CURSOR_X,
457 wxSYS_CURSOR_Y,
458 wxSYS_DCLICK_X,
459 wxSYS_DCLICK_Y,
460 wxSYS_DRAG_X,
461 wxSYS_DRAG_Y,
462 wxSYS_EDGE_X,
463 wxSYS_EDGE_Y,
464 wxSYS_HSCROLL_ARROW_X,
465 wxSYS_HSCROLL_ARROW_Y,
466 wxSYS_HTHUMB_X,
467 wxSYS_ICON_X,
468 wxSYS_ICON_Y,
469 wxSYS_ICONSPACING_X,
470 wxSYS_ICONSPACING_Y,
471 wxSYS_WINDOWMIN_X,
472 wxSYS_WINDOWMIN_Y,
473 wxSYS_SCREEN_X,
474 wxSYS_SCREEN_Y,
475 wxSYS_FRAMESIZE_X,
476 wxSYS_FRAMESIZE_Y,
477 wxSYS_SMALLICON_X,
478 wxSYS_SMALLICON_Y,
479 wxSYS_HSCROLL_Y,
480 wxSYS_VSCROLL_X,
481 wxSYS_VSCROLL_ARROW_X,
482 wxSYS_VSCROLL_ARROW_Y,
483 wxSYS_VTHUMB_Y,
484 wxSYS_CAPTION_Y,
485 wxSYS_MENU_Y,
486 wxSYS_NETWORK_PRESENT,
487 wxSYS_PENWINDOWS_PRESENT,
488 wxSYS_SHOW_SOUNDS,
489 wxSYS_SWAP_BUTTONS,
490 };
491
492
493
494 %inline %{
495
496 wxColour wxSystemSettings_GetSystemColour(int index) {
497 return wxSystemSettings::GetSystemColour(index);
498 }
499
500 wxFont wxSystemSettings_GetSystemFont(int index) {
501 return wxSystemSettings::GetSystemFont(index);
502 }
503
504 int wxSystemSettings_GetSystemMetric(int index) {
505 return wxSystemSettings::GetSystemMetric(index);
506 }
507 %}
508
509 //---------------------------------------------------------------------------
510 //---------------------------------------------------------------------------
511
512