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