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