]>
git.saurik.com Git - wxWidgets.git/blob - interface/listbox.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxListBox
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A listbox is used to select one or more of a list of strings. The
14 strings are displayed in a scrolling box, with the selected string(s)
15 marked in reverse video. A listbox can be single selection (if an item
16 is selected, the previous selection is removed) or multiple selection
17 (clicking an item toggles the item on or off independently of other
20 List box elements are numbered from zero. Their number may be limited
23 A listbox callback gets an event wxEVT_COMMAND_LISTBOX_SELECTED for
24 single clicks, and wxEVT_COMMAND_LISTBOX_DOUBLECLICKED for double clicks.
28 Single-selection list.
30 Multiple-selection list: the user can toggle multiple items on and
31 off. This is the same as wxLB_EXTENDED in wxGTK2 port.
33 Extended-selection list: the user can extend the selection by using
34 @c SHIFT or @c CTRL keys together with the cursor movement keys or
37 Create horizontal scrollbar if contents are too wide (Windows only).
38 @style{wxLB_ALWAYS_SB}
39 Always show a vertical scrollbar.
40 @style{wxLB_NEEDED_SB}
41 Only create a vertical scrollbar if needed.
43 The listbox contents are sorted in alphabetical order.
46 @beginEventTable{wxCommandEvent}
47 @event{EVT_LISTBOX(id, func)}
48 Process a wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the
49 list is selected or the selection changes.
50 @event{EVT_LISTBOX_DCLICK(id, func)}
51 Process a wxEVT_COMMAND_LISTBOXDOUBLECLICKED event, when the
52 listbox is double-clicked.
57 <!-- @appearance{listbox.png} -->
59 @see wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
61 class wxListBox
: public wxControlWithItems
73 Number of strings with which to initialise the control.
75 Window style. See wxListBox.
78 wxListBox(wxWindow
* parent
, wxWindowID id
,
79 const wxPoint
& pos
= wxDefaultPosition
,
80 const wxSize
& size
= wxDefaultSize
,
82 const wxString choices
[] = NULL
,
84 const wxValidator
& validator
= wxDefaultValidator
,
85 const wxString
& name
= "listBox");
91 An array of strings with which to initialise the control.
93 Window style. See wxListBox.
96 wxListBox(wxWindow
* parent
, wxWindowID id
,
99 const wxArrayString
& choices
,
101 const wxValidator
& validator
= wxDefaultValidator
,
102 const wxString
& name
= "listBox");
105 Destructor, destroying the list box.
111 Creates the listbox for two-step construction. See wxListBox()
114 bool Create(wxWindow
* parent
, wxWindowID id
,
115 const wxPoint
& pos
= wxDefaultPosition
,
116 const wxSize
& size
= wxDefaultSize
,
118 const wxString choices
[] = NULL
,
120 const wxValidator
& validator
= wxDefaultValidator
,
121 const wxString
& name
= "listBox");
122 bool Create(wxWindow
* parent
, wxWindowID id
,
125 const wxArrayString
& choices
,
127 const wxValidator
& validator
= wxDefaultValidator
,
128 const wxString
& name
= "listBox");
132 Deselects an item in the list box.
135 The zero-based item to deselect.
137 @remarks This applies to multiple selection listboxes only.
139 void Deselect(int n
);
142 Fill an array of ints with the positions of the currently selected items.
145 A reference to an wxArrayInt instance that is used to store the result of
148 @return The number of selections.
150 @remarks Use this with a multiple selection listbox.
152 @see wxControlWithItems::GetSelection, wxControlWithItems::GetStringSelection,
153 wxControlWithItems::SetSelection
155 int GetSelections(wxArrayInt
& selections
) const;
158 Returns the item located at @e point, or @c wxNOT_FOUND if there
159 is no item located at @e point.
161 It is currently implemented for wxMSW, wxMac and wxGTK2 ports.
164 Point of item (in client coordinates) to obtain
166 @return Item located at point, or wxNOT_FOUND if unimplemented or the
171 int HitTest(const wxPoint point
) const;
174 Insert the given number of strings before the specified position.
177 Number of items in the array items
179 Labels of items to be inserted
181 Position before which to insert the items: if pos is 0 the
182 items will be inserted in the beginning of the listbox
184 void InsertItems(int nItems
, const wxString
*items
,
188 Insert the given number of strings before the specified position.
191 Labels of items to be inserted
193 Position before which to insert the items: if pos is 0 the
194 items will be inserted in the beginning of the listbox
196 void InsertItems(const wxArrayString
& items
,
200 Determines whether an item is selected.
203 The zero-based item index.
205 @return @true if the given item is selected, @false otherwise.
207 bool IsSelected(int n
) const;
210 Clears the list box and adds the given strings to it.
213 The number of strings to set.
215 An array of strings to set.
217 Options array of client data pointers
219 void Set(int n
, const wxString
* choices
, void **clientData
= NULL
);
222 Clears the list box and adds the given strings to it. You may
223 free the array from the calling program after this method
227 An array of strings to set.
229 Options array of client data pointers
231 void Set(const wxArrayString
& choices
,
232 void **clientData
= NULL
);
235 Set the specified item to be the first visible item.
238 The zero-based item index that should be visible.
240 void SetFirstItem(int n
);
243 Set the specified item to be the first visible item.
246 The string that should be visible.
248 void SetFirstItem(const wxString
& string
);