]> git.saurik.com Git - wxWidgets.git/blob - include/wx/dataview.h
Added wxDataViewColumn
[wxWidgets.git] / include / wx / dataview.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/dataview.h
3 // Purpose: wxDataViewCtrl base classes
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 08.01.06
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DATAVIEW_H_BASE_
13 #define _WX_DATAVIEW_H_BASE_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_DATAVIEWCTRL
18
19 #include "wx/control.h"
20 #include "wx/textctrl.h"
21 #include "wx/bitmap.h"
22 #include "wx/variant.h"
23
24 // ----------------------------------------------------------------------------
25 // wxDataViewCtrl flags
26 // ----------------------------------------------------------------------------
27
28 // ----------------------------------------------------------------------------
29 // wxDataViewCtrl globals
30 // ----------------------------------------------------------------------------
31
32 class WXDLLIMPEXP_CORE wxDataViewCtrl;
33 class WXDLLIMPEXP_CORE wxDataViewColumn;
34
35 extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
36
37 // ---------------------------------------------------------
38 // wxDataViewModel
39 // ---------------------------------------------------------
40
41 class wxDataViewModel: public wxObject
42 {
43 public:
44 wxDataViewModel() { }
45 virtual ~wxDataViewModel() { }
46
47 protected:
48 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel)
49 };
50
51 // ---------------------------------------------------------
52 // wxDataViewListModelNotifier
53 // ---------------------------------------------------------
54
55 class wxDataViewListModelNotifier
56 {
57 public:
58 wxDataViewListModelNotifier() { }
59 virtual ~wxDataViewListModelNotifier() { }
60
61 virtual bool RowAppended() = 0;
62 virtual bool RowPrepended() = 0;
63 virtual bool RowInserted( size_t before ) = 0;
64 virtual bool RowDeleted( size_t row ) = 0;
65 virtual bool RowChanged( size_t row ) = 0;
66 virtual bool ValueChanged( size_t row, size_t col ) = 0;
67 virtual bool Cleared() = 0;
68 };
69
70 // ---------------------------------------------------------
71 // wxDataViewListModel
72 // ---------------------------------------------------------
73
74 class wxDataViewListModel: public wxDataViewModel
75 {
76 public:
77 wxDataViewListModel();
78 virtual ~wxDataViewListModel();
79
80 virtual size_t GetNumberOfRows() = 0;
81 virtual size_t GetNumberOfCols() = 0;
82 // as reported by wxVariant
83 virtual wxString GetColType( size_t col ) = 0;
84 virtual wxVariant GetValue( size_t col, size_t row ) = 0;
85
86 // delegated notifiers
87 bool RowAppended();
88 bool RowPrepended();
89 bool RowInserted( size_t before );
90 bool RowDeleted( size_t row );
91 bool RowChanged( size_t row );
92 bool ValueChanged( size_t row, size_t col );
93 bool Cleared();
94
95 void SetNotifier( wxDataViewListModelNotifier *notifier );
96 wxDataViewListModelNotifier* GetNotifier();
97
98 private:
99 wxDataViewListModelNotifier *m_notifier;
100
101 protected:
102 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
103 };
104
105 // ---------------------------------------------------------
106 // wxDataViewColumn
107 // ---------------------------------------------------------
108
109 enum wxDataViewColumnType
110 {
111 wxDATAVIEW_COL_TEXT,
112 wxDATAVIEW_COL_ICON,
113 wxDATAVIEW_COL_ICONTEXT,
114 wxDATAVIEW_COL_CHECK,
115 wxDATAVIEW_COL_DATETIME,
116 wxDATAVIEW_COL_PROGRESS,
117 wxDATAVIEW_COL_CHOICE,
118 wxDATAVIEW_COL_CUSTOM
119 };
120
121 enum wxDataViewColumnFlags
122 {
123 wxDATAVIEW_COL_RESIZABLE = 1,
124 wxDATAVIEW_COL_SORTABLE = 2,
125 wxDATAVIEW_COL_HIDDEN = 4
126 };
127
128 class wxDataViewColumnBase: public wxObject
129 {
130 public:
131 wxDataViewColumnBase( const wxString &title, wxDataViewCtrl *ctrl,
132 wxDataViewColumnType kind, int flags = 0 );
133
134 virtual void SetTitle( const wxString &title );
135 virtual wxString GetTitle();
136
137 private:
138 wxDataViewCtrl *m_ctrl;
139 wxDataViewColumnType m_kind;
140 int m_flags;
141 wxString m_title;
142
143 protected:
144 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
145 };
146
147 // ---------------------------------------------------------
148 // wxDataViewCtrlBase
149 // ---------------------------------------------------------
150
151 class wxDataViewCtrlBase: public wxControl
152 {
153 public:
154 wxDataViewCtrlBase();
155 ~wxDataViewCtrlBase();
156
157
158 virtual bool AssociateModel( wxDataViewListModel *model );
159 wxDataViewListModel* GetModel();
160
161 virtual bool AppendStringColumn( const wxString &label );
162 virtual bool AppendColumn( wxDataViewColumn *col );
163 virtual size_t GetNumberOfColumns();
164 virtual bool DeleteColumn( size_t pos );
165 virtual bool ClearColumns();
166 virtual wxDataViewColumn* GetColumn( size_t pos );
167
168 private:
169 wxDataViewListModel *m_model;
170 wxList m_cols;
171
172 protected:
173 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
174 };
175
176 #if defined(__WXGTK20__)
177 #include "wx/gtk/dataview.h"
178 #elif defined(__WXMAC__)
179 #include "wx/mac/dataview.h"
180 #else
181 #include "wx/generic/dataview.h"
182 #endif
183
184 #endif // wxUSE_DATAVIEWCTRL
185
186 #endif
187 // _WX_DATAVIEW_H_BASE_