]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/controls.i
finally, wx/setup.h is not needed in the .spec
[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 int FindString(const wxString& string);
162 int GetColumns();
163 int GetSelection();
164 wxString GetString(const int n);
165 wxString GetStringSelection();
166 int Number();
167 void SetColumns(const int n = 1);
168 void SetSelection(const int n);
169 void SetStringSelection(const wxString& string);
170 };
171
172 //----------------------------------------------------------------------
173
174 class wxComboBox : public wxChoice {
175 public:
176 wxComboBox(wxWindow* parent, wxWindowID id, char* value = "",
177 const wxPoint& pos = wxDefaultPosition,
178 const wxSize& size = wxDefaultSize,
179 int LCOUNT=0, wxString* choices=NULL,
180 long style = 0,
181 const wxValidator& validator = wxDefaultValidator,
182 char* name = "comboBox");
183
184 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
185
186 void Append(const wxString& item);
187 // TODO: void Append(const wxString& item, char* clientData);
188 void Clear();
189 void Copy();
190 void Cut();
191 void Delete(int n);
192 // NotMember??: void Deselect(int n);
193 int FindString(const wxString& string);
194 // TODO: char* GetClientData(const int n);
195 long GetInsertionPoint();
196 long GetLastPosition();
197 int GetSelection();
198 wxString GetString(int n);
199 wxString GetStringSelection();
200 wxString GetValue();
201 int Number();
202 void Paste();
203 void Replace(long from, long to, const wxString& text);
204 void Remove(long from, long to);
205 // TODO: void SetClientData(const int n, char* data);
206 void SetInsertionPoint(long pos);
207 void SetInsertionPointEnd();
208 void SetSelection(int n);
209 %name(SetMark)void SetSelection(long from, long to);
210 void SetValue(const wxString& text);
211 };
212
213 //----------------------------------------------------------------------
214
215 class wxGauge : public wxControl {
216 public:
217 wxGauge(wxWindow* parent, wxWindowID id, int range,
218 const wxPoint& pos = wxDefaultPosition,
219 const wxSize& size = wxDefaultSize,
220 long style = wxGA_HORIZONTAL,
221 const wxValidator& validator = wxDefaultValidator,
222 char* name = "gauge");
223
224 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
225
226 int GetBezelFace();
227 int GetRange();
228 int GetShadowWidth();
229 int GetValue();
230 void SetBezelFace(int width);
231 void SetRange(int range);
232 void SetShadowWidth(int width);
233 void SetValue(int pos);
234 };
235
236 //----------------------------------------------------------------------
237
238 class wxStaticBox : public wxControl {
239 public:
240 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
241 const wxPoint& pos = wxDefaultPosition,
242 const wxSize& size = wxDefaultSize,
243 long style = 0,
244 char* name = "staticBox");
245 };
246
247
248 //----------------------------------------------------------------------
249
250
251 class wxStaticLine : public wxControl {
252 public:
253 wxStaticLine( wxWindow *parent, wxWindowID id,
254 const wxPoint &pos = wxDefaultPosition,
255 const wxSize &size = wxDefaultSize,
256 long style = wxLI_HORIZONTAL,
257 const char* name = "staticLine" );
258 };
259
260
261 //----------------------------------------------------------------------
262
263 class wxStaticText : public wxControl {
264 public:
265 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
266 const wxPoint& pos = wxDefaultPosition,
267 const wxSize& size = wxDefaultSize,
268 long style = 0,
269 char* name = "staticText");
270
271 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
272
273 wxString GetLabel();
274 void SetLabel(const wxString& label);
275 };
276
277 //----------------------------------------------------------------------
278
279 class wxListBox : public wxControl {
280 public:
281 wxListBox(wxWindow* parent, wxWindowID id,
282 const wxPoint& pos = wxDefaultPosition,
283 const wxSize& size = wxDefaultSize,
284 int LCOUNT, wxString* choices = NULL,
285 long style = 0,
286 const wxValidator& validator = wxDefaultValidator,
287 char* name = "listBox");
288
289 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
290
291 void Append(const wxString& item);
292 // TODO: void Append(const wxString& item, char* clientData);
293 void Clear();
294 void Delete(int n);
295 void Deselect(int n);
296 int FindString(const wxString& string);
297 // TODO: char* GetClientData(const int n);
298 int GetSelection();
299
300 // int GetSelections(int **selections);
301 %addmethods {
302 PyObject* GetSelections() {
303 wxArrayInt lst;
304 self->GetSelections(lst);
305 PyObject *tup = PyTuple_New(lst.GetCount());
306 for(size_t i=0; i<lst.GetCount(); i++) {
307 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
308 }
309 return tup;
310 }
311 }
312
313 void InsertItems(int LCOUNT, wxString* choices, int pos);
314
315 wxString GetString(int n);
316 wxString GetStringSelection();
317 int Number();
318 bool Selected(const int n);
319 void Set(int LCOUNT, wxString* choices);
320 // TODO: void SetClientData(const int n, char* data);
321 void SetFirstItem(int n);
322 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
323 void SetSelection(int n, bool select = TRUE);
324 void SetString(int n, const wxString& string);
325 void SetStringSelection(const wxString& string, bool select = TRUE);
326 };
327
328
329 //----------------------------------------------------------------------
330
331 class wxCheckListBox : public wxListBox {
332 public:
333 wxCheckListBox(wxWindow *parent, wxWindowID id,
334 const wxPoint& pos = wxDefaultPosition,
335 const wxSize& size = wxDefaultSize,
336 int LCOUNT = 0,
337 wxString* choices = NULL,
338 long style = 0,
339 const wxValidator& validator = wxDefaultValidator,
340 char* name = "listBox");
341
342 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
343
344 bool IsChecked(int uiIndex);
345 void Check(int uiIndex, int bCheck = TRUE);
346 void InsertItems(int LCOUNT, wxString* choices, int pos);
347
348 int GetItemHeight();
349 };
350
351 //----------------------------------------------------------------------
352
353
354 class wxTextAttr
355 {
356 public:
357 // ctors
358 wxTextAttr(const wxColour& colText = wxNullColour,
359 const wxColour& colBack = wxNullColour,
360 const wxFont& font = wxNullFont);
361 ~wxTextAttr();
362
363 // setters
364 void SetTextColour(const wxColour& colText);
365 void SetBackgroundColour(const wxColour& colBack);
366 void SetFont(const wxFont& font);
367
368 // accessors
369 bool HasTextColour() const;
370 bool HasBackgroundColour() const;
371 bool HasFont() const;
372
373 const wxColour& GetTextColour() const;
374 const wxColour& GetBackgroundColour() const;
375 const wxFont& GetFont() const;
376 };
377
378
379
380 class wxTextCtrl : public wxControl {
381 public:
382 wxTextCtrl(wxWindow* parent, wxWindowID id, char* value = "",
383 const wxPoint& pos = wxDefaultPosition,
384 const wxSize& size = wxDefaultSize,
385 long style = 0,
386 const wxValidator& validator = wxDefaultValidator,
387 char* name = "text");
388
389 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
390
391 void Clear();
392 void Copy();
393 void Cut();
394 void DiscardEdits();
395 long GetInsertionPoint();
396 long GetLastPosition();
397 int GetLineLength(long lineNo);
398 wxString GetLineText(long lineNo);
399 int GetNumberOfLines();
400 wxString GetValue();
401 bool IsModified();
402 bool LoadFile(const wxString& filename);
403 void Paste();
404 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT);
405 void Remove(long from, long to);
406 void Replace(long from, long to, const wxString& value);
407 bool SaveFile(const wxString& filename);
408 void SetEditable(bool editable);
409 void SetInsertionPoint(long pos);
410 void SetInsertionPointEnd();
411 void SetSelection(long from, long to);
412 void SetValue(const wxString& value);
413 void ShowPosition(long pos);
414 void WriteText(const wxString& text);
415 void AppendText(const wxString& text);
416 long XYToPosition(long x, long y);
417
418 bool CanCopy();
419 bool CanCut();
420 bool CanPaste();
421 bool CanRedo();
422 bool CanUndo();
423 void GetSelection(long* OUTPUT, long* OUTPUT);
424 bool IsEditable();
425 void Undo();
426 void Redo();
427
428 bool SetStyle(long start, long end, const wxTextAttr& style);
429 bool SetDefaultStyle(const wxTextAttr& style);
430 const wxTextAttr& GetDefaultStyle() const;
431
432 %addmethods {
433 void write(const wxString& text) {
434 self->AppendText(text);
435 }
436 }
437 };
438
439 //----------------------------------------------------------------------
440
441 class wxScrollBar : public wxControl {
442 public:
443 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
444 const wxPoint& pos = wxDefaultPosition,
445 const wxSize& size = wxDefaultSize,
446 long style = wxSB_HORIZONTAL,
447 const wxValidator& validator = wxDefaultValidator,
448 char* name = "scrollBar");
449
450 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
451
452 int GetRange();
453 int GetPageSize();
454 int GetThumbPosition();
455 int GetThumbSize();
456 %name(GetThumbLength) int GetThumbSize(); // to match the docs
457 void SetThumbPosition(int viewStart);
458 void SetScrollbar(int position, int thumbSize,
459 int range, int pageSize,
460 bool refresh = TRUE);
461 };
462
463 //----------------------------------------------------------------------
464
465 class wxSpinButton : public wxControl {
466 public:
467 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
468 const wxPoint& pos = wxDefaultPosition,
469 const wxSize& size = wxDefaultSize,
470 long style = wxSP_HORIZONTAL,
471 char* name = "spinButton");
472
473 int GetMax();
474 int GetMin();
475 int GetValue();
476 void SetRange(int min, int max);
477 void SetValue(int value);
478 };
479
480 //----------------------------------------------------------------------
481
482 class wxStaticBitmap : public wxControl {
483 public:
484 wxStaticBitmap(wxWindow* parent, wxWindowID id,
485 const wxBitmap& bitmap,
486 const wxPoint& pos = wxDefaultPosition,
487 const wxSize& size = wxDefaultSize,
488 long style = 0,
489 char* name = "staticBitmap");
490
491 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
492
493 const wxBitmap& GetBitmap();
494 void SetBitmap(const wxBitmap& bitmap);
495 void SetIcon(const wxIcon& icon);
496 };
497
498 //----------------------------------------------------------------------
499
500 class wxRadioBox : public wxControl {
501 public:
502 wxRadioBox(wxWindow* parent, wxWindowID id,
503 const wxString& label,
504 const wxPoint& point = wxDefaultPosition,
505 const wxSize& size = wxDefaultSize,
506 int LCOUNT = 0, wxString* choices = NULL,
507 int majorDimension = 0,
508 long style = wxRA_HORIZONTAL,
509 const wxValidator& validator = wxDefaultValidator,
510 char* name = "radioBox");
511
512 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
513
514 void Enable(bool enable);
515 %name(EnableItem)void Enable(int n, bool enable);
516 int FindString(const wxString& string);
517
518 //*** wxString GetLabel();
519 //*** void SetLabel(const wxString& label);
520
521 %name(GetItemLabel)wxString GetLabel(int n);
522 int GetSelection();
523 wxString GetString(int n);
524 wxString GetStringSelection();
525 int Number();
526 %name(SetItemLabel)void SetLabel(int n, const wxString& label);
527 void SetSelection(int n);
528 void SetStringSelection(const wxString& string);
529 void Show(bool show);
530 %name(ShowItem)void Show(int item, bool show);
531 };
532
533 //----------------------------------------------------------------------
534
535 class wxRadioButton : public wxControl {
536 public:
537 wxRadioButton(wxWindow* parent, wxWindowID id,
538 const wxString& label,
539 const wxPoint& pos = wxDefaultPosition,
540 const wxSize& size = wxDefaultSize,
541 long style = 0,
542 const wxValidator& validator = wxDefaultValidator,
543 char* name = "radioButton");
544
545 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
546
547 bool GetValue();
548 void SetValue(bool value);
549 };
550
551 //----------------------------------------------------------------------
552
553 class wxSlider : public wxControl {
554 public:
555 wxSlider(wxWindow* parent, wxWindowID id,
556 int value, int minValue, int maxValue,
557 const wxPoint& point = wxDefaultPosition,
558 const wxSize& size = wxDefaultSize,
559 long style = wxSL_HORIZONTAL,
560 const wxValidator& validator = wxDefaultValidator,
561 char* name = "slider");
562
563 %pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
564
565 void ClearSel();
566 void ClearTicks();
567 int GetLineSize();
568 int GetMax();
569 int GetMin();
570 int GetPageSize();
571 int GetSelEnd();
572 int GetSelStart();
573 int GetThumbLength();
574 int GetTickFreq();
575 int GetValue();
576 void SetRange(int minValue, int maxValue);
577 void SetTickFreq(int n, int pos);
578 void SetLineSize(int lineSize);
579 void SetPageSize(int pageSize);
580 void SetSelection(int startPos, int endPos);
581 void SetThumbLength(int len);
582 void SetTick(int tickPos);
583 void SetValue(int value);
584 };
585
586
587 //----------------------------------------------------------------------
588
589 class wxSpinCtrl : public wxSpinButton {
590 public:
591 wxSpinCtrl(wxWindow *parent,
592 wxWindowID id = -1,
593 const char* value = "",
594 const wxPoint& pos = wxDefaultPosition,
595 const wxSize& size = wxDefaultSize,
596 long style = wxSP_ARROW_KEYS,
597 int min = 0, int max = 100, int initial = 0,
598 const char* name = "wxSpinCtrl");
599
600
601 int GetMax();
602 int GetMin();
603 int GetValue();
604 void SetRange(int min, int max);
605 void SetValue(int value);
606
607 };
608
609
610 //----------------------------------------------------------------------
611
612 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
613
614 class wxToggleButton : public wxControl {
615 public:
616 wxToggleButton(wxWindow *parent,
617 wxWindowID id,
618 const wxString& label,
619 const wxPoint& pos = wxDefaultPosition,
620 const wxSize& size = wxDefaultSize,
621 long style = 0,
622 const wxValidator& validator = wxDefaultValidator,
623 const char* name = "toggle");
624
625 void SetValue(bool value);
626 bool GetValue() const ;
627 void SetLabel(const wxString& label);
628
629 };
630
631 //----------------------------------------------------------------------
632 //----------------------------------------------------------------------
633 //----------------------------------------------------------------------
634
635
636