$szTitle = "wxlistbox"; include "./_header.inc"; ?>
a listbox is used to select one or more of a list of strings. the strings are displayed in a scrolling box, with the selected string(s) marked in reverse video. a listbox can be single selection (if an item is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections).
list box elements are numbered from zero. their number may be limited under some platforms.
a listbox callback gets an event wxevt_command_listbox_selected for single clicks, and wxevt_command_listbox_double_clicked for double clicks.
derived from
wxcontrolwithitems
wxcontrol
wxwindow
wxevthandler
wxobject
include files
<wx/listbox.h>
window styles
wxlb_single | single-selection list. |
wxlb_multiple | multiple-selection list: the user can toggle multiple items on and off. |
wxlb_extended | extended-selection list: the user can select multiple items using the shift key and the mouse or special key combinations. |
wxlb_hscroll | create horizontal scrollbar if contents are too wide (windows only). |
wxlb_always_sb | always show a vertical scrollbar. |
wxlb_needed_sb | only create a vertical scrollbar if needed. |
wxlb_sort | the listbox contents are sorted in alphabetical order. |
note that wxlb_single, wxlb_multiple and wxlb_extended styles are mutually exclusive and you can specify at most one of them (single selection is the default).
see also window styles overview.
event handling
evt_listbox(id, func) | process a wxevt_command_listbox_selected event, when an item on the list is selected or the selection changes. |
evt_listbox_dclick(id, func) | process a wxevt_command_listbox_doubleclicked event, when the listbox is double-clicked. |
see also
wxchoice, wxcombobox, wxlistctrl, wxcommandevent
members
wxlistbox::wxlistbox
wxlistbox::~wxlistbox
wxlistbox::create
wxlistbox::deselect
wxlistbox::getselections
wxlistbox::insertitems
wxlistbox::hittest
wxlistbox::isselected
wxlistbox::set
wxlistbox::setfirstitem
wxlistbox()
default constructor.
wxlistbox(wxwindow* parent, wxwindowid id, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, int n = 0, const wxstring choices[] = null, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "listbox")
wxlistbox(wxwindow* parent, wxwindowid id, const wxpoint& pos, const wxsize& size, const wxarraystring& choices, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "listbox")
constructor, creating and showing a list box.
parameters
parent
id
pos
size
n
choices
style
validator
name
see also
wxlistbox::create, wxvalidator
wxpython note: the wxlistbox constructor in wxpython reduces the n and choices arguments are to a single argument, which is a list of strings.
wxperl note: in wxperl there is just an array reference in place of n and choices.
void ~wxlistbox()
destructor, destroying the list box.
bool create(wxwindow* parent, wxwindowid id, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, int n, const wxstring choices[] = null, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "listbox")
bool create(wxwindow* parent, wxwindowid id, const wxpoint& pos, const wxsize& size, const wxarraystring& choices, long style = 0, const wxvalidator& validator = wxdefaultvalidator, const wxstring& name = "listbox")
creates the listbox for two-step construction. see wxlistbox::wxlistbox for further details.
void deselect(int n)
deselects an item in the list box.
parameters
n
remarks
this applies to multiple selection listboxes only.
int getselections(wxarrayint& selections) const
fill an array of ints with the positions of the currently selected items.
parameters
selections
return value
the number of selections.
remarks
use this with a multiple selection listbox.
see also
wxcontrolwithitems::getselection, wxcontrolwithitems::getstringselection, wxcontrolwithitems::setselection
wxpython note: the wxpython version of this method takes no parameters and returns a tuple of the selected items.
wxperl note: in wxperl this method takes no parameters and return the selected items as a list.
void insertitems(int nitems, const wxstring *items, unsigned int pos)
void insertitems(const wxarraystring& nitems, unsigned int pos)
insert the given number of strings before the specified position.
parameters
nitems
items
pos
wxpython note: the first two parameters are collapsed into a single parameter for wxpython, which is a list of strings.
wxperl note: in wxperl there is just an array reference in place of nitems and items.
int hittest(const wxpoint point) const
returns the item located at point, or wxnot_found if there is no item located at point.
this function is new since wxwidgets version 2.7.0. it is currently implemented for wxmsw, wxmac and wxgtk2 ports.
parameters
point
return value
item located at point, or wxnot_found if unimplemented or the item does not exist.
bool isselected(int n) const
determines whether an item is selected.
parameters
n
return value
true if the given item is selected, false otherwise.
void set(int n, const wxstring* choices, void **clientdata = null)
void set(const wxarraystring& choices, void **clientdata = null)
clears the list box and adds the given strings to it.
parameters
n
choices
clientdata
remarks
you may free the array from the calling program after this function has been called.
void setfirstitem(int n)
void setfirstitem(const wxstring& string)
set the specified item to be the first visible item.
parameters
n
string
include "./_footer.inc"; ?>