]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxListView class: this is going to be a wxListCtrl with human (inter)face
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 13 Jul 2001 19:26:44 +0000 (19:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 13 Jul 2001 19:26:44 +0000 (19:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11020 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/listctrl.h

index c0507e1396bd1de9e4fee2e7eeec8d7af731d11f..d88abdfdd2726cef5a670cded2e9ae325f40f763 100644 (file)
@@ -284,6 +284,55 @@ private:
     #include "wx/generic/listctrl.h"
 #endif
 
     #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
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // wxListEvent - the event class for the wxListCtrl notifications
 // ----------------------------------------------------------------------------