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()
43 bool wxDataViewListModel::RowAppended()
47 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
50 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
51 if (!notifier
->RowAppended())
53 node
= node
->GetNext();
59 bool wxDataViewListModel::RowPrepended()
63 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
66 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
67 if (!notifier
->RowPrepended())
69 node
= node
->GetNext();
75 bool wxDataViewListModel::RowInserted( unsigned int before
)
79 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
82 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
83 if (!notifier
->RowInserted(before
))
85 node
= node
->GetNext();
91 bool wxDataViewListModel::RowDeleted( unsigned int row
)
95 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
98 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
99 if (!notifier
->RowDeleted( row
))
101 node
= node
->GetNext();
107 bool wxDataViewListModel::RowChanged( unsigned int row
)
111 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
114 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
115 if (!notifier
->RowChanged( row
))
117 node
= node
->GetNext();
123 bool wxDataViewListModel::ValueChanged( unsigned int col
, unsigned int row
)
127 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
130 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
131 if (!notifier
->ValueChanged( col
, row
))
133 node
= node
->GetNext();
139 bool wxDataViewListModel::RowsReordered( unsigned int *new_order
)
143 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
146 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
147 if (!notifier
->RowsReordered( new_order
))
149 node
= node
->GetNext();
155 bool wxDataViewListModel::Cleared()
159 wxList::compatibility_iterator node
= m_notifiers
.GetFirst();
162 wxDataViewListModelNotifier
* notifier
= (wxDataViewListModelNotifier
*) node
->GetData();
163 if (!notifier
->Cleared())
165 node
= node
->GetNext();
171 void wxDataViewListModel::AddViewingColumn( wxDataViewColumn
*view_column
, unsigned int model_column
)
173 m_viewingColumns
.Append( new wxDataViewViewingColumn( view_column
, model_column
) );
176 void wxDataViewListModel::RemoveViewingColumn( wxDataViewColumn
*column
)
178 wxList::compatibility_iterator node
= m_viewingColumns
.GetFirst();
181 wxDataViewViewingColumn
* tmp
= (wxDataViewViewingColumn
*) node
->GetData();
183 if (tmp
->m_viewColumn
== column
)
185 m_viewingColumns
.DeleteObject( tmp
);
189 node
= node
->GetNext();
193 void wxDataViewListModel::AddNotifier( wxDataViewListModelNotifier
*notifier
)
195 m_notifiers
.Append( notifier
);
196 notifier
->SetOwner( this );
199 void wxDataViewListModel::RemoveNotifier( wxDataViewListModelNotifier
*notifier
)
201 m_notifiers
.DeleteObject( notifier
);
204 // ---------------------------------------------------------
205 // wxDataViewSortedListModelNotifier
206 // ---------------------------------------------------------
208 class wxDataViewSortedListModelNotifier
: public wxDataViewListModelNotifier
211 wxDataViewSortedListModelNotifier( wxDataViewSortedListModel
*model
)
214 ~wxDataViewSortedListModelNotifier()
215 { m_model
->DetachChild(); }
217 virtual bool RowAppended()
218 { return m_model
->ChildRowAppended(); }
220 virtual bool RowPrepended()
221 { return m_model
->ChildRowPrepended(); }
223 virtual bool RowInserted( unsigned int before
)
224 { return m_model
->ChildRowInserted( before
); }
226 virtual bool RowDeleted( unsigned int row
)
227 { return m_model
->ChildRowDeleted( row
); }
229 virtual bool RowChanged( unsigned int row
)
230 { return m_model
->ChildRowChanged( row
); }
232 virtual bool ValueChanged( unsigned int col
, unsigned int row
)
233 { return m_model
->ChildValueChanged( col
, row
); }
235 virtual bool RowsReordered( unsigned int *new_order
)
236 { return m_model
->ChildRowsReordered( new_order
); }
238 virtual bool Cleared()
239 { return m_model
->ChildCleared(); }
241 wxDataViewSortedListModel
*m_model
;
244 // ---------------------------------------------------------
245 // wxDataViewSortedListModel compare function
246 // ---------------------------------------------------------
248 int wxCALLBACK wxDataViewListModelSortedDefaultCompare
249 (unsigned int row1
, unsigned int row2
, unsigned int col
, wxDataViewListModel
* model
)
251 wxVariant value1
,value2
;
252 model
->GetValue( value1
, col
, row1
);
253 model
->GetValue( value2
, col
, row2
);
254 if (value1
.GetType() == wxT("string"))
256 wxString str1
= value1
.GetString();
257 wxString str2
= value2
.GetString();
258 return str1
.Cmp( str2
);
260 if (value1
.GetType() == wxT("long"))
262 long l1
= value1
.GetLong();
263 long l2
= value2
.GetLong();
266 if (value1
.GetType() == wxT("double"))
268 double d1
= value1
.GetDouble();
269 double d2
= value2
.GetDouble();
270 if (d1
== d2
) return 0;
271 if (d1
< d2
) return 1;
274 if (value1
.GetType() == wxT("datetime"))
276 wxDateTime dt1
= value1
.GetDateTime();
277 wxDateTime dt2
= value2
.GetDateTime();
278 if (dt1
.IsEqualTo(dt2
)) return 0;
279 if (dt1
.IsEarlierThan(dt2
)) return 1;
286 int wxCALLBACK wxDataViewListModelSortedDefaultCompareDescending
287 (unsigned int row1
, unsigned int row2
, unsigned int col
, wxDataViewListModel
* model
)
289 return wxDataViewListModelSortedDefaultCompare( row2
, row1
, col
, model
);
292 static wxDataViewListModelCompare s_CmpFunc
;
293 static wxDataViewListModel
*s_CmpModel
;
294 static unsigned int s_CmpCol
;
296 int LINKAGEMODE
wxDataViewIntermediateCmp( unsigned int row1
, unsigned int row2
)
298 return s_CmpFunc( row1
, row2
, s_CmpCol
, s_CmpModel
);
301 // ---------------------------------------------------------
302 // wxDataViewSortedListModel
303 // ---------------------------------------------------------
305 wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel
*child
) :
306 m_array( wxDataViewIntermediateCmp
)
312 m_notifierOnChild
= new wxDataViewSortedListModelNotifier( this );
313 m_child
->AddNotifier( m_notifierOnChild
);
318 wxDataViewSortedListModel::~wxDataViewSortedListModel()
321 m_child
->RemoveNotifier( m_notifierOnChild
);
324 void wxDataViewSortedListModel::DetachChild()
330 void wxDataViewSortedListModel::InitStatics()
333 s_CmpModel
= m_child
;
335 s_CmpFunc
= wxDataViewListModelSortedDefaultCompare
;
337 s_CmpFunc
= wxDataViewListModelSortedDefaultCompareDescending
;
340 void wxDataViewSortedListModel::Resort()
345 unsigned int n
= m_child
->GetRowCount();
347 for (i
= 0; i
< n
; i
++)
350 // do we need the neworder?
351 wxDataViewListModel::RowsReordered( NULL
);
355 static void Dump( wxDataViewListModel
*model
, unsigned int col
)
357 unsigned int n
= model
->GetRowCount();
359 for (i
= 0; i
< n
; i
++)
362 model
->GetValue( variant
, col
, i
);
364 tmp
= variant
.GetString();
365 wxPrintf( wxT("%d: %s\n"), (int) i
, tmp
.c_str() );
370 bool wxDataViewSortedListModel::ChildRowAppended()
372 // no need to fix up array
374 unsigned int len
= m_array
.GetCount();
376 unsigned int pos
= m_array
.Add( len
);
379 return wxDataViewListModel::RowPrepended();
382 return wxDataViewListModel::RowAppended();
384 return wxDataViewListModel::RowInserted( pos
);
387 bool wxDataViewSortedListModel::ChildRowPrepended()
391 unsigned int len
= m_array
.GetCount();
392 for (i
= 0; i
< len
; i
++)
394 unsigned int value
= m_array
[i
];
395 m_array
[i
] = value
+1;
398 unsigned int pos
= m_array
.Add( 0 );
401 return wxDataViewListModel::RowPrepended();
404 return wxDataViewListModel::RowAppended();
406 return wxDataViewListModel::RowInserted( pos
);
409 bool wxDataViewSortedListModel::ChildRowInserted( unsigned int before
)
413 unsigned int len
= m_array
.GetCount();
414 for (i
= 0; i
< len
; i
++)
416 unsigned int value
= m_array
[i
];
418 m_array
[i
] = value
+1;
421 unsigned int pos
= m_array
.Add( before
);
424 return wxDataViewListModel::RowPrepended();
427 return wxDataViewListModel::RowAppended();
429 return wxDataViewListModel::RowInserted( pos
);
432 bool wxDataViewSortedListModel::ChildRowDeleted( unsigned int row
)
435 unsigned int len
= m_array
.GetCount();
437 for (i
= 0; i
< len
; i
++)
439 unsigned int value
= m_array
[i
];
449 m_array
[i
] = value
-1;
454 return false; // we should probably assert
457 m_array
.RemoveAt( (unsigned int) pos
);
459 return wxDataViewListModel::RowDeleted( (unsigned int) pos
);
462 bool wxDataViewSortedListModel::ChildRowChanged( unsigned int row
)
465 unsigned int len
= m_array
.GetCount();
467 // Remove and readd sorted. Find out at which
468 // position it was and where it ended.
469 unsigned int start_pos
= 0,end_pos
= 0;
470 for (i
= 0; i
< len
; i
++)
471 if (m_array
[i
] == row
)
476 m_array
.RemoveAt( start_pos
);
479 for (i
= 0; i
< len
; i
++)
480 if (m_array
[i
] == row
)
486 if (end_pos
== start_pos
)
487 return wxDataViewListModel::RowChanged( start_pos
);
489 // Create an array where order[old] -> new_pos, so that
490 // if nothing changed order[0] -> 0 etc.
491 unsigned int *order
= new unsigned int[ len
];
492 // Fill up initial values.
493 for (i
= 0; i
< len
; i
++)
496 if (start_pos
< end_pos
)
498 for (i
= start_pos
; i
< end_pos
; i
++)
499 order
[i
] = order
[i
+1];
500 order
[end_pos
] = start_pos
;
504 for (i
= end_pos
; i
> start_pos
; i
--)
505 order
[i
] = order
[i
-1];
506 order
[start_pos
] = end_pos
;
509 wxDataViewListModel::RowsReordered( order
);
516 bool wxDataViewSortedListModel::ChildValueChanged( unsigned int col
, unsigned int row
)
519 unsigned int len
= m_array
.GetCount();
521 // Remove and readd sorted. Find out at which
522 // position it was and where it ended.
523 unsigned int start_pos
= 0,end_pos
= 0;
524 for (i
= 0; i
< len
; i
++)
525 if (m_array
[i
] == row
)
530 m_array
.RemoveAt( start_pos
);
533 for (i
= 0; i
< len
; i
++)
534 if (m_array
[i
] == row
)
540 if (end_pos
== start_pos
)
541 return wxDataViewListModel::ValueChanged( col
, start_pos
);
543 // Create an array where order[old] -> new_pos, so that
544 // if nothing changed order[0] -> 0 etc.
545 unsigned int *order
= new unsigned int[ len
];
546 // Fill up initial values.
547 for (i
= 0; i
< len
; i
++)
550 if (start_pos
< end_pos
)
552 for (i
= start_pos
; i
< end_pos
; i
++)
553 order
[i
] = order
[i
+1];
554 order
[end_pos
] = start_pos
;
558 for (i
= end_pos
; i
> start_pos
; i
--)
559 order
[i
] = order
[i
-1];
560 order
[start_pos
] = end_pos
;
563 wxDataViewListModel::RowsReordered( order
);
570 bool wxDataViewSortedListModel::ChildRowsReordered( unsigned int *WXUNUSED(new_order
) )
572 // Nothing needs to be done. If the sort criteria
573 // of this list don't change, the order of the
574 // items of the child list isn't relevant.
578 bool wxDataViewSortedListModel::ChildCleared()
580 return wxDataViewListModel::Cleared();
583 unsigned int wxDataViewSortedListModel::GetRowCount() const
585 return m_array
.GetCount();
588 unsigned int wxDataViewSortedListModel::GetColumnCount() const
590 return m_child
->GetColumnCount();
593 wxString
wxDataViewSortedListModel::GetColumnType( unsigned int col
) const
595 return m_child
->GetColumnType( col
);
598 void wxDataViewSortedListModel::GetValue( wxVariant
&variant
, unsigned int col
, unsigned int row
) const
600 unsigned int child_row
= m_array
[row
];
601 m_child
->GetValue( variant
, col
, child_row
);
604 bool wxDataViewSortedListModel::SetValue( const wxVariant
&variant
, unsigned int col
, unsigned int row
)
606 unsigned int child_row
= m_array
[row
];
607 bool ret
= m_child
->SetValue( variant
, col
, child_row
);
609 // Do nothing here as the change in the
610 // child model will be reported back.
615 bool wxDataViewSortedListModel::RowAppended()
617 // you can only append
618 bool ret
= m_child
->RowAppended();
620 // Do nothing here as the change in the
621 // child model will be reported back.
626 bool wxDataViewSortedListModel::RowPrepended()
628 // you can only append
629 bool ret
= m_child
->RowAppended();
631 // Do nothing here as the change in the
632 // child model will be reported back.
637 bool wxDataViewSortedListModel::RowInserted( unsigned int WXUNUSED(before
) )
639 // you can only append
640 bool ret
= m_child
->RowAppended();
642 // Do nothing here as the change in the
643 // child model will be reported back.
648 bool wxDataViewSortedListModel::RowDeleted( unsigned int row
)
650 unsigned int child_row
= m_array
[row
];
652 bool ret
= m_child
->RowDeleted( child_row
);
654 // Do nothing here as the change in the
655 // child model will be reported back.
660 bool wxDataViewSortedListModel::RowChanged( unsigned int row
)
662 unsigned int child_row
= m_array
[row
];
663 bool ret
= m_child
->RowChanged( child_row
);
665 // Do nothing here as the change in the
666 // child model will be reported back.
671 bool wxDataViewSortedListModel::ValueChanged( unsigned int col
, unsigned int row
)
673 unsigned int child_row
= m_array
[row
];
674 bool ret
= m_child
->ValueChanged( col
, child_row
);
676 // Do nothing here as the change in the
677 // child model will be reported back.
682 bool wxDataViewSortedListModel::RowsReordered( unsigned int *WXUNUSED(new_order
) )
684 // We sort them ourselves.
689 bool wxDataViewSortedListModel::Cleared()
691 bool ret
= m_child
->Cleared();
693 // Do nothing here as the change in the
694 // child model will be reported back.
699 // ---------------------------------------------------------
700 // wxDataViewRendererBase
701 // ---------------------------------------------------------
703 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase
, wxObject
)
705 wxDataViewRendererBase::wxDataViewRendererBase( const wxString
&varianttype
,
706 wxDataViewCellMode
WXUNUSED(mode
),
707 int WXUNUSED(align
) )
709 m_variantType
= varianttype
;
711 m_row
= (unsigned int) -1;
714 const wxDataViewCtrl
* wxDataViewRendererBase::GetView() const
716 return wx_const_cast(wxDataViewRendererBase
*, this)->GetOwner()->GetOwner();
719 bool wxDataViewRendererBase::StartEditing( unsigned int row
, wxRect labelRect
)
721 m_row
= row
; // remember for later
723 unsigned int col
= GetOwner()->GetModelColumn();
725 GetOwner()->GetOwner()->GetModel()->GetValue( value
, col
, row
);
727 m_editorCtrl
= CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect
, value
);
729 wxDataViewEditorCtrlEvtHandler
*handler
=
730 new wxDataViewEditorCtrlEvtHandler( m_editorCtrl
, (wxDataViewRenderer
*) this );
732 m_editorCtrl
->PushEventHandler( handler
);
734 #if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL)
735 handler
->SetFocusOnIdle();
737 m_editorCtrl
->SetFocus();
743 void wxDataViewRendererBase::CancelEditing()
745 wxPendingDelete
.Append( m_editorCtrl
);
747 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
749 // m_editorCtrl->PopEventHandler( true );
752 bool wxDataViewRendererBase::FinishEditing()
755 GetValueFromEditorCtrl( m_editorCtrl
, value
);
757 wxPendingDelete
.Append( m_editorCtrl
);
759 GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
761 if (!Validate(value
))
764 unsigned int col
= GetOwner()->GetModelColumn();
765 GetOwner()->GetOwner()->GetModel()->SetValue( value
, col
, m_row
);
766 GetOwner()->GetOwner()->GetModel()->ValueChanged( col
, m_row
);
768 // m_editorCtrl->PopEventHandler( true );
773 //-----------------------------------------------------------------------------
774 // wxDataViewEditorCtrlEvtHandler
775 //-----------------------------------------------------------------------------
777 BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler
, wxEvtHandler
)
778 EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar
)
779 EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus
)
780 EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle
)
783 wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
784 wxControl
*editorCtrl
,
785 wxDataViewRenderer
*owner
)
788 m_editorCtrl
= editorCtrl
;
793 void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent
&event
)
797 m_focusOnIdle
= false;
798 if (wxWindow::FindFocus() != m_editorCtrl
)
799 m_editorCtrl
->SetFocus();
805 void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent
&event
)
807 switch ( event
.m_keyCode
)
811 m_owner
->FinishEditing();
816 m_owner
->CancelEditing();
824 void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent
&event
)
829 m_owner
->FinishEditing();
835 // ---------------------------------------------------------
836 // wxDataViewColumnBase
837 // ---------------------------------------------------------
839 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase
, wxObject
)
841 wxDataViewColumnBase::wxDataViewColumnBase(const wxString
& WXUNUSED(title
),
842 wxDataViewRenderer
*renderer
,
843 unsigned int model_column
,
845 wxAlignment
WXUNUSED(align
),
848 m_renderer
= renderer
;
849 m_model_column
= model_column
;
851 m_renderer
->SetOwner( (wxDataViewColumn
*) this );
853 // NOTE: the wxDataViewColumn's ctor must store the width, align, flags
854 // parameters inside the native control!
857 wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap
& bitmap
,
858 wxDataViewRenderer
*renderer
,
859 unsigned int model_column
,
861 wxAlignment
WXUNUSED(align
),
862 int WXUNUSED(flags
) )
864 m_renderer
= renderer
;
865 m_model_column
= model_column
;
868 m_renderer
->SetOwner( (wxDataViewColumn
*) this );
871 wxDataViewColumnBase::~wxDataViewColumnBase()
878 GetOwner()->GetModel()->RemoveViewingColumn( (wxDataViewColumn
*) this );
882 int wxDataViewColumnBase::GetFlags() const
887 ret
|= wxDATAVIEW_COL_SORTABLE
;
889 ret
|= wxDATAVIEW_COL_RESIZABLE
;
891 ret
|= wxDATAVIEW_COL_HIDDEN
;
896 void wxDataViewColumnBase::SetFlags(int flags
)
898 SetSortable((flags
& wxDATAVIEW_COL_SORTABLE
) != 0);
899 SetResizeable((flags
& wxDATAVIEW_COL_RESIZABLE
) != 0);
900 SetHidden((flags
& wxDATAVIEW_COL_HIDDEN
) != 0);
904 // ---------------------------------------------------------
905 // wxDataViewCtrlBase
906 // ---------------------------------------------------------
908 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase
, wxControl
)
910 wxDataViewCtrlBase::wxDataViewCtrlBase()
913 m_cols
.DeleteContents( true );
916 wxDataViewCtrlBase::~wxDataViewCtrlBase()
918 // IMPORTANT: before calling DecRef() on our model (since it may
919 // result in a free() call), erase all columns (since
920 // they hold a pointer to our model)
930 bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel
*model
)
933 m_model
->DecRef(); // discard old model, if any
935 // add our own reference to the new model:
943 wxDataViewListModel
* wxDataViewCtrlBase::GetModel()
948 bool wxDataViewCtrlBase::AppendTextColumn( const wxString
&label
, unsigned int model_column
,
949 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
951 return AppendColumn( new wxDataViewColumn( label
,
952 new wxDataViewTextRenderer( wxT("string"), mode
, (int)align
),
953 model_column
, width
, align
, flags
) );
956 bool wxDataViewCtrlBase::AppendToggleColumn( const wxString
&label
, unsigned int model_column
,
957 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
959 return AppendColumn( new wxDataViewColumn( label
,
960 new wxDataViewToggleRenderer( wxT("bool"), mode
, (int)align
),
961 model_column
, width
, align
, flags
) );
964 bool wxDataViewCtrlBase::AppendProgressColumn( const wxString
&label
, unsigned int model_column
,
965 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
967 return AppendColumn( new wxDataViewColumn( label
,
968 new wxDataViewProgressRenderer( wxEmptyString
, wxT("long"), mode
, (int)align
),
969 model_column
, width
, align
, flags
) );
972 bool wxDataViewCtrlBase::AppendDateColumn( const wxString
&label
, unsigned int model_column
,
973 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
975 return AppendColumn( new wxDataViewColumn( label
,
976 new wxDataViewDateRenderer( wxT("datetime"), mode
, (int)align
),
977 model_column
, width
, align
, flags
) );
980 bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString
&label
, unsigned int model_column
,
981 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
983 return AppendColumn( new wxDataViewColumn( label
,
984 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode
, (int)align
),
985 model_column
, width
, align
, flags
) );
988 bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap
&label
, unsigned int model_column
,
989 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
991 return AppendColumn( new wxDataViewColumn( label
,
992 new wxDataViewTextRenderer( wxT("string"), mode
, (int)align
),
993 model_column
, width
, align
, flags
) );
996 bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap
&label
, unsigned int model_column
,
997 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
999 return AppendColumn( new wxDataViewColumn( label
,
1000 new wxDataViewToggleRenderer( wxT("bool"), mode
, (int)align
),
1001 model_column
, width
, align
, flags
) );
1004 bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap
&label
, unsigned int model_column
,
1005 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1007 return AppendColumn( new wxDataViewColumn( label
,
1008 new wxDataViewProgressRenderer( wxEmptyString
, wxT("long"), mode
, (int)align
),
1009 model_column
, width
, align
, flags
) );
1012 bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap
&label
, unsigned int model_column
,
1013 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1015 return AppendColumn( new wxDataViewColumn( label
,
1016 new wxDataViewDateRenderer( wxT("datetime"), mode
, (int)align
),
1017 model_column
, width
, align
, flags
) );
1020 bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap
&label
, unsigned int model_column
,
1021 wxDataViewCellMode mode
, int width
, wxAlignment align
, int flags
)
1023 return AppendColumn( new wxDataViewColumn( label
,
1024 new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode
, (int)align
),
1025 model_column
, width
, align
, flags
) );
1028 bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn
*col
)
1030 m_cols
.Append( (wxObject
*) col
);
1031 col
->SetOwner( (wxDataViewCtrl
*) this );
1032 m_model
->AddViewingColumn( col
, col
->GetModelColumn() );
1036 unsigned int wxDataViewCtrlBase::GetColumnCount() const
1038 return m_cols
.GetCount();
1041 bool wxDataViewCtrlBase::DeleteColumn( unsigned int WXUNUSED(pos
) )
1046 bool wxDataViewCtrlBase::ClearColumns()
1051 wxDataViewColumn
* wxDataViewCtrlBase::GetColumn( unsigned int pos
)
1053 return (wxDataViewColumn
*) m_cols
[ pos
];
1056 // ---------------------------------------------------------
1058 // ---------------------------------------------------------
1060 IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent
,wxNotifyEvent
)
1062 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED
)
1063 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED
)
1064 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
)
1065 DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
)