1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/datavcmn.cpp
3 // Purpose: wxDataViewCtrl base classes and common parts
4 // Author: Robert Roebling
7 // Copyright: (c) 2006, Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_DATAVIEWCTRL
20 #include "wx/dataview.h"
26 const wxChar wxDataViewCtrlNameStr
[] = wxT("dataviewCtrl");
29 // ---------------------------------------------------------
30 // wxDataViewListModel
31 // ---------------------------------------------------------
33 wxDataViewListModel::wxDataViewListModel()
35 m_viewingColumns
.DeleteContents( true );
36 m_notifiers
.DeleteContents( true );
39 wxDataViewListModel::~wxDataViewListModel()
41 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
44 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
46 node
= node
->GetNext();
50 bool wxDataViewListModel::RowAppended()
54 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
57 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
58 if (!notifier
->RowAppended())
60 node
= node
->GetNext();
66 bool wxDataViewListModel::RowPrepended()
70 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
73 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
74 if (!notifier
->RowPrepended())
76 node
= node
->GetNext();
82 bool wxDataViewListModel::RowInserted( unsigned int before
)
86 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
89 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
90 if (!notifier
->RowInserted(before
))
92 node
= node
->GetNext();
98 bool wxDataViewListModel::RowDeleted( unsigned int row
)
102 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
105 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
106 if (!notifier
->RowDeleted( row
))
108 node
= node
->GetNext();
114 bool wxDataViewListModel::RowChanged( unsigned int row
)
118 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
121 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
122 if (!notifier
->RowChanged( row
))
124 node
= node
->GetNext();
130 bool wxDataViewListModel::ValueChanged( unsigned int col
, unsigned int row
)
134 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
137 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
138 if (!notifier
->ValueChanged( col
, row
))
140 node
= node
->GetNext();
146 bool wxDataViewListModel::RowsReordered( unsigned int *new_order
)
150 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
153 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
154 if (!notifier
->RowsReordered( new_order
))
156 node
= node
->GetNext();
162 bool wxDataViewListModel::Cleared()
166 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
169 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
170 if (!notifier
->Cleared())
172 node
= node
->GetNext();
178 void wxDataViewListModel::AddViewingColumn( wxDataViewColumn
*view_column
, unsigned int model_column
)
180 m_viewingColumns
.Append( new wxDataViewViewingColumn( view_column
, model_column
) );
183 void wxDataViewListModel::RemoveViewingColumn( wxDataViewColumn
*column
)
185 wxList::compatibility_iterator node
= m_viewingColumns
.GetFirst();
188 wxDataViewViewingColumn
* tmp
= (wxDataViewViewingColumn
*) node
->GetData();
190 if (tmp
->m_viewColumn
== column
)
192 m_viewingColumns
.DeleteObject( tmp
);
196 node
= node
->GetNext();
200 void wxDataViewListModel::AddNotifier( wxDataViewListModelNotifier
*notifier
)
202 m_notifiers
.Append( notifier
);
203 notifier
->SetOwner( this );
206 void wxDataViewListModel::RemoveNotifier( wxDataViewListModelNotifier
*notifier
)
208 m_notifiers
.DeleteObject( notifier
);
211 // ---------------------------------------------------------
212 // wxDataViewSortedListModelNotifier
213 // ---------------------------------------------------------
215 class wxDataViewSortedListModelNotifier
: public wxDataViewListModelNotifier
218 wxDataViewSortedListModelNotifier( wxDataViewSortedListModel
*model
)
221 virtual bool RowAppended()
222 { return m_model
->ChildRowAppended(); }
224 virtual bool RowPrepended()
225 { return m_model
->ChildRowPrepended(); }
227 virtual bool RowInserted( unsigned int before
)
228 { return m_model
->ChildRowInserted( before
); }
230 virtual bool RowDeleted( unsigned int row
)
231 { return m_model
->ChildRowDeleted( row
); }
233 virtual bool RowChanged( unsigned int row
)
234 { return m_model
->ChildRowChanged( row
); }
236 virtual bool ValueChanged( unsigned int col
, unsigned int row
)
237 { return m_model
->ChildValueChanged( col
, row
); }
239 virtual bool RowsReordered( unsigned int *new_order
)
240 { return m_model
->ChildRowsReordered( new_order
); }
242 virtual bool Cleared()
243 { return m_model
->ChildCleared(); }
246 { m_model
->m_child
= NULL
; return wxDataViewListModelNotifier::Freed(); }
248 wxDataViewSortedListModel
*m_model
;
251 // ---------------------------------------------------------
252 // wxDataViewSortedListModel compare function
253 // ---------------------------------------------------------
255 int wxCALLBACK wxDataViewListModelSortedDefaultCompare
256 (unsigned int row1
, unsigned int row2
, unsigned int col
, wxDataViewListModel
* model
)
258 wxVariant value1
,value2
;
259 model
->GetValue( value1
, col
, row1
);
260 model
->GetValue( value2
, col
, row2
);
261 if (value1
.GetType() == wxT("string"))
263 wxString str1
= value1
.GetString();
264 wxString str2
= value2
.GetString();
265 return str1
.Cmp( str2
);
267 if (value1
.GetType() == wxT("long"))
269 long l1
= value1
.GetLong();
270 long l2
= value2
.GetLong();
273 if (value1
.GetType() == wxT("double"))
275 double d1
= value1
.GetDouble();
276 double d2
= value2
.GetDouble();
277 if (d1
== d2
) return 0;
278 if (d1
< d2
) return 1;
281 if (value1
.GetType() == wxT("datetime"))
283 wxDateTime dt1
= value1
.GetDateTime();
284 wxDateTime dt2
= value2
.GetDateTime();
285 if (dt1
.IsEqualTo(dt2
)) return 0;
286 if (dt1
.IsEarlierThan(dt2
)) return 1;
293 int wxCALLBACK wxDataViewListModelSortedDefaultCompareDescending
294 (unsigned int row1
, unsigned int row2
, unsigned int col
, wxDataViewListModel
* model
)
296 return wxDataViewListModelSortedDefaultCompare( row2
, row1
, col
, model
);
299 static wxDataViewListModelCompare s_CmpFunc
;
300 static wxDataViewListModel
*s_CmpModel
;
301 static unsigned int s_CmpCol
;
303 int LINKAGEMODE
wxDataViewIntermediateCmp( unsigned int row1
, unsigned int row2
)
305 return s_CmpFunc( row1
, row2
, s_CmpCol
, s_CmpModel
);
308 // ---------------------------------------------------------
309 // wxDataViewSortedListModel
310 // ---------------------------------------------------------
312 wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel
*child
) :
313 m_array( wxDataViewIntermediateCmp
)
319 m_notifierOnChild
= new wxDataViewSortedListModelNotifier( this );
320 m_child
->AddNotifier( m_notifierOnChild
);
325 wxDataViewSortedListModel::~wxDataViewSortedListModel()
328 m_child
->RemoveNotifier( m_notifierOnChild
);
332 void wxDataViewSortedListModel::InitStatics()
335 s_CmpModel
= m_child
;
337 s_CmpFunc
= wxDataViewListModelSortedDefaultCompare
;
339 s_CmpFunc
= wxDataViewListModelSortedDefaultCompareDescending
;
342 void wxDataViewSortedListModel::Resort()
347 unsigned int n
= m_child
->GetRowCount();
349 for (i
= 0; i
< n
; i
++)
352 // do we need the neworder?
353 wxDataViewListModel::RowsReordered( NULL
);
357 static void Dump( wxDataViewListModel
*model
, unsigned int col
)
359 unsigned int n
= model
->GetRowCount();
361 for (i
= 0; i
< n
; i
++)
364 model
->GetValue( variant
, col
, i
);
366 tmp
= variant
.GetString();
367 wxPrintf( wxT("%d: %s\n"), (int) i
, tmp
.c_str() );
372 bool wxDataViewSortedListModel::ChildRowAppended()
374 // no need to fix up array
376 unsigned int len
= m_array
.GetCount();
378 unsigned int pos
= m_array
.Add( len
);
381 return wxDataViewListModel::RowPrepended();
384 return wxDataViewListModel::RowAppended();
386 return wxDataViewListModel::RowInserted( pos
);
389 bool wxDataViewSortedListModel::ChildRowPrepended()
393 unsigned int len
= m_array
.GetCount();
394 for (i
= 0; i
< len
; i
++)
396 unsigned int value
= m_array
[i
];
397 m_array
[i
] = value
+1;
400 unsigned int pos
= m_array
.Add( 0 );
403 return wxDataViewListModel::RowPrepended();
406 return wxDataViewListModel::RowAppended();
408 return wxDataViewListModel::RowInserted( pos
);
411 bool wxDataViewSortedListModel::ChildRowInserted( unsigned int before
)
415 unsigned int len
= m_array
.GetCount();
416 for (i
= 0; i
< len
; i
++)
418 unsigned int value
= m_array
[i
];
420 m_array
[i
] = value
+1;
423 unsigned int pos
= m_array
.Add( before
);
426 return wxDataViewListModel::RowPrepended();
429 return wxDataViewListModel::RowAppended();
431 return wxDataViewListModel::RowInserted( pos
);
434 bool wxDataViewSortedListModel::ChildRowDeleted( unsigned int row
)
437 unsigned int len
= m_array
.GetCount();
439 for (i
= 0; i
< len
; i
++)
441 unsigned int value
= m_array
[i
];
451 m_array
[i
] = value
-1;
456 return false; // we should probably assert
459 m_array
.RemoveAt( (unsigned int) pos
);
461 return wxDataViewListModel::RowDeleted( (unsigned int) pos
);
464 bool wxDataViewSortedListModel::ChildRowChanged( unsigned int row
)
467 unsigned int len
= m_array
.GetCount();
469 // Remove and readd sorted. Find out at which
470 // position it was and where it ended.
471 unsigned int start_pos
= 0,end_pos
= 0;
472 for (i
= 0; i
< len
; i
++)
473 if (m_array
[i
] == row
)
478 m_array
.RemoveAt( start_pos
);
481 for (i
= 0; i
< len
; i
++)
482 if (m_array
[i
] == row
)
488 if (end_pos
== start_pos
)
489 return wxDataViewListModel::RowChanged( start_pos
);
491 // Create an array where order[old] -> new_pos, so that
492 // if nothing changed order[0] -> 0 etc.
493 unsigned int *order
= new unsigned int[ len
];
494 // Fill up initial values.
495 for (i
= 0; i
< len
; i
++)
498 if (start_pos
< end_pos
)
500 for (i
= start_pos
; i
< end_pos
; i
++)
501 order
[i
] = order
[i
+1];
502 order
[end_pos
] = start_pos
;
506 for (i
= end_pos
; i
> start_pos
; i
--)
507 order
[i
] = order
[i
-1];
508 order
[start_pos
] = end_pos
;
511 wxDataViewListModel::RowsReordered( order
);
518 bool wxDataViewSortedListModel::ChildValueChanged( unsigned int col
, unsigned int row
)
521 unsigned int len
= m_array
.GetCount();
523 // Remove and readd sorted. Find out at which
524 // position it was and where it ended.
525 unsigned int start_pos
= 0,end_pos
= 0;
526 for (i
= 0; i
< len
; i
++)
527 if (m_array
[i
] == row
)
532 m_array
.RemoveAt( start_pos
);
535 for (i
= 0; i
< len
; i
++)
536 if (m_array
[i
] == row
)
542 if (end_pos
== start_pos
)
543 return wxDataViewListModel::ValueChanged( col
, start_pos
);
545 // Create an array where order[old] -> new_pos, so that
546 // if nothing changed order[0] -> 0 etc.
547 unsigned int *order
= new unsigned int[ len
];
548 // Fill up initial values.
549 for (i
= 0; i
< len
; i
++)
552 if (start_pos
< end_pos
)
554 for (i
= start_pos
; i
< end_pos
; i
++)
555 order
[i
] = order
[i
+1];
556 order
[end_pos
] = start_pos
;
560 for (i
= end_pos
; i
> start_pos
; i
--)
561 order
[i
] = order
[i
-1];
562 order
[start_pos
] = end_pos
;
565 wxDataViewListModel::RowsReordered( order
);
572 bool wxDataViewSortedListModel::ChildRowsReordered( unsigned int *WXUNUSED(new_order
) )
574 // Nothing needs to be done. If the sort criteria
575 // of this list don't change, the order of the
576 // items of the child list isn't relevant.
580 bool wxDataViewSortedListModel::ChildCleared()
582 return wxDataViewListModel::Cleared();
585 unsigned int wxDataViewSortedListModel::GetRowCount() const
587 return m_array
.GetCount();
590 unsigned int wxDataViewSortedListModel::GetColumnCount() const
592 return m_child
->GetColumnCount();
595 wxString
wxDataViewSortedListModel::GetColumnType( unsigned int col
) const
597 return m_child
->GetColumnType( col
);
600 void wxDataViewSortedListModel::GetValue( wxVariant
&variant
, unsigned int col
, unsigned int row
) const
602 unsigned int child_row
= m_array
[row
];
603 m_child
->GetValue( variant
, col
, child_row
);
606 bool wxDataViewSortedListModel::SetValue( const wxVariant
&variant
, unsigned int col
, unsigned int row
)
608 unsigned int child_row
= m_array
[row
];
609 bool ret
= m_child
->SetValue( variant
, col
, child_row
);
611 // Do nothing here as the change in the
612 // child model will be reported back.
617 bool wxDataViewSortedListModel::RowAppended()
619 // you can only append
620 bool ret
= m_child
->RowAppended();
622 // Do nothing here as the change in the
623 // child model will be reported back.
628 bool wxDataViewSortedListModel::RowPrepended()
630 // you can only append
631 bool ret
= m_child
->RowAppended();
633 // Do nothing here as the change in the
634 // child model will be reported back.
639 bool wxDataViewSortedListModel::RowInserted( unsigned int WXUNUSED(before
) )
641 // you can only append
642 bool ret
= m_child
->RowAppended();
644 // Do nothing here as the change in the
645 // child model will be reported back.
650 bool wxDataViewSortedListModel::RowDeleted( unsigned int row
)
652 unsigned int child_row
= m_array
[row
];
654 bool ret
= m_child
->RowDeleted( child_row
);
656 // Do nothing here as the change in the
657 // child model will be reported back.
662 bool wxDataViewSortedListModel::RowChanged( unsigned int row
)
664 unsigned int child_row
= m_array
[row
];
665 bool ret
= m_child
->RowChanged( child_row
);
667 // Do nothing here as the change in the
668 // child model will be reported back.
673 bool wxDataViewSortedListModel::ValueChanged( unsigned int col
, unsigned int row
)
675 unsigned int child_row
= m_array
[row
];
676 bool ret
= m_child
->ValueChanged( col
, child_row
);
678 // Do nothing here as the change in the
679 // child model will be reported back.
684 bool wxDataViewSortedListModel::RowsReordered( unsigned int *WXUNUSED(new_order
) )
686 // We sort them ourselves.
691 bool wxDataViewSortedListModel::Cleared()
693 bool ret
= m_child
->Cleared();
695 // Do nothing here as the change in the
696 // child model will be reported back.
701 // ---------------------------------------------------------
702 // wxDataViewRendererBase
703 // ---------------------------------------------------------
705 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase
, wxObject
)
707 wxDataViewRendererBase::wxDataViewRendererBase( const wxString
&varianttype
,
708 wxDataViewCellMode
WXUNUSED(mode
),
709 int WXUNUSED(align
) )
711 m_variantType
= varianttype
;
713 m_row
= (unsigned int) -1;
716 const wxDataViewCtrl
* wxDataViewRendererBase::GetView() const
718 return wx_const_cast(wxDataViewRendererBase
*, this)->GetOwner()->GetOwner();
721 bool wxDataViewRendererBase::StartEditing( unsigned int row
, wxRect labelRect
)
723 m_row
= row
; // remember for later
725 unsigned int col
= GetOwner()->GetModelColumn();
727 GetOwner()->GetOwner()->GetModel()->GetValue( value
, col
, row
);
729 m_editorCtrl
= CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect
, value
);
731 wxDataViewEditorCtrlEvtHandler
*handler
=
732 new wxDataViewEditorCtrlEvtHandler( m_editorCtrl
, (wxDataViewRenderer
*) this );
734 m_editorCtrl
->PushEventHandler( handler
);
736 #if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL)
737 handler
->SetFocusOnIdle();
739 m_editorCtrl
->SetFocus();
745 void wxDataViewRendererBase::CancelEditing()
747 wxPendingDelete
.Append( m_editorCtrl
);
749 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
751 // m_editorCtrl->PopEventHandler( true );
754 bool wxDataViewRendererBase::FinishEditing()
757 GetValueFromEditorCtrl( m_editorCtrl
, value
);
759 wxPendingDelete
.Append( m_editorCtrl
);
761 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
763 if (!Validate(value
))
766 unsigned int col
= GetOwner()->GetModelColumn();
767 GetOwner()->GetOwner()->GetModel()->SetValue( value
, col
, m_row
);
768 GetOwner()->GetOwner()->GetModel()->ValueChanged( col
, m_row
);
770 // m_editorCtrl->PopEventHandler( true );
775 //-----------------------------------------------------------------------------
776 // wxDataViewEditorCtrlEvtHandler
777 //-----------------------------------------------------------------------------
779 BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler
, wxEvtHandler
)
780 EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar
)
781 EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus
)
782 EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle
)
785 wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
786 wxControl
*editorCtrl
,
787 wxDataViewRenderer
*owner
)
790 m_editorCtrl
= editorCtrl
;
795 void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent
&event
)
799 m_focusOnIdle
= false;
800 if (wxWindow::FindFocus() != m_editorCtrl
)
801 m_editorCtrl
->SetFocus();
807 void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent
&event
)
809 switch ( event
.m_keyCode
)
813 m_owner
->FinishEditing();
818 m_owner
->CancelEditing();
826 void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent
&event
)
831 m_owner
->FinishEditing();
837 // ---------------------------------------------------------
838 // wxDataViewColumnBase
839 // ---------------------------------------------------------
841 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase
, wxObject
)
843 wxDataViewColumnBase::wxDataViewColumnBase(const wxString
& WXUNUSED(title
),
844 wxDataViewRenderer
*renderer
,
845 unsigned int model_column
,
847 wxAlignment
WXUNUSED(align
),
850 m_renderer
= renderer
;
851 m_model_column
= model_column
;
853 m_renderer
->SetOwner( (wxDataViewColumn
*) this );
855 // NOTE: the wxDataViewColumn's ctor must store the width, align, flags
856 // parameters inside the native control!
859 wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap
& bitmap
,
860 wxDataViewRenderer
*renderer
,
861 unsigned int model_column
,
863 wxAlignment
WXUNUSED(align
),
864 int WXUNUSED(flags
) )
866 m_renderer
= renderer
;
867 m_model_column
= model_column
;
870 m_renderer
->SetOwner( (wxDataViewColumn
*) this );
873 wxDataViewColumnBase::~wxDataViewColumnBase()
880 GetOwner()->GetModel()->RemoveViewingColumn( (wxDataViewColumn
*) this );
884 int wxDataViewColumnBase::GetFlags() const
889 ret
|= wxDATAVIEW_COL_SORTABLE
;
891 ret
|= wxDATAVIEW_COL_RESIZABLE
;
893 ret
|= wxDATAVIEW_COL_HIDDEN
;
898 void wxDataViewColumnBase::SetFlags(int flags
)
900 SetSortable((flags
& wxDATAVIEW_COL_SORTABLE
) != 0);
901 SetResizeable((flags
& wxDATAVIEW_COL_RESIZABLE
) != 0);
902 SetHidden((flags
& wxDATAVIEW_COL_HIDDEN
) != 0);
906 // ---------------------------------------------------------
907 // wxDataViewCtrlBase
908 // ---------------------------------------------------------
910 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase
, wxControl
)
912 wxDataViewCtrlBase::wxDataViewCtrlBase()
915 m_cols
.DeleteContents( true );
918 wxDataViewCtrlBase::~wxDataViewCtrlBase()
920 // IMPORTANT: before calling DecRef() on our model (since it may
921 // result in a free() call), erase all columns (since
922 // they hold a pointer to our model)
932 bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel
*model
)
935 m_model
->DecRef(); // discard old model, if any
937 // add our own reference to the new model:
945 wxDataViewListModel
* wxDataViewCtrlBase::GetModel()
950 bool wxDataViewCtrlBase::AppendTextColumn( const wxString
&label
, unsigned int model_column
,
951 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
953 return AppendColumn( new wxDataViewColumn( label
,
954 new wxDataViewTextRenderer( wxT("string"), mode
, (int)align
),
955 model_column
, width
, align
, flags
) );
958 bool wxDataViewCtrlBase::AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
959 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
961 return AppendColumn( new wxDataViewColumn( label
,
962 new wxDataViewToggleRenderer( wxT("bool"), mode
, (int)align
),
963 model_column
, width
, align
, flags
) );
966 bool wxDataViewCtrlBase::AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
967 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
969 return AppendColumn( new wxDataViewColumn( label
,
970 new wxDataViewProgressRenderer( wxEmptyString
, wxT("long"), mode
, (int)align
),
971 model_column
, width
, align
, flags
) );
974 bool wxDataViewCtrlBase::AppendDateColumn( const wxString
&label
, unsigned int model_column
,
975 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
977 return AppendColumn( new wxDataViewColumn( label
,
978 new wxDataViewDateRenderer( wxT("datetime"), mode
, (int)align
),
979 model_column
, width
, align
, flags
) );
982 bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
983 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
985 return AppendColumn( new wxDataViewColumn( label
,
986 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode
, (int)align
),
987 model_column
, width
, align
, flags
) );
990 bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
991 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
993 return AppendColumn( new wxDataViewColumn( label
,
994 new wxDataViewTextRenderer( wxT("string"), mode
, (int)align
),
995 model_column
, width
, align
, flags
) );
998 bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
999 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1001 return AppendColumn( new wxDataViewColumn( label
,
1002 new wxDataViewToggleRenderer( wxT("bool"), mode
, (int)align
),
1003 model_column
, width
, align
, flags
) );
1006 bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
1007 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1009 return AppendColumn( new wxDataViewColumn( label
,
1010 new wxDataViewProgressRenderer( wxEmptyString
, wxT("long"), mode
, (int)align
),
1011 model_column
, width
, align
, flags
) );
1014 bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
1015 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1017 return AppendColumn( new wxDataViewColumn( label
,
1018 new wxDataViewDateRenderer( wxT("datetime"), mode
, (int)align
),
1019 model_column
, width
, align
, flags
) );
1022 bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
1023 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1025 return AppendColumn( new wxDataViewColumn( label
,
1026 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode
, (int)align
),
1027 model_column
, width
, align
, flags
) );
1030 bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn
*col
)
1032 m_cols
.Append( (wxObject
*) col
);
1033 col
->SetOwner( (wxDataViewCtrl
*) this );
1034 m_model
->AddViewingColumn( col
, col
->GetModelColumn() );
1038 unsigned int wxDataViewCtrlBase::GetColumnCount() const
1040 return m_cols
.GetCount();
1043 bool wxDataViewCtrlBase::DeleteColumn( unsigned int WXUNUSED(pos
) )
1048 bool wxDataViewCtrlBase::ClearColumns()
1053 wxDataViewColumn
* wxDataViewCtrlBase::GetColumn( unsigned int pos
)
1055 return (wxDataViewColumn
*) m_cols
[ pos
];
1058 // ---------------------------------------------------------
1060 // ---------------------------------------------------------
1062 IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent
,wxNotifyEvent
)
1064 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED
)
1065 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED
)
1066 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
)
1067 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
)