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