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>
21 DECLARE_DEF_STRING(ListBoxNameStr);
24 //---------------------------------------------------------------------------
27 class wxListBox : public wxControlWithItems
30 %addtofunc wxListBox "self._setOORInfo(self)"
31 %addtofunc wxListBox() ""
33 wxListBox(wxWindow* parent, wxWindowID id,
34 const wxPoint& pos = wxDefaultPosition,
35 const wxSize& size = wxDefaultSize,
36 int choices=0, wxString* choices_array = NULL,
38 const wxValidator& validator = wxDefaultValidator,
39 const wxString& name = wxPyListBoxNameStr);
40 %name(PreListBox)wxListBox();
42 bool Create(wxWindow* parent, wxWindowID id,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 int choices=0, wxString* choices_array = NULL,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxPyListBoxNameStr);
50 // all generic methods are in wxControlWithItems...
53 void Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
55 wxPyClientData* data = new wxPyClientData(clientData);
56 self->Insert(item, pos, data);
58 self->Insert(item, pos);
62 void InsertItems(const wxArrayString& items, int pos);
63 void Set(const wxArrayString& items/*, void **clientData = NULL */);
65 // multiple selection logic
66 virtual bool IsSelected(int n) const;
67 virtual void SetSelection(int n, bool select = True);
68 virtual void Select(int n);
70 void DeselectAll(int itemToLeaveSelected = -1);
72 virtual bool SetStringSelection(const wxString& s, bool select = True);
74 // works for single as well as multiple selection listboxes (unlike
75 // GetSelection which only works for listboxes with single selection)
76 //virtual int GetSelections(wxArrayInt& aSelections) const;
78 PyObject* GetSelections() {
80 self->GetSelections(lst);
81 PyObject *tup = PyTuple_New(lst.GetCount());
82 for(size_t i=0; i<lst.GetCount(); i++) {
83 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
89 // set the specified item at the first visible item or scroll to max
91 void SetFirstItem(int n);
92 %name(SetFirstItemStr) void SetFirstItem(const wxString& s);
94 // ensures that the given item is visible scrolling the listbox if
96 virtual void EnsureVisible(int n);
98 // a combination of Append() and EnsureVisible(): appends the item to the
99 // listbox and ensures that it is visible i.e. not scrolled out of view
100 void AppendAndEnsureVisible(const wxString& s);
102 // return True if this listbox is sorted
103 bool IsSorted() const;
107 //---------------------------------------------------------------------------
111 // wxCheckListBox: a listbox whose items may be checked
112 class wxCheckListBox : public wxListBox
115 %addtofunc wxListBox "self._setOORInfo(self)"
116 %addtofunc wxListBox() ""
118 wxCheckListBox(wxWindow *parent, wxWindowID id,
119 const wxPoint& pos = wxDefaultPosition,
120 const wxSize& size = wxDefaultSize,
121 int choices = 0, wxString* choices_array = NULL,
123 const wxValidator& validator = wxDefaultValidator,
124 const wxString& name = wxPyListBoxNameStr);
125 %name(PreCheckListBox)wxCheckListBox();
127 bool Create(wxWindow *parent, wxWindowID id,
128 const wxPoint& pos = wxDefaultPosition,
129 const wxSize& size = wxDefaultSize,
130 int choices = 0, wxString* choices_array = NULL,
132 const wxValidator& validator = wxDefaultValidator,
133 const wxString& name = wxPyListBoxNameStr);
135 bool IsChecked(int index);
136 void Check(int index, int check = True);
142 // return the index of the item at this position or wxNOT_FOUND
143 int HitTest(const wxPoint& pt) const;
144 %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const;
147 //---------------------------------------------------------------------------