Add notifier class.
Only use listmodel for now, treemodel later. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37662 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
111f83c49e
commit
6e2e590f2a
@ -111,11 +111,11 @@ public:
|
|||||||
|
|
||||||
virtual bool AppendStringColumn( const wxString &label ) = 0;
|
virtual bool AppendStringColumn( const wxString &label ) = 0;
|
||||||
|
|
||||||
virtual bool AssociateModel( wxDataViewModel *model );
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
||||||
wxDataViewModel* GetModel();
|
wxDataViewListModel* GetModel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDataViewModel *m_model;
|
wxDataViewListModel *m_model;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCtrlBase)
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
virtual bool AppendStringColumn( const wxString &label );
|
virtual bool AppendStringColumn( const wxString &label );
|
||||||
|
|
||||||
virtual bool AssociateModel( wxDataViewModel *model );
|
virtual bool AssociateModel( wxDataViewListModel *model );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -129,7 +129,7 @@ wxDataViewCtrlBase::~wxDataViewCtrlBase()
|
|||||||
delete m_model;
|
delete m_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrlBase::AssociateModel( wxDataViewModel *model )
|
bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel *model )
|
||||||
{
|
{
|
||||||
if (m_model)
|
if (m_model)
|
||||||
delete m_model;
|
delete m_model;
|
||||||
@ -139,7 +139,7 @@ bool wxDataViewCtrlBase::AssociateModel( wxDataViewModel *model )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewModel* wxDataViewCtrlBase::GetModel()
|
wxDataViewListModel* wxDataViewCtrlBase::GetModel()
|
||||||
{
|
{
|
||||||
return m_model;
|
return m_model;
|
||||||
}
|
}
|
||||||
|
@ -423,6 +423,84 @@ wxgtk_list_store_iter_parent (GtkTreeModel *tree_model,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
// wxGtkDataViewListModelNotifier
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
class wxGtkDataViewListModelNotifier: public wxDataViewListModelNotifier
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxGtkDataViewListModelNotifier( GtkWxListStore* gtk_store, wxDataViewListModel *wx_model );
|
||||||
|
|
||||||
|
virtual bool RowAppended();
|
||||||
|
virtual bool RowPrepended();
|
||||||
|
virtual bool RowInserted( size_t before );
|
||||||
|
virtual bool RowDeleted( size_t row );
|
||||||
|
virtual bool RowChanged( size_t row );
|
||||||
|
virtual bool ValueChanged( size_t row, size_t col );
|
||||||
|
virtual bool Cleared();
|
||||||
|
|
||||||
|
GtkWxListStore *m_gtk_store;
|
||||||
|
wxDataViewListModel *m_wx_model;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
// wxGtkDataViewListModelNotifier
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
wxGtkDataViewListModelNotifier::wxGtkDataViewListModelNotifier(
|
||||||
|
GtkWxListStore* gtk_store, wxDataViewListModel *wx_model )
|
||||||
|
{
|
||||||
|
m_gtk_store = gtk_store;
|
||||||
|
m_wx_model = wx_model;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGtkDataViewListModelNotifier::RowAppended()
|
||||||
|
{
|
||||||
|
size_t pos = m_wx_model->GetNumberOfRows()-1;
|
||||||
|
|
||||||
|
GtkTreeIter iter;
|
||||||
|
iter.stamp = m_gtk_store->stamp;
|
||||||
|
iter.user_data = (gpointer) pos;
|
||||||
|
|
||||||
|
GtkTreePath *path = gtk_tree_path_new ();
|
||||||
|
gtk_tree_path_append_index (path, (gint) pos);
|
||||||
|
gtk_tree_model_row_inserted (GTK_TREE_MODEL (m_gtk_store), path, &iter);
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGtkDataViewListModelNotifier::RowPrepended()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGtkDataViewListModelNotifier::RowInserted( size_t before )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGtkDataViewListModelNotifier::RowDeleted( size_t row )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGtkDataViewListModelNotifier::RowChanged( size_t row )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGtkDataViewListModelNotifier::ValueChanged( size_t row, size_t col )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGtkDataViewListModelNotifier::Cleared()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxDataViewCtrl
|
// wxDataViewCtrl
|
||||||
@ -476,15 +554,20 @@ bool wxDataViewCtrl::AppendStringColumn( const wxString &label )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
|
bool wxDataViewCtrl::AssociateModel( wxDataViewListModel *model )
|
||||||
{
|
{
|
||||||
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
GtkWxListStore *wxmodel = wxgtk_list_store_new();
|
GtkWxListStore *gtk_store = wxgtk_list_store_new();
|
||||||
wxmodel->model = (wxDataViewListModel*) model;
|
gtk_store->model = model;
|
||||||
|
|
||||||
gtk_tree_view_set_model( GTK_TREE_VIEW(m_widget), GTK_TREE_MODEL(wxmodel) );
|
wxGtkDataViewListModelNotifier *notifier =
|
||||||
|
new wxGtkDataViewListModelNotifier( gtk_store, model );
|
||||||
|
|
||||||
|
model->SetNotifier( notifier );
|
||||||
|
|
||||||
|
gtk_tree_view_set_model( GTK_TREE_VIEW(m_widget), GTK_TREE_MODEL(gtk_store) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user