]> git.saurik.com Git - wxWidgets.git/blob - src/common/datavcmn.cpp
WinCE friendly wxCheckListBox sample.
[wxWidgets.git] / src / common / datavcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/datavcmn.cpp
3 // Purpose: wxDataViewCtrl base classes and common parts
4 // Author: Robert Roebling
5 // Created: 2006/02/20
6 // RCS-ID: $Id$
7 // Copyright: (c) 2006, Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
13
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/defs.h"
19
20 #if wxUSE_DATAVIEWCTRL
21
22 #include "wx/object.h"
23 #include "wx/dataview.h"
24 #include "wx/log.h"
25 #include "wx/image.h"
26
27 // ---------------------------------------------------------
28 // wxDataViewModel
29 // ---------------------------------------------------------
30
31 IMPLEMENT_ABSTRACT_CLASS(wxDataViewModel, wxObject)
32
33 // ---------------------------------------------------------
34 // wxDataViewListModel
35 // ---------------------------------------------------------
36
37 IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel, wxDataViewModel)
38
39 wxDataViewListModel::wxDataViewListModel()
40 {
41 m_notifier = NULL;
42 }
43
44 wxDataViewListModel::~wxDataViewListModel()
45 {
46 if (m_notifier)
47 delete m_notifier;
48 }
49
50 bool wxDataViewListModel::RowAppended()
51 {
52 if (m_notifier)
53 return m_notifier->RowAppended();
54
55 return false;
56 }
57
58 bool wxDataViewListModel::RowPrepended()
59 {
60 if (m_notifier)
61 return m_notifier->RowPrepended();
62
63 return false;
64 }
65
66 bool wxDataViewListModel::RowInserted( size_t before )
67 {
68 if (m_notifier)
69 return m_notifier->RowInserted( before );
70
71 return false;
72 }
73
74 bool wxDataViewListModel::RowDeleted( size_t row )
75 {
76 if (m_notifier)
77 return m_notifier->RowDeleted( row );
78
79 return false;
80 }
81
82 bool wxDataViewListModel::RowChanged( size_t row )
83 {
84 if (m_notifier)
85 return m_notifier->RowChanged( row );
86
87 return false;
88 }
89
90 bool wxDataViewListModel::ValueChanged( size_t col, size_t row )
91 {
92 if (m_notifier)
93 return m_notifier->ValueChanged( col, row );
94
95 return false;
96 }
97
98 bool wxDataViewListModel::Cleared()
99 {
100 if (m_notifier)
101 return m_notifier->Cleared();
102
103 return false;
104 }
105
106 void wxDataViewListModel::SetNotifier( wxDataViewListModelNotifier *notifier )
107 {
108 if (m_notifier)
109 delete m_notifier;
110
111 m_notifier = notifier;
112 }
113
114 wxDataViewListModelNotifier* wxDataViewListModel::GetNotifier()
115 {
116 return m_notifier;
117 }
118
119 // ---------------------------------------------------------
120 // wxDataViewCellBase
121 // ---------------------------------------------------------
122
123 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCellBase, wxObject)
124
125 wxDataViewCellBase::wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode )
126 {
127 m_variantType = varianttype;
128 m_mode = mode;
129 }
130
131 // ---------------------------------------------------------
132 // wxDataViewColumnBase
133 // ---------------------------------------------------------
134
135 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
136
137 wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags)
138 {
139 m_cell = cell;
140 m_model_column = model_column;
141 m_flags = flags;
142 m_title = title;
143 m_owner = NULL;
144 m_cell->SetOwner( (wxDataViewColumn*) this );
145 }
146
147 wxDataViewColumnBase::~wxDataViewColumnBase()
148 {
149 if (m_cell)
150 delete m_cell;
151 }
152
153 void wxDataViewColumnBase::SetTitle( const wxString &title )
154 {
155 m_title = title;
156 }
157
158 wxString wxDataViewColumnBase::GetTitle()
159 {
160 return m_title;
161 }
162
163 // ---------------------------------------------------------
164 // wxDataViewCtrlBase
165 // ---------------------------------------------------------
166
167 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
168
169 wxDataViewCtrlBase::wxDataViewCtrlBase()
170 {
171 m_model = NULL;
172 m_cols.DeleteContents( true );
173 }
174
175 wxDataViewCtrlBase::~wxDataViewCtrlBase()
176 {
177 if (m_model)
178 delete m_model;
179 }
180
181 bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel *model )
182 {
183 if (m_model)
184 delete m_model;
185
186 m_model = model;
187
188 return true;
189 }
190
191 wxDataViewListModel* wxDataViewCtrlBase::GetModel()
192 {
193 return m_model;
194 }
195
196 bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, size_t model_column )
197 {
198 return AppendColumn( new wxDataViewColumn( label, new wxDataViewTextCell(), model_column ) );
199 }
200
201 bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, size_t model_column )
202 {
203 return AppendColumn( new wxDataViewColumn( label, new wxDataViewToggleCell(), model_column ) );
204 }
205
206 bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, size_t model_column )
207 {
208 return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressCell(), model_column ) );
209 }
210
211 bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
212 {
213 m_cols.Append( (wxObject*) col );
214 col->SetOwner( (wxDataViewCtrl*) this );
215 return true;
216 }
217
218 size_t wxDataViewCtrlBase::GetNumberOfColumns()
219 {
220 return m_cols.GetCount();
221 }
222
223 bool wxDataViewCtrlBase::DeleteColumn( size_t pos )
224 {
225 return false;
226 }
227
228 bool wxDataViewCtrlBase::ClearColumns()
229 {
230 return false;
231 }
232
233 wxDataViewColumn* wxDataViewCtrlBase::GetColumn( size_t pos )
234 {
235 return (wxDataViewColumn*) m_cols[ pos ];
236 }
237
238 #endif