]>
git.saurik.com Git - wxWidgets.git/blob - interface/listbox.h
7c1ab8e1d4092d607a691095a0f144326ca8a59c
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxListBox class
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 single
25 wxEVT_COMMAND_LISTBOX_DOUBLE_CLICKED for double clicks.
29 Single-selection list.
30 @style{wxLB_MULTIPLE}:
31 Multiple-selection list: the user can toggle multiple items on and
33 @style{wxLB_EXTENDED}:
34 Extended-selection list: the user can select multiple items using
35 the SHIFT key and the mouse or special key combinations.
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.
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_LISTBOX_DOUBLECLICKED event, when the
52 listbox is double-clicked.
57 @appearance{listbox.png}
60 wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
62 class wxListBox
: public wxControlWithItems
67 Constructor, creating and showing a list box.
70 Parent window. Must not be @NULL.
73 Window identifier. The value wxID_ANY indicates a default value.
79 Window size. If wxDefaultSize is specified then the window is sized
83 Number of strings with which to initialise the control.
86 An array of strings with which to initialise the control.
89 Window style. See wxListBox.
97 @sa Create(), wxValidator
100 wxListBox(wxWindow
* parent
, wxWindowID id
,
101 const wxPoint
& pos
= wxDefaultPosition
,
102 const wxSize
& size
= wxDefaultSize
,
104 const wxString choices
[] = @NULL
,
106 const wxValidator
& validator
= wxDefaultValidator
,
107 const wxString
& name
= "listBox");
108 wxListBox(wxWindow
* parent
, wxWindowID id
,
111 const wxArrayString
& choices
,
113 const wxValidator
& validator
= wxDefaultValidator
,
114 const wxString
& name
= "listBox");
118 Destructor, destroying the list box.
124 Creates the listbox for two-step construction. See wxListBox()
127 bool Create(wxWindow
* parent
, wxWindowID id
,
128 const wxPoint
& pos
= wxDefaultPosition
,
129 const wxSize
& size
= wxDefaultSize
,
131 const wxString choices
[] = @NULL
,
133 const wxValidator
& validator
= wxDefaultValidator
,
134 const wxString
& name
= "listBox");
135 bool Create(wxWindow
* parent
, wxWindowID id
,
138 const wxArrayString
& choices
,
140 const wxValidator
& validator
= wxDefaultValidator
,
141 const wxString
& name
= "listBox");
145 Deselects an item in the list box.
148 The zero-based item to deselect.
150 @remarks This applies to multiple selection listboxes only.
152 void Deselect(int n
);
155 Fill an array of ints with the positions of the currently selected items.
158 A reference to an wxArrayInt instance that is used to store the result of the
161 @returns The number of selections.
163 @remarks Use this with a multiple selection listbox.
165 @sa wxControlWithItems::GetSelection, wxControlWithItems::GetStringSelection,
166 wxControlWithItems::SetSelection
168 int GetSelections(wxArrayInt
& selections
);
171 Returns the item located at @e point, or @c wxNOT_FOUND if there
172 is no item located at @e point.
174 This function is new since wxWidgets version 2.7.0. It is currently implemented
175 for wxMSW, wxMac and wxGTK2
179 Point of item (in client coordinates) to obtain
181 @returns Item located at point, or wxNOT_FOUND if unimplemented or the
184 int HitTest(const wxPoint point
);
188 Insert the given number of strings before the specified position.
191 Number of items in the array items
194 Labels of items to be inserted
197 Position before which to insert the items: for example, if pos is 0 the items
198 will be inserted in the beginning of the listbox
200 void InsertItems(int nItems
, const wxString items
,
202 void InsertItems(const wxArrayString
& nItems
,
207 Determines whether an item is selected.
210 The zero-based item index.
212 @returns @true if the given item is selected, @false otherwise.
214 bool IsSelected(int n
);
218 Clears the list box and adds the given strings to it.
221 The number of strings to set.
224 An array of strings to set.
227 Options array of client data pointers
229 @remarks You may free the array from the calling program after this
230 function has been called.
232 void Set(int n
, const wxString
* choices
, void clientData
= @NULL
);
233 void Set(const wxArrayString
& choices
,
234 void clientData
= @NULL
);
239 Set the specified item to be the first visible item.
242 The zero-based item index.
245 The string that should be visible.
247 void SetFirstItem(int n
);
248 void SetFirstItem(const wxString
& string
);