]>
Commit | Line | Data |
---|---|---|
bcd846ea RR |
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 | ||
239eaa41 RR |
19 | #include "wx/control.h" |
20 | #include "wx/textctrl.h" | |
21 | #include "wx/bitmap.h" | |
64ffb888 | 22 | #include "wx/variant.h" |
239eaa41 | 23 | |
bcd846ea RR |
24 | // ---------------------------------------------------------------------------- |
25 | // wxDataViewCtrl flags | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
239eaa41 RR |
28 | // ---------------------------------------------------------------------------- |
29 | // wxDataViewCtrl globals | |
30 | // ---------------------------------------------------------------------------- | |
bcd846ea | 31 | |
fa28826d RR |
32 | class WXDLLIMPEXP_CORE wxDataViewCtrl; |
33 | class WXDLLIMPEXP_CORE wxDataViewColumn; | |
6842a71a | 34 | class WXDLLIMPEXP_CORE wxDataViewCell; |
fa28826d | 35 | |
63ec432b | 36 | extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[]; |
bcd846ea | 37 | |
239eaa41 RR |
38 | // --------------------------------------------------------- |
39 | // wxDataViewModel | |
40 | // --------------------------------------------------------- | |
41 | ||
42 | class wxDataViewModel: public wxObject | |
43 | { | |
44 | public: | |
45 | wxDataViewModel() { } | |
46 | virtual ~wxDataViewModel() { } | |
47 | ||
48 | protected: | |
260b9be7 | 49 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel) |
239eaa41 RR |
50 | }; |
51 | ||
52 | // --------------------------------------------------------- | |
53 | // wxDataViewListModelNotifier | |
54 | // --------------------------------------------------------- | |
55 | ||
56 | class wxDataViewListModelNotifier | |
57 | { | |
58 | public: | |
59 | wxDataViewListModelNotifier() { } | |
60 | virtual ~wxDataViewListModelNotifier() { } | |
61 | ||
62 | virtual bool RowAppended() = 0; | |
63 | virtual bool RowPrepended() = 0; | |
64 | virtual bool RowInserted( size_t before ) = 0; | |
65 | virtual bool RowDeleted( size_t row ) = 0; | |
66 | virtual bool RowChanged( size_t row ) = 0; | |
67 | virtual bool ValueChanged( size_t row, size_t col ) = 0; | |
68 | virtual bool Cleared() = 0; | |
64ffb888 | 69 | }; |
239eaa41 RR |
70 | |
71 | // --------------------------------------------------------- | |
72 | // wxDataViewListModel | |
73 | // --------------------------------------------------------- | |
74 | ||
75 | class wxDataViewListModel: public wxDataViewModel | |
76 | { | |
77 | public: | |
78 | wxDataViewListModel(); | |
79 | virtual ~wxDataViewListModel(); | |
80 | ||
81 | virtual size_t GetNumberOfRows() = 0; | |
82 | virtual size_t GetNumberOfCols() = 0; | |
a7f61f76 | 83 | // return type as reported by wxVariant |
239eaa41 | 84 | virtual wxString GetColType( size_t col ) = 0; |
a7f61f76 | 85 | // get value into a wxVariant |
239eaa41 | 86 | virtual wxVariant GetValue( size_t col, size_t row ) = 0; |
a7f61f76 RR |
87 | // set value, call ValueChanged() afterwards! |
88 | virtual bool SetValue( wxVariant &variant, size_t col, size_t row ) = 0; | |
239eaa41 RR |
89 | |
90 | // delegated notifiers | |
91 | bool RowAppended(); | |
92 | bool RowPrepended(); | |
93 | bool RowInserted( size_t before ); | |
94 | bool RowDeleted( size_t row ); | |
95 | bool RowChanged( size_t row ); | |
a7f61f76 | 96 | bool ValueChanged( size_t col, size_t row ); |
239eaa41 RR |
97 | bool Cleared(); |
98 | ||
99 | void SetNotifier( wxDataViewListModelNotifier *notifier ); | |
100 | wxDataViewListModelNotifier* GetNotifier(); | |
101 | ||
102 | private: | |
103 | wxDataViewListModelNotifier *m_notifier; | |
104 | ||
105 | protected: | |
260b9be7 | 106 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel) |
239eaa41 RR |
107 | }; |
108 | ||
fa28826d | 109 | // --------------------------------------------------------- |
6842a71a | 110 | // wxDataViewCellBase |
fa28826d RR |
111 | // --------------------------------------------------------- |
112 | ||
6842a71a | 113 | enum wxDataViewCellMode |
fa28826d | 114 | { |
6842a71a RR |
115 | wxDATAVIEW_CELL_INERT, |
116 | wxDATAVIEW_CELL_ACTIVATABLE, | |
117 | wxDATAVIEW_CELL_EDITABLE | |
fa28826d RR |
118 | }; |
119 | ||
6842a71a RR |
120 | enum wxDataViewCellRenderState |
121 | { | |
122 | wxDATAVIEW_CELL_SELECTED = 1, | |
123 | wxDATAVIEW_CELL_PRELIT = 2, | |
124 | wxDATAVIEW_CELL_INSENSITIVE = 4, | |
125 | wxDATAVIEW_CELL_FOCUSED = 8 | |
126 | }; | |
127 | ||
128 | class wxDataViewCellBase: public wxObject | |
129 | { | |
130 | public: | |
131 | wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT ); | |
132 | ||
133 | virtual bool SetValue( const wxVariant &value ) { return true; } | |
134 | virtual bool GetValue( wxVariant &value ) { return true; } | |
a7f61f76 | 135 | virtual bool Validate( wxVariant &value ) { return true; } |
6842a71a RR |
136 | virtual bool BeginEdit() { return true; } |
137 | virtual bool EndEdit() { return true; } | |
138 | ||
139 | virtual bool Render( wxRect cell, wxRect exposed, wxDC *dc, int state ) { return true; } | |
140 | ||
141 | void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } | |
142 | wxDataViewColumn* GetOwner() { return m_owner; } | |
143 | ||
6090c7d3 RR |
144 | wxString GetVariantType() { return m_variantType; } |
145 | ||
a7f61f76 | 146 | protected: |
6842a71a RR |
147 | wxDataViewCellMode m_mode; |
148 | wxString m_variantType; | |
149 | wxDataViewColumn *m_owner; | |
150 | ||
151 | protected: | |
152 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCellBase) | |
153 | }; | |
154 | ||
155 | // --------------------------------------------------------- | |
156 | // wxDataViewColumnBase | |
157 | // --------------------------------------------------------- | |
158 | ||
fa28826d RR |
159 | enum wxDataViewColumnFlags |
160 | { | |
161 | wxDATAVIEW_COL_RESIZABLE = 1, | |
162 | wxDATAVIEW_COL_SORTABLE = 2, | |
163 | wxDATAVIEW_COL_HIDDEN = 4 | |
164 | }; | |
165 | ||
166 | class wxDataViewColumnBase: public wxObject | |
167 | { | |
168 | public: | |
6842a71a RR |
169 | wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 ); |
170 | ~wxDataViewColumnBase(); | |
fa28826d RR |
171 | |
172 | virtual void SetTitle( const wxString &title ); | |
173 | virtual wxString GetTitle(); | |
6842a71a RR |
174 | |
175 | wxDataViewCell* GetCell() { return m_cell; } | |
176 | ||
177 | size_t GetModelColumn() { return m_model_column; } | |
178 | ||
179 | void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; } | |
180 | wxDataViewCtrl *GetOwner() { return m_owner; } | |
fa28826d RR |
181 | |
182 | private: | |
183 | wxDataViewCtrl *m_ctrl; | |
6842a71a RR |
184 | wxDataViewCell *m_cell; |
185 | int m_model_column; | |
fa28826d RR |
186 | int m_flags; |
187 | wxString m_title; | |
6842a71a | 188 | wxDataViewCtrl *m_owner; |
fa28826d RR |
189 | |
190 | protected: | |
191 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase) | |
192 | }; | |
193 | ||
239eaa41 RR |
194 | // --------------------------------------------------------- |
195 | // wxDataViewCtrlBase | |
196 | // --------------------------------------------------------- | |
197 | ||
198 | class wxDataViewCtrlBase: public wxControl | |
199 | { | |
200 | public: | |
201 | wxDataViewCtrlBase(); | |
202 | ~wxDataViewCtrlBase(); | |
239eaa41 | 203 | |
6e2e590f RR |
204 | virtual bool AssociateModel( wxDataViewListModel *model ); |
205 | wxDataViewListModel* GetModel(); | |
239eaa41 | 206 | |
6842a71a | 207 | virtual bool AppendStringColumn( const wxString &label, size_t model_column ); |
fa28826d RR |
208 | virtual bool AppendColumn( wxDataViewColumn *col ); |
209 | virtual size_t GetNumberOfColumns(); | |
210 | virtual bool DeleteColumn( size_t pos ); | |
211 | virtual bool ClearColumns(); | |
212 | virtual wxDataViewColumn* GetColumn( size_t pos ); | |
213 | ||
239eaa41 | 214 | private: |
6e2e590f | 215 | wxDataViewListModel *m_model; |
fa28826d | 216 | wxList m_cols; |
bcd846ea | 217 | |
239eaa41 | 218 | protected: |
260b9be7 | 219 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase) |
239eaa41 | 220 | }; |
bcd846ea | 221 | |
bcd846ea RR |
222 | #if defined(__WXGTK20__) |
223 | #include "wx/gtk/dataview.h" | |
224 | #elif defined(__WXMAC__) | |
225 | #include "wx/mac/dataview.h" | |
226 | #else | |
227 | #include "wx/generic/dataview.h" | |
228 | #endif | |
229 | ||
230 | #endif // wxUSE_DATAVIEWCTRL | |
231 | ||
232 | #endif | |
233 | // _WX_DATAVIEW_H_BASE_ |