1 ///////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/listctrl.h
3 // Purpose:     wxListCtrl class
4 // Author:      Vadim Zeitlin
5 // Modified by:
6 // Created:     04.12.99
7 // RCS-ID:      $Id: listctrl.h 46432 2007-06-13 03:46:20Z SC $
8 // Copyright:   (c) wxWidgets team
9 // Licence:     wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 
12 #ifndef _WX_LISTCTRL_H_BASE_
13 #define _WX_LISTCTRL_H_BASE_
14 
15 #include "wx/defs.h" // headers should include this before first wxUSE_XXX check
16 
17 #if wxUSE_LISTCTRL
18 
19 #include "wx/listbase.h"
20 
21 // ----------------------------------------------------------------------------
22 // constants
23 // ----------------------------------------------------------------------------
24 
25 extern WXDLLEXPORT_DATA(const wxChar) wxListCtrlNameStr[];
26 
27 // ----------------------------------------------------------------------------
28 // include the wxListCtrl class declaration
29 // ----------------------------------------------------------------------------
30 
31 #if defined(__WIN32__) && !defined(__WXUNIVERSAL__)
32     #include "wx/msw/listctrl.h"
33 #elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
34     #include "wx/mac/carbon/listctrl.h"
35 #else
36     #include "wx/generic/listctrl.h"
37 #endif
38 
39 // ----------------------------------------------------------------------------
40 // wxListView: a class which provides a better API for list control
41 // ----------------------------------------------------------------------------
42 
43 class WXDLLEXPORT wxListView : public wxListCtrl
44 {
45 public:
wxListView()46     wxListView() { }
47     wxListView( wxWindow *parent,
48                 wxWindowID winid = wxID_ANY,
49                 const wxPoint& pos = wxDefaultPosition,
50                 const wxSize& size = wxDefaultSize,
51                 long style = wxLC_REPORT,
52                 const wxValidator& validator = wxDefaultValidator,
53                 const wxString &name = wxListCtrlNameStr)
54     {
55         Create(parent, winid, pos, size, style, validator, name);
56     }
57 
58     // focus/selection stuff
59     // ---------------------
60 
61     // [de]select an item
62     void Select(long n, bool on = true)
63     {
64         SetItemState(n, on ? wxLIST_STATE_SELECTED : 0, wxLIST_STATE_SELECTED);
65     }
66 
67     // focus and show the given item
Focus(long index)68     void Focus(long index)
69     {
70         SetItemState(index, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
71         EnsureVisible(index);
72     }
73 
74     // get the currently focused item or -1 if none
GetFocusedItem()75     long GetFocusedItem() const
76     {
77         return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
78     }
79 
80     // get first and subsequent selected items, return -1 when no more
GetNextSelected(long item)81     long GetNextSelected(long item) const
82         { return GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); }
GetFirstSelected()83     long GetFirstSelected() const
84         { return GetNextSelected(-1); }
85 
86     // return true if the item is selected
IsSelected(long index)87     bool IsSelected(long index) const
88         { return GetItemState(index, wxLIST_STATE_SELECTED) != 0; }
89 
90     // columns
91     // -------
92 
SetColumnImage(int col,int image)93     void SetColumnImage(int col, int image)
94     {
95         wxListItem item;
96         item.SetMask(wxLIST_MASK_IMAGE);
97         item.SetImage(image);
98         SetColumn(col, item);
99     }
100 
ClearColumnImage(int col)101     void ClearColumnImage(int col) { SetColumnImage(col, -1); }
102 
103 private:
104     DECLARE_DYNAMIC_CLASS_NO_COPY(wxListView)
105 };
106 
107 #endif // wxUSE_LISTCTRL
108 
109 #endif
110     // _WX_LISTCTRL_H_BASE_
111