1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDataViewCtrl base classes
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DATAVIEW_H_BASE_
13 #define _WX_DATAVIEW_H_BASE_
17 #if wxUSE_DATAVIEWCTRL
19 #include "wx/control.h"
20 #include "wx/textctrl.h"
21 #include "wx/bitmap.h"
22 #include "wx/variant.h"
24 // ----------------------------------------------------------------------------
25 // wxDataViewCtrl flags
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
29 // wxDataViewCtrl globals
30 // ----------------------------------------------------------------------------
32 class WXDLLIMPEXP_CORE wxDataViewCtrl
;
33 class WXDLLIMPEXP_CORE wxDataViewColumn
;
34 class WXDLLIMPEXP_CORE wxDataViewCell
;
36 extern WXDLLEXPORT_DATA(const wxChar
) wxDataViewCtrlNameStr
[];
38 // ---------------------------------------------------------
40 // ---------------------------------------------------------
42 class wxDataViewModel
: public wxObject
46 virtual ~wxDataViewModel() { }
49 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewModel
)
52 // ---------------------------------------------------------
53 // wxDataViewListModelNotifier
54 // ---------------------------------------------------------
56 class wxDataViewListModelNotifier
59 wxDataViewListModelNotifier() { }
60 virtual ~wxDataViewListModelNotifier() { }
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;
71 // ---------------------------------------------------------
72 // wxDataViewListModel
73 // ---------------------------------------------------------
75 class wxDataViewListModel
: public wxDataViewModel
78 wxDataViewListModel();
79 virtual ~wxDataViewListModel();
81 virtual size_t GetNumberOfRows() = 0;
82 virtual size_t GetNumberOfCols() = 0;
83 // as reported by wxVariant
84 virtual wxString
GetColType( size_t col
) = 0;
85 virtual wxVariant
GetValue( size_t col
, size_t row
) = 0;
87 // delegated notifiers
90 bool RowInserted( size_t before
);
91 bool RowDeleted( size_t row
);
92 bool RowChanged( size_t row
);
93 bool ValueChanged( size_t row
, size_t col
);
96 void SetNotifier( wxDataViewListModelNotifier
*notifier
);
97 wxDataViewListModelNotifier
* GetNotifier();
100 wxDataViewListModelNotifier
*m_notifier
;
103 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel
)
106 // ---------------------------------------------------------
107 // wxDataViewCellBase
108 // ---------------------------------------------------------
110 enum wxDataViewCellMode
112 wxDATAVIEW_CELL_INERT
,
113 wxDATAVIEW_CELL_ACTIVATABLE
,
114 wxDATAVIEW_CELL_EDITABLE
117 enum wxDataViewCellRenderState
119 wxDATAVIEW_CELL_SELECTED
= 1,
120 wxDATAVIEW_CELL_PRELIT
= 2,
121 wxDATAVIEW_CELL_INSENSITIVE
= 4,
122 wxDATAVIEW_CELL_FOCUSED
= 8
125 class wxDataViewCellBase
: public wxObject
128 wxDataViewCellBase( const wxString
&varianttype
, wxDataViewCellMode mode
= wxDATAVIEW_CELL_INERT
);
130 virtual bool SetValue( const wxVariant
&value
) { return true; }
131 virtual bool GetValue( wxVariant
&value
) { return true; }
132 virtual bool BeginEdit() { return true; }
133 virtual bool EndEdit() { return true; }
135 virtual bool Render( wxRect cell
, wxRect exposed
, wxDC
*dc
, int state
) { return true; }
137 void SetOwner( wxDataViewColumn
*owner
) { m_owner
= owner
; }
138 wxDataViewColumn
* GetOwner() { return m_owner
; }
141 wxDataViewCellMode m_mode
;
142 wxString m_variantType
;
143 wxDataViewColumn
*m_owner
;
146 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCellBase
)
149 // ---------------------------------------------------------
150 // wxDataViewColumnBase
151 // ---------------------------------------------------------
153 enum wxDataViewColumnFlags
155 wxDATAVIEW_COL_RESIZABLE
= 1,
156 wxDATAVIEW_COL_SORTABLE
= 2,
157 wxDATAVIEW_COL_HIDDEN
= 4
160 class wxDataViewColumnBase
: public wxObject
163 wxDataViewColumnBase( const wxString
&title
, wxDataViewCell
*cell
, size_t model_column
, int flags
= 0 );
164 ~wxDataViewColumnBase();
166 virtual void SetTitle( const wxString
&title
);
167 virtual wxString
GetTitle();
169 wxDataViewCell
* GetCell() { return m_cell
; }
171 size_t GetModelColumn() { return m_model_column
; }
173 void SetOwner( wxDataViewCtrl
*owner
) { m_owner
= owner
; }
174 wxDataViewCtrl
*GetOwner() { return m_owner
; }
177 wxDataViewCtrl
*m_ctrl
;
178 wxDataViewCell
*m_cell
;
182 wxDataViewCtrl
*m_owner
;
185 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumnBase
)
188 // ---------------------------------------------------------
189 // wxDataViewCtrlBase
190 // ---------------------------------------------------------
192 class wxDataViewCtrlBase
: public wxControl
195 wxDataViewCtrlBase();
196 ~wxDataViewCtrlBase();
198 virtual bool AssociateModel( wxDataViewListModel
*model
);
199 wxDataViewListModel
* GetModel();
201 virtual bool AppendStringColumn( const wxString
&label
, size_t model_column
);
202 virtual bool AppendColumn( wxDataViewColumn
*col
);
203 virtual size_t GetNumberOfColumns();
204 virtual bool DeleteColumn( size_t pos
);
205 virtual bool ClearColumns();
206 virtual wxDataViewColumn
* GetColumn( size_t pos
);
209 wxDataViewListModel
*m_model
;
213 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase
)
216 #if defined(__WXGTK20__)
217 #include "wx/gtk/dataview.h"
218 #elif defined(__WXMAC__)
219 #include "wx/mac/dataview.h"
221 #include "wx/generic/dataview.h"
224 #endif // wxUSE_DATAVIEWCTRL
227 // _WX_DATAVIEW_H_BASE_