]> git.saurik.com Git - wxWidgets.git/blame - include/wx/dataview.h
Added stubs for variaous tests.
[wxWidgets.git] / include / wx / dataview.h
CommitLineData
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
8f850e28
RR
32class WXDLLIMPEXP_CORE wxDataViewModel;
33class WXDLLIMPEXP_CORE wxDataViewListModel;
fa28826d
RR
34class WXDLLIMPEXP_CORE wxDataViewCtrl;
35class WXDLLIMPEXP_CORE wxDataViewColumn;
6842a71a 36class WXDLLIMPEXP_CORE wxDataViewCell;
fa28826d 37
63ec432b 38extern WXDLLEXPORT_DATA(const wxChar) wxDataViewCtrlNameStr[];
bcd846ea 39
239eaa41
RR
40// ---------------------------------------------------------
41// wxDataViewModel
42// ---------------------------------------------------------
43
44class wxDataViewModel: public wxObject
45{
46public:
47 wxDataViewModel() { }
48 virtual ~wxDataViewModel() { }
49
50protected:
260b9be7 51 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel)
239eaa41
RR
52};
53
54// ---------------------------------------------------------
55// wxDataViewListModelNotifier
56// ---------------------------------------------------------
57
8f850e28
RR
58
59class wxDataViewListModelNotifier: public wxObject
239eaa41
RR
60{
61public:
62 wxDataViewListModelNotifier() { }
63 virtual ~wxDataViewListModelNotifier() { }
64
65 virtual bool RowAppended() = 0;
66 virtual bool RowPrepended() = 0;
67 virtual bool RowInserted( size_t before ) = 0;
68 virtual bool RowDeleted( size_t row ) = 0;
69 virtual bool RowChanged( size_t row ) = 0;
b5d777c7 70 virtual bool ValueChanged( size_t col, size_t row ) = 0;
239eaa41 71 virtual bool Cleared() = 0;
8f850e28
RR
72
73 void SetOwner( wxDataViewListModel *owner ) { m_owner = owner; }
74 wxDataViewListModel *GetOwner() { return m_owner; }
75
76private:
77 wxDataViewListModel *m_owner;
64ffb888 78};
239eaa41
RR
79
80// ---------------------------------------------------------
81// wxDataViewListModel
82// ---------------------------------------------------------
83
8f850e28
RR
84class wxDataViewViewingColumn: public wxObject
85{
86public:
87 wxDataViewViewingColumn( wxDataViewColumn *view_column, size_t model_column )
88 {
89 m_viewColumn = view_column;
90 m_modelColumn = model_column;
91 }
92
93 wxDataViewColumn *m_viewColumn;
94 size_t m_modelColumn;
95};
96
239eaa41
RR
97class wxDataViewListModel: public wxDataViewModel
98{
99public:
100 wxDataViewListModel();
101 virtual ~wxDataViewListModel();
102
103 virtual size_t GetNumberOfRows() = 0;
104 virtual size_t GetNumberOfCols() = 0;
a7f61f76 105 // return type as reported by wxVariant
239eaa41 106 virtual wxString GetColType( size_t col ) = 0;
a7f61f76 107 // get value into a wxVariant
239eaa41 108 virtual wxVariant GetValue( size_t col, size_t row ) = 0;
a7f61f76
RR
109 // set value, call ValueChanged() afterwards!
110 virtual bool SetValue( wxVariant &variant, size_t col, size_t row ) = 0;
239eaa41
RR
111
112 // delegated notifiers
8981608c
RR
113 virtual bool RowAppended();
114 virtual bool RowPrepended();
115 virtual bool RowInserted( size_t before );
116 virtual bool RowDeleted( size_t row );
117 virtual bool RowChanged( size_t row );
118 virtual bool ValueChanged( size_t col, size_t row );
119 virtual bool Cleared();
b5d777c7
RR
120
121 // Used internally
8981608c
RR
122 virtual void AddViewingColumn( wxDataViewColumn *view_column, size_t model_column );
123 virtual void RemoveViewingColumn( wxDataViewColumn *column );
239eaa41 124
8f850e28
RR
125 virtual void AddNotifier( wxDataViewListModelNotifier *notifier );
126 virtual void RemoveNotifier( wxDataViewListModelNotifier *notifier );
239eaa41 127
8f850e28
RR
128 wxList m_notifiers;
129 wxList m_viewingColumns;
239eaa41
RR
130
131protected:
260b9be7 132 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
239eaa41
RR
133};
134
8981608c
RR
135// ---------------------------------------------------------
136// wxDataViewSortedListModel
137// ---------------------------------------------------------
138
139typedef int (wxCALLBACK *wxDataViewListModelCompare)
140 (size_t row1, size_t row2, size_t col, wxDataViewListModel* model );
141
142WX_DEFINE_SORTED_EXPORTED_ARRAY_SIZE_T(size_t, wxDataViewSortedIndexArray );
143
144class wxDataViewSortedListModel: public wxDataViewListModel
145{
146public:
147 wxDataViewSortedListModel( wxDataViewListModel *child );
148 virtual ~wxDataViewSortedListModel();
149
150 virtual size_t GetNumberOfRows();
151 virtual size_t GetNumberOfCols();
152 // return type as reported by wxVariant
153 virtual wxString GetColType( size_t col );
154 // get value into a wxVariant
155 virtual wxVariant GetValue( size_t col, size_t row );
156 // set value, call ValueChanged() afterwards!
157 virtual bool SetValue( wxVariant &variant, size_t col, size_t row );
158
159 // delegated notifiers
160 virtual bool RowAppended();
161 virtual bool RowPrepended();
162 virtual bool RowInserted( size_t before );
163 virtual bool RowDeleted( size_t row );
164 virtual bool RowChanged( size_t row );
165 virtual bool ValueChanged( size_t col, size_t row );
166 virtual bool Cleared();
167
8f850e28
RR
168 virtual void Resort();
169
8981608c
RR
170private:
171 wxDataViewListModel *m_child;
172 wxDataViewSortedIndexArray m_array;
173
174protected:
175 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewSortedListModel)
176};
177
fa28826d 178// ---------------------------------------------------------
6842a71a 179// wxDataViewCellBase
fa28826d
RR
180// ---------------------------------------------------------
181
6842a71a 182enum wxDataViewCellMode
fa28826d 183{
6842a71a
RR
184 wxDATAVIEW_CELL_INERT,
185 wxDATAVIEW_CELL_ACTIVATABLE,
186 wxDATAVIEW_CELL_EDITABLE
fa28826d
RR
187};
188
6842a71a
RR
189enum wxDataViewCellRenderState
190{
191 wxDATAVIEW_CELL_SELECTED = 1,
192 wxDATAVIEW_CELL_PRELIT = 2,
193 wxDATAVIEW_CELL_INSENSITIVE = 4,
194 wxDATAVIEW_CELL_FOCUSED = 8
195};
196
197class wxDataViewCellBase: public wxObject
198{
199public:
200 wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
201
202 virtual bool SetValue( const wxVariant &value ) { return true; }
203 virtual bool GetValue( wxVariant &value ) { return true; }
a7f61f76 204 virtual bool Validate( wxVariant &value ) { return true; }
6842a71a 205
e152afc3 206 wxString GetVariantType() { return m_variantType; }
6842a71a
RR
207
208 void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; }
209 wxDataViewColumn* GetOwner() { return m_owner; }
210
a7f61f76 211protected:
6842a71a
RR
212 wxDataViewCellMode m_mode;
213 wxString m_variantType;
214 wxDataViewColumn *m_owner;
215
216protected:
217 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCellBase)
218};
219
220// ---------------------------------------------------------
221// wxDataViewColumnBase
222// ---------------------------------------------------------
223
fa28826d
RR
224enum wxDataViewColumnFlags
225{
226 wxDATAVIEW_COL_RESIZABLE = 1,
227 wxDATAVIEW_COL_SORTABLE = 2,
228 wxDATAVIEW_COL_HIDDEN = 4
229};
230
231class wxDataViewColumnBase: public wxObject
232{
233public:
6842a71a
RR
234 wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags = 0 );
235 ~wxDataViewColumnBase();
fa28826d
RR
236
237 virtual void SetTitle( const wxString &title );
238 virtual wxString GetTitle();
6842a71a
RR
239
240 wxDataViewCell* GetCell() { return m_cell; }
241
242 size_t GetModelColumn() { return m_model_column; }
243
244 void SetOwner( wxDataViewCtrl *owner ) { m_owner = owner; }
245 wxDataViewCtrl *GetOwner() { return m_owner; }
fa28826d
RR
246
247private:
248 wxDataViewCtrl *m_ctrl;
6842a71a
RR
249 wxDataViewCell *m_cell;
250 int m_model_column;
fa28826d
RR
251 int m_flags;
252 wxString m_title;
6842a71a 253 wxDataViewCtrl *m_owner;
fa28826d
RR
254
255protected:
256 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase)
257};
258
239eaa41
RR
259// ---------------------------------------------------------
260// wxDataViewCtrlBase
261// ---------------------------------------------------------
262
263class wxDataViewCtrlBase: public wxControl
264{
265public:
266 wxDataViewCtrlBase();
267 ~wxDataViewCtrlBase();
239eaa41 268
6e2e590f
RR
269 virtual bool AssociateModel( wxDataViewListModel *model );
270 wxDataViewListModel* GetModel();
239eaa41 271
605c2c4a
RR
272 virtual bool AppendTextColumn( const wxString &label, size_t model_column );
273 virtual bool AppendToggleColumn( const wxString &label, size_t model_column );
ad63bf41 274 virtual bool AppendProgressColumn( const wxString &label, size_t model_column );
4d496ecb 275 virtual bool AppendDateColumn( const wxString &label, size_t model_column );
fa28826d
RR
276 virtual bool AppendColumn( wxDataViewColumn *col );
277 virtual size_t GetNumberOfColumns();
278 virtual bool DeleteColumn( size_t pos );
279 virtual bool ClearColumns();
280 virtual wxDataViewColumn* GetColumn( size_t pos );
281
239eaa41 282private:
6e2e590f 283 wxDataViewListModel *m_model;
fa28826d 284 wxList m_cols;
bcd846ea 285
239eaa41 286protected:
260b9be7 287 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
239eaa41 288};
bcd846ea 289
bcd846ea
RR
290#if defined(__WXGTK20__)
291 #include "wx/gtk/dataview.h"
292#elif defined(__WXMAC__)
293 #include "wx/mac/dataview.h"
294#else
295 #include "wx/generic/dataview.h"
296#endif
297
298#endif // wxUSE_DATAVIEWCTRL
299
300#endif
301 // _WX_DATAVIEW_H_BASE_