![]() ![]() ![]() ![]() wxvlistboxwxvlistbox is a listbox-like control with the following two main differences from a regular listbox: it can have an arbitrarily huge number of items because it doesn't store them itself but uses ondrawitem() callback to draw them (so it is a virtual listbox) and its items can have variable height as determined by onmeasureitem() (so it is also a listbox with the lines of variable height). also, as a consequence of its virtual nature, it doesn't have any methods to append or insert items in it as it isn't necessary to do it: you just have to call setitemcount() to tell the control how many items it should display. of course, this also means that you will never use this class directly because it has pure virtual functions, but will need to derive your own class, such as wxhtmllistbox, from it. however it emits the same events as wxlistbox and the same event macros may be used with it. derived from
wxvscrolledwindow include files <wx/vlbox.h> see also wxsimplehtmllistbox, wxhtmllistbox members
wxvlistbox::wxvlistbox
wxvlistbox::wxvlistboxwxvlistbox(wxwindow* parent, wxwindowid id = wxid_any, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, size_t countitems = 0, long style = 0, const wxstring& name = wxvlistboxnamestr) normal constructor which calls create() internally. wxvlistbox() default constructor, you must call create() later.
wxvlistbox::clearvoid clear() deletes all items from the control.
wxvlistbox::createbool create(wxwindow* parent, wxwindowid id = wxid_any, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style = 0, const wxstring& name = wxvlistboxnamestr) creates the control. to finish creating it you also should call setitemcount() to let it know about the number of items it contains. the only special style which may be used with wxvlistbox is wxlb_multiple which indicates that the listbox should support multiple selection. returns true on success or false if the control couldn't be created
wxvlistbox::deselectallbool deselectall() deselects all the items in the listbox. returns true if any items were changed, i.e. if there had been any selected items before, or false if all the items were already deselected. this method is only valid for multi selection listboxes. see also
wxvlistbox::getfirstselectedint getfirstselected(unsigned long& cookie) const returns the index of the first selected item in the listbox or wxnot_found if no items are currently selected. cookie is an opaque parameter which should be passed to the subsequent calls to getnextselected. it is needed in order to allow parallel iterations over the selected items. here is a typical example of using these functions: unsigned long cookie; int item = hlbox->getfirstselected(cookie); while ( item != wxnot_found ) { ... process item ... item = hlbox->getnextselected(cookie); }this method is only valid for multi selection listboxes.
wxvlistbox::getitemcountsize_t getitemcount() const get the number of items in the control. see also
wxvlistbox::getmarginswxpoint getmargins() const returns the margins used by the control. the x field of the returned point is the horizontal margin and the y field is the vertical one. see also
wxvlistbox::getnextselectedint getnextselected(unsigned long& cookie) const returns the index of the next selected item or wxnot_found if there are no more. this method is only valid for multi selection listboxes. see also
wxvlistbox::getselectedcountsize_t getselectedcount() const returns the number of the items currently selected. it is valid for both single and multi selection controls. in the former case it may only return 0 or 1 however. see also
isselected,
wxvlistbox::getselectionint getselection() const get the currently selected item or wxnot_found if there is no selection.
wxvlistbox::getselectionbackgroundconst wxcolour& getselectionbackground() const returns the background colour used for the selected cells. by default the standard system colour is used. see also
wxsystemsettings::getcolour,
wxvlistbox::hasmultipleselectionbool hasmultipleselection() const returns true if the listbox was created with wxlb_multiple style and so supports multiple selection or false if it is a single selection listbox.
wxvlistbox::iscurrentbool iscurrent(size_t item) const returns true if this item is the current one, false otherwise. current item is always the same as selected one for the single selection listbox and in this case this method is equivalent to isselected but they are different for multi selection listboxes where many items may be selected but only one (at most) is current.
wxvlistbox::isselectedbool isselected(size_t item) const returns true if this item is selected, false otherwise.
wxvlistbox::ondrawbackgroundvoid ondrawbackground(wxdc& dc, const wxrect& rect, size_t n) const this method is used to draw the items background and, maybe, a border around it. the base class version implements a reasonable default behaviour which consists in drawing the selected item with the standard background colour and drawing a border around the item if it is either selected or current.
wxvlistbox::ondrawitemvoid ondrawitem(wxdc& dc, const wxrect& rect, size_t n) const the derived class must implement this function to actually draw the item with the given index on the provided dc. parameters dc
rect
n
wxvlistbox::ondrawseparatorvoid ondrawseparator(wxdc& dc, wxrect& rect, size_t n) const this method may be used to draw separators between the lines. the rectangle passed to it may be modified, typically to deflate it a bit before passing to ondrawitem(). the base class version of this method doesn't do anything. parameters dc
rect
n
wxvlistbox::onmeasureitemwxcoord onmeasureitem(size_t n) const the derived class must implement this method to return the height of the specified item (in pixels).
wxvlistbox::selectbool select(size_t item, bool select = true) selects or deselects the specified item which must be valid (i.e. not equal to wxnot_found). return true if the items selection status has changed or false otherwise. this function is only valid for the multiple selection listboxes, use setselection for the single selection ones.
wxvlistbox::selectallbool selectall() selects all the items in the listbox. returns true if any items were changed, i.e. if there had been any unselected items before, or false if all the items were already selected. this method is only valid for multi selection listboxes. see also
wxvlistbox::selectrangebool selectrange(size_t from, size_t to) selects all items in the specified range which may be given in any order. return true if the items selection status has changed or false otherwise. this method is only valid for multi selection listboxes. see also
wxvlistbox::setitemcountvoid setitemcount(size_t count) set the number of items to be shown in the control. this is just a synonym for wxvscrolledwindow::setlinecount().
wxvlistbox::setmarginsvoid setmargins(const wxpoint& pt) void setmargins(wxcoord x, wxcoord y) set the margins: horizontal margin is the distance between the window border and the item contents while vertical margin is half of the distance between items. by default both margins are 0.
wxvlistbox::setselectionvoid setselection(int selection) set the selection to the specified item, if it is -1 the selection is unset. the selected item will be automatically scrolled into view if it isn't currently visible. this method may be used both with single and multiple selection listboxes.
wxvlistbox::setselectionbackgroundvoid setselectionbackground(const wxcolour& col) sets the colour to be used for the selected cells background. the background of the standard cells may be changed by simply calling setbackgroundcolour. see also
wxvlistbox::togglevoid toggle(size_t item) toggles the state of the specified item, i.e. selects it if it was unselected and deselects it if it was selected. this method is only valid for multi selection listboxes. see also
|