]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/listbox.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxListBox
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 A listbox is used to select one or more of a list of strings. The
13 strings are displayed in a scrolling box, with the selected string(s)
14 marked in reverse video. A listbox can be single selection (if an item
15 is selected, the previous selection is removed) or multiple selection
16 (clicking an item toggles the item on or off independently of other
19 List box elements are numbered from zero. Their number may be limited
22 A listbox callback gets an event wxEVT_COMMAND_LISTBOX_SELECTED for
23 single clicks, and wxEVT_COMMAND_LISTBOX_DOUBLECLICKED for double clicks.
27 Single-selection list.
29 Multiple-selection list: the user can toggle multiple items on and
30 off. This is the same as wxLB_EXTENDED in wxGTK2 port.
32 Extended-selection list: the user can extend the selection by using
33 @c SHIFT or @c CTRL keys together with the cursor movement keys or
36 Create horizontal scrollbar if contents are too wide (Windows only).
37 @style{wxLB_ALWAYS_SB}
38 Always show a vertical scrollbar.
39 @style{wxLB_NEEDED_SB}
40 Only create a vertical scrollbar if needed.
42 The listbox contents are sorted in alphabetical order.
45 @beginEventTable{wxCommandEvent}
46 @event{EVT_LISTBOX(id, func)}
47 Process a wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the
48 list is selected or the selection changes.
49 @event{EVT_LISTBOX_DCLICK(id, func)}
50 Process a wxEVT_COMMAND_LISTBOXDOUBLECLICKED event, when the
51 listbox is double-clicked.
56 <!-- @appearance{listbox.png} -->
58 @see wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
60 class wxListBox
: public wxControlWithItems
72 Number of strings with which to initialise the control.
74 Window style. See wxListBox.
77 wxListBox(wxWindow
* parent
, wxWindowID id
,
78 const wxPoint
& pos
= wxDefaultPosition
,
79 const wxSize
& size
= wxDefaultSize
,
81 const wxString choices
[] = NULL
,
83 const wxValidator
& validator
= wxDefaultValidator
,
84 const wxString
& name
= "listBox");
90 An array of strings with which to initialise the control.
92 Window style. See wxListBox.
95 wxListBox(wxWindow
* parent
, wxWindowID id
,
98 const wxArrayString
& choices
,
100 const wxValidator
& validator
= wxDefaultValidator
,
101 const wxString
& name
= "listBox");
104 Destructor, destroying the list box.
110 Creates the listbox for two-step construction. See wxListBox()
113 bool Create(wxWindow
* parent
, wxWindowID id
,
114 const wxPoint
& pos
= wxDefaultPosition
,
115 const wxSize
& size
= wxDefaultSize
,
117 const wxString choices
[] = NULL
,
119 const wxValidator
& validator
= wxDefaultValidator
,
120 const wxString
& name
= "listBox");
121 bool Create(wxWindow
* parent
, wxWindowID id
,
124 const wxArrayString
& choices
,
126 const wxValidator
& validator
= wxDefaultValidator
,
127 const wxString
& name
= "listBox");
131 Deselects an item in the list box.
134 The zero-based item to deselect.
136 @remarks This applies to multiple selection listboxes only.
138 void Deselect(int n
);
141 Fill an array of ints with the positions of the currently selected items.
144 A reference to an wxArrayInt instance that is used to store the result of
147 @return The number of selections.
149 @remarks Use this with a multiple selection listbox.
151 @see wxControlWithItems::GetSelection, wxControlWithItems::GetStringSelection,
152 wxControlWithItems::SetSelection
154 int GetSelections(wxArrayInt
& selections
) const;
157 Returns the item located at @e point, or @c wxNOT_FOUND if there
158 is no item located at @e point.
160 It is currently implemented for wxMSW, wxMac and wxGTK2 ports.
163 Point of item (in client coordinates) to obtain
165 @return Item located at point, or wxNOT_FOUND if unimplemented or the
170 int HitTest(const wxPoint point
) const;
173 Insert the given number of strings before the specified position.
176 Number of items in the array items
178 Labels of items to be inserted
180 Position before which to insert the items: if pos is 0 the
181 items will be inserted in the beginning of the listbox
183 void InsertItems(int nItems
, const wxString
*items
,
187 Insert the given number of strings before the specified position.
190 Labels of items to be inserted
192 Position before which to insert the items: if pos is 0 the
193 items will be inserted in the beginning of the listbox
195 void InsertItems(const wxArrayString
& items
,
199 Determines whether an item is selected.
202 The zero-based item index.
204 @return @true if the given item is selected, @false otherwise.
206 bool IsSelected(int n
) const;
209 Clears the list box and adds the given strings to it.
212 The number of strings to set.
214 An array of strings to set.
216 Options array of client data pointers
218 void Set(int n
, const wxString
* choices
, void **clientData
= NULL
);
221 Clears the list box and adds the given strings to it. You may
222 free the array from the calling program after this method
226 An array of strings to set.
228 Options array of client data pointers
230 void Set(const wxArrayString
& choices
,
231 void **clientData
= NULL
);
234 Set the specified item to be the first visible item.
237 The zero-based item index that should be visible.
239 void SetFirstItem(int n
);
242 Set the specified item to be the first visible item.
245 The string that should be visible.
247 void SetFirstItem(const wxString
& string
);