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