]> git.saurik.com Git - wxWidgets.git/blob - src/common/datavcmn.cpp
vc6 did not like this (void function returning a value)
[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 #if wxUSE_DATAVIEWCTRL
19
20 #include "wx/dataview.h"
21
22 #ifndef WX_PRECOMP
23 #include "wx/log.h"
24 #endif
25
26 const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl");
27
28
29 bool operator == (const wxDataViewItem &left, const wxDataViewItem &right)
30 {
31 return (left.GetID() == right.GetID() );
32 }
33
34
35 // ---------------------------------------------------------
36 // wxDataViewModel
37 // ---------------------------------------------------------
38
39 #include "wx/listimpl.cpp"
40 WX_DEFINE_LIST(wxDataViewModelNotifiers);
41
42 wxDataViewModel::wxDataViewModel()
43 {
44 m_notifiers.DeleteContents( true );
45 }
46
47 bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item )
48 {
49 bool ret = true;
50
51 wxDataViewModelNotifiers::iterator iter;
52 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
53 {
54 wxDataViewModelNotifier* notifier = *iter;
55 if (!notifier->ItemAdded( parent, item ))
56 ret = false;
57 }
58
59 return ret;
60 }
61
62 bool wxDataViewModel::ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item )
63 {
64 bool ret = true;
65
66 wxDataViewModelNotifiers::iterator iter;
67 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
68 {
69 wxDataViewModelNotifier* notifier = *iter;
70 if (!notifier->ItemDeleted( parent, item ))
71 ret = false;
72 }
73
74 return ret;
75 }
76
77 bool wxDataViewModel::ItemChanged( const wxDataViewItem &item )
78 {
79 bool ret = true;
80
81 wxDataViewModelNotifiers::iterator iter;
82 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
83 {
84 wxDataViewModelNotifier* notifier = *iter;
85 if (!notifier->ItemChanged( item ))
86 ret = false;
87 }
88
89 return ret;
90 }
91
92 bool wxDataViewModel::ValueChanged( const wxDataViewItem &item, unsigned int col )
93 {
94 bool ret = true;
95
96 wxDataViewModelNotifiers::iterator iter;
97 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
98 {
99 wxDataViewModelNotifier* notifier = *iter;
100 if (!notifier->ValueChanged( item, col ))
101 ret = false;
102 }
103
104 return ret;
105 }
106
107 bool wxDataViewModel::Cleared()
108 {
109 bool ret = true;
110
111 wxDataViewModelNotifiers::iterator iter;
112 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
113 {
114 wxDataViewModelNotifier* notifier = *iter;
115 if (!notifier->Cleared())
116 ret = false;
117 }
118
119 return ret;
120 }
121
122 void wxDataViewModel::Resort()
123 {
124 wxDataViewModelNotifiers::iterator iter;
125 for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
126 {
127 wxDataViewModelNotifier* notifier = *iter;
128 notifier->Resort();
129 }
130 }
131
132 void wxDataViewModel::AddNotifier( wxDataViewModelNotifier *notifier )
133 {
134 m_notifiers.push_back( notifier );
135 notifier->SetOwner( this );
136 }
137
138 void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier )
139 {
140 m_notifiers.DeleteObject( notifier );
141 }
142
143 int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
144 unsigned int column, bool ascending )
145 {
146 // sort branches before leaves
147 bool item1_is_container = IsContainer(item1);
148 bool item2_is_container = IsContainer(item2);
149
150 if (item1_is_container && !item2_is_container)
151 return 1;
152 if (item2_is_container && !item1_is_container)
153 return -1;
154
155 wxVariant value1,value2;
156 GetValue( value1, item1, column );
157 GetValue( value2, item2, column );
158
159 if (!ascending)
160 {
161 wxVariant temp = value1;
162 value1 = value2;
163 value2 = temp;
164 }
165
166 if (value1.GetType() == wxT("string"))
167 {
168 wxString str1 = value1.GetString();
169 wxString str2 = value2.GetString();
170 int res = str1.Cmp( str2 );
171 if (res) return res;
172 } else
173 if (value1.GetType() == wxT("long"))
174 {
175 long l1 = value1.GetLong();
176 long l2 = value2.GetLong();
177 long res = l1-l2;
178 if (res) return res;
179 } else
180 if (value1.GetType() == wxT("double"))
181 {
182 double d1 = value1.GetDouble();
183 double d2 = value2.GetDouble();
184 if (d1 < d2) return 1;
185 if (d1 > d2) return -1;
186 } else
187 if (value1.GetType() == wxT("datetime"))
188 {
189 wxDateTime dt1 = value1.GetDateTime();
190 wxDateTime dt2 = value2.GetDateTime();
191 if (dt1.IsEarlierThan(dt2)) return 1;
192 if (dt2.IsEarlierThan(dt1)) return -11;
193 }
194
195 // items must be different
196 unsigned long litem1 = (unsigned long) item1.GetID();
197 unsigned long litem2 = (unsigned long) item2.GetID();
198
199 if (!ascending)
200 return litem2-litem2;
201
202 return litem1-litem2;
203 }
204
205 // ---------------------------------------------------------
206 // wxDataViewIndexListModel
207 // ---------------------------------------------------------
208
209 wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size )
210 {
211 // build initial index
212 unsigned int i;
213 for (i = 1; i < initial_size+1; i++)
214 m_hash.Add( (void*) i );
215 m_lastIndex = initial_size + 1;
216 }
217
218 wxDataViewIndexListModel::~wxDataViewIndexListModel()
219 {
220 }
221
222 void wxDataViewIndexListModel::RowPrepended()
223 {
224 unsigned int id = m_lastIndex++;
225 m_hash.Insert( (void*) id, 0 );
226 wxDataViewItem item( (void*) id );
227 ItemAdded( wxDataViewItem(0), item );
228 }
229
230 void wxDataViewIndexListModel::RowInserted( unsigned int before )
231 {
232 unsigned int id = m_lastIndex++;
233 m_hash.Insert( (void*) id, before );
234 wxDataViewItem item( (void*) id );
235 ItemAdded( wxDataViewItem(0), item );
236 }
237
238 void wxDataViewIndexListModel::RowAppended()
239 {
240 unsigned int id = m_lastIndex++;
241 m_hash.Add( (void*) id );
242 wxDataViewItem item( (void*) id );
243 ItemAdded( wxDataViewItem(0), item );
244 }
245
246 void wxDataViewIndexListModel::RowDeleted( unsigned int row )
247 {
248 wxDataViewItem item( m_hash[row] );
249 wxDataViewModel::ItemDeleted( wxDataViewItem(0), item );
250 m_hash.RemoveAt( row );
251 }
252
253 void wxDataViewIndexListModel::RowChanged( unsigned int row )
254 {
255 wxDataViewModel::ItemChanged( GetItem(row) );
256 }
257
258 void wxDataViewIndexListModel::RowValueChanged( unsigned int row, unsigned int col )
259 {
260 wxDataViewModel::ValueChanged( GetItem(row), col );
261 }
262
263 unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) const
264 {
265 // assert for not found
266 return (unsigned int) m_hash.Index( item.GetID() );
267 }
268
269 wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const
270 {
271 wxASSERT( row < m_hash.GetCount() );
272 return wxDataViewItem( m_hash[row] );
273 }
274
275 int wxDataViewIndexListModel::Compare(const wxDataViewItem& item1,
276 const wxDataViewItem& item2,
277 unsigned int WXUNUSED(column),
278 bool ascending)
279 {
280 if (ascending)
281 return GetRow(item1) - GetRow(item2);
282
283 return GetRow(item2) - GetRow(item1);
284 }
285
286 void wxDataViewIndexListModel::GetValue( wxVariant &variant,
287 const wxDataViewItem &item, unsigned int col ) const
288 {
289 GetValue( variant, GetRow(item), col );
290 }
291
292 bool wxDataViewIndexListModel::SetValue( const wxVariant &variant,
293 const wxDataViewItem &item, unsigned int col )
294 {
295 return SetValue( variant, GetRow(item), col );
296 }
297
298 wxDataViewItem wxDataViewIndexListModel::GetParent( const wxDataViewItem & WXUNUSED(item) ) const
299 {
300 return wxDataViewItem(0);
301 }
302
303 bool wxDataViewIndexListModel::IsContainer( const wxDataViewItem &item ) const
304 {
305 // only the invisible root item has children
306 if (!item.IsOk())
307 return true;
308
309 return false;
310 }
311
312 unsigned int wxDataViewIndexListModel::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const
313 {
314 if (item.IsOk())
315 return 0;
316
317 children = m_hash;
318
319 return m_hash.GetCount();
320 }
321
322 //-----------------------------------------------------------------------------
323 // wxDataViewIconText
324 //-----------------------------------------------------------------------------
325
326 IMPLEMENT_DYNAMIC_CLASS(wxDataViewIconText,wxObject)
327
328 IMPLEMENT_VARIANT_OBJECT(wxDataViewIconText)
329
330 bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two)
331 {
332 if (one.GetText() != two.GetText()) return false;
333 if (one.IsSameAs(two)) return false;
334 return true;
335 }
336
337 // ---------------------------------------------------------
338 // wxDataViewRendererBase
339 // ---------------------------------------------------------
340
341 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject)
342
343 wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype,
344 wxDataViewCellMode WXUNUSED(mode),
345 int WXUNUSED(align) )
346 {
347 m_variantType = varianttype;
348 m_editorCtrl = NULL;
349 }
350
351 const wxDataViewCtrl* wxDataViewRendererBase::GetView() const
352 {
353 return wx_const_cast(wxDataViewRendererBase*, this)->GetOwner()->GetOwner();
354 }
355
356 bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect labelRect )
357 {
358 m_item = item; // remember for later
359
360 unsigned int col = GetOwner()->GetModelColumn();
361 wxVariant value;
362 GetOwner()->GetOwner()->GetModel()->GetValue( value, item, col );
363
364 m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value );
365
366 wxDataViewEditorCtrlEvtHandler *handler =
367 new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this );
368
369 m_editorCtrl->PushEventHandler( handler );
370
371 #if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL)
372 handler->SetFocusOnIdle();
373 #else
374 m_editorCtrl->SetFocus();
375 #endif
376
377 // Now we should send Editing Started event
378 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, GetOwner()->GetOwner()->GetId() );
379 event.SetDataViewColumn( GetOwner() );
380 event.SetModel( GetOwner()->GetOwner()->GetModel() );
381 event.SetItem( item );
382 GetOwner()->GetOwner()->GetEventHandler()->ProcessEvent( event );
383
384 return true;
385 }
386
387 void wxDataViewRendererBase::CancelEditing()
388 {
389 wxPendingDelete.Append( m_editorCtrl );
390
391 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
392
393 // m_editorCtrl->PopEventHandler( true );
394 }
395
396 bool wxDataViewRendererBase::FinishEditing()
397 {
398 wxVariant value;
399 GetValueFromEditorCtrl( m_editorCtrl, value );
400
401 wxPendingDelete.Append( m_editorCtrl );
402
403 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
404
405 if (!Validate(value))
406 return false;
407
408 unsigned int col = GetOwner()->GetModelColumn();
409 GetOwner()->GetOwner()->GetModel()->SetValue( value, m_item, col );
410 GetOwner()->GetOwner()->GetModel()->ValueChanged( m_item, col );
411
412 // m_editorCtrl->PopEventHandler( true );
413
414 // Now we should send Editing Done event
415 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, GetOwner()->GetOwner()->GetId() );
416 event.SetDataViewColumn( GetOwner() );
417 event.SetModel( GetOwner()->GetOwner()->GetModel() );
418 event.SetItem( m_item );
419 GetOwner()->GetOwner()->GetEventHandler()->ProcessEvent( event );
420
421 return true;
422 }
423
424 //-----------------------------------------------------------------------------
425 // wxDataViewEditorCtrlEvtHandler
426 //-----------------------------------------------------------------------------
427
428 BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler)
429 EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar)
430 EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus)
431 EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle)
432 END_EVENT_TABLE()
433
434 wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
435 wxControl *editorCtrl,
436 wxDataViewRenderer *owner )
437 {
438 m_owner = owner;
439 m_editorCtrl = editorCtrl;
440
441 m_finished = false;
442 }
443
444 void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event )
445 {
446 if (m_focusOnIdle)
447 {
448 m_focusOnIdle = false;
449 if (wxWindow::FindFocus() != m_editorCtrl)
450 m_editorCtrl->SetFocus();
451 }
452
453 event.Skip();
454 }
455
456 void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event )
457 {
458 switch ( event.m_keyCode )
459 {
460 case WXK_RETURN:
461 m_finished = true;
462 m_owner->FinishEditing();
463 break;
464
465 case WXK_ESCAPE:
466 m_finished = true;
467 m_owner->CancelEditing();
468 break;
469
470 default:
471 event.Skip();
472 }
473 }
474
475 void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event )
476 {
477 if (!m_finished)
478 {
479 m_finished = true;
480 m_owner->FinishEditing();
481 }
482
483 event.Skip();
484 }
485
486 // ---------------------------------------------------------
487 // wxDataViewColumnBase
488 // ---------------------------------------------------------
489
490 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
491
492 wxDataViewColumnBase::wxDataViewColumnBase(const wxString& WXUNUSED(title),
493 wxDataViewRenderer *renderer,
494 unsigned int model_column,
495 int WXUNUSED(width),
496 wxAlignment WXUNUSED(align),
497 int WXUNUSED(flags))
498 {
499 m_renderer = renderer;
500 m_model_column = model_column;
501 m_owner = NULL;
502 m_renderer->SetOwner( (wxDataViewColumn*) this );
503
504 // NOTE: the wxDataViewColumn's ctor must store the width, align, flags
505 // parameters inside the native control!
506 }
507
508 wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap,
509 wxDataViewRenderer *renderer,
510 unsigned int model_column,
511 int WXUNUSED(width),
512 wxAlignment WXUNUSED(align),
513 int WXUNUSED(flags) )
514 {
515 m_renderer = renderer;
516 m_model_column = model_column;
517 m_bitmap = bitmap;
518 m_owner = NULL;
519 m_renderer->SetOwner( (wxDataViewColumn*) this );
520 }
521
522 wxDataViewColumnBase::~wxDataViewColumnBase()
523 {
524 if (m_renderer)
525 delete m_renderer;
526 }
527
528 int wxDataViewColumnBase::GetFlags() const
529 {
530 int ret = 0;
531
532 if (IsSortable())
533 ret |= wxDATAVIEW_COL_SORTABLE;
534 if (IsResizeable())
535 ret |= wxDATAVIEW_COL_RESIZABLE;
536 if (IsHidden())
537 ret |= wxDATAVIEW_COL_HIDDEN;
538
539 return ret;
540 }
541
542 void wxDataViewColumnBase::SetFlags(int flags)
543 {
544 SetSortable((flags & wxDATAVIEW_COL_SORTABLE) != 0);
545 SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
546 SetHidden((flags & wxDATAVIEW_COL_HIDDEN) != 0);
547 }
548
549 // ---------------------------------------------------------
550 // wxDataViewCtrlBase
551 // ---------------------------------------------------------
552
553 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
554
555 wxDataViewCtrlBase::wxDataViewCtrlBase()
556 {
557 m_model = NULL;
558 m_expander_column = 0;
559 m_indent = 8;
560 }
561
562 wxDataViewCtrlBase::~wxDataViewCtrlBase()
563 {
564 if (m_model)
565 {
566 m_model->DecRef();
567 m_model = NULL;
568 }
569 }
570
571 bool wxDataViewCtrlBase::AssociateModel( wxDataViewModel *model )
572 {
573 if (m_model)
574 {
575 m_model->DecRef(); // discard old model, if any
576 }
577
578 // add our own reference to the new model:
579 m_model = model;
580 if (m_model)
581 {
582 m_model->IncRef();
583 }
584
585 return true;
586 }
587
588 wxDataViewModel* wxDataViewCtrlBase::GetModel()
589 {
590 return m_model;
591 }
592
593 wxDataViewColumn *
594 wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column,
595 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
596 {
597 wxDataViewColumn *ret = new wxDataViewColumn( label,
598 new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
599 model_column, width, align, flags );
600 AppendColumn( ret );
601 return ret;
602 }
603
604 wxDataViewColumn *
605 wxDataViewCtrlBase::AppendIconTextColumn( const wxString &label, unsigned int model_column,
606 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
607 {
608 wxDataViewColumn *ret = new wxDataViewColumn( label,
609 new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode, (int)align ),
610 model_column, width, align, flags );
611 AppendColumn( ret );
612 return ret;
613 }
614
615 wxDataViewColumn *
616 wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column,
617 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
618 {
619
620 wxDataViewColumn *ret = new wxDataViewColumn( label,
621 new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
622 model_column, width, align, flags );
623 AppendColumn( ret );
624 return ret;
625 }
626
627 wxDataViewColumn *
628 wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column,
629 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
630 {
631 wxDataViewColumn *ret = new wxDataViewColumn( label,
632 new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
633 model_column, width, align, flags );
634 AppendColumn( ret );
635 return ret;
636 }
637
638 wxDataViewColumn *
639 wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column,
640 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
641 {
642 wxDataViewColumn *ret = new wxDataViewColumn( label,
643 new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
644 model_column, width, align, flags );
645 AppendColumn( ret );
646 return ret;
647 }
648
649 wxDataViewColumn *
650 wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column,
651 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
652 {
653 wxDataViewColumn *ret = new wxDataViewColumn( label,
654 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
655 model_column, width, align, flags );
656 AppendColumn( ret );
657 return ret;
658 }
659
660 wxDataViewColumn *
661 wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column,
662 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
663 {
664 wxDataViewColumn *ret = new wxDataViewColumn( label,
665 new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
666 model_column, width, align, flags );
667 AppendColumn( ret );
668 return ret;
669 }
670
671 wxDataViewColumn *
672 wxDataViewCtrlBase::AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
673 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
674 {
675 wxDataViewColumn *ret = new wxDataViewColumn( label,
676 new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode, (int)align ),
677 model_column, width, align, flags );
678 AppendColumn( ret );
679 return ret;
680 }
681
682 wxDataViewColumn *
683 wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
684 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
685 {
686 wxDataViewColumn *ret = new wxDataViewColumn( label,
687 new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
688 model_column, width, align, flags );
689 AppendColumn( ret );
690 return ret;
691 }
692
693 wxDataViewColumn *
694 wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
695 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
696 {
697 wxDataViewColumn *ret = new wxDataViewColumn( label,
698 new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
699 model_column, width, align, flags );
700 AppendColumn( ret );
701 return ret;
702 }
703
704 wxDataViewColumn *
705 wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column,
706 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
707 {
708 wxDataViewColumn *ret = new wxDataViewColumn( label,
709 new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
710 model_column, width, align, flags );
711 AppendColumn( ret );
712 return ret;
713 }
714
715 wxDataViewColumn *
716 wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
717 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
718 {
719 wxDataViewColumn *ret = new wxDataViewColumn( label,
720 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
721 model_column, width, align, flags );
722 AppendColumn( ret );
723 return ret;
724 }
725
726 bool
727 wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
728 {
729 col->SetOwner( (wxDataViewCtrl*) this );
730 return true;
731 }
732
733 // ---------------------------------------------------------
734 // wxDataViewEvent
735 // ---------------------------------------------------------
736
737 IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent)
738
739 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED)
740
741 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED)
742 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING)
743 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED)
744 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING)
745 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED)
746 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED)
747 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE)
748
749 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK)
750 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK)
751 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED)
752
753 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED)
754 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED)
755 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED)
756 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED)
757 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED)
758
759 #endif
760