Added generic MVC hookup code.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37749 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -64,8 +64,9 @@ public:
|
|||||||
virtual bool RowInserted( size_t before ) = 0;
|
virtual bool RowInserted( size_t before ) = 0;
|
||||||
virtual bool RowDeleted( size_t row ) = 0;
|
virtual bool RowDeleted( size_t row ) = 0;
|
||||||
virtual bool RowChanged( size_t row ) = 0;
|
virtual bool RowChanged( size_t row ) = 0;
|
||||||
virtual bool ValueChanged( size_t row, size_t col ) = 0;
|
virtual bool ValueChanged( size_t col, size_t row ) = 0;
|
||||||
virtual bool Cleared() = 0;
|
virtual bool Cleared() = 0;
|
||||||
|
virtual bool ValueChanged( wxDataViewColumn *view_column, size_t model_column, size_t row ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -96,11 +97,17 @@ public:
|
|||||||
bool ValueChanged( size_t col, size_t row );
|
bool ValueChanged( size_t col, size_t row );
|
||||||
bool Cleared();
|
bool Cleared();
|
||||||
|
|
||||||
|
// Used internally
|
||||||
|
void AddViewingColumn( wxDataViewColumn *view_column, size_t model_column );
|
||||||
|
void RemoveViewingColumn( wxDataViewColumn *column );
|
||||||
|
|
||||||
|
// Used internally
|
||||||
void SetNotifier( wxDataViewListModelNotifier *notifier );
|
void SetNotifier( wxDataViewListModelNotifier *notifier );
|
||||||
wxDataViewListModelNotifier* GetNotifier();
|
wxDataViewListModelNotifier* GetNotifier();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDataViewListModelNotifier *m_notifier;
|
wxDataViewListModelNotifier *m_notifier;
|
||||||
|
wxList m_viewingColumns;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewListModel)
|
||||||
|
@@ -34,11 +34,26 @@ IMPLEMENT_ABSTRACT_CLASS(wxDataViewModel, wxObject)
|
|||||||
// wxDataViewListModel
|
// wxDataViewListModel
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
class wxDataViewViewingColumn: public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxDataViewViewingColumn( wxDataViewColumn *view_column, size_t model_column )
|
||||||
|
{
|
||||||
|
m_viewColumn = view_column;
|
||||||
|
m_modelColumn = model_column;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDataViewColumn *m_viewColumn;
|
||||||
|
size_t m_modelColumn;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel, wxDataViewModel)
|
IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel, wxDataViewModel)
|
||||||
|
|
||||||
wxDataViewListModel::wxDataViewListModel()
|
wxDataViewListModel::wxDataViewListModel()
|
||||||
{
|
{
|
||||||
m_notifier = NULL;
|
m_notifier = NULL;
|
||||||
|
m_viewingColumns.DeleteContents( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewListModel::~wxDataViewListModel()
|
wxDataViewListModel::~wxDataViewListModel()
|
||||||
@@ -89,10 +104,23 @@ bool wxDataViewListModel::RowChanged( size_t row )
|
|||||||
|
|
||||||
bool wxDataViewListModel::ValueChanged( size_t col, size_t row )
|
bool wxDataViewListModel::ValueChanged( size_t col, size_t row )
|
||||||
{
|
{
|
||||||
if (m_notifier)
|
bool ret = false;
|
||||||
return m_notifier->ValueChanged( col, row );
|
|
||||||
|
|
||||||
return false;
|
if (m_notifier)
|
||||||
|
ret = m_notifier->ValueChanged( col, row );
|
||||||
|
|
||||||
|
wxNode *node = m_viewingColumns.GetFirst();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
wxDataViewViewingColumn* tmp = (wxDataViewViewingColumn*) node->GetData();
|
||||||
|
|
||||||
|
if (tmp->m_modelColumn == col)
|
||||||
|
m_notifier->ValueChanged( tmp->m_viewColumn, col, row );
|
||||||
|
|
||||||
|
node = node->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewListModel::Cleared()
|
bool wxDataViewListModel::Cleared()
|
||||||
@@ -103,6 +131,28 @@ bool wxDataViewListModel::Cleared()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxDataViewListModel::AddViewingColumn( wxDataViewColumn *view_column, size_t model_column )
|
||||||
|
{
|
||||||
|
m_viewingColumns.Append( new wxDataViewViewingColumn( view_column, model_column ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDataViewListModel::RemoveViewingColumn( wxDataViewColumn *column )
|
||||||
|
{
|
||||||
|
wxNode *node = m_viewingColumns.GetFirst();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
wxDataViewViewingColumn* tmp = (wxDataViewViewingColumn*) node->GetData();
|
||||||
|
|
||||||
|
if (tmp->m_viewColumn == column)
|
||||||
|
{
|
||||||
|
m_viewingColumns.DeleteObject( tmp );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
node = node->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxDataViewListModel::SetNotifier( wxDataViewListModelNotifier *notifier )
|
void wxDataViewListModel::SetNotifier( wxDataViewListModelNotifier *notifier )
|
||||||
{
|
{
|
||||||
if (m_notifier)
|
if (m_notifier)
|
||||||
@@ -148,6 +198,11 @@ wxDataViewColumnBase::~wxDataViewColumnBase()
|
|||||||
{
|
{
|
||||||
if (m_cell)
|
if (m_cell)
|
||||||
delete m_cell;
|
delete m_cell;
|
||||||
|
|
||||||
|
if (GetOwner())
|
||||||
|
{
|
||||||
|
GetOwner()->GetModel()->RemoveViewingColumn( (wxDataViewColumn*) this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataViewColumnBase::SetTitle( const wxString &title )
|
void wxDataViewColumnBase::SetTitle( const wxString &title )
|
||||||
@@ -217,6 +272,7 @@ bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col )
|
|||||||
{
|
{
|
||||||
m_cols.Append( (wxObject*) col );
|
m_cols.Append( (wxObject*) col );
|
||||||
col->SetOwner( (wxDataViewCtrl*) this );
|
col->SetOwner( (wxDataViewCtrl*) this );
|
||||||
|
m_model->AddViewingColumn( col, col->GetModelColumn() );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -736,6 +736,7 @@ public:
|
|||||||
virtual bool RowChanged( size_t row );
|
virtual bool RowChanged( size_t row );
|
||||||
virtual bool ValueChanged( size_t col, size_t row );
|
virtual bool ValueChanged( size_t col, size_t row );
|
||||||
virtual bool Cleared();
|
virtual bool Cleared();
|
||||||
|
virtual bool ValueChanged( wxDataViewColumn *view_column, size_t model_column, size_t row );
|
||||||
|
|
||||||
GtkWxListStore *m_gtk_store;
|
GtkWxListStore *m_gtk_store;
|
||||||
wxDataViewListModel *m_wx_model;
|
wxDataViewListModel *m_wx_model;
|
||||||
@@ -814,6 +815,11 @@ bool wxGtkDataViewListModelNotifier::Cleared()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxGtkDataViewListModelNotifier::ValueChanged( wxDataViewColumn *view_column, size_t model_column, size_t row )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewCell
|
// wxDataViewCell
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user