int GetChildCount( const wxDataViewItem& parent ) const
{ return GetStore()->GetChildCount(parent); }
- void SetItemText( const wxDataViewItem& item, const wxString &text )
- { GetStore()->SetItemText(item,text); }
+ void SetItemText( const wxDataViewItem& item, const wxString &text );
wxString GetItemText( const wxDataViewItem& item ) const
{ return GetStore()->GetItemText(item); }
- void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
- { GetStore()->SetItemIcon(item,icon); }
+ void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
{ return GetStore()->GetItemIcon(item); }
- void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
- { GetStore()->SetItemExpandedIcon(item,icon); }
+ void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
{ return GetStore()->GetItemExpandedIcon(item); }
void SetItemData( const wxDataViewItem& item, wxClientData *data )
wxClientData *GetItemData( const wxDataViewItem& item ) const
{ return GetStore()->GetItemData(item); }
- void DeleteItem( const wxDataViewItem& item )
- { GetStore()->DeleteItem(item); }
- void DeleteChildren( const wxDataViewItem& item )
- { GetStore()->DeleteChildren(item); }
- void DeleteAllItems()
- { GetStore()->DeleteAllItems(); }
+ void DeleteItem( const wxDataViewItem& item );
+ void DeleteChildren( const wxDataViewItem& item );
+ void DeleteAllItems();
void OnExpanded( wxDataViewEvent &event );
void OnCollapsed( wxDataViewEvent &event );
new wxDataViewTreeStoreNode( parent_node, text, icon, data );
parent_node->GetChildren().Append( node );
- // notify control
- ItemAdded( parent, node->GetItem() );
-
return node->GetItem();
}
new wxDataViewTreeStoreNode( parent_node, text, icon, data );
parent_node->GetChildren().Insert( node );
- // notify control
- ItemAdded( parent, node->GetItem() );
-
return node->GetItem();
}
wxDataViewItem
-wxDataViewTreeStore::InsertItem(const wxDataViewItem& WXUNUSED(parent),
- const wxDataViewItem& WXUNUSED(previous),
- const wxString& WXUNUSED(text),
- const wxIcon& WXUNUSED(icon),
- wxClientData * WXUNUSED(data))
+wxDataViewTreeStore::InsertItem(const wxDataViewItem& parent,
+ const wxDataViewItem& previous,
+ const wxString& text,
+ const wxIcon& icon,
+ wxClientData *data)
{
- return wxDataViewItem(0);
+ wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
+ if (!parent_node) return wxDataViewItem(0);
+
+ wxDataViewTreeStoreNode *previous_node = FindNode( previous );
+ int pos = parent_node->GetChildren().IndexOf( previous_node );
+ if (pos == wxNOT_FOUND) return wxDataViewItem(0);
+
+ wxDataViewTreeStoreNode *node =
+ new wxDataViewTreeStoreNode( parent_node, text, icon, data );
+ parent_node->GetChildren().Insert( (size_t) pos, node );
+
+ return node->GetItem();
}
wxDataViewItem wxDataViewTreeStore::PrependContainer( const wxDataViewItem& parent,
new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data );
parent_node->GetChildren().Insert( node );
- // notify control
- ItemAdded( parent, node->GetItem() );
-
return node->GetItem();
}
new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data );
parent_node->GetChildren().Append( node );
- // notify control
- ItemAdded( parent, node->GetItem() );
-
return node->GetItem();
}
wxDataViewItem
-wxDataViewTreeStore::InsertContainer(const wxDataViewItem& WXUNUSED(parent),
- const wxDataViewItem& WXUNUSED(previous),
- const wxString& WXUNUSED(text),
- const wxIcon& WXUNUSED(icon),
- const wxIcon& WXUNUSED(expanded),
- wxClientData * WXUNUSED(data))
+wxDataViewTreeStore::InsertContainer(const wxDataViewItem& parent,
+ const wxDataViewItem& previous,
+ const wxString& text,
+ const wxIcon& icon,
+ const wxIcon& expanded,
+ wxClientData * data)
{
- return wxDataViewItem(0);
+ wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
+ if (!parent_node) return wxDataViewItem(0);
+
+ wxDataViewTreeStoreNode *previous_node = FindNode( previous );
+ int pos = parent_node->GetChildren().IndexOf( previous_node );
+ if (pos == wxNOT_FOUND) return wxDataViewItem(0);
+
+ wxDataViewTreeStoreContainerNode *node =
+ new wxDataViewTreeStoreContainerNode( parent_node, text, icon, expanded, data );
+ parent_node->GetChildren().Insert( (size_t) pos, node );
+
+ return node->GetItem();
}
wxDataViewItem wxDataViewTreeStore::GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
if (!node) return;
node->SetText( text );
-
- // notify control
- ValueChanged( item, 0 );
}
wxString wxDataViewTreeStore::GetItemText( const wxDataViewItem& item ) const
if (!node) return;
node->SetIcon( icon );
-
- // notify control
- ValueChanged( item, 0 );
}
const wxIcon &wxDataViewTreeStore::GetItemIcon( const wxDataViewItem& item ) const
if (!node) return;
node->SetExpandedIcon( icon );
-
- // notify control
- ValueChanged( item, 0 );
}
const wxIcon &wxDataViewTreeStore::GetItemExpandedIcon( const wxDataViewItem& item ) const
if (!node) return;
node->SetData( data );
-
- // notify control? only sensible when sorting on client data
- // ValueChanged( item, 0 );
}
wxClientData *wxDataViewTreeStore::GetItemData( const wxDataViewItem& item ) const
if (!node) return;
parent_node->GetChildren().DeleteObject( node );
-
- // notify control
- ItemDeleted( parent_item, item );
}
void wxDataViewTreeStore::DeleteChildren( const wxDataViewItem& item )
if (m_imageList && (iconIndex != -1))
icon = m_imageList->GetIcon( iconIndex );
- return GetStore()->AppendItem( parent, text, icon, data );
+ wxDataViewItem res = GetStore()->AppendItem( parent, text, icon, data );
+
+ GetStore()->ItemAdded( parent, res );
+
+ return res;
}
wxDataViewItem wxDataViewTreeCtrl::PrependItem( const wxDataViewItem& parent,
if (m_imageList && (iconIndex != -1))
icon = m_imageList->GetIcon( iconIndex );
- return GetStore()->PrependItem( parent, text, icon, data );
+ wxDataViewItem res = GetStore()->PrependItem( parent, text, icon, data );
+
+ GetStore()->ItemAdded( parent, res );
+
+ return res;
}
wxDataViewItem wxDataViewTreeCtrl::InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
if (m_imageList && (iconIndex != -1))
icon = m_imageList->GetIcon( iconIndex );
- return GetStore()->InsertItem( parent, previous, text, icon, data );
+ wxDataViewItem res = GetStore()->InsertItem( parent, previous, text, icon, data );
+
+ GetStore()->ItemAdded( parent, res );
+
+ return res;
}
wxDataViewItem wxDataViewTreeCtrl::PrependContainer( const wxDataViewItem& parent,
if (m_imageList && (expandedIndex != -1))
expanded = m_imageList->GetIcon( expandedIndex );
- return GetStore()->PrependContainer( parent, text, icon, expanded, data );
+ wxDataViewItem res = GetStore()->PrependContainer( parent, text, icon, expanded, data );
+
+ GetStore()->ItemAdded( parent, res );
+
+ return res;
}
wxDataViewItem wxDataViewTreeCtrl::AppendContainer( const wxDataViewItem& parent,
if (m_imageList && (expandedIndex != -1))
expanded = m_imageList->GetIcon( expandedIndex );
- return GetStore()->AppendContainer( parent, text, icon, expanded, data );
+ wxDataViewItem res = GetStore()->AppendContainer( parent, text, icon, expanded, data );
+
+ GetStore()->ItemAdded( parent, res );
+
+ return res;
}
wxDataViewItem wxDataViewTreeCtrl::InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
if (m_imageList && (expandedIndex != -1))
expanded = m_imageList->GetIcon( expandedIndex );
- return GetStore()->InsertContainer( parent, previous, text, icon, expanded, data );
+ wxDataViewItem res = GetStore()->InsertContainer( parent, previous, text, icon, expanded, data );
+
+ GetStore()->ItemAdded( parent, res );
+
+ return res;
+}
+
+void wxDataViewTreeCtrl::SetItemText( const wxDataViewItem& item, const wxString &text )
+{
+ GetStore()->SetItemText(item,text);
+
+ // notify control
+ GetStore()->ValueChanged( item, 0 );
+}
+
+void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
+{
+ GetStore()->SetItemIcon(item,icon);
+
+ // notify control
+ GetStore()->ValueChanged( item, 0 );
+}
+
+void wxDataViewTreeCtrl::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
+{
+ GetStore()->SetItemExpandedIcon(item,icon);
+
+ // notify control
+ GetStore()->ValueChanged( item, 0 );
+}
+
+void wxDataViewTreeCtrl::DeleteItem( const wxDataViewItem& item )
+{
+ wxDataViewItem parent_item = GetStore()->GetParent( item );
+
+ GetStore()->DeleteItem(item);
+
+ // notify control
+ GetStore()->ItemDeleted( parent_item, item );
+}
+
+void wxDataViewTreeCtrl::DeleteChildren( const wxDataViewItem& item )
+{
+ GetStore()->DeleteChildren(item);
+}
+
+void wxDataViewTreeCtrl::DeleteAllItems()
+{
+ GetStore()->DeleteAllItems();
+
+ GetStore()->Cleared();
}
void wxDataViewTreeCtrl::OnExpanded( wxDataViewEvent &event )
if (!container) return;
container->SetExpanded( true );
+
GetStore()->ItemChanged( event.GetItem() );
}
if (!container) return;
container->SetExpanded( false );
+
GetStore()->ItemChanged( event.GetItem() );
}