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