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 class wxListBox : public wxControlWithItems
32 %addtofunc wxListBox "self._setOORInfo(self)"
33 %addtofunc wxListBox() ""
35 wxListBox(wxWindow* parent, wxWindowID id,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize,
38 int choices=0, wxString* choices_array = NULL,
40 const wxValidator& validator = wxDefaultValidator,
41 const wxString& name = wxPyListBoxNameStr);
42 %name(PreListBox)wxListBox();
44 bool Create(wxWindow* parent, wxWindowID id,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 int choices=0, wxString* choices_array = NULL,
49 const wxValidator& validator = wxDefaultValidator,
50 const wxString& name = wxPyListBoxNameStr);
52 // all generic methods are in wxControlWithItems...
55 void Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
57 wxPyClientData* data = new wxPyClientData(clientData);
58 self->Insert(item, pos, data);
60 self->Insert(item, pos);
64 void InsertItems(const wxArrayString& items, int pos);
65 void Set(const wxArrayString& items/*, void **clientData = NULL */);
67 // multiple selection logic
68 virtual bool IsSelected(int n) const;
69 virtual void SetSelection(int n, bool select = True);
70 virtual void Select(int n);
72 void DeselectAll(int itemToLeaveSelected = -1);
74 virtual bool SetStringSelection(const wxString& s, bool select = True);
76 // works for single as well as multiple selection listboxes (unlike
77 // GetSelection which only works for listboxes with single selection)
78 //virtual int GetSelections(wxArrayInt& aSelections) const;
80 PyObject* GetSelections() {
82 self->GetSelections(lst);
83 PyObject *tup = PyTuple_New(lst.GetCount());
84 for(size_t i=0; i<lst.GetCount(); i++) {
85 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
91 // set the specified item at the first visible item or scroll to max
93 void SetFirstItem(int n);
94 %name(SetFirstItemStr) void SetFirstItem(const wxString& s);
96 // ensures that the given item is visible scrolling the listbox if
98 virtual void EnsureVisible(int n);
100 // a combination of Append() and EnsureVisible(): appends the item to the
101 // listbox and ensures that it is visible i.e. not scrolled out of view
102 void AppendAndEnsureVisible(const wxString& s);
104 // return True if this listbox is sorted
105 bool IsSorted() const;
109 //---------------------------------------------------------------------------
113 // wxCheckListBox: a listbox whose items may be checked
114 class wxCheckListBox : public wxListBox
117 %addtofunc wxCheckListBox "self._setOORInfo(self)"
118 %addtofunc wxCheckListBox() ""
120 wxCheckListBox(wxWindow *parent, wxWindowID id,
121 const wxPoint& pos = wxDefaultPosition,
122 const wxSize& size = wxDefaultSize,
123 int choices = 0, wxString* choices_array = NULL,
125 const wxValidator& validator = wxDefaultValidator,
126 const wxString& name = wxPyListBoxNameStr);
127 %name(PreCheckListBox)wxCheckListBox();
129 bool Create(wxWindow *parent, wxWindowID id,
130 const wxPoint& pos = wxDefaultPosition,
131 const wxSize& size = wxDefaultSize,
132 int choices = 0, wxString* choices_array = NULL,
134 const wxValidator& validator = wxDefaultValidator,
135 const wxString& name = wxPyListBoxNameStr);
137 bool IsChecked(int index);
138 void Check(int index, int check = True);
144 // return the index of the item at this position or wxNOT_FOUND
145 int HitTest(const wxPoint& pt) const;
146 %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const;
149 //---------------------------------------------------------------------------