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