+//-----------------------------------------------------------------------------
+// wxGtkTreeModelNode
+//-----------------------------------------------------------------------------
+
+class wxGtkTreeModelNode;
+WX_DEFINE_ARRAY_PTR( wxGtkTreeModelNode*, wxGtkTreeModelNodes );
+
+class wxGtkTreeModelNode
+{
+public:
+ wxGtkTreeModelNode( wxGtkTreeModelNode* parent, const wxDataViewItem &item )
+ {
+ m_parent = parent;
+ m_item = item;
+ }
+
+ ~wxGtkTreeModelNode()
+ {
+ size_t count = m_children.GetCount();
+ size_t i;
+ for (i = 0; i < count; i++)
+ {
+ wxGtkTreeModelNode *child = m_children[i];
+ delete child;
+ }
+ }
+
+ wxGtkTreeModelNode* GetParent()
+ { return m_parent; }
+ wxGtkTreeModelNodes &GetChildren()
+ { return m_children; }
+ wxGtkTreeModelNode* GetNthChild( unsigned int n )
+ { return m_children.Item( n ); }
+ void Insert( wxGtkTreeModelNode* child, unsigned int n)
+ { m_children.Insert( child, n); }
+ void Append( wxGtkTreeModelNode* child )
+ { m_children.Add( child ); }
+
+ unsigned int GetChildCount() { return m_children.GetCount(); }
+
+ wxDataViewItem &GetItem() { return m_item; }
+
+ bool HasChildren() { return m_hasChildren; }
+ void SetHasChildren( bool has ) { m_hasChildren = has; }
+
+private:
+ wxGtkTreeModelNode *m_parent;
+ wxGtkTreeModelNodes m_children;
+ wxDataViewItem m_item;
+ bool m_hasChildren;
+};
+
+
+extern "C" {
+typedef struct _GtkWxTreeModel GtkWxTreeModel;
+}
+
+class wxGtkTreeModel
+{
+public:
+ wxGtkTreeModel( wxDataViewModel *wx_model, GtkWxTreeModel *owner );
+ ~wxGtkTreeModel();
+
+ gboolean get_iter( GtkTreeIter *iter, GtkTreePath *path );
+ GtkTreePath *get_path( GtkTreeIter *iter);
+ gboolean iter_next( GtkTreeIter *iter );
+ gboolean iter_children( GtkTreeIter *iter, GtkTreeIter *parent);
+ gboolean iter_has_child( GtkTreeIter *iter );
+ gint iter_n_children( GtkTreeIter *iter );
+ gboolean iter_nth_child( GtkTreeIter *iter, GtkTreeIter *parent, gint n );
+ gboolean iter_parent( GtkTreeIter *iter, GtkTreeIter *child );
+
+ wxDataViewModel* GetDataViewModel() { return m_wx_model; }
+ GtkWxTreeModel* GetOwner() { return m_owner; }
+
+ bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
+
+protected:
+ void InitTree();
+ wxGtkTreeModelNode *FindNode( const wxDataViewItem &item );
+ wxGtkTreeModelNode *FindNode( GtkTreeIter *iter );
+ void BuildBranch( wxGtkTreeModelNode *branch );
+
+private:
+ wxGtkTreeModelNode *m_root;
+ wxDataViewModel *m_wx_model;
+ GtkWxTreeModel *m_owner;
+};