From 491b5be8305968871bc289453ed088a70c3de044 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 13 Jul 2001 19:26:44 +0000 Subject: [PATCH] added wxListView class: this is going to be a wxListCtrl with human (inter)face git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11020 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/listctrl.h | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) 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 // ---------------------------------------------------------------------------- -- 2.45.2