]>
Commit | Line | Data |
---|---|---|
239eaa41 RR |
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 | ||
8045736e RR |
18 | #if wxUSE_DATAVIEWCTRL |
19 | ||
e7445ff8 PC |
20 | #include "wx/dataview.h" |
21 | ||
f554a14b | 22 | #ifndef WX_PRECOMP |
f554a14b WS |
23 | #include "wx/log.h" |
24 | #endif | |
25 | ||
4a2e5ee8 | 26 | const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl"); |
239eaa41 | 27 | |
239eaa41 | 28 | |
f554a14b | 29 | // --------------------------------------------------------- |
239eaa41 | 30 | // wxDataViewListModel |
f554a14b | 31 | // --------------------------------------------------------- |
239eaa41 | 32 | |
e0062c04 | 33 | wxDataViewModel::wxDataViewModel() |
239eaa41 | 34 | { |
8f850e28 | 35 | m_notifiers.DeleteContents( true ); |
239eaa41 RR |
36 | } |
37 | ||
e0062c04 | 38 | bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) |
239eaa41 | 39 | { |
8f850e28 RR |
40 | bool ret = true; |
41 | ||
85e5bb6a | 42 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
43 | while (node) |
44 | { | |
e0062c04 RR |
45 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
46 | if (!notifier->ItemAdded( parent, item )) | |
8f850e28 RR |
47 | ret = false; |
48 | node = node->GetNext(); | |
49 | } | |
f554a14b | 50 | |
8f850e28 | 51 | return ret; |
239eaa41 RR |
52 | } |
53 | ||
e0062c04 | 54 | bool wxDataViewModel::ItemDeleted( const wxDataViewItem &item ) |
239eaa41 | 55 | { |
8f850e28 RR |
56 | bool ret = true; |
57 | ||
85e5bb6a | 58 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
59 | while (node) |
60 | { | |
e0062c04 RR |
61 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
62 | if (!notifier->ItemDeleted( item )) | |
8f850e28 RR |
63 | ret = false; |
64 | node = node->GetNext(); | |
65 | } | |
f554a14b | 66 | |
8f850e28 | 67 | return ret; |
239eaa41 RR |
68 | } |
69 | ||
e0062c04 | 70 | bool wxDataViewModel::ItemChanged( const wxDataViewItem &item ) |
239eaa41 | 71 | { |
8f850e28 RR |
72 | bool ret = true; |
73 | ||
85e5bb6a | 74 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
75 | while (node) |
76 | { | |
e0062c04 RR |
77 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
78 | if (!notifier->ItemChanged( item )) | |
8f850e28 RR |
79 | ret = false; |
80 | node = node->GetNext(); | |
81 | } | |
f554a14b | 82 | |
8f850e28 | 83 | return ret; |
239eaa41 RR |
84 | } |
85 | ||
e0062c04 | 86 | bool wxDataViewModel::ValueChanged( const wxDataViewItem &item, unsigned int col ) |
239eaa41 | 87 | { |
8f850e28 | 88 | bool ret = true; |
b5d777c7 | 89 | |
85e5bb6a | 90 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
b5d777c7 RR |
91 | while (node) |
92 | { | |
e0062c04 RR |
93 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
94 | if (!notifier->ValueChanged( item, col )) | |
8f850e28 | 95 | ret = false; |
b5d777c7 RR |
96 | node = node->GetNext(); |
97 | } | |
f554a14b | 98 | |
b5d777c7 | 99 | return ret; |
239eaa41 RR |
100 | } |
101 | ||
e0062c04 | 102 | bool wxDataViewModel::Cleared() |
4eccd3a1 RR |
103 | { |
104 | bool ret = true; | |
105 | ||
85e5bb6a | 106 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
4eccd3a1 RR |
107 | while (node) |
108 | { | |
e0062c04 | 109 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
8f850e28 RR |
110 | if (!notifier->Cleared()) |
111 | ret = false; | |
112 | node = node->GetNext(); | |
113 | } | |
f554a14b | 114 | |
8f850e28 | 115 | return ret; |
239eaa41 RR |
116 | } |
117 | ||
e0062c04 | 118 | void wxDataViewModel::AddNotifier( wxDataViewModelNotifier *notifier ) |
239eaa41 | 119 | { |
8f850e28 RR |
120 | m_notifiers.Append( notifier ); |
121 | notifier->SetOwner( this ); | |
239eaa41 RR |
122 | } |
123 | ||
e0062c04 | 124 | void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier ) |
239eaa41 | 125 | { |
8f850e28 | 126 | m_notifiers.DeleteObject( notifier ); |
239eaa41 RR |
127 | } |
128 | ||
f554a14b | 129 | // --------------------------------------------------------- |
baa9ebc4 | 130 | // wxDataViewRendererBase |
f554a14b | 131 | // --------------------------------------------------------- |
6842a71a | 132 | |
baa9ebc4 | 133 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject) |
6842a71a | 134 | |
9861f022 RR |
135 | wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype, |
136 | wxDataViewCellMode WXUNUSED(mode), | |
137 | int WXUNUSED(align) ) | |
6842a71a RR |
138 | { |
139 | m_variantType = varianttype; | |
1e510b1e | 140 | m_editorCtrl = NULL; |
9861f022 RR |
141 | } |
142 | ||
143 | const wxDataViewCtrl* wxDataViewRendererBase::GetView() const | |
144 | { | |
145 | return wx_const_cast(wxDataViewRendererBase*, this)->GetOwner()->GetOwner(); | |
6842a71a | 146 | } |
f554a14b | 147 | |
e0062c04 | 148 | bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect labelRect ) |
1e510b1e | 149 | { |
e0062c04 | 150 | m_item = item; // remember for later |
1e510b1e RR |
151 | |
152 | unsigned int col = GetOwner()->GetModelColumn(); | |
153 | wxVariant value; | |
e0062c04 | 154 | GetOwner()->GetOwner()->GetModel()->GetValue( value, item, col ); |
1e510b1e RR |
155 | |
156 | m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value ); | |
157 | ||
30715fa1 RR |
158 | wxDataViewEditorCtrlEvtHandler *handler = |
159 | new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this ); | |
160 | ||
161 | m_editorCtrl->PushEventHandler( handler ); | |
1e510b1e | 162 | |
30715fa1 RR |
163 | #if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL) |
164 | handler->SetFocusOnIdle(); | |
165 | #else | |
1e510b1e | 166 | m_editorCtrl->SetFocus(); |
30715fa1 RR |
167 | #endif |
168 | ||
1e510b1e RR |
169 | return true; |
170 | } | |
171 | ||
172 | void wxDataViewRendererBase::CancelEditing() | |
173 | { | |
2fa73716 | 174 | wxPendingDelete.Append( m_editorCtrl ); |
1e510b1e RR |
175 | |
176 | GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); | |
2fa73716 RR |
177 | |
178 | // m_editorCtrl->PopEventHandler( true ); | |
1e510b1e RR |
179 | } |
180 | ||
181 | bool wxDataViewRendererBase::FinishEditing() | |
182 | { | |
1e510b1e RR |
183 | wxVariant value; |
184 | GetValueFromEditorCtrl( m_editorCtrl, value ); | |
185 | ||
2fa73716 | 186 | wxPendingDelete.Append( m_editorCtrl ); |
1e510b1e RR |
187 | |
188 | GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); | |
189 | ||
190 | if (!Validate(value)) | |
191 | return false; | |
192 | ||
193 | unsigned int col = GetOwner()->GetModelColumn(); | |
e0062c04 RR |
194 | GetOwner()->GetOwner()->GetModel()->SetValue( value, m_item, col ); |
195 | GetOwner()->GetOwner()->GetModel()->ValueChanged( m_item, col ); | |
1e510b1e | 196 | |
2fa73716 RR |
197 | // m_editorCtrl->PopEventHandler( true ); |
198 | ||
1e510b1e RR |
199 | return true; |
200 | } | |
201 | ||
202 | //----------------------------------------------------------------------------- | |
203 | // wxDataViewEditorCtrlEvtHandler | |
204 | //----------------------------------------------------------------------------- | |
205 | ||
206 | BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler) | |
207 | EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar) | |
208 | EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus) | |
30715fa1 | 209 | EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle) |
1e510b1e RR |
210 | END_EVENT_TABLE() |
211 | ||
212 | wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler( | |
213 | wxControl *editorCtrl, | |
214 | wxDataViewRenderer *owner ) | |
215 | { | |
216 | m_owner = owner; | |
217 | m_editorCtrl = editorCtrl; | |
218 | ||
219 | m_finished = false; | |
220 | } | |
221 | ||
30715fa1 RR |
222 | void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event ) |
223 | { | |
224 | if (m_focusOnIdle) | |
225 | { | |
226 | m_focusOnIdle = false; | |
227 | if (wxWindow::FindFocus() != m_editorCtrl) | |
228 | m_editorCtrl->SetFocus(); | |
229 | } | |
230 | ||
231 | event.Skip(); | |
232 | } | |
233 | ||
1e510b1e RR |
234 | void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event ) |
235 | { | |
236 | switch ( event.m_keyCode ) | |
237 | { | |
238 | case WXK_RETURN: | |
239 | m_finished = true; | |
240 | m_owner->FinishEditing(); | |
241 | break; | |
242 | ||
243 | case WXK_ESCAPE: | |
244 | m_finished = true; | |
245 | m_owner->CancelEditing(); | |
246 | break; | |
247 | ||
248 | default: | |
249 | event.Skip(); | |
250 | } | |
251 | } | |
252 | ||
253 | void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event ) | |
254 | { | |
255 | if (!m_finished) | |
256 | { | |
257 | m_finished = true; | |
258 | m_owner->FinishEditing(); | |
259 | } | |
260 | ||
1e510b1e RR |
261 | event.Skip(); |
262 | } | |
263 | ||
f554a14b | 264 | // --------------------------------------------------------- |
fa28826d | 265 | // wxDataViewColumnBase |
f554a14b | 266 | // --------------------------------------------------------- |
fa28826d RR |
267 | |
268 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject) | |
269 | ||
9861f022 | 270 | wxDataViewColumnBase::wxDataViewColumnBase(const wxString& WXUNUSED(title), |
baa9ebc4 | 271 | wxDataViewRenderer *renderer, |
0a71f9e9 | 272 | unsigned int model_column, |
008b5a66 | 273 | int WXUNUSED(width), |
87f0efe2 | 274 | wxAlignment WXUNUSED(align), |
9861f022 | 275 | int WXUNUSED(flags)) |
fa28826d | 276 | { |
baa9ebc4 | 277 | m_renderer = renderer; |
6842a71a | 278 | m_model_column = model_column; |
6842a71a | 279 | m_owner = NULL; |
baa9ebc4 | 280 | m_renderer->SetOwner( (wxDataViewColumn*) this ); |
9861f022 RR |
281 | |
282 | // NOTE: the wxDataViewColumn's ctor must store the width, align, flags | |
283 | // parameters inside the native control! | |
6842a71a RR |
284 | } |
285 | ||
07a84e7b RR |
286 | wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap, |
287 | wxDataViewRenderer *renderer, | |
288 | unsigned int model_column, | |
289 | int WXUNUSED(width), | |
87f0efe2 | 290 | wxAlignment WXUNUSED(align), |
9861f022 | 291 | int WXUNUSED(flags) ) |
07a84e7b RR |
292 | { |
293 | m_renderer = renderer; | |
294 | m_model_column = model_column; | |
07a84e7b RR |
295 | m_bitmap = bitmap; |
296 | m_owner = NULL; | |
297 | m_renderer->SetOwner( (wxDataViewColumn*) this ); | |
298 | } | |
299 | ||
6842a71a RR |
300 | wxDataViewColumnBase::~wxDataViewColumnBase() |
301 | { | |
baa9ebc4 RR |
302 | if (m_renderer) |
303 | delete m_renderer; | |
fa28826d RR |
304 | } |
305 | ||
9861f022 | 306 | int wxDataViewColumnBase::GetFlags() const |
fa28826d | 307 | { |
9861f022 | 308 | int ret = 0; |
fa28826d | 309 | |
9861f022 RR |
310 | if (IsSortable()) |
311 | ret |= wxDATAVIEW_COL_SORTABLE; | |
312 | if (IsResizeable()) | |
313 | ret |= wxDATAVIEW_COL_RESIZABLE; | |
314 | if (IsHidden()) | |
315 | ret |= wxDATAVIEW_COL_HIDDEN; | |
fa28826d | 316 | |
9861f022 | 317 | return ret; |
07a84e7b RR |
318 | } |
319 | ||
9861f022 | 320 | void wxDataViewColumnBase::SetFlags(int flags) |
07a84e7b | 321 | { |
9861f022 RR |
322 | SetSortable((flags & wxDATAVIEW_COL_SORTABLE) != 0); |
323 | SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0); | |
324 | SetHidden((flags & wxDATAVIEW_COL_HIDDEN) != 0); | |
07a84e7b RR |
325 | } |
326 | ||
1821abd1 | 327 | // --------------------------------------------------------- |
e0062c04 | 328 | // wxDataViewEventModelNotifier |
1821abd1 RR |
329 | // --------------------------------------------------------- |
330 | ||
e0062c04 | 331 | class WXDLLIMPEXP_ADV wxDataViewEventModelNotifier: public wxDataViewModelNotifier |
1821abd1 RR |
332 | { |
333 | public: | |
e0062c04 | 334 | wxDataViewEventModelNotifier( wxDataViewCtrl *ctrl ) { m_ctrl = ctrl; } |
1821abd1 | 335 | |
e0062c04 | 336 | bool SendEvent( wxEventType event_type, const wxDataViewItem &item, unsigned int col = 0 ) |
1821abd1 RR |
337 | { |
338 | wxDataViewEvent event( event_type, m_ctrl->GetId() ); | |
339 | event.SetEventObject( m_ctrl ); | |
340 | event.SetModel( m_ctrl->GetModel() ); | |
e0062c04 | 341 | event.SetItem( item ); |
1821abd1 RR |
342 | event.SetColumn( col ); |
343 | m_ctrl->GetEventHandler()->ProcessEvent( event ); | |
344 | return true; | |
345 | } | |
346 | ||
e0062c04 RR |
347 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) |
348 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED, item ); } | |
349 | virtual bool ItemDeleted( const wxDataViewItem &item ) | |
350 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED, item ); } | |
351 | virtual bool ItemChanged( const wxDataViewItem &item ) | |
352 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED, item ); } | |
353 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) | |
354 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, item, col ); } | |
355 | virtual bool Cleared() | |
356 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, wxDataViewItem(0) ); } | |
1821abd1 RR |
357 | |
358 | private: | |
359 | wxDataViewCtrl *m_ctrl; | |
360 | }; | |
361 | ||
9861f022 | 362 | |
f554a14b | 363 | // --------------------------------------------------------- |
239eaa41 | 364 | // wxDataViewCtrlBase |
f554a14b | 365 | // --------------------------------------------------------- |
239eaa41 RR |
366 | |
367 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl) | |
368 | ||
369 | wxDataViewCtrlBase::wxDataViewCtrlBase() | |
370 | { | |
371 | m_model = NULL; | |
fa28826d | 372 | m_cols.DeleteContents( true ); |
1821abd1 | 373 | m_eventNotifier = NULL; |
239eaa41 RR |
374 | } |
375 | ||
376 | wxDataViewCtrlBase::~wxDataViewCtrlBase() | |
377 | { | |
87f0efe2 RR |
378 | // IMPORTANT: before calling DecRef() on our model (since it may |
379 | // result in a free() call), erase all columns (since | |
380 | // they hold a pointer to our model) | |
381 | m_cols.Clear(); | |
382 | ||
383 | if (m_model) | |
384 | { | |
1821abd1 RR |
385 | if (m_eventNotifier) |
386 | m_model->RemoveNotifier( m_eventNotifier ); | |
387 | m_eventNotifier = NULL; | |
388 | ||
87f0efe2 RR |
389 | m_model->DecRef(); |
390 | m_model = NULL; | |
391 | } | |
239eaa41 RR |
392 | } |
393 | ||
e0062c04 | 394 | bool wxDataViewCtrlBase::AssociateModel( wxDataViewModel *model ) |
239eaa41 | 395 | { |
1821abd1 RR |
396 | if (m_model) |
397 | { | |
398 | if (m_eventNotifier) | |
399 | m_model->RemoveNotifier( m_eventNotifier ); | |
400 | m_eventNotifier = NULL; | |
401 | ||
87f0efe2 | 402 | m_model->DecRef(); // discard old model, if any |
1821abd1 | 403 | } |
87f0efe2 RR |
404 | |
405 | // add our own reference to the new model: | |
239eaa41 | 406 | m_model = model; |
1821abd1 RR |
407 | if (m_model) |
408 | { | |
87f0efe2 | 409 | m_model->IncRef(); |
e0062c04 | 410 | m_eventNotifier = new wxDataViewEventModelNotifier( (wxDataViewCtrl*) this ); |
1821abd1 RR |
411 | m_model->AddNotifier( m_eventNotifier ); |
412 | } | |
f554a14b | 413 | |
239eaa41 RR |
414 | return true; |
415 | } | |
416 | ||
e0062c04 | 417 | wxDataViewModel* wxDataViewCtrlBase::GetModel() |
239eaa41 RR |
418 | { |
419 | return m_model; | |
420 | } | |
421 | ||
1286b7ba | 422 | bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 423 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
fa28826d | 424 | { |
1286b7ba | 425 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
426 | new wxDataViewTextRenderer( wxT("string"), mode, (int)align ), |
427 | model_column, width, align, flags ) ); | |
fa28826d RR |
428 | } |
429 | ||
1286b7ba | 430 | bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 431 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
605c2c4a | 432 | { |
1286b7ba | 433 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
434 | new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ), |
435 | model_column, width, align, flags ) ); | |
605c2c4a RR |
436 | } |
437 | ||
1286b7ba | 438 | bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 439 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
ad63bf41 | 440 | { |
1286b7ba | 441 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
442 | new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ), |
443 | model_column, width, align, flags ) ); | |
ad63bf41 RR |
444 | } |
445 | ||
1286b7ba | 446 | bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 447 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
4d496ecb | 448 | { |
1286b7ba | 449 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
450 | new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ), |
451 | model_column, width, align, flags ) ); | |
4d496ecb RR |
452 | } |
453 | ||
1286b7ba | 454 | bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 455 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 456 | { |
1286b7ba | 457 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
458 | new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ), |
459 | model_column, width, align, flags ) ); | |
07a84e7b RR |
460 | } |
461 | ||
1286b7ba | 462 | bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 463 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 464 | { |
1286b7ba | 465 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
466 | new wxDataViewTextRenderer( wxT("string"), mode, (int)align ), |
467 | model_column, width, align, flags ) ); | |
07a84e7b RR |
468 | } |
469 | ||
1286b7ba | 470 | bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 471 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 472 | { |
1286b7ba | 473 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
474 | new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ), |
475 | model_column, width, align, flags ) ); | |
07a84e7b RR |
476 | } |
477 | ||
1286b7ba | 478 | bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 479 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 480 | { |
1286b7ba | 481 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
482 | new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ), |
483 | model_column, width, align, flags ) ); | |
07a84e7b RR |
484 | } |
485 | ||
1286b7ba | 486 | bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 487 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 488 | { |
1286b7ba | 489 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
490 | new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ), |
491 | model_column, width, align, flags ) ); | |
07a84e7b RR |
492 | } |
493 | ||
1286b7ba | 494 | bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 495 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 496 | { |
1286b7ba | 497 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
498 | new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ), |
499 | model_column, width, align, flags ) ); | |
07a84e7b RR |
500 | } |
501 | ||
fa28826d RR |
502 | bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col ) |
503 | { | |
504 | m_cols.Append( (wxObject*) col ); | |
6842a71a | 505 | col->SetOwner( (wxDataViewCtrl*) this ); |
fa28826d RR |
506 | return true; |
507 | } | |
508 | ||
9861f022 | 509 | unsigned int wxDataViewCtrlBase::GetColumnCount() const |
fa28826d RR |
510 | { |
511 | return m_cols.GetCount(); | |
512 | } | |
513 | ||
0a71f9e9 | 514 | bool wxDataViewCtrlBase::DeleteColumn( unsigned int WXUNUSED(pos) ) |
fa28826d RR |
515 | { |
516 | return false; | |
517 | } | |
518 | ||
519 | bool wxDataViewCtrlBase::ClearColumns() | |
520 | { | |
521 | return false; | |
522 | } | |
523 | ||
0a71f9e9 | 524 | wxDataViewColumn* wxDataViewCtrlBase::GetColumn( unsigned int pos ) |
fa28826d RR |
525 | { |
526 | return (wxDataViewColumn*) m_cols[ pos ]; | |
527 | } | |
528 | ||
eb7f97f8 RR |
529 | // --------------------------------------------------------- |
530 | // wxDataViewEvent | |
531 | // --------------------------------------------------------- | |
532 | ||
533 | IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) | |
534 | ||
e0062c04 RR |
535 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED) |
536 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED) | |
31fb32e1 RR |
537 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK) |
538 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK) | |
c0a66d92 | 539 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED) |
eb7f97f8 | 540 | |
e0062c04 RR |
541 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED) |
542 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED) | |
543 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED) | |
1821abd1 | 544 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED) |
1821abd1 | 545 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED) |
eb7f97f8 | 546 | |
8045736e | 547 | #endif |