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( 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 // m_editorCtrl->PopEventHandler( true );
751 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
754 bool wxDataViewRendererBase::FinishEditing()
756 // m_editorCtrl->PopEventHandler( true );
759 GetValueFromEditorCtrl( m_editorCtrl
, value
);
763 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
765 if (!Validate(value
))
768 unsigned int col
= GetOwner()->GetModelColumn();
769 GetOwner()->GetOwner()->GetModel()->SetValue( value
, col
, m_row
);
770 GetOwner()->GetOwner()->GetModel()->ValueChanged( col
, m_row
);
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();
834 // We must let the native text control handle focus
838 // ---------------------------------------------------------
839 // wxDataViewColumnBase
840 // ---------------------------------------------------------
842 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase
, wxObject
)
844 wxDataViewColumnBase::wxDataViewColumnBase(const wxString
& WXUNUSED(title
),
845 wxDataViewRenderer
*renderer
,
846 unsigned int model_column
,
848 wxAlignment
WXUNUSED(align
),
851 m_renderer
= renderer
;
852 m_model_column
= model_column
;
854 m_renderer
->SetOwner( (wxDataViewColumn
*) this );
856 // NOTE: the wxDataViewColumn's ctor must store the width, align, flags
857 // parameters inside the native control!
860 wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap
& bitmap
,
861 wxDataViewRenderer
*renderer
,
862 unsigned int model_column
,
864 wxAlignment
WXUNUSED(align
),
865 int WXUNUSED(flags
) )
867 m_renderer
= renderer
;
868 m_model_column
= model_column
;
871 m_renderer
->SetOwner( (wxDataViewColumn
*) this );
874 wxDataViewColumnBase::~wxDataViewColumnBase()
881 GetOwner()->GetModel()->RemoveViewingColumn( (wxDataViewColumn
*) this );
885 int wxDataViewColumnBase::GetFlags() const
890 ret
|= wxDATAVIEW_COL_SORTABLE
;
892 ret
|= wxDATAVIEW_COL_RESIZABLE
;
894 ret
|= wxDATAVIEW_COL_HIDDEN
;
899 void wxDataViewColumnBase::SetFlags(int flags
)
901 SetSortable((flags
& wxDATAVIEW_COL_SORTABLE
) != 0);
902 SetResizeable((flags
& wxDATAVIEW_COL_RESIZABLE
) != 0);
903 SetHidden((flags
& wxDATAVIEW_COL_HIDDEN
) != 0);
907 // ---------------------------------------------------------
908 // wxDataViewCtrlBase
909 // ---------------------------------------------------------
911 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase
, wxControl
)
913 wxDataViewCtrlBase::wxDataViewCtrlBase()
916 m_cols
.DeleteContents( true );
919 wxDataViewCtrlBase::~wxDataViewCtrlBase()
921 // IMPORTANT: before calling DecRef() on our model (since it may
922 // result in a free() call), erase all columns (since
923 // they hold a pointer to our model)
933 bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel
*model
)
936 m_model
->DecRef(); // discard old model, if any
938 // add our own reference to the new model:
946 wxDataViewListModel
* wxDataViewCtrlBase::GetModel()
951 bool wxDataViewCtrlBase::AppendTextColumn( const wxString
&label
, unsigned int model_column
,
952 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
954 return AppendColumn( new wxDataViewColumn( label
,
955 new wxDataViewTextRenderer( wxT("string"), mode
, (int)align
),
956 model_column
, width
, align
, flags
) );
959 bool wxDataViewCtrlBase::AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
960 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
962 return AppendColumn( new wxDataViewColumn( label
,
963 new wxDataViewToggleRenderer( wxT("bool"), mode
, (int)align
),
964 model_column
, width
, align
, flags
) );
967 bool wxDataViewCtrlBase::AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
968 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
970 return AppendColumn( new wxDataViewColumn( label
,
971 new wxDataViewProgressRenderer( wxEmptyString
, wxT("long"), mode
, (int)align
),
972 model_column
, width
, align
, flags
) );
975 bool wxDataViewCtrlBase::AppendDateColumn( const wxString
&label
, unsigned int model_column
,
976 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
978 return AppendColumn( new wxDataViewColumn( label
,
979 new wxDataViewDateRenderer( wxT("datetime"), mode
, (int)align
),
980 model_column
, width
, align
, flags
) );
983 bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
984 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
986 return AppendColumn( new wxDataViewColumn( label
,
987 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode
, (int)align
),
988 model_column
, width
, align
, flags
) );
991 bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
992 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
994 return AppendColumn( new wxDataViewColumn( label
,
995 new wxDataViewTextRenderer( wxT("string"), mode
, (int)align
),
996 model_column
, width
, align
, flags
) );
999 bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
1000 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1002 return AppendColumn( new wxDataViewColumn( label
,
1003 new wxDataViewToggleRenderer( wxT("bool"), mode
, (int)align
),
1004 model_column
, width
, align
, flags
) );
1007 bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
1008 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1010 return AppendColumn( new wxDataViewColumn( label
,
1011 new wxDataViewProgressRenderer( wxEmptyString
, wxT("long"), mode
, (int)align
),
1012 model_column
, width
, align
, flags
) );
1015 bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
1016 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1018 return AppendColumn( new wxDataViewColumn( label
,
1019 new wxDataViewDateRenderer( wxT("datetime"), mode
, (int)align
),
1020 model_column
, width
, align
, flags
) );
1023 bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
1024 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1026 return AppendColumn( new wxDataViewColumn( label
,
1027 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode
, (int)align
),
1028 model_column
, width
, align
, flags
) );
1031 bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn
*col
)
1033 m_cols
.Append( (wxObject
*) col
);
1034 col
->SetOwner( (wxDataViewCtrl
*) this );
1035 m_model
->AddViewingColumn( col
, col
->GetModelColumn() );
1039 unsigned int wxDataViewCtrlBase::GetColumnCount() const
1041 return m_cols
.GetCount();
1044 bool wxDataViewCtrlBase::DeleteColumn( unsigned int WXUNUSED(pos
) )
1049 bool wxDataViewCtrlBase::ClearColumns()
1054 wxDataViewColumn
* wxDataViewCtrlBase::GetColumn( unsigned int pos
)
1056 return (wxDataViewColumn
*) m_cols
[ pos
];
1059 // ---------------------------------------------------------
1061 // ---------------------------------------------------------
1063 IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent
,wxNotifyEvent
)
1065 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED
)
1066 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED
)
1067 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
)
1068 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
)