]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_listbox.i
reSWIGged
[wxWidgets.git] / wxPython / src / _listbox.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _listbox.i
3 // Purpose: SWIG interface defs for wxListBox and wxCheckListBox
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 10-June-1998
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 %{
19 #include <wx/checklst.h>
20
21 %}
22
23 MAKE_CONST_WXSTRING(ListBoxNameStr);
24
25
26 //---------------------------------------------------------------------------
27 %newgroup
28
29 class wxListBox : public wxControlWithItems
30 {
31 public:
32 %pythonAppend wxListBox "self._setOORInfo(self)"
33 %pythonAppend wxListBox() ""
34
35 wxListBox(wxWindow* parent, wxWindowID id,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize,
38 //int choices=0, wxString* choices_array = NULL,
39 const wxArrayString& choices = wxPyEmptyStringArray,
40 long style = 0,
41 const wxValidator& validator = wxDefaultValidator,
42 const wxString& name = wxPyListBoxNameStr);
43 %name(PreListBox)wxListBox();
44
45 bool Create(wxWindow* parent, wxWindowID id,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 //int choices=0, wxString* choices_array = NULL,
49 const wxArrayString& choices = wxPyEmptyStringArray,
50 long style = 0,
51 const wxValidator& validator = wxDefaultValidator,
52 const wxString& name = wxPyListBoxNameStr);
53
54 // all generic methods are in wxControlWithItems...
55
56 %extend {
57 void Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
58 if (clientData) {
59 wxPyClientData* data = new wxPyClientData(clientData);
60 self->Insert(item, pos, data);
61 } else
62 self->Insert(item, pos);
63 }
64 }
65
66 void InsertItems(const wxArrayString& items, int pos);
67 void Set(const wxArrayString& items/*, void **clientData = NULL */);
68
69 // multiple selection logic
70 virtual bool IsSelected(int n) const;
71 virtual void SetSelection(int n, bool select = True);
72 virtual void Select(int n);
73 void Deselect(int n);
74 void DeselectAll(int itemToLeaveSelected = -1);
75
76 virtual bool SetStringSelection(const wxString& s, bool select = True);
77
78 // works for single as well as multiple selection listboxes (unlike
79 // GetSelection which only works for listboxes with single selection)
80 //virtual int GetSelections(wxArrayInt& aSelections) const;
81 %extend {
82 PyObject* GetSelections() {
83 wxArrayInt lst;
84 self->GetSelections(lst);
85 PyObject *tup = PyTuple_New(lst.GetCount());
86 for(size_t i=0; i<lst.GetCount(); i++) {
87 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
88 }
89 return tup;
90 }
91 }
92
93 // set the specified item at the first visible item or scroll to max
94 // range.
95 void SetFirstItem(int n);
96 %name(SetFirstItemStr) void SetFirstItem(const wxString& s);
97
98 // ensures that the given item is visible scrolling the listbox if
99 // necessary
100 virtual void EnsureVisible(int n);
101
102 // a combination of Append() and EnsureVisible(): appends the item to the
103 // listbox and ensures that it is visible i.e. not scrolled out of view
104 void AppendAndEnsureVisible(const wxString& s);
105
106 // return True if this listbox is sorted
107 bool IsSorted() const;
108
109
110 %extend {
111 void SetItemForegroundColour(int item, const wxColour& c) {
112 %#ifdef __WXMSW__
113 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
114 self->GetItem(item)->SetTextColour(c);
115 %#endif
116 }
117 void SetItemBackgroundColour(int item, const wxColour& c) {
118 %#ifdef __WXMSW__
119 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
120 self->GetItem(item)->SetBackgroundColour(c);
121 %#endif
122 }
123 void SetItemFont(int item, const wxFont& f) {
124 %#ifdef __WXMSW__
125 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
126 self->GetItem(item)->SetFont(f);
127 %#endif
128 }
129 }
130
131 static wxVisualAttributes
132 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
133 };
134
135
136 //---------------------------------------------------------------------------
137 %newgroup
138
139
140 // wxCheckListBox: a listbox whose items may be checked
141 class wxCheckListBox : public wxListBox
142 {
143 public:
144 %pythonAppend wxCheckListBox "self._setOORInfo(self)"
145 %pythonAppend wxCheckListBox() ""
146
147 wxCheckListBox(wxWindow *parent, wxWindowID id,
148 const wxPoint& pos = wxDefaultPosition,
149 const wxSize& size = wxDefaultSize,
150 //int choices = 0, wxString* choices_array = NULL,
151 const wxArrayString& choices = wxPyEmptyStringArray,
152 long style = 0,
153 const wxValidator& validator = wxDefaultValidator,
154 const wxString& name = wxPyListBoxNameStr);
155 %name(PreCheckListBox)wxCheckListBox();
156
157 bool Create(wxWindow *parent, wxWindowID id,
158 const wxPoint& pos = wxDefaultPosition,
159 const wxSize& size = wxDefaultSize,
160 //int choices = 0, wxString* choices_array = NULL,
161 const wxArrayString& choices = wxPyEmptyStringArray,
162 long style = 0,
163 const wxValidator& validator = wxDefaultValidator,
164 const wxString& name = wxPyListBoxNameStr);
165
166 bool IsChecked(int index);
167 void Check(int index, int check = True);
168
169 #if defined(__WXMSW__) || defined(__WXGTK__)
170 int GetItemHeight();
171 #endif
172
173 // return the index of the item at this position or wxNOT_FOUND
174 int HitTest(const wxPoint& pt) const;
175 %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const;
176 };
177
178 //---------------------------------------------------------------------------