]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/controls.i
Make scrollbars appear.
[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 %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 %readonly
52 wxValidator wxDefaultValidator;
53 %readwrite
54
55 //----------------------------------------------------------------------
56
57 %{
58 //#define DECLARE_DEF_STRING(name) static wxString* wxPy##name
59
60 // Put some wx default wxChar* values into wxStrings.
61 DECLARE_DEF_STRING(ControlNameStr);
62 DECLARE_DEF_STRING(ButtonNameStr);
63 DECLARE_DEF_STRING(CheckBoxNameStr);
64 DECLARE_DEF_STRING(ChoiceNameStr);
65 DECLARE_DEF_STRING(ComboBoxNameStr);
66 DECLARE_DEF_STRING(GaugeNameStr);
67 DECLARE_DEF_STRING(StaticBoxNameStr);
68 DECLARE_DEF_STRING(StaticTextNameStr);
69 DECLARE_DEF_STRING(ListBoxNameStr);
70 DECLARE_DEF_STRING(TextCtrlNameStr);
71 DECLARE_DEF_STRING(ScrollBarNameStr);
72 DECLARE_DEF_STRING(SPIN_BUTTON_NAME);
73 DECLARE_DEF_STRING(StaticBitmapNameStr);
74 DECLARE_DEF_STRING(RadioBoxNameStr);
75 DECLARE_DEF_STRING(RadioButtonNameStr);
76 DECLARE_DEF_STRING(SliderNameStr);
77
78 wxChar* wxSpinCtrlNameStr = _T("wxSpinCtrl");
79 DECLARE_DEF_STRING(SpinCtrlNameStr);
80
81 static const wxString wxPyEmptyString(wxT(""));
82 %}
83
84 //----------------------------------------------------------------------
85
86 // This is the base class for a control or 'widget'.
87 //
88 // A control is generally a small window which processes user input and/or
89 // displays one or more item of data.
90 class wxControl : public wxWindow {
91 public:
92
93 //
94 wxControl(wxWindow *parent,
95 wxWindowID id,
96 const wxPoint& pos=wxDefaultPosition,
97 const wxSize& size=wxDefaultSize,
98 long style=0,
99 const wxValidator& validator=wxDefaultValidator,
100 const wxString& name=wxPyControlNameStr);
101
102 //
103 %name(wxPreControl)wxControl();
104
105 //
106 bool Create(wxWindow *parent,
107 wxWindowID id,
108 const wxPoint& pos=wxDefaultPosition,
109 const wxSize& size=wxDefaultSize,
110 long style=0,
111 const wxValidator& validator=wxDefaultValidator,
112 const wxString& name=wxPyControlNameStr);
113
114 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
115 %pragma(python) addtomethod = "wxPreControl:val._setOORInfo(val)"
116
117 // Simulates the effect of the user issuing a command to the item. See
118 // wxCommandEvent.
119 void Command(wxCommandEvent& event);
120
121 // Return a control's text.
122 wxString GetLabel();
123
124 // Sets the item's text.
125 void SetLabel(const wxString& label);
126 };
127
128
129 //----------------------------------------------------------------------
130
131
132 class wxControlWithItems : public wxControl {
133 public:
134
135 // void Clear(); ambiguous, redefine below...
136
137 // Deletes an item from the control
138 void Delete(int n);
139
140 // Returns the number of items in the control.
141 int GetCount();
142 %pragma(python) addtoclass = "Number = GetCount"
143
144 // Returns the string at the given position.
145 wxString GetString(int n);
146
147 // Sets the string value of an item.
148 void SetString(int n, const wxString& s);
149
150 // Finds an item matching the given string. Returns the zero-based
151 // position of the item, or -1 if the string was not found.
152 int FindString(const wxString& s);
153
154 // Select the item at postion n.
155 void Select(int n);
156
157 // Gets the position of the selected item.
158 int GetSelection();
159
160 // Gets the current selection as a string.
161 wxString GetStringSelection() const;
162
163 // void Append(const wxString& item);
164 // void Append(const wxString& item, char* clientData);
165 // char* GetClientData(const int n);
166 // void SetClientData(const int n, char* data);
167
168
169 %addmethods {
170 // Adds the item to the control, associating the given data with the
171 // item if not None.
172 void Append(const wxString& item, PyObject* clientData=NULL) {
173 if (clientData) {
174 wxPyClientData* data = new wxPyClientData(clientData);
175 self->Append(item, data);
176 } else
177 self->Append(item);
178 }
179
180 // Returns the client data associated with the given item, (if any.)
181 PyObject* GetClientData(int n) {
182 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
183 if (data) {
184 Py_INCREF(data->m_obj);
185 return data->m_obj;
186 } else {
187 Py_INCREF(Py_None);
188 return Py_None;
189 }
190 }
191
192 // Associate the given client data with the item at position n.
193 void SetClientData(int n, PyObject* clientData) {
194 wxPyClientData* data = new wxPyClientData(clientData);
195 self->SetClientObject(n, data);
196 }
197 }
198
199 // append several items at once to the control
200 %name(AppendItems)void Append(const wxArrayString& strings);
201
202 };
203
204 //----------------------------------------------------------------------
205
206 // A button is a control that contains a text string, and is one of the most
207 // common elements of a GUI. It may be placed on a dialog box or panel, or
208 // indeed almost any other window.
209 //
210 // Styles
211 // wxBU_LEFT: Left-justifies the label. WIN32 only.
212 // wxBU_TOP: Aligns the label to the top of the button. WIN32 only.
213 // wxBU_RIGHT: Right-justifies the bitmap label. WIN32 only.
214 // wxBU_BOTTOM: Aligns the label to the bottom of the button. WIN32 only.
215 // wxBU_EXACTFIT: Creates the button as small as possible instead of making
216 // it of the standard size (which is the default behaviour.)
217 //
218 // Events
219 // EVT_BUTTON(win,id,func):
220 // Sent when the button is clicked.
221 //
222 class wxButton : public wxControl {
223 public:
224 // Constructor, creating and showing a button.
225 //
226 // parent: Parent window. Must not be None.
227 // id: Button identifier. A value of -1 indicates a default value.
228 // label: The text to be displayed on the button.
229 // pos: The button position on it's parent.
230 // size: Button size. If the default size (-1, -1) is specified then the
231 // button is sized appropriately for the text.
232 // style: Window style. See wxButton.
233 // validator: Window validator.
234 // name: Window name.
235 wxButton(wxWindow* parent, wxWindowID id, const wxString& label,
236 const wxPoint& pos = wxDefaultPosition,
237 const wxSize& size = wxDefaultSize,
238 long style = 0,
239 const wxValidator& validator = wxDefaultValidator,
240 const wxString& name = wxPyButtonNameStr);
241
242 // Default constructor
243 %name(wxPreButton)wxButton();
244
245 // Button creation function for two-step creation.
246 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
247 const wxPoint& pos = wxDefaultPosition,
248 const wxSize& size = wxDefaultSize,
249 long style = 0,
250 const wxValidator& validator = wxDefaultValidator,
251 const wxString& name = wxPyButtonNameStr);
252
253 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
254 %pragma(python) addtomethod = "wxPreButton:val._setOORInfo(val)"
255
256 // This sets the button to be the default item for the panel or dialog box.
257 //
258 // Under Windows, only dialog box buttons respond to this function. As
259 // normal under Windows and Motif, pressing return causes the default
260 // button to be depressed when the return key is pressed. See also
261 // wxWindow.SetFocus which sets the keyboard focus for windows and text
262 // panel items, and wxPanel.SetDefaultItem.
263 void SetDefault();
264
265 //
266 void SetBackgroundColour(const wxColour& colour);
267 //
268 void SetForegroundColour(const wxColour& colour);
269
270 #ifdef __WXMSW__
271 // show the image in the button in addition to the label
272 void SetImageLabel(const wxBitmap& bitmap);
273
274 // set the margins around the image
275 void SetImageMargins(wxCoord x, wxCoord y);
276 #endif
277
278 // returns the default button size for this platform
279 static wxSize GetDefaultSize();
280 };
281
282 //----------------------------------------------------------------------
283
284 class wxBitmapButton : public wxButton {
285 public:
286 wxBitmapButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
287 const wxPoint& pos = wxDefaultPosition,
288 const wxSize& size = wxDefaultSize,
289 long style = wxBU_AUTODRAW,
290 const wxValidator& validator = wxDefaultValidator,
291 const wxString& name = wxPyButtonNameStr);
292 %name(wxPreBitmapButton)wxBitmapButton();
293
294 bool Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap,
295 const wxPoint& pos = wxDefaultPosition,
296 const wxSize& size = wxDefaultSize,
297 long style = wxBU_AUTODRAW,
298 const wxValidator& validator = wxDefaultValidator,
299 const wxString& name = wxPyButtonNameStr);
300
301 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
302 %pragma(python) addtomethod = "wxPreBitmapButton:val._setOORInfo(val)"
303
304 wxBitmap GetBitmapLabel();
305 wxBitmap GetBitmapDisabled();
306 wxBitmap GetBitmapFocus();
307 wxBitmap GetBitmapSelected();
308 void SetBitmapDisabled(const wxBitmap& bitmap);
309 void SetBitmapFocus(const wxBitmap& bitmap);
310 void SetBitmapSelected(const wxBitmap& bitmap);
311 void SetBitmapLabel(const wxBitmap& bitmap);
312
313 void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
314 int GetMarginX() const { return m_marginX; }
315 int GetMarginY() const { return m_marginY; }
316 };
317
318 //----------------------------------------------------------------------
319
320 class wxCheckBox : public wxControl {
321 public:
322 wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label,
323 const wxPoint& pos = wxDefaultPosition,
324 const wxSize& size = wxDefaultSize,
325 long style = 0,
326 const wxValidator& val = wxDefaultValidator,
327 const wxString& name = wxPyCheckBoxNameStr);
328 %name(wxPreCheckBox)wxCheckBox();
329
330 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
331 const wxPoint& pos = wxDefaultPosition,
332 const wxSize& size = wxDefaultSize,
333 long style = 0,
334 const wxValidator& val = wxDefaultValidator,
335 const wxString& name = wxPyCheckBoxNameStr);
336
337 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
338 %pragma(python) addtomethod = "wxPreCheckBox:val._setOORInfo(val)"
339
340 bool GetValue();
341 void SetValue(const bool state);
342 };
343
344 //----------------------------------------------------------------------
345
346 class wxChoice : public wxControlWithItems {
347 public:
348 wxChoice(wxWindow *parent, wxWindowID id,
349 const wxPoint& pos = wxDefaultPosition,
350 const wxSize& size = wxDefaultSize,
351 int LCOUNT=0, wxString* choices=NULL,
352 long style = 0,
353 const wxValidator& validator = wxDefaultValidator,
354 const wxString& name = wxPyChoiceNameStr);
355 %name(wxPreChoice)wxChoice();
356
357 bool Create(wxWindow *parent, wxWindowID id,
358 const wxPoint& pos = wxDefaultPosition,
359 const wxSize& size = wxDefaultSize,
360 int LCOUNT=0, wxString* choices=NULL,
361 long style = 0,
362 const wxValidator& validator = wxDefaultValidator,
363 const wxString& name = wxPyChoiceNameStr);
364
365 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
366 %pragma(python) addtomethod = "wxPreChoice:val._setOORInfo(val)"
367
368 void Clear();
369
370 int GetColumns();
371 void SetColumns(const int n = 1);
372 void SetSelection(const int n);
373 void SetStringSelection(const wxString& string);
374 void SetString(int n, const wxString& s);
375
376 %pragma(python) addtoclass = "
377 Select = SetSelection
378 "
379 };
380
381 //----------------------------------------------------------------------
382
383 // wxGTK's wxComboBox doesn't derive from wxChoice like wxMSW, or
384 // even wxControlWithItems, so we have to duplicate the methods
385 // here... <blech!>
386
387 #ifdef __WXGTK__
388 class wxComboBox : public wxControl
389 {
390 public:
391 wxComboBox(wxWindow* parent, wxWindowID id,
392 const wxString& value = wxPyEmptyString,
393 const wxPoint& pos = wxDefaultPosition,
394 const wxSize& size = wxDefaultSize,
395 int LCOUNT=0, wxString* choices=NULL,
396 long style = 0,
397 const wxValidator& validator = wxDefaultValidator,
398 const wxString& name = wxPyComboBoxNameStr);
399 %name(wxPreComboBox)wxComboBox();
400
401 bool Create(wxWindow* parent, wxWindowID id,
402 const wxString& value = wxPyEmptyString,
403 const wxPoint& pos = wxDefaultPosition,
404 const wxSize& size = wxDefaultSize,
405 int LCOUNT=0, wxString* choices=NULL,
406 long style = 0,
407 const wxValidator& validator = wxDefaultValidator,
408 const wxString& name = wxPyComboBoxNameStr);
409
410 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
411 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
412
413 void Copy();
414 void Cut();
415 long GetInsertionPoint();
416 long GetLastPosition();
417 wxString GetValue();
418 void Paste();
419 void Replace(long from, long to, const wxString& text);
420 void Remove(long from, long to);
421 void SetInsertionPoint(long pos);
422 void SetInsertionPointEnd();
423 void SetSelection(int n);
424 %name(SetMark)void SetSelection(long from, long to);
425 void SetValue(const wxString& text);
426 void SetEditable(bool editable);
427
428
429 void Clear();
430 void Delete(int n);
431
432 int GetCount();
433 %pragma(python) addtoclass = "Number = GetCount"
434 wxString GetString(int n);
435 int FindString(const wxString& s);
436
437 //void SetString(int n, const wxString& s); *** No equivalent for wxGTK!!!
438
439 // void Select(int n);
440 %pragma(python) addtoclass = "Select = SetSelection"
441
442 int GetSelection();
443 wxString GetStringSelection() const;
444
445 // void Append(const wxString& item);
446 // void Append(const wxString& item, char* clientData);
447 // char* GetClientData(const int n);
448 // void SetClientData(const int n, char* data);
449 %addmethods {
450 void Append(const wxString& item, PyObject* clientData=NULL) {
451 if (clientData) {
452 wxPyClientData* data = new wxPyClientData(clientData);
453 self->Append(item, data);
454 } else
455 self->Append(item);
456 }
457
458 PyObject* GetClientData(int n) {
459 wxPyClientData* data = (wxPyClientData*)self->GetClientObject(n);
460 if (data) {
461 Py_INCREF(data->m_obj);
462 return data->m_obj;
463 } else {
464 Py_INCREF(Py_None);
465 return Py_None;
466 }
467 }
468
469 void SetClientData(int n, PyObject* clientData) {
470 wxPyClientData* data = new wxPyClientData(clientData);
471 self->SetClientObject(n, data);
472 }
473 }
474
475 };
476
477
478
479 #else // For all but wxGTK
480
481
482 class wxComboBox : public wxChoice {
483 public:
484 wxComboBox(wxWindow* parent, wxWindowID id,
485 const wxString& value = wxPyEmptyString,
486 const wxPoint& pos = wxDefaultPosition,
487 const wxSize& size = wxDefaultSize,
488 int LCOUNT=0, wxString* choices=NULL,
489 long style = 0,
490 const wxValidator& validator = wxDefaultValidator,
491 const wxString& name = wxPyComboBoxNameStr);
492 %name(wxPreComboBox)wxComboBox();
493
494 bool Create(wxWindow* parent, wxWindowID id,
495 const wxString& value = wxPyEmptyString,
496 const wxPoint& pos = wxDefaultPosition,
497 const wxSize& size = wxDefaultSize,
498 int LCOUNT=0, wxString* choices=NULL,
499 long style = 0,
500 const wxValidator& validator = wxDefaultValidator,
501 const wxString& name = wxPyComboBoxNameStr);
502
503 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
504 %pragma(python) addtomethod = "wxPreComboBox:val._setOORInfo(val)"
505
506 void Copy();
507 void Cut();
508 long GetInsertionPoint();
509 long GetLastPosition();
510 wxString GetValue();
511 void Paste();
512 void Replace(long from, long to, const wxString& text);
513 void Remove(long from, long to);
514 void SetInsertionPoint(long pos);
515 void SetInsertionPointEnd();
516 void SetSelection(int n);
517 %name(SetMark)void SetSelection(long from, long to);
518 void SetValue(const wxString& text);
519 void SetEditable(bool editable);
520 };
521 #endif
522
523
524 //----------------------------------------------------------------------
525
526 class wxGauge : public wxControl {
527 public:
528 wxGauge(wxWindow* parent, wxWindowID id, int range,
529 const wxPoint& pos = wxDefaultPosition,
530 const wxSize& size = wxDefaultSize,
531 long style = wxGA_HORIZONTAL,
532 const wxValidator& validator = wxDefaultValidator,
533 const wxString& name = wxPyGaugeNameStr);
534 %name(wxPreGauge)wxGauge();
535
536 bool Create(wxWindow* parent, wxWindowID id, int range,
537 const wxPoint& pos = wxDefaultPosition,
538 const wxSize& size = wxDefaultSize,
539 long style = wxGA_HORIZONTAL,
540 const wxValidator& validator = wxDefaultValidator,
541 const wxString& name = wxPyGaugeNameStr);
542
543 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
544 %pragma(python) addtomethod = "wxPreGauge:val._setOORInfo(val)"
545
546 int GetBezelFace();
547 int GetRange();
548 int GetShadowWidth();
549 int GetValue();
550 void SetBezelFace(int width);
551 void SetRange(int range);
552 void SetShadowWidth(int width);
553 void SetValue(int pos);
554 };
555
556 //----------------------------------------------------------------------
557
558 class wxStaticBox : public wxControl {
559 public:
560 wxStaticBox(wxWindow* parent, wxWindowID id, const wxString& label,
561 const wxPoint& pos = wxDefaultPosition,
562 const wxSize& size = wxDefaultSize,
563 long style = 0,
564 const wxString& name = wxPyStaticBoxNameStr);
565 %name(wxPreStaticBox)wxStaticBox();
566
567 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
568 const wxPoint& pos = wxDefaultPosition,
569 const wxSize& size = wxDefaultSize,
570 long style = 0,
571 const wxString& name = wxPyStaticBoxNameStr);
572
573 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
574 %pragma(python) addtomethod = "wxPreStaticBox:val._setOORInfo(val)"
575 };
576
577
578 //----------------------------------------------------------------------
579
580
581 class wxStaticLine : public wxControl {
582 public:
583 wxStaticLine( wxWindow *parent, wxWindowID id,
584 const wxPoint &pos = wxDefaultPosition,
585 const wxSize &size = wxDefaultSize,
586 long style = wxLI_HORIZONTAL,
587 const wxString& name = wxPyStaticTextNameStr);
588 %name(wxPreStaticLine)wxStaticLine();
589
590 bool Create( wxWindow *parent, wxWindowID id,
591 const wxPoint &pos = wxDefaultPosition,
592 const wxSize &size = wxDefaultSize,
593 long style = wxLI_HORIZONTAL,
594 const wxString& name = wxPyStaticTextNameStr);
595
596 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
597 %pragma(python) addtomethod = "wxPreStaticLine:val._setOORInfo(val)"
598 };
599
600
601 //----------------------------------------------------------------------
602
603 class wxStaticText : public wxControl {
604 public:
605 wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label,
606 const wxPoint& pos = wxDefaultPosition,
607 const wxSize& size = wxDefaultSize,
608 long style = 0,
609 const wxString& name = wxPyStaticTextNameStr);
610 %name(wxPreStaticText)wxStaticText();
611
612 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
613 const wxPoint& pos = wxDefaultPosition,
614 const wxSize& size = wxDefaultSize,
615 long style = 0,
616 const wxString& name = wxPyStaticTextNameStr);
617
618 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
619 %pragma(python) addtomethod = "wxPreStaticText:val._setOORInfo(val)"
620
621 wxString GetLabel();
622 void SetLabel(const wxString& label);
623 };
624
625 //----------------------------------------------------------------------
626
627 class wxListBox : public wxControlWithItems {
628 public:
629 wxListBox(wxWindow* parent, wxWindowID id,
630 const wxPoint& pos = wxDefaultPosition,
631 const wxSize& size = wxDefaultSize,
632 int LCOUNT, wxString* choices = NULL,
633 long style = 0,
634 const wxValidator& validator = wxDefaultValidator,
635 const wxString& name = wxPyListBoxNameStr);
636 %name(wxPreListBox)wxListBox();
637
638 bool Create(wxWindow* parent, wxWindowID id,
639 const wxPoint& pos = wxDefaultPosition,
640 const wxSize& size = wxDefaultSize,
641 int LCOUNT, wxString* choices = NULL,
642 long style = 0,
643 const wxValidator& validator = wxDefaultValidator,
644 const wxString& name = wxPyListBoxNameStr);
645
646 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
647 %pragma(python) addtomethod = "wxPreListBox:val._setOORInfo(val)"
648
649 void Clear();
650 void Deselect(int n);
651
652 // int GetSelections(int **selections);
653 %addmethods {
654 PyObject* GetSelections() {
655 wxArrayInt lst;
656 self->GetSelections(lst);
657 PyObject *tup = PyTuple_New(lst.GetCount());
658 for(size_t i=0; i<lst.GetCount(); i++) {
659 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
660 }
661 return tup;
662 }
663 }
664
665
666 void InsertItems(int LCOUNT, wxString* choices, int pos);
667
668 bool IsSelected(const int n);
669 bool Selected(const int n);
670 void Set(int LCOUNT, wxString* choices);
671 void SetFirstItem(int n);
672 %name(SetFirstItemStr)void SetFirstItem(const wxString& string);
673 void SetSelection(int n, bool select = TRUE);
674 void SetString(int n, const wxString& string);
675 void SetStringSelection(const wxString& string, bool select = TRUE);
676 };
677
678
679 //----------------------------------------------------------------------
680
681 class wxCheckListBox : public wxListBox {
682 public:
683 wxCheckListBox(wxWindow *parent, wxWindowID id,
684 const wxPoint& pos = wxDefaultPosition,
685 const wxSize& size = wxDefaultSize,
686 int LCOUNT = 0,
687 wxString* choices = NULL,
688 long style = 0,
689 const wxValidator& validator = wxDefaultValidator,
690 const wxString& name = wxPyListBoxNameStr);
691 %name(wxPreCheckListBox)wxCheckListBox();
692
693 bool Create(wxWindow *parent, wxWindowID id,
694 const wxPoint& pos = wxDefaultPosition,
695 const wxSize& size = wxDefaultSize,
696 int LCOUNT = 0,
697 wxString* choices = NULL,
698 long style = 0,
699 const wxValidator& validator = wxDefaultValidator,
700 const wxString& name = wxPyListBoxNameStr);
701
702 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
703 %pragma(python) addtomethod = "wxPreCheckListBox:val._setOORInfo(val)"
704
705 bool IsChecked(int uiIndex);
706 void Check(int uiIndex, int bCheck = TRUE);
707 void InsertItems(int LCOUNT, wxString* choices, int pos);
708
709 #ifndef __WXMAC__
710 int GetItemHeight();
711 #endif
712 };
713
714 //----------------------------------------------------------------------
715
716
717 class wxTextAttr
718 {
719 public:
720 // ctors
721 wxTextAttr(const wxColour& colText = wxNullColour,
722 const wxColour& colBack = wxNullColour,
723 const wxFont& font = wxNullFont);
724 ~wxTextAttr();
725
726 // setters
727 void SetTextColour(const wxColour& colText);
728 void SetBackgroundColour(const wxColour& colBack);
729 void SetFont(const wxFont& font);
730
731 // accessors
732 bool HasTextColour() const;
733 bool HasBackgroundColour() const;
734 bool HasFont() const;
735
736 wxColour GetTextColour() const;
737 wxColour GetBackgroundColour() const;
738 wxFont GetFont() const;
739
740 // returns false if we have any attributes set, true otherwise
741 bool IsDefault();
742
743 // return the attribute having the valid font and colours: it uses the
744 // attributes set in attr and falls back first to attrDefault and then to
745 // the text control font/colours for those attributes which are not set
746 static wxTextAttr Combine(const wxTextAttr& attr,
747 const wxTextAttr& attrDef,
748 const wxTextCtrl *text);
749 };
750
751
752
753 class wxTextCtrl : public wxControl {
754 public:
755 wxTextCtrl(wxWindow* parent, wxWindowID id,
756 const wxString& value = wxPyEmptyString,
757 const wxPoint& pos = wxDefaultPosition,
758 const wxSize& size = wxDefaultSize,
759 long style = 0,
760 const wxValidator& validator = wxDefaultValidator,
761 const wxString& name = wxPyTextCtrlNameStr);
762 %name(wxPreTextCtrl)wxTextCtrl();
763
764 bool Create(wxWindow* parent, wxWindowID id,
765 const wxString& value = wxPyEmptyString,
766 const wxPoint& pos = wxDefaultPosition,
767 const wxSize& size = wxDefaultSize,
768 long style = 0,
769 const wxValidator& validator = wxDefaultValidator,
770 const wxString& name = wxPyTextCtrlNameStr);
771
772 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
773 %pragma(python) addtomethod = "wxPreTextCtrl:val._setOORInfo(val)"
774
775
776 wxString GetValue() const;
777 void SetValue(const wxString& value);
778
779 wxString GetRange(long from, long to);
780
781 int GetLineLength(long lineNo) const;
782 wxString GetLineText(long lineNo) const;
783 int GetNumberOfLines() const;
784
785 bool IsModified() const;
786 bool IsEditable() const;
787
788 // If the return values from and to are the same, there is no selection.
789 void GetSelection(long* OUTPUT, long* OUTPUT) const;
790 wxString GetStringSelection();
791
792 void Clear();
793 void Replace(long from, long to, const wxString& value);
794 void Remove(long from, long to);
795
796 // load/save the controls contents from/to the file
797 bool LoadFile(const wxString& file);
798 bool SaveFile(const wxString& file = wxPyEmptyString);
799
800 // clears the dirty flag
801 void DiscardEdits();
802
803 // set the max number of characters which may be entered in a single line
804 // text control
805 void SetMaxLength(unsigned long len);
806
807 // writing text inserts it at the current position, appending always
808 // inserts it at the end
809 void WriteText(const wxString& text);
810 void AppendText(const wxString& text);
811
812 // text control under some platforms supports the text styles: these
813 // methods allow to apply the given text style to the given selection or to
814 // set/get the style which will be used for all appended text
815 bool SetStyle(long start, long end, const wxTextAttr& style);
816 bool SetDefaultStyle(const wxTextAttr& style);
817 const wxTextAttr& GetDefaultStyle() const;
818
819 // translate between the position (which is just an index in the text ctrl
820 // considering all its contents as a single strings) and (x, y) coordinates
821 // which represent column and line.
822 long XYToPosition(long x, long y) const;
823 void PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
824
825 //bool PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const;
826 // TODO: check return value, raise exception.
827
828 void ShowPosition(long pos);
829
830 // Clipboard operations
831 void Copy();
832 void Cut();
833 void Paste();
834
835 bool CanCopy() const;
836 bool CanCut() const;
837 bool CanPaste() const;
838
839 // Undo/redo
840 void Undo();
841 void Redo();
842
843 bool CanUndo() const;
844 bool CanRedo() const;
845
846 // Insertion point
847 void SetInsertionPoint(long pos);
848 void SetInsertionPointEnd();
849 long GetInsertionPoint() const;
850 long GetLastPosition() const;
851
852 void SetSelection(long from, long to);
853 void SelectAll();
854 void SetEditable(bool editable);
855
856 %addmethods {
857 void write(const wxString& text) {
858 self->AppendText(text);
859 }
860 }
861
862 // TODO: replace this when the method is really added to wxTextCtrl
863 %addmethods {
864 wxString GetString(long from, long to) {
865 return self->GetValue().Mid(from, to-from);
866 }
867 }
868 };
869
870 //----------------------------------------------------------------------
871
872 class wxScrollBar : public wxControl {
873 public:
874 wxScrollBar(wxWindow* parent, wxWindowID id = -1,
875 const wxPoint& pos = wxDefaultPosition,
876 const wxSize& size = wxDefaultSize,
877 long style = wxSB_HORIZONTAL,
878 const wxValidator& validator = wxDefaultValidator,
879 const wxString& name = wxPyScrollBarNameStr);
880 %name(wxPreScrollBar)wxScrollBar();
881
882 bool Create(wxWindow* parent, wxWindowID id = -1,
883 const wxPoint& pos = wxDefaultPosition,
884 const wxSize& size = wxDefaultSize,
885 long style = wxSB_HORIZONTAL,
886 const wxValidator& validator = wxDefaultValidator,
887 const wxString& name = wxPyScrollBarNameStr);
888
889 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
890 %pragma(python) addtomethod = "wxPreScrollBar:val._setOORInfo(val)"
891
892 int GetRange();
893 int GetPageSize();
894 int GetThumbPosition();
895 int GetThumbSize();
896 %name(GetThumbLength) int GetThumbSize(); // to match the docs
897
898 bool IsVertical();
899
900 void SetThumbPosition(int viewStart);
901 void SetScrollbar(int position, int thumbSize,
902 int range, int pageSize,
903 bool refresh = TRUE);
904 };
905
906 //----------------------------------------------------------------------
907
908 class wxSpinButton : public wxControl {
909 public:
910 wxSpinButton(wxWindow* parent, wxWindowID id = -1,
911 const wxPoint& pos = wxDefaultPosition,
912 const wxSize& size = wxDefaultSize,
913 long style = wxSP_HORIZONTAL,
914 const wxString& name = wxPySPIN_BUTTON_NAME);
915 %name(wxPreSpinButton)wxSpinButton();
916
917 bool Create(wxWindow* parent, wxWindowID id = -1,
918 const wxPoint& pos = wxDefaultPosition,
919 const wxSize& size = wxDefaultSize,
920 long style = wxSP_HORIZONTAL,
921 const wxString& name = wxPySPIN_BUTTON_NAME);
922
923 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
924 %pragma(python) addtomethod = "wxPreSpinButton:val._setOORInfo(val)"
925
926 int GetMax();
927 int GetMin();
928 int GetValue();
929 void SetRange(int min, int max);
930 void SetValue(int value);
931 };
932
933 //----------------------------------------------------------------------
934
935 class wxStaticBitmap : public wxControl {
936 public:
937 wxStaticBitmap(wxWindow* parent, wxWindowID id,
938 const wxBitmap& bitmap,
939 const wxPoint& pos = wxDefaultPosition,
940 const wxSize& size = wxDefaultSize,
941 long style = 0,
942 const wxString& name = wxPyStaticBitmapNameStr);
943 %name(wxPreStaticBitmap)wxStaticBitmap();
944
945 bool Create(wxWindow* parent, wxWindowID id,
946 const wxBitmap& bitmap,
947 const wxPoint& pos = wxDefaultPosition,
948 const wxSize& size = wxDefaultSize,
949 long style = 0,
950 const wxString& name = wxPyStaticBitmapNameStr);
951
952 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
953 %pragma(python) addtomethod = "wxPreStaticBitmap:val._setOORInfo(val)"
954
955 wxBitmap GetBitmap();
956 void SetBitmap(const wxBitmap& bitmap);
957 void SetIcon(const wxIcon& icon);
958 };
959
960 //----------------------------------------------------------------------
961
962 class wxRadioBox : public wxControl {
963 public:
964 wxRadioBox(wxWindow* parent, wxWindowID id,
965 const wxString& label,
966 const wxPoint& point = wxDefaultPosition,
967 const wxSize& size = wxDefaultSize,
968 int LCOUNT = 0, wxString* choices = NULL,
969 int majorDimension = 0,
970 long style = wxRA_HORIZONTAL,
971 const wxValidator& validator = wxDefaultValidator,
972 const wxString& name = wxPyRadioBoxNameStr);
973 %name(wxPreRadioBox)wxRadioBox();
974
975 bool Create(wxWindow* parent, wxWindowID id,
976 const wxString& label,
977 const wxPoint& point = wxDefaultPosition,
978 const wxSize& size = wxDefaultSize,
979 int LCOUNT = 0, wxString* choices = NULL,
980 int majorDimension = 0,
981 long style = wxRA_HORIZONTAL,
982 const wxValidator& validator = wxDefaultValidator,
983 const wxString& name = wxPyRadioBoxNameStr);
984
985 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
986 %pragma(python) addtomethod = "wxPreRadioBox:val._setOORInfo(val)"
987
988 void Enable(bool enable);
989 %name(EnableItem)void Enable(int n, bool enable);
990 int FindString(const wxString& string);
991
992 wxString GetString(int n);
993
994 #ifdef __WXGTK__
995 %name(GetItemLabel)wxString GetLabel( int item );
996 %name(SetItemLabel)void SetLabel( int item, const wxString& label );
997 #else
998 void SetString(int n, const wxString& label);
999 %pragma(python) addtoclass = "
1000 GetItemLabel = GetString
1001 SetItemLabel = SetString
1002 "
1003 int GetColumnCount();
1004 int GetRowCount();
1005 #endif
1006
1007 int GetSelection();
1008 wxString GetStringSelection();
1009 int GetCount();
1010 %pragma(python) addtoclass = "Number = GetCount"
1011
1012 void SetSelection(int n);
1013 void SetStringSelection(const wxString& string);
1014 void Show(bool show);
1015 %name(ShowItem)void Show(int item, bool show);
1016 };
1017
1018 //----------------------------------------------------------------------
1019
1020 class wxRadioButton : public wxControl {
1021 public:
1022 wxRadioButton(wxWindow* parent, wxWindowID id,
1023 const wxString& label,
1024 const wxPoint& pos = wxDefaultPosition,
1025 const wxSize& size = wxDefaultSize,
1026 long style = 0,
1027 const wxValidator& validator = wxDefaultValidator,
1028 const wxString& name = wxPyRadioButtonNameStr);
1029 %name(wxPreRadioButton)wxRadioButton();
1030
1031 bool Create(wxWindow* parent, wxWindowID id,
1032 const wxString& label,
1033 const wxPoint& pos = wxDefaultPosition,
1034 const wxSize& size = wxDefaultSize,
1035 long style = 0,
1036 const wxValidator& validator = wxDefaultValidator,
1037 const wxString& name = wxPyRadioButtonNameStr);
1038
1039 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1040 %pragma(python) addtomethod = "wxPreRadioButton:val._setOORInfo(val)"
1041
1042 bool GetValue();
1043 void SetValue(bool value);
1044 };
1045
1046 //----------------------------------------------------------------------
1047
1048 class wxSlider : public wxControl {
1049 public:
1050 wxSlider(wxWindow* parent, wxWindowID id,
1051 int value, int minValue, int maxValue,
1052 const wxPoint& point = wxDefaultPosition,
1053 const wxSize& size = wxDefaultSize,
1054 long style = wxSL_HORIZONTAL,
1055 const wxValidator& validator = wxDefaultValidator,
1056 const wxString& name = wxPySliderNameStr);
1057 %name(wxPreSlider)wxSlider();
1058
1059 bool Create(wxWindow* parent, wxWindowID id,
1060 int value, int minValue, int maxValue,
1061 const wxPoint& point = wxDefaultPosition,
1062 const wxSize& size = wxDefaultSize,
1063 long style = wxSL_HORIZONTAL,
1064 const wxValidator& validator = wxDefaultValidator,
1065 const wxString& name = wxPySliderNameStr);
1066
1067 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1068 %pragma(python) addtomethod = "wxPreSlider:val._setOORInfo(val)"
1069
1070 void ClearSel();
1071 void ClearTicks();
1072 int GetLineSize();
1073 int GetMax();
1074 int GetMin();
1075 int GetPageSize();
1076 int GetSelEnd();
1077 int GetSelStart();
1078 int GetThumbLength();
1079 int GetTickFreq();
1080 int GetValue();
1081 void SetRange(int minValue, int maxValue);
1082 void SetTickFreq(int n, int pos);
1083 void SetLineSize(int lineSize);
1084 void SetPageSize(int pageSize);
1085 void SetSelection(int startPos, int endPos);
1086 void SetThumbLength(int len);
1087 void SetTick(int tickPos);
1088 void SetValue(int value);
1089 };
1090
1091
1092 //----------------------------------------------------------------------
1093
1094 class wxSpinCtrl : public wxSpinButton {
1095 public:
1096 wxSpinCtrl(wxWindow *parent,
1097 wxWindowID id = -1,
1098 const wxString& value = wxPyEmptyString,
1099 const wxPoint& pos = wxDefaultPosition,
1100 const wxSize& size = wxDefaultSize,
1101 long style = wxSP_ARROW_KEYS,
1102 int min = 0, int max = 100, int initial = 0,
1103 const wxString& name = wxPySpinCtrlNameStr);
1104 %name(wxPreSpinCtrl)wxSpinCtrl();
1105
1106 bool Create(wxWindow *parent,
1107 wxWindowID id = -1,
1108 const wxString& value = wxPyEmptyString,
1109 const wxPoint& pos = wxDefaultPosition,
1110 const wxSize& size = wxDefaultSize,
1111 long style = wxSP_ARROW_KEYS,
1112 int min = 0, int max = 100, int initial = 0,
1113 const wxString& name = wxPySpinCtrlNameStr);
1114
1115 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1116 %pragma(python) addtomethod = "wxPreSpinCtrl:val._setOORInfo(val)"
1117
1118 int GetMax();
1119 int GetMin();
1120 int GetValue();
1121 void SetRange(int min, int max);
1122 void SetValue(int value);
1123
1124 };
1125
1126
1127 //----------------------------------------------------------------------
1128
1129 #ifndef __WXMAC__
1130 enum { wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, };
1131
1132 class wxToggleButton : public wxControl {
1133 public:
1134 wxToggleButton(wxWindow *parent,
1135 wxWindowID id,
1136 const wxString& label,
1137 const wxPoint& pos = wxDefaultPosition,
1138 const wxSize& size = wxDefaultSize,
1139 long style = 0,
1140 const wxValidator& validator = wxDefaultValidator,
1141 const wxString& name = wxPyCheckBoxNameStr);
1142 %name(wxPreToggleButton)wxToggleButton();
1143
1144 bool Create(wxWindow *parent,
1145 wxWindowID id,
1146 const wxString& label,
1147 const wxPoint& pos = wxDefaultPosition,
1148 const wxSize& size = wxDefaultSize,
1149 long style = 0,
1150 const wxValidator& validator = wxDefaultValidator,
1151 const wxString& name = wxPyCheckBoxNameStr);
1152
1153 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
1154 %pragma(python) addtomethod = "wxPreToggleButton:val._setOORInfo(val)"
1155
1156 void SetValue(bool value);
1157 bool GetValue() const ;
1158 void SetLabel(const wxString& label);
1159
1160 };
1161
1162 #endif
1163
1164 //----------------------------------------------------------------------
1165 //----------------------------------------------------------------------
1166 //----------------------------------------------------------------------
1167
1168
1169