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>
22 MAKE_CONST_WXSTRING(ListBoxNameStr);
25 //---------------------------------------------------------------------------
28 MustHaveApp(wxListBox);
30 class wxListBox : public wxControlWithItems
33 %pythonAppend wxListBox "self._setOORInfo(self)"
34 %pythonAppend wxListBox() ""
36 wxListBox(wxWindow* parent,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 const wxArrayString& choices = wxPyEmptyStringArray,
42 const wxValidator& validator = wxDefaultValidator,
43 const wxString& name = wxPyListBoxNameStr);
45 // wxListBox(wxWindow* parent,
46 // wxWindowID id = -1,
47 // const wxPoint& pos = wxDefaultPosition,
48 // const wxSize& size = wxDefaultSize,
50 // const wxString choices[] = NULL,
52 // const wxValidator& validator = wxDefaultValidator,
53 // const wxString& name = wxPyListBoxNameStr);
54 %RenameCtor(PreListBox, wxListBox());
56 bool Create(wxWindow* parent,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 const wxArrayString& choices = wxPyEmptyStringArray,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxPyListBoxNameStr);
65 // bool Create(wxWindow *parent,
66 // wxWindowID id = -1,
67 // const wxPoint& pos = wxDefaultPosition,
68 // const wxSize& size = wxDefaultSize,
70 // const wxString choices[] = NULL,
72 // const wxValidator& validator = wxDefaultValidator,
73 // const wxString& name = wxPyListBoxNameStr);
75 // all generic methods are in wxControlWithItems...
79 void Insert(const wxString& item, int pos, PyObject* clientData = NULL)
83 wxPyClientData* data = new wxPyClientData(clientData);
84 self->Insert(item, pos, data);
87 self->Insert(item, pos);
91 void InsertItems(const wxArrayString& items, unsigned int pos);
92 void Set(const wxArrayString& items/*, void **clientData = NULL */);
94 // multiple selection logic
95 virtual bool IsSelected(int n) const;
96 virtual void SetSelection(int n, bool select = true);
97 virtual void Select(int n);
100 void DeselectAll(int itemToLeaveSelected = -1);
102 virtual bool SetStringSelection(const wxString& s, bool select = true);
104 // works for single as well as multiple selection listboxes (unlike
105 // GetSelection which only works for listboxes with single selection)
106 //virtual int GetSelections(wxArrayInt& aSelections) const;
108 PyObject* GetSelections() {
109 wxPyBlock_t blocked = wxPyBeginBlockThreads();
111 self->GetSelections(lst);
112 PyObject *tup = PyTuple_New(lst.GetCount());
113 for (size_t i=0; i<lst.GetCount(); i++)
115 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
117 wxPyEndBlockThreads(blocked);
122 // set the specified item at the first visible item or scroll to max
124 void SetFirstItem(int n);
125 %Rename(SetFirstItemStr, void, SetFirstItem(const wxString& s));
127 // ensures that the given item is visible scrolling the listbox
129 virtual void EnsureVisible(int n);
131 // a combination of Append() and EnsureVisible(): appends the item to the
132 // listbox and ensures that it is visible i.e. not scrolled out of view
133 void AppendAndEnsureVisible(const wxString& s);
135 // return True if this listbox is sorted
136 bool IsSorted() const;
138 // return the index of the item at this position or wxNOT_FOUND
139 int HitTest(const wxPoint& pt) const;
143 void SetItemForegroundColour(int item, const wxColour& c)
146 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
147 self->GetItem(item)->SetTextColour(c);
150 void SetItemBackgroundColour(int item, const wxColour& c)
153 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
154 self->GetItem(item)->SetBackgroundColour(c);
157 void SetItemFont(int item, const wxFont& f)
160 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
161 self->GetItem(item)->SetFont(f);
166 static wxVisualAttributes
167 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
171 //---------------------------------------------------------------------------
175 MustHaveApp(wxCheckListBox);
177 // wxCheckListBox: a listbox whose items may be checked
178 class wxCheckListBox : public wxListBox
181 %pythonAppend wxCheckListBox "self._setOORInfo(self)"
182 %pythonAppend wxCheckListBox() ""
184 wxCheckListBox(wxWindow *parent,
186 const wxPoint& pos = wxDefaultPosition,
187 const wxSize& size = wxDefaultSize,
188 const wxArrayString& choices = wxPyEmptyStringArray,
190 const wxValidator& validator = wxDefaultValidator,
191 const wxString& name = wxPyListBoxNameStr);
192 %RenameCtor(PreCheckListBox, wxCheckListBox());
194 bool Create(wxWindow *parent,
196 const wxPoint& pos = wxDefaultPosition,
197 const wxSize& size = wxDefaultSize,
198 const wxArrayString& choices = wxPyEmptyStringArray,
200 const wxValidator& validator = wxDefaultValidator,
201 const wxString& name = wxPyListBoxNameStr);
203 bool IsChecked(unsigned int index);
204 void Check(unsigned int index, int check = true);
206 #if defined(__WXMSW__) || defined(__WXGTK__)
210 %property(ItemHeight, GetItemHeight, doc="See `GetItemHeight`");
213 //---------------------------------------------------------------------------