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