]> git.saurik.com Git - wxWidgets.git/blob - src/common/datavcmn.cpp
remove the drag-and-drop compatibility hack for extracting the embedded size of the...
[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, const wxDataViewItem &item2,
276 unsigned int column, bool ascending )
277 {
278 if (ascending)
279 return GetRow(item1) - GetRow(item2);
280
281 return GetRow(item2) - GetRow(item1);
282 }
283
284 void wxDataViewIndexListModel::GetValue( wxVariant &variant,
285 const wxDataViewItem &item, unsigned int col ) const
286 {
287 GetValue( variant, GetRow(item), col );
288 }
289
290 bool wxDataViewIndexListModel::SetValue( const wxVariant &variant,
291 const wxDataViewItem &item, unsigned int col )
292 {
293 return SetValue( variant, GetRow(item), col );
294 }
295
296 wxDataViewItem wxDataViewIndexListModel::GetParent( const wxDataViewItem & WXUNUSED(item) ) const
297 {
298 return wxDataViewItem(0);
299 }
300
301 bool wxDataViewIndexListModel::IsContainer( const wxDataViewItem &item ) const
302 {
303 // only the invisible root item has children
304 if (!item.IsOk())
305 return true;
306
307 return false;
308 }
309
310 unsigned int wxDataViewIndexListModel::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const
311 {
312 if (item.IsOk())
313 return 0;
314
315 children = m_hash;
316
317 return m_hash.GetCount();
318 }
319
320 //-----------------------------------------------------------------------------
321 // wxDataViewIconText
322 //-----------------------------------------------------------------------------
323
324 IMPLEMENT_DYNAMIC_CLASS(wxDataViewIconText,wxObject)
325
326 IMPLEMENT_VARIANT_OBJECT(wxDataViewIconText)
327
328 bool operator == (const wxDataViewIconText &one, const wxDataViewIconText &two)
329 {
330 if (one.GetText() != two.GetText()) return false;
331 if (one.IsSameAs(two)) return false;
332 return true;
333 }
334
335 // ---------------------------------------------------------
336 // wxDataViewRendererBase
337 // ---------------------------------------------------------
338
339 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject)
340
341 wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype,
342 wxDataViewCellMode WXUNUSED(mode),
343 int WXUNUSED(align) )
344 {
345 m_variantType = varianttype;
346 m_editorCtrl = NULL;
347 }
348
349 const wxDataViewCtrl* wxDataViewRendererBase::GetView() const
350 {
351 return wx_const_cast(wxDataViewRendererBase*, this)->GetOwner()->GetOwner();
352 }
353
354 bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect labelRect )
355 {
356 m_item = item; // remember for later
357
358 unsigned int col = GetOwner()->GetModelColumn();
359 wxVariant value;
360 GetOwner()->GetOwner()->GetModel()->GetValue( value, item, col );
361
362 m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value );
363
364 wxDataViewEditorCtrlEvtHandler *handler =
365 new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this );
366
367 m_editorCtrl->PushEventHandler( handler );
368
369 #if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL)
370 handler->SetFocusOnIdle();
371 #else
372 m_editorCtrl->SetFocus();
373 #endif
374
375 // Now we should send Editing Started event
376 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, GetOwner()->GetOwner()->GetId() );
377 event.SetDataViewColumn( GetOwner() );
378 event.SetModel( GetOwner()->GetOwner()->GetModel() );
379 event.SetItem( item );
380 GetOwner()->GetOwner()->GetEventHandler()->ProcessEvent( event );
381
382 return true;
383 }
384
385 void wxDataViewRendererBase::CancelEditing()
386 {
387 wxPendingDelete.Append( m_editorCtrl );
388
389 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
390
391 // m_editorCtrl->PopEventHandler( true );
392 }
393
394 bool wxDataViewRendererBase::FinishEditing()
395 {
396 wxVariant value;
397 GetValueFromEditorCtrl( m_editorCtrl, value );
398
399 wxPendingDelete.Append( m_editorCtrl );
400
401 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
402
403 if (!Validate(value))
404 return false;
405
406 unsigned int col = GetOwner()->GetModelColumn();
407 GetOwner()->GetOwner()->GetModel()->SetValue( value, m_item, col );
408 GetOwner()->GetOwner()->GetModel()->ValueChanged( m_item, col );
409
410 // m_editorCtrl->PopEventHandler( true );
411
412 // Now we should send Editing Done event
413 wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, GetOwner()->GetOwner()->GetId() );
414 event.SetDataViewColumn( GetOwner() );
415 event.SetModel( GetOwner()->GetOwner()->GetModel() );
416 event.SetItem( m_item );
417 GetOwner()->GetOwner()->GetEventHandler()->ProcessEvent( event );
418
419 return true;
420 }
421
422 //-----------------------------------------------------------------------------
423 // wxDataViewEditorCtrlEvtHandler
424 //-----------------------------------------------------------------------------
425
426 BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler)
427 EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar)
428 EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus)
429 EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle)
430 END_EVENT_TABLE()
431
432 wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
433 wxControl *editorCtrl,
434 wxDataViewRenderer *owner )
435 {
436 m_owner = owner;
437 m_editorCtrl = editorCtrl;
438
439 m_finished = false;
440 }
441
442 void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event )
443 {
444 if (m_focusOnIdle)
445 {
446 m_focusOnIdle = false;
447 if (wxWindow::FindFocus() != m_editorCtrl)
448 m_editorCtrl->SetFocus();
449 }
450
451 event.Skip();
452 }
453
454 void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event )
455 {
456 switch ( event.m_keyCode )
457 {
458 case WXK_RETURN:
459 m_finished = true;
460 m_owner->FinishEditing();
461 break;
462
463 case WXK_ESCAPE:
464 m_finished = true;
465 m_owner->CancelEditing();
466 break;
467
468 default:
469 event.Skip();
470 }
471 }
472
473 void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event )
474 {
475 if (!m_finished)
476 {
477 m_finished = true;
478 m_owner->FinishEditing();
479 }
480
481 event.Skip();
482 }
483
484 // ---------------------------------------------------------
485 // wxDataViewColumnBase
486 // ---------------------------------------------------------
487
488 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
489
490 wxDataViewColumnBase::wxDataViewColumnBase(const wxString& WXUNUSED(title),
491 wxDataViewRenderer *renderer,
492 unsigned int model_column,
493 int WXUNUSED(width),
494 wxAlignment WXUNUSED(align),
495 int WXUNUSED(flags))
496 {
497 m_renderer = renderer;
498 m_model_column = model_column;
499 m_owner = NULL;
500 m_renderer->SetOwner( (wxDataViewColumn*) this );
501
502 // NOTE: the wxDataViewColumn's ctor must store the width, align, flags
503 // parameters inside the native control!
504 }
505
506 wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap,
507 wxDataViewRenderer *renderer,
508 unsigned int model_column,
509 int WXUNUSED(width),
510 wxAlignment WXUNUSED(align),
511 int WXUNUSED(flags) )
512 {
513 m_renderer = renderer;
514 m_model_column = model_column;
515 m_bitmap = bitmap;
516 m_owner = NULL;
517 m_renderer->SetOwner( (wxDataViewColumn*) this );
518 }
519
520 wxDataViewColumnBase::~wxDataViewColumnBase()
521 {
522 if (m_renderer)
523 delete m_renderer;
524 }
525
526 int wxDataViewColumnBase::GetFlags() const
527 {
528 int ret = 0;
529
530 if (IsSortable())
531 ret |= wxDATAVIEW_COL_SORTABLE;
532 if (IsResizeable())
533 ret |= wxDATAVIEW_COL_RESIZABLE;
534 if (IsHidden())
535 ret |= wxDATAVIEW_COL_HIDDEN;
536
537 return ret;
538 }
539
540 void wxDataViewColumnBase::SetFlags(int flags)
541 {
542 SetSortable((flags & wxDATAVIEW_COL_SORTABLE) != 0);
543 SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0);
544 SetHidden((flags & wxDATAVIEW_COL_HIDDEN) != 0);
545 }
546
547 // ---------------------------------------------------------
548 // wxDataViewCtrlBase
549 // ---------------------------------------------------------
550
551 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
552
553 wxDataViewCtrlBase::wxDataViewCtrlBase()
554 {
555 m_model = NULL;
556 m_expander_column = 0;
557 m_indent = 8;
558 }
559
560 wxDataViewCtrlBase::~wxDataViewCtrlBase()
561 {
562 if (m_model)
563 {
564 m_model->DecRef();
565 m_model = NULL;
566 }
567 }
568
569 bool wxDataViewCtrlBase::AssociateModel( wxDataViewModel *model )
570 {
571 if (m_model)
572 {
573 m_model->DecRef(); // discard old model, if any
574 }
575
576 // add our own reference to the new model:
577 m_model = model;
578 if (m_model)
579 {
580 m_model->IncRef();
581 }
582
583 return true;
584 }
585
586 wxDataViewModel* wxDataViewCtrlBase::GetModel()
587 {
588 return m_model;
589 }
590
591 wxDataViewColumn *
592 wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column,
593 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
594 {
595 wxDataViewColumn *ret = new wxDataViewColumn( label,
596 new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
597 model_column, width, align, flags );
598 AppendColumn( ret );
599 return ret;
600 }
601
602 wxDataViewColumn *
603 wxDataViewCtrlBase::AppendIconTextColumn( const wxString &label, unsigned int model_column,
604 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
605 {
606 wxDataViewColumn *ret = new wxDataViewColumn( label,
607 new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode, (int)align ),
608 model_column, width, align, flags );
609 AppendColumn( ret );
610 return ret;
611 }
612
613 wxDataViewColumn *
614 wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column,
615 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
616 {
617
618 wxDataViewColumn *ret = new wxDataViewColumn( label,
619 new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
620 model_column, width, align, flags );
621 AppendColumn( ret );
622 return ret;
623 }
624
625 wxDataViewColumn *
626 wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column,
627 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
628 {
629 wxDataViewColumn *ret = new wxDataViewColumn( label,
630 new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
631 model_column, width, align, flags );
632 AppendColumn( ret );
633 return ret;
634 }
635
636 wxDataViewColumn *
637 wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column,
638 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
639 {
640 wxDataViewColumn *ret = new wxDataViewColumn( label,
641 new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
642 model_column, width, align, flags );
643 AppendColumn( ret );
644 return ret;
645 }
646
647 wxDataViewColumn *
648 wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column,
649 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
650 {
651 wxDataViewColumn *ret = new wxDataViewColumn( label,
652 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
653 model_column, width, align, flags );
654 AppendColumn( ret );
655 return ret;
656 }
657
658 wxDataViewColumn *
659 wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column,
660 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
661 {
662 wxDataViewColumn *ret = new wxDataViewColumn( label,
663 new wxDataViewTextRenderer( wxT("string"), mode, (int)align ),
664 model_column, width, align, flags );
665 AppendColumn( ret );
666 return ret;
667 }
668
669 wxDataViewColumn *
670 wxDataViewCtrlBase::AppendIconTextColumn( const wxBitmap &label, unsigned int model_column,
671 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
672 {
673 wxDataViewColumn *ret = new wxDataViewColumn( label,
674 new wxDataViewIconTextRenderer( wxT("wxDataViewIconText"), mode, (int)align ),
675 model_column, width, align, flags );
676 AppendColumn( ret );
677 return ret;
678 }
679
680 wxDataViewColumn *
681 wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column,
682 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
683 {
684 wxDataViewColumn *ret = new wxDataViewColumn( label,
685 new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ),
686 model_column, width, align, flags );
687 AppendColumn( ret );
688 return ret;
689 }
690
691 wxDataViewColumn *
692 wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column,
693 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
694 {
695 wxDataViewColumn *ret = new wxDataViewColumn( label,
696 new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ),
697 model_column, width, align, flags );
698 AppendColumn( ret );
699 return ret;
700 }
701
702 wxDataViewColumn *
703 wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column,
704 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
705 {
706 wxDataViewColumn *ret = new wxDataViewColumn( label,
707 new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ),
708 model_column, width, align, flags );
709 AppendColumn( ret );
710 return ret;
711 }
712
713 wxDataViewColumn *
714 wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column,
715 wxDataViewCellMode mode, int width, wxAlignment align, int flags )
716 {
717 wxDataViewColumn *ret = new wxDataViewColumn( label,
718 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ),
719 model_column, width, align, flags );
720 AppendColumn( ret );
721 return ret;
722 }
723
724 bool
725 wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
726 {
727 col->SetOwner( (wxDataViewCtrl*) this );
728 return true;
729 }
730
731 // ---------------------------------------------------------
732 // wxDataViewEvent
733 // ---------------------------------------------------------
734
735 IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent)
736
737 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED)
738 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_DESELECTED)
739 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED)
740 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING)
741 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED)
742 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING)
743 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED)
744 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED)
745 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE)
746
747 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK)
748 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK)
749 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED)
750
751 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED)
752 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED)
753 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED)
754 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED)
755 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED)
756
757 #endif
758