Applied patch [ 832096 ] Final separation for GUI and console for Open Watcom
[wxWidgets.git] / include / wx / listctrl.h
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$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_LISTCTRL_H_BASE_
13 #define _WX_LISTCTRL_H_BASE_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "listctrlbase.h"
17 #endif
18
19 #if wxUSE_LISTCTRL
20
21 #include "wx/listbase.h"
22
23 // ----------------------------------------------------------------------------
24 // include the wxListCtrl class declaration
25 // ----------------------------------------------------------------------------
26
27 #if defined(__WIN32__) && !defined(__WXUNIVERSAL__)
28 #include "wx/msw/listctrl.h"
29 #else
30 #include "wx/generic/listctrl.h"
31 #endif
32
33 // ----------------------------------------------------------------------------
34 // wxListView: a class which provides a better API for list control
35 // ----------------------------------------------------------------------------
36
37 class WXDLLEXPORT wxListView : public wxListCtrl
38 {
39 public:
40 wxListView();
41 wxListView( wxWindow *parent,
42 wxWindowID winid = -1,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = wxLC_REPORT,
46 const wxValidator& validator = wxDefaultValidator,
47 const wxString &name = wxT("listctrl") );
48
49 // focus/selection stuff
50 // ---------------------
51
52 // [de]select an item
53 void Select(long n, bool on = TRUE)
54 {
55 SetItemState(n, on ? wxLIST_STATE_SELECTED : 0, wxLIST_STATE_SELECTED);
56 }
57
58 // focus and show the given item
59 void Focus(long index)
60 {
61 SetItemState(index, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
62 EnsureVisible(index);
63 }
64
65 // get the currently focused item or -1 if none
66 long GetFocusedItem() const
67 {
68 return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
69 }
70
71 // get first and subsequent selected items, return -1 when no more
72 long GetNextSelected(long item) const
73 { return GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); }
74 long GetFirstSelected() const
75 { return GetNextSelected(-1); }
76
77 // return TRUE if the item is selected
78 bool IsSelected(long index)
79 { return GetItemState(index, wxLIST_STATE_SELECTED) != 0; }
80
81 // columns
82 // -------
83
84 void SetColumnImage(int col, int image)
85 {
86 wxListItem item;
87 item.SetMask(wxLIST_MASK_IMAGE);
88 item.SetImage(image);
89 SetColumn(col, item);
90 }
91
92 void ClearColumnImage(int col) { SetColumnImage(col, -1); }
93
94 private:
95 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListView)
96 };
97
98 #endif // wxUSE_LISTCTRL
99
100 #endif
101 // _WX_LISTCTRL_H_BASE_