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