X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/83ac6a4ea3f110b84bd7e1b0cd5ef580d7b145a4..6e040042bae080a3fe8907e3772c103deab91c13:/include/wx/listctrl.h?ds=inline diff --git a/include/wx/listctrl.h b/include/wx/listctrl.h index c0507e1396..d88abdfdd2 100644 --- a/include/wx/listctrl.h +++ b/include/wx/listctrl.h @@ -284,6 +284,55 @@ private: #include "wx/generic/listctrl.h" #endif +// ---------------------------------------------------------------------------- +// wxListView: a class which provides a better API for list control +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxListView : public wxListCtrl +{ +public: + wxListView() { } + wxListView( wxWindow *parent, + wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxLC_REPORT, + const wxValidator& validator = wxDefaultValidator, + const wxString &name = "listctrl" ) + { + Create(parent, id, pos, size, style, wxDefaultValidator, name); + } + + // [de]select an item + void Select(long n, bool on = true) + { + SetItemState(n, on ? wxLIST_STATE_SELECTED : 0, wxLIST_STATE_SELECTED); + } + + // focus and show the given item + void Focus(long index) + { + SetItemState(index, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); + EnsureVisible(index); + } + + // get the currently focused item or -1 if none + long GetFocusedItem() const + { + return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED); + } + + // get first and subsequent selected items, return -1 when no more + long GetNextSelected(long item) const + { return GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); } + long GetFirstSelected() const + { return GetNextSelected(-1); } + + // return TRUE if the item is selected + bool IsSelected(long index) + { return GetItemState(index, wxLIST_STATE_SELECTED) != 0; } +}; + // ---------------------------------------------------------------------------- // wxListEvent - the event class for the wxListCtrl notifications // ----------------------------------------------------------------------------