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