1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface defs for wxListBox and wxCheckListBox
7 // Created: 10-June-1998
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
19 #include <wx/checklst.h>
23 MAKE_CONST_WXSTRING(ListBoxNameStr);
26 //---------------------------------------------------------------------------
29 MustHaveApp(wxListBox);
31 class wxListBox : public wxControlWithItems
34 %pythonAppend wxListBox "self._setOORInfo(self)"
35 %pythonAppend wxListBox() ""
37 wxListBox(wxWindow* parent, wxWindowID id=-1,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 //int choices=0, wxString* choices_array = NULL,
41 const wxArrayString& choices = wxPyEmptyStringArray,
43 const wxValidator& validator = wxDefaultValidator,
44 const wxString& name = wxPyListBoxNameStr);
45 %RenameCtor(PreListBox, wxListBox());
47 bool Create(wxWindow* parent, wxWindowID id=-1,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 //int choices=0, wxString* choices_array = NULL,
51 const wxArrayString& choices = wxPyEmptyStringArray,
53 const wxValidator& validator = wxDefaultValidator,
54 const wxString& name = wxPyListBoxNameStr);
56 // all generic methods are in wxControlWithItems...
59 void Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
61 wxPyClientData* data = new wxPyClientData(clientData);
62 self->Insert(item, pos, data);
64 self->Insert(item, pos);
68 void InsertItems(const wxArrayString& items, int pos);
69 void Set(const wxArrayString& items/*, void **clientData = NULL */);
71 // multiple selection logic
72 virtual bool IsSelected(int n) const;
73 virtual void SetSelection(int n, bool select = true);
74 virtual void Select(int n);
76 void DeselectAll(int itemToLeaveSelected = -1);
78 virtual bool SetStringSelection(const wxString& s, bool select = true);
80 // works for single as well as multiple selection listboxes (unlike
81 // GetSelection which only works for listboxes with single selection)
82 //virtual int GetSelections(wxArrayInt& aSelections) const;
84 PyObject* GetSelections() {
86 self->GetSelections(lst);
87 PyObject *tup = PyTuple_New(lst.GetCount());
88 for(size_t i=0; i<lst.GetCount(); i++) {
89 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
95 // set the specified item at the first visible item or scroll to max
97 void SetFirstItem(int n);
98 %Rename(SetFirstItemStr, void, SetFirstItem(const wxString& s));
100 // ensures that the given item is visible scrolling the listbox if
102 virtual void EnsureVisible(int n);
104 // a combination of Append() and EnsureVisible(): appends the item to the
105 // listbox and ensures that it is visible i.e. not scrolled out of view
106 void AppendAndEnsureVisible(const wxString& s);
108 // return True if this listbox is sorted
109 bool IsSorted() const;
113 void SetItemForegroundColour(int item, const wxColour& c) {
115 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
116 self->GetItem(item)->SetTextColour(c);
119 void SetItemBackgroundColour(int item, const wxColour& c) {
121 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
122 self->GetItem(item)->SetBackgroundColour(c);
125 void SetItemFont(int item, const wxFont& f) {
127 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
128 self->GetItem(item)->SetFont(f);
133 static wxVisualAttributes
134 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
138 //---------------------------------------------------------------------------
142 MustHaveApp(wxCheckListBox);
144 // wxCheckListBox: a listbox whose items may be checked
145 class wxCheckListBox : public wxListBox
148 %pythonAppend wxCheckListBox "self._setOORInfo(self)"
149 %pythonAppend wxCheckListBox() ""
151 wxCheckListBox(wxWindow *parent, wxWindowID id=-1,
152 const wxPoint& pos = wxDefaultPosition,
153 const wxSize& size = wxDefaultSize,
154 //int choices = 0, wxString* choices_array = NULL,
155 const wxArrayString& choices = wxPyEmptyStringArray,
157 const wxValidator& validator = wxDefaultValidator,
158 const wxString& name = wxPyListBoxNameStr);
159 %RenameCtor(PreCheckListBox, wxCheckListBox());
161 bool Create(wxWindow *parent, wxWindowID id=-1,
162 const wxPoint& pos = wxDefaultPosition,
163 const wxSize& size = wxDefaultSize,
164 //int choices = 0, wxString* choices_array = NULL,
165 const wxArrayString& choices = wxPyEmptyStringArray,
167 const wxValidator& validator = wxDefaultValidator,
168 const wxString& name = wxPyListBoxNameStr);
170 bool IsChecked(int index);
171 void Check(int index, int check = true);
173 #if defined(__WXMSW__) || defined(__WXGTK__)
177 // return the index of the item at this position or wxNOT_FOUND
178 int HitTest(const wxPoint& pt) const;
179 %Rename(HitTestXY, int, HitTest(wxCoord x, wxCoord y) const);
182 //---------------------------------------------------------------------------