]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/controls.i
wxPython 2.0b9, first phase (win32)
[wxWidgets.git] / utils / wxPython / src / controls.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: controls.i
3 // Purpose: Control (widget) classes for wxPython
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 6/10/98
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module controls
14
15 %{
16 #include "helpers.h"
17 #include <wx/slider.h>
18 #include <wx/spinbutt.h>
19 #include <wx/dynarray.h>
20
21 #ifdef __WXMSW__
22 #if wxUSE_OWNER_DRAWN
23 #include <wx/checklst.h>
24 #endif
25 #endif
26
27 #ifdef __WXGTK__
28 #include <wx/checklst.h>
29 #endif
30 %}
31
32 //----------------------------------------------------------------------
33
34 %include typemaps.i
35 %include my_typemaps.i
36
37 // Import some definitions of other classes, etc.
38 %import _defs.i
39 %import misc.i
40 %import windows.i
41 %import gdi.i
42 %import events.i
43
44 %pragma(python) code = "import wx"
45
46 //----------------------------------------------------------------------
47
48 %{
49 wxValidator wxPyDefaultValidator; // Non-const default because of SWIG
50 %}
51
52 //----------------------------------------------------------------------
53
54 class wxControl : public wxWindow {
55 public:
56 void Command(wxCommandEvent& event);
57 wxString GetLabel();
58 void SetLabel(const wxString& label);
59 };
60
61 //----------------------------------------------------------------------
62
63 class wxButton : public wxControl {
64 public:
65 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
66 const wxPoint& pos = wxPyDefaultPosition,
67 const wxSize& size = wxPyDefaultSize,
68 long style = 0,
69 const wxValidator& validator = wxPyDefaultValidator,
70 char* name = "button");
71
72 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
73
74 void SetDefault();
75 };
76
77 //----------------------------------------------------------------------
78
79 class wxBitmapButton : public wxButton {
80 public:
81 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
82 const wxPoint& pos = wxPyDefaultPosition,
83 const wxSize& size = wxPyDefaultSize,
84 long style = wxBU_AUTODRAW,
85 const wxValidator& validator = wxPyDefaultValidator,
86 char* name = "button");
87
88 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
89
90 wxBitmap& GetBitmapLabel();
91 wxBitmap& GetBitmapDisabled();
92 wxBitmap& GetBitmapFocus();
93 wxBitmap& GetBitmapSelected();
94 void SetBitmapDisabled(const wxBitmap& bitmap);
95 void SetBitmapFocus(const wxBitmap& bitmap);
96 void SetBitmapSelected(const wxBitmap& bitmap);
97 void SetBitmapLabel(const wxBitmap& bitmap);
98
99 };
100
101 //----------------------------------------------------------------------
102
103 class wxCheckBox : public wxControl {
104 public:
105 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
106 const wxPoint& pos = wxPyDefaultPosition,
107 const wxSize& size = wxPyDefaultSize,
108 long style = 0,
109 const wxValidator& val = wxPyDefaultValidator,
110 char* name = "checkBox");
111
112 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
113
114 bool GetValue();
115 void SetValue(const bool state);
116 };
117
118 //----------------------------------------------------------------------
119
120 class wxChoice : public wxControl {
121 public:
122 wxChoice(wxWindow *parent, wxWindowID id,
123 const wxPoint& pos = wxPyDefaultPosition,
124 const wxSize& size = wxPyDefaultSize,
125 int LCOUNT=0, wxString* LIST=NULL,
126 long style = 0,
127 const wxValidator& validator = wxPyDefaultValidator,
128 char* name = "choice");
129
130 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
131
132 void Append(const wxString& item);
133 void Clear();
134 int FindString(const wxString& string);
135 int GetColumns();
136 int GetSelection();
137 wxString GetString(const int n);
138 wxString GetStringSelection();
139 int Number();
140 void SetColumns(const int n = 1);
141 void SetSelection(const int n);
142 void SetStringSelection(const wxString& string);
143 };
144
145 //----------------------------------------------------------------------
146
147 class wxComboBox : public wxControl {
148 public:
149 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
150 const wxPoint& pos = wxPyDefaultPosition,
151 const wxSize& size = wxPyDefaultSize,
152 int LCOUNT=0, wxString* LIST=NULL,
153 long style = 0,
154 const wxValidator& validator = wxPyDefaultValidator,
155 char* name = "comboBox");
156
157 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
158
159 void Append(const wxString& item);
160 // TODO: void Append(const wxString& item, char* clientData);
161 void Clear();
162 void Copy();
163 void Cut();
164 void Delete(int n);
165 // NotMember??: void Deselect(int n);
166 int FindString(const wxString& string);
167 // TODO: char* GetClientData(const int n);
168 long GetInsertionPoint();
169 long GetLastPosition();
170 int GetSelection();
171 wxString GetString(int n);
172 wxString GetStringSelection();
173 wxString GetValue();
174 int Number();
175 void Paste();
176 void Replace(long from, long to, const wxString& text);
177 void Remove(long from, long to);
178 // TODO: void SetClientData(const int n, char* data);
179 void SetInsertionPoint(long pos);
180 void SetInsertionPointEnd();
181 void SetSelection(int n, bool select = TRUE);
182 %name(SetMark)void SetSelection(long from, long to);
183 void SetValue(const wxString& text);
184 };
185
186 //----------------------------------------------------------------------
187
188 class wxGauge : public wxControl {
189 public:
190 wxGauge(wxWindow* parent, wxWindowID id, int range,
191 const wxPoint& pos = wxPyDefaultPosition,
192 const wxSize& size = wxPyDefaultSize,
193 long style = wxGA_HORIZONTAL,
194 const wxValidator& validator = wxPyDefaultValidator,
195 char* name = "gauge");
196
197 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
198
199 int GetBezelFace();
200 int GetRange();
201 int GetShadowWidth();
202 int GetValue();
203 void SetBezelFace(int width);
204 void SetRange(int range);
205 void SetShadowWidth(int width);
206 void SetValue(int pos);
207 };
208
209 //----------------------------------------------------------------------
210
211 class wxStaticBox : public wxControl {
212 public:
213 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
214 const wxPoint& pos = wxPyDefaultPosition,
215 const wxSize& size = wxPyDefaultSize,
216 long style = 0,
217 char* name = "staticBox");
218 };
219
220
221 //----------------------------------------------------------------------
222
223 class wxStaticText : public wxControl {
224 public:
225 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
226 const wxPoint& pos = wxPyDefaultPosition,
227 const wxSize& size = wxPyDefaultSize,
228 long style = 0,
229 char* name = "staticText");
230
231 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
232
233 wxString GetLabel();
234 void SetLabel(const wxString& label);
235 };
236
237 //----------------------------------------------------------------------
238
239 class wxListBox : public wxControl {
240 public:
241 wxListBox(wxWindow* parent, wxWindowID id,
242 const wxPoint& pos = wxPyDefaultPosition,
243 const wxSize& size = wxPyDefaultSize,
244 int LCOUNT, wxString* LIST = NULL,
245 long style = 0,
246 const wxValidator& validator = wxPyDefaultValidator,
247 char* name = "listBox");
248
249 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
250
251 void Append(const wxString& item);
252 // TODO: void Append(const wxString& item, char* clientData);
253 void Clear();
254 void Delete(int n);
255 void Deselect(int n);
256 int FindString(const wxString& string);
257 // TODO: char* GetClientData(const int n);
258 int GetSelection();
259
260 // int GetSelections(int **selections);
261 %addmethods {
262 PyObject* GetSelections() {
263 wxArrayInt lst;
264 self->GetSelections(lst);
265 PyObject *tup = PyTuple_New(lst.GetCount());
266 for(int i=0; i<lst.GetCount(); i++) {
267 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
268 }
269 return tup;
270 }
271 }
272
273 wxString GetString(int n);
274 wxString GetStringSelection();
275 int Number();
276 bool Selected(const int n);
277 void Set(int LCOUNT, wxString* LIST);
278 // TODO: void SetClientData(const int n, char* data);
279 void SetFirstItem(int n);
280 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
281 void SetSelection(int n, bool select = TRUE);
282 void SetString(int n, const wxString& string);
283 void SetStringSelection(const wxString& string, bool select = TRUE);
284 };
285
286
287 //----------------------------------------------------------------------
288
289 class wxCheckListBox : public wxListBox {
290 public:
291 wxCheckListBox(wxWindow *parent, wxWindowID id,
292 const wxPoint& pos = wxPyDefaultPosition,
293 const wxSize& size = wxPyDefaultSize,
294 int LCOUNT = 0,
295 wxString* LIST = NULL,
296 long style = 0,
297 const wxValidator& validator = wxPyDefaultValidator,
298 char* name = "listBox");
299
300 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
301
302 bool IsChecked(int uiIndex);
303 void Check(int uiIndex, bool bCheck = TRUE);
304
305 int GetItemHeight();
306 };
307
308 //----------------------------------------------------------------------
309
310 class wxTextCtrl : public wxControl {
311 public:
312 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
313 const wxPoint& pos = wxPyDefaultPosition,
314 const wxSize& size = wxPyDefaultSize,
315 long style = 0,
316 const wxValidator& validator = wxPyDefaultValidator,
317 char* name = "text");
318
319 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
320
321 void Clear();
322 void Copy();
323 void Cut();
324 void DiscardEdits();
325 long GetInsertionPoint();
326 long GetLastPosition();
327 int GetLineLength(long lineNo);
328 wxString GetLineText(long lineNo);
329 int GetNumberOfLines();
330 wxString GetValue();
331 bool IsModified();
332 bool LoadFile(const wxString& filename);
333 void Paste();
334 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
335 void Remove(long from, long to);
336 void Replace(long from, long to, const wxString& value);
337 bool SaveFile(const wxString& filename);
338 void SetEditable(bool editable);
339 void SetInsertionPoint(long pos);
340 void SetInsertionPointEnd();
341 void SetSelection(long from, long to);
342 void SetValue(const wxString& value);
343 void ShowPosition(long pos);
344 void WriteText(const wxString& text);
345 void AppendText(const wxString& text);
346 long XYToPosition(long x, long y);
347
348 bool CanCopy();
349 bool CanCut();
350 bool CanPaste();
351 bool CanRedo();
352 bool CanUndo();
353 void GetSelection(long* OUTPUT, long* OUTPUT);
354 bool IsEditable();
355 };
356
357 //----------------------------------------------------------------------
358
359 class wxScrollBar : public wxControl {
360 public:
361 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
362 const wxPoint& pos = wxPyDefaultPosition,
363 const wxSize& size = wxPyDefaultSize,
364 long style = wxSB_HORIZONTAL,
365 const wxValidator& validator = wxPyDefaultValidator,
366 char* name = "scrollBar");
367
368 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
369
370 int GetRange();
371 int GetPageSize();
372 int GetThumbPosition();
373 int GetThumbSize();
374 void SetThumbPosition(int viewStart);
375 void SetScrollbar(int position, int thumbSize,
376 int range, int pageSize,
377 bool refresh = TRUE);
378 };
379
380 //----------------------------------------------------------------------
381
382 class wxSpinButton : public wxControl {
383 public:
384 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
385 const wxPoint& pos = wxPyDefaultPosition,
386 const wxSize& size = wxPyDefaultSize,
387 long style = wxSP_HORIZONTAL,
388 char* name = "spinButton");
389
390 int GetMax();
391 int GetMin();
392 int GetValue();
393 void SetRange(int min, int max);
394 void SetValue(int value);
395 };
396
397 //----------------------------------------------------------------------
398
399 class wxStaticBitmap : public wxControl {
400 public:
401 wxStaticBitmap(wxWindow* parent, wxWindowID id,
402 const wxBitmap& bitmap,
403 const wxPoint& pos = wxPyDefaultPosition,
404 const wxSize& size = wxPyDefaultSize,
405 long style = 0,
406 char* name = "staticBitmap");
407
408 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
409
410 const wxBitmap& GetBitmap();
411 void SetBitmap(const wxBitmap& bitmap);
412 };
413
414 //----------------------------------------------------------------------
415
416 class wxRadioBox : public wxControl {
417 public:
418 wxRadioBox(wxWindow* parent, wxWindowID id,
419 const wxString& label,
420 const wxPoint& point = wxPyDefaultPosition,
421 const wxSize& size = wxPyDefaultSize,
422 int LCOUNT = 0, wxString* LIST = NULL,
423 int majorDimension = 0,
424 long style = wxRA_HORIZONTAL,
425 const wxValidator& validator = wxPyDefaultValidator,
426 char* name = "radioBox");
427
428 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
429
430 void Enable(bool enable);
431 %name(EnableItem)void Enable(int n, bool enable);
432 int FindString(const wxString& string);
433 #ifdef __WXMSW__
434 wxString GetLabel();
435 #endif
436 %name(GetItemLabel)wxString GetLabel(int n);
437 int GetSelection();
438 wxString GetString(int n);
439 wxString GetStringSelection();
440 int Number();
441 void SetLabel(const wxString& label);
442 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
443 void SetSelection(int n);
444 void SetStringSelection(const wxString& string);
445 void Show(bool show);
446 %name(ShowItem)void Show(int item, bool show);
447 };
448
449 //----------------------------------------------------------------------
450
451 class wxRadioButton : public wxControl {
452 public:
453 wxRadioButton(wxWindow* parent, wxWindowID id,
454 const wxString& label,
455 const wxPoint& pos = wxPyDefaultPosition,
456 const wxSize& size = wxPyDefaultSize,
457 long style = 0,
458 const wxValidator& validator = wxPyDefaultValidator,
459 char* name = "radioButton");
460
461 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
462
463 bool GetValue();
464 void SetValue(bool value);
465 };
466
467 //----------------------------------------------------------------------
468
469 class wxSlider : public wxControl {
470 public:
471 wxSlider(wxWindow* parent, wxWindowID id,
472 int value, int minValue, int maxValue,
473 const wxPoint& point = wxPyDefaultPosition,
474 const wxSize& size = wxPyDefaultSize,
475 long style = wxSL_HORIZONTAL,
476 const wxValidator& validator = wxPyDefaultValidator,
477 char* name = "slider");
478
479 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
480
481 void ClearSel();
482 void ClearTicks();
483 int GetLineSize();
484 int GetMax();
485 int GetMin();
486 int GetPageSize();
487 int GetSelEnd();
488 int GetSelStart();
489 int GetThumbLength();
490 int GetTickFreq();
491 int GetValue();
492 void SetRange(int minValue, int maxValue);
493 void SetTickFreq(int n, int pos);
494 void SetLineSize(int lineSize);
495 void SetPageSize(int pageSize);
496 void SetSelection(int startPos, int endPos);
497 void SetThumbLength(int len);
498 void SetTick(int tickPos);
499 void SetValue(int value);
500 };
501
502
503 //----------------------------------------------------------------------
504
505
506 /////////////////////////////////////////////////////////////////////////////
507 //
508 // $Log$
509 // Revision 1.13 1999/04/30 21:13:43 RD
510 // wxPython 2.0b9, first phase (win32)
511 // Added gobs of stuff, see wxPython/README.txt for details
512 //
513 // Revision 1.12 1999/04/30 03:29:18 RD
514 //
515 // wxPython 2.0b9, first phase (win32)
516 // Added gobs of stuff, see wxPython/README.txt for details
517 //
518 // Revision 1.11.4.1 1999/03/27 23:29:14 RD
519 //
520 // wxPython 2.0b8
521 // Python thread support
522 // various minor additions
523 // various minor fixes
524 //
525 // Revision 1.11 1999/02/25 07:08:30 RD
526 //
527 // wxPython version 2.0b5
528 //
529 // Revision 1.10 1998/12/17 17:52:19 RD
530 //
531 // wxPython 0.5.2
532 // Minor fixes and SWIG code generation for RR's changes. MSW and GTK
533 // versions are much closer now!
534 //
535 // Revision 1.9 1998/12/17 14:07:29 RR
536 //
537 // Removed minor differences between wxMSW and wxGTK
538 //
539 // Revision 1.8 1998/12/15 20:41:15 RD
540 // Changed the import semantics from "from wxPython import *" to "from
541 // wxPython.wx import *" This is for people who are worried about
542 // namespace pollution, they can use "from wxPython import wx" and then
543 // prefix all the wxPython identifiers with "wx."
544 //
545 // Added wxTaskbarIcon for wxMSW.
546 //
547 // Made the events work for wxGrid.
548 //
549 // Added wxConfig.
550 //
551 // Added wxMiniFrame for wxGTK, (untested.)
552 //
553 // Changed many of the args and return values that were pointers to gdi
554 // objects to references to reflect changes in the wxWindows API.
555 //
556 // Other assorted fixes and additions.
557 //
558 // Revision 1.7 1998/11/16 00:00:53 RD
559 // Generic treectrl for wxPython/GTK compiles...
560 //
561 // Revision 1.6 1998/11/15 23:03:43 RD
562 // Removing some ifdef's for wxGTK
563 //
564 // Revision 1.5 1998/10/07 07:34:32 RD
565 // Version 0.4.1 for wxGTK
566 //
567 // Revision 1.4 1998/10/02 06:40:35 RD
568 //
569 // Version 0.4 of wxPython for MSW.
570 //
571 // Revision 1.3 1998/08/18 19:48:14 RD
572 // more wxGTK compatibility things.
573 //
574 // It builds now but there are serious runtime problems...
575 //
576 // Revision 1.2 1998/08/15 07:36:28 RD
577 // - Moved the header in the .i files out of the code that gets put into
578 // the .cpp files. It caused CVS conflicts because of the RCS ID being
579 // different each time.
580 //
581 // - A few minor fixes.
582 //
583 // Revision 1.1 1998/08/09 08:25:49 RD
584 // Initial version
585 //
586 //
587