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 #include "wx/object.h"
19 #include "wx/dataview.h"
23 // ---------------------------------------------------------
25 // ---------------------------------------------------------
27 IMPLEMENT_ABSTRACT_CLASS(wxDataViewModel
, wxObject
)
29 // ---------------------------------------------------------
30 // wxDataViewListModel
31 // ---------------------------------------------------------
33 IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel
, wxDataViewModel
)
35 wxDataViewListModel::wxDataViewListModel()
40 wxDataViewListModel::~wxDataViewListModel()
46 bool wxDataViewListModel::RowAppended()
49 return m_notifier
->RowAppended();
54 bool wxDataViewListModel::RowPrepended()
57 return m_notifier
->RowPrepended();
62 bool wxDataViewListModel::RowInserted( size_t before
)
65 return m_notifier
->RowInserted( before
);
70 bool wxDataViewListModel::RowDeleted( size_t row
)
73 return m_notifier
->RowDeleted( row
);
78 bool wxDataViewListModel::RowChanged( size_t row
)
81 return m_notifier
->RowChanged( row
);
86 bool wxDataViewListModel::ValueChanged( size_t col
, size_t row
)
89 return m_notifier
->ValueChanged( col
, row
);
94 bool wxDataViewListModel::Cleared()
97 return m_notifier
->Cleared();
102 void wxDataViewListModel::SetNotifier( wxDataViewListModelNotifier
*notifier
)
107 m_notifier
= notifier
;
110 wxDataViewListModelNotifier
* wxDataViewListModel::GetNotifier()
115 // ---------------------------------------------------------
116 // wxDataViewCellBase
117 // ---------------------------------------------------------
119 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCellBase
, wxObject
)
121 wxDataViewCellBase::wxDataViewCellBase( const wxString
&varianttype
, wxDataViewCellMode mode
)
123 m_variantType
= varianttype
;
127 // ---------------------------------------------------------
128 // wxDataViewColumnBase
129 // ---------------------------------------------------------
131 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase
, wxObject
)
133 wxDataViewColumnBase::wxDataViewColumnBase( const wxString
&title
, wxDataViewCell
*cell
, size_t model_column
, int flags
)
136 m_model_column
= model_column
;
140 m_cell
->SetOwner( (wxDataViewColumn
*) this );
143 wxDataViewColumnBase::~wxDataViewColumnBase()
149 void wxDataViewColumnBase::SetTitle( const wxString
&title
)
154 wxString
wxDataViewColumnBase::GetTitle()
159 // ---------------------------------------------------------
160 // wxDataViewCtrlBase
161 // ---------------------------------------------------------
163 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase
, wxControl
)
165 wxDataViewCtrlBase::wxDataViewCtrlBase()
168 m_cols
.DeleteContents( true );
171 wxDataViewCtrlBase::~wxDataViewCtrlBase()
177 bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel
*model
)
187 wxDataViewListModel
* wxDataViewCtrlBase::GetModel()
192 bool wxDataViewCtrlBase::AppendTextColumn( const wxString
&label
, size_t model_column
)
194 return AppendColumn( new wxDataViewColumn( label
, new wxDataViewTextCell(), model_column
) );
197 bool wxDataViewCtrlBase::AppendToggleColumn( const wxString
&label
, size_t model_column
)
199 return AppendColumn( new wxDataViewColumn( label
, new wxDataViewToggleCell(), model_column
) );
202 bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn
*col
)
204 m_cols
.Append( (wxObject
*) col
);
205 col
->SetOwner( (wxDataViewCtrl
*) this );
209 size_t wxDataViewCtrlBase::GetNumberOfColumns()
211 return m_cols
.GetCount();
214 bool wxDataViewCtrlBase::DeleteColumn( size_t pos
)
219 bool wxDataViewCtrlBase::ClearColumns()
224 wxDataViewColumn
* wxDataViewCtrlBase::GetColumn( size_t pos
)
226 return (wxDataViewColumn
*) m_cols
[ pos
];