]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/misc.i
TreeCtrl indentation and spacing
[wxWidgets.git] / utils / wxPython / src / misc.i
CommitLineData
7bf85405
RD
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
03e9bead 13%module misc
7bf85405 14
03e9bead 15%{
7bf85405
RD
16#include "helpers.h"
17#include <wx/resource.h>
af309447 18#include <wx/tooltip.h>
7bf85405
RD
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
33class wxSize {
34public:
af309447
RD
35 long x;
36 long y;
7bf85405
RD
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);
af309447
RD
43 long GetX();
44 long GetY();
7bf85405
RD
45 %name(GetWidth) long GetX();
46 %name(GetHeight)long GetY();
47
48 %addmethods {
af309447 49 PyObject* asTuple() {
7bf85405
RD
50 PyObject* tup = PyTuple_New(2);
51 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
52 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
53 return tup;
54 }
55 }
af309447
RD
56 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
57 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
58
7bf85405
RD
59};
60
61//---------------------------------------------------------------------------
62
63class wxRealPoint {
64public:
65 double x;
66 double y;
67 wxRealPoint(double x=0.0, double y=0.0);
68 ~wxRealPoint();
69};
70
71class wxPoint {
72public:
73 long x;
74 long y;
75 wxPoint(long x=0, long y=0);
76 ~wxPoint();
77
78 %addmethods {
79 void Set(long x, long y) {
80 self->x = x;
81 self->y = y;
82 }
af309447 83 PyObject* asTuple() {
7bf85405
RD
84 PyObject* tup = PyTuple_New(2);
85 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
86 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
87 return tup;
88 }
89 }
af309447
RD
90 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
91 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
7bf85405
RD
92};
93
94//---------------------------------------------------------------------------
95
96class wxRect {
97public:
98 wxRect(long x=0, long y=0, long w=0, long h=0);
99 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
100 ~wxRect();
101
102 long GetX();
103 void SetX(long X);
104 long GetY();
105 void SetY(long Y);
106 long GetWidth();
107 void SetWidth(long w);
108 long GetHeight();
109 void SetHeight(long h);
110
111
112 wxPoint GetPosition();
113 wxSize GetSize();
114
115 long GetLeft();
116 long GetTop();
117 long GetBottom();
118 long GetRight();
119
120 long x, y, width, height;
af309447
RD
121
122 %addmethods {
123 PyObject* asTuple() {
124 PyObject* tup = PyTuple_New(4);
125 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
126 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
127 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->width));
128 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->height));
129 return tup;
130 }
131 }
132 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
133 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
7bf85405
RD
134};
135
136
137
138//---------------------------------------------------------------------------
139// Dialog Functions
140
08127323 141wxString wxFileSelector(char* message,
7bf85405
RD
142 char* default_path = NULL,
143 char* default_filename = NULL,
144 char* default_extension = NULL,
145 char* wildcard = "*.*",
146 int flags = 0,
147 wxWindow *parent = NULL,
148 int x = -1, int y = -1);
149
150wxString wxGetTextFromUser(const wxString& message,
151 const wxString& caption = wxPyEmptyStr,
152 const wxString& default_value = wxPyEmptyStr,
153 wxWindow *parent = NULL,
154 int x = -1, int y = -1,
155 bool centre = TRUE);
156
157// TODO: Need to custom wrap this one...
158// int wxGetMultipleChoice(char* message, char* caption,
159// int LCOUNT, char** LIST,
160// int nsel, int *selection,
161// wxWindow *parent = NULL, int x = -1, int y = -1,
162// bool centre = TRUE, int width=150, int height=200);
163
164
165wxString wxGetSingleChoice(const wxString& message, const wxString& caption,
166 int LCOUNT, wxString* LIST,
167 wxWindow *parent = NULL,
168 int x = -1, int y = -1,
169 bool centre = TRUE,
170 int width=150, int height=200);
171
172int wxGetSingleChoiceIndex(const wxString& message, const wxString& caption,
173 int LCOUNT, wxString* LIST,
174 wxWindow *parent = NULL,
175 int x = -1, int y = -1,
176 bool centre = TRUE,
177 int width=150, int height=200);
178
179
180int wxMessageBox(const wxString& message,
181 const wxString& caption = wxPyEmptyStr,
182 int style = wxOK | wxCENTRE,
183 wxWindow *parent = NULL,
184 int x = -1, int y = -1);
185
186//---------------------------------------------------------------------------
187// GDI Functions
188
189bool wxColourDisplay();
190int wxDisplayDepth();
b8b8dda7 191void wxSetCursor(wxCursor& cursor);
7bf85405
RD
192
193//---------------------------------------------------------------------------
194// Miscellaneous functions
195
cf694132
RD
196long wxNewId();
197void wxRegisterId(long id);
198%name(NewId) long wxNewId();
199%name(RegisterId) void wxRegisterId(long id);
200
7bf85405
RD
201void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
202void wxBell();
203void wxDisplaySize(int *OUTPUT, int *OUTPUT);
204void wxEndBusyCursor();
205long wxExecute(const wxString& command, bool sync = FALSE);
206wxWindow * wxFindWindowByLabel(const wxString& label, wxWindow *parent=NULL);
207wxWindow * wxFindWindowByName(const wxString& name, wxWindow *parent=NULL);
714e6a9e 208#ifdef __WXMSW__
7bf85405
RD
209wxWindow * wxGetActiveWindow();
210long wxGetElapsedTime(bool resetTimer = TRUE);
211long wxGetFreeMemory();
fb5e0af0 212#endif
7bf85405
RD
213void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
214bool wxIsBusy();
215wxString wxNow();
714e6a9e 216#ifdef __WXMSW__
fb5e0af0 217bool wxShell(const wxString& command = wxPyEmptyStr);
7bf85405 218void wxStartTimer();
fb5e0af0 219int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
714e6a9e 220#endif
fb5e0af0 221
7bf85405 222bool wxYield();
cf694132 223bool wxSafeYield();
7bf85405 224
7bf85405
RD
225%inline %{
226 char* wxGetResource(char *section, char *entry, char *file = NULL) {
227 char * retval;
228 wxGetResource(section, entry, &retval, file);
229 return retval;
230 }
231%}
232
233//---------------------------------------------------------------------------
234// Resource System
235
236bool wxResourceAddIdentifier(char *name, int value);
237void wxResourceClear(void);
d5c9047a
RD
238wxBitmap wxResourceCreateBitmap(char *resource);
239wxIcon wxResourceCreateIcon(char *resource);
7bf85405
RD
240wxMenuBar * wxResourceCreateMenuBar(char *resource);
241int wxResourceGetIdentifier(char *name);
242bool wxResourceParseData(char *resource, wxResourceTable *table = NULL);
243bool wxResourceParseFile(char *filename, wxResourceTable *table = NULL);
244bool wxResourceParseString(char *resource, wxResourceTable *table = NULL);
245
246
247
248//----------------------------------------------------------------------
249
250class wxPyTimer {
251public:
252 wxPyTimer(PyObject* notify);
253 ~wxPyTimer();
254 int Interval();
255 void Start(int milliseconds=-1, int oneShot=FALSE);
256 void Stop();
257};
258
259//---------------------------------------------------------------------------
260
261enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
262 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
263enum wxRelationship { wxUnconstrained = 0,
264 wxAsIs,
265 wxPercentOf,
266 wxAbove,
267 wxBelow,
268 wxLeftOf,
269 wxRightOf,
270 wxSameAs,
271 wxAbsolute };
272
273
274class wxIndividualLayoutConstraint {
275public:
276// wxIndividualLayoutConstraint();
277// ~wxIndividualLayoutConstraint();
278
279 void Above(wxWindow *otherWin, int margin=0);
280 void Absolute(int value);
08127323 281 void AsIs();
7bf85405 282 void Below(wxWindow *otherWin, int margin=0);
08127323 283 void Unconstrained();
7bf85405
RD
284 void LeftOf(wxWindow *otherWin, int margin=0);
285 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
286 void RightOf(wxWindow *otherWin, int margin=0);
287 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
288 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
289};
290
291
292class wxLayoutConstraints {
293public:
294 wxLayoutConstraints();
295
296%readonly
297 wxIndividualLayoutConstraint bottom;
298 wxIndividualLayoutConstraint centreX;
299 wxIndividualLayoutConstraint centreY;
300 wxIndividualLayoutConstraint height;
301 wxIndividualLayoutConstraint left;
302 wxIndividualLayoutConstraint right;
303 wxIndividualLayoutConstraint top;
304 wxIndividualLayoutConstraint width;
305%readwrite
306}
307
308
b639c3c5
RD
309//---------------------------------------------------------------------------
310// Regions, etc.
311
312enum wxRegionContain {
313 wxOutRegion, wxPartRegion, wxInRegion
314};
315
316
317class wxRegion {
318public:
319 wxRegion();
320 ~wxRegion();
321
322 void Clear();
323 wxRegionContain Contains(long x, long y);
324 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
325 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
326
327 wxRect GetBox();
328 bool Intersect(const wxRect& rect);
105e45b9 329#ifdef __WXMSW__
b639c3c5 330 bool IsEmpty();
105e45b9 331#endif
b639c3c5
RD
332 bool Subtract(const wxRect& rect);
333 bool Union(const wxRect& rect);
334 bool Xor(const wxRect& rect);
335};
336
337
338
339class wxRegionIterator {
340public:
341 wxRegionIterator(const wxRegion& region);
342 ~wxRegionIterator();
343
344 long GetX();
345 long GetY();
346 long GetW();
347 long GetWidth();
348 long GetH();
349 long GetHeight();
350 wxRect GetRect();
351 bool HaveRects();
352 void Reset();
353
354 %addmethods {
355 void Next() {
356 (*self) ++;
357 }
358 };
359};
360
361
362
7bf85405
RD
363//---------------------------------------------------------------------------
364// Accelerator Entry and Table
365
366class wxAcceleratorEntry {
367public:
368 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
369 //~wxAcceleratorEntry(); *** ?
370
371 void Set(int flags, int keyCode, int Cmd);
372 int GetFlags();
373 int GetKeyCode();
374 int GetCommand();
375};
376
377
378class wxAcceleratorTable {
379public:
380 // Can also accept a list of 3-tuples
381 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* LIST);
382 // ~wxAcceleratorEntry(); *** ?
383
384};
faf3cb35 385
af309447
RD
386//---------------------------------------------------------------------------
387// wxToolTip
388
389class wxToolTip {
390public:
391 wxToolTip(const wxString &tip);
392
393 void SetTip(const wxString& tip);
394 wxString GetTip();
0699c864 395 // *** Not in the "public" interface void SetWindow(wxWindow *win);
af309447
RD
396 wxWindow *GetWindow();
397};
398
399
400%inline %{
401 void wxToolTip_Enable(bool flag) {
402 wxToolTip::Enable(flag);
403 }
404
405 void wxToolTip_SetDelay(long milliseconds) {
406 wxToolTip::SetDelay(milliseconds);
407 }
408%}
409
7bf85405
RD
410//---------------------------------------------------------------------------
411/////////////////////////////////////////////////////////////////////////////
412//
413// $Log$
cf694132
RD
414// Revision 1.14 1999/04/30 03:29:19 RD
415// wxPython 2.0b9, first phase (win32)
416// Added gobs of stuff, see wxPython/README.txt for details
417//
418// Revision 1.13.4.1 1999/03/27 23:29:15 RD
419//
420// wxPython 2.0b8
421// Python thread support
422// various minor additions
423// various minor fixes
424//
0699c864 425// Revision 1.13 1999/02/25 07:08:34 RD
cf694132 426//
0699c864
RD
427// wxPython version 2.0b5
428//
b57bdb5a 429// Revision 1.12 1999/02/20 10:02:37 RD
0699c864 430//
b57bdb5a
RD
431// Changes needed to enable wxGTK compatibility.
432//
af309447
RD
433// Revision 1.11 1999/02/20 09:03:01 RD
434// Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
435// window handle. If you can get the window handle into the python code,
436// it should just work... More news on this later.
437//
438// Added wxImageList, wxToolTip.
439//
440// Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
441// wxRegConfig class.
442//
443// As usual, some bug fixes, tweaks, etc.
444//
08127323 445// Revision 1.10 1999/01/30 07:30:14 RD
af309447 446//
08127323
RD
447// Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
448//
449// Various cleanup, tweaks, minor additions, etc. to maintain
450// compatibility with the current wxWindows.
451//
105e45b9 452// Revision 1.9 1998/12/16 22:10:55 RD
08127323 453//
105e45b9
RD
454// Tweaks needed to be able to build wxPython with wxGTK.
455//
b8b8dda7
RD
456// Revision 1.8 1998/12/15 20:41:22 RD
457// Changed the import semantics from "from wxPython import *" to "from
458// wxPython.wx import *" This is for people who are worried about
459// namespace pollution, they can use "from wxPython import wx" and then
460// prefix all the wxPython identifiers with "wx."
461//
462// Added wxTaskbarIcon for wxMSW.
463//
464// Made the events work for wxGrid.
465//
466// Added wxConfig.
467//
468// Added wxMiniFrame for wxGTK, (untested.)
469//
470// Changed many of the args and return values that were pointers to gdi
471// objects to references to reflect changes in the wxWindows API.
472//
473// Other assorted fixes and additions.
474//
b639c3c5 475// Revision 1.7 1998/11/25 08:45:27 RD
b8b8dda7 476//
b639c3c5
RD
477// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
478// Added events for wxGrid
479// Other various fixes and additions
480//
faf3cb35
RD
481// Revision 1.6 1998/11/15 23:03:46 RD
482// Removing some ifdef's for wxGTK
483//
d5c9047a
RD
484// Revision 1.5 1998/10/20 06:43:59 RD
485// New wxTreeCtrl wrappers (untested)
486// some changes in helpers
487// etc.
488//
fb5e0af0
RD
489// Revision 1.4 1998/08/18 19:48:19 RD
490// more wxGTK compatibility things.
491//
492// It builds now but there are serious runtime problems...
493//
714e6a9e
RD
494// Revision 1.3 1998/08/16 04:31:10 RD
495// More wxGTK work.
496//
03e9bead
RD
497// Revision 1.2 1998/08/15 07:36:41 RD
498// - Moved the header in the .i files out of the code that gets put into
499// the .cpp files. It caused CVS conflicts because of the RCS ID being
500// different each time.
501//
502// - A few minor fixes.
503//
7bf85405
RD
504// Revision 1.1 1998/08/09 08:25:51 RD
505// Initial version
506//
507//
508
509