Implement and document wxDataViewTreeCtrl::IsContainer(), use it in the sample to not add items to non-containers
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62630 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1212,6 +1212,9 @@ public:
|
||||
const wxDataViewTreeStore *GetStore() const
|
||||
{ return (const wxDataViewTreeStore*) GetModel(); }
|
||||
|
||||
bool IsContainer( const wxDataViewItem& item ) const
|
||||
{ return GetStore()->IsContainer(item); }
|
||||
|
||||
void SetImageList( wxImageList *imagelist );
|
||||
wxImageList* GetImageList() { return m_imageList; }
|
||||
|
||||
|
@@ -2023,6 +2023,11 @@ public:
|
||||
int icon = -1,
|
||||
wxClientData* data = NULL);
|
||||
|
||||
/**
|
||||
Returns true if item is a container.
|
||||
*/
|
||||
bool IsContainer( const wxDataViewItem& item );
|
||||
|
||||
/**
|
||||
Calls the same method from wxDataViewTreeStore but uses
|
||||
an index position in the image list instead of a wxIcon.
|
||||
|
@@ -1092,6 +1092,7 @@ void MyFrame::OnAddTreeItem(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[3];
|
||||
wxDataViewItem selected = ctrl->GetSelection();
|
||||
if (ctrl->IsContainer(selected))
|
||||
ctrl->AppendItem( selected, "Item", 0 );
|
||||
}
|
||||
|
||||
@@ -1099,6 +1100,7 @@ void MyFrame::OnAddTreeContainerItem(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[3];
|
||||
wxDataViewItem selected = ctrl->GetSelection();
|
||||
if (ctrl->IsContainer(selected))
|
||||
ctrl->AppendContainer(selected, "Container", 0 );
|
||||
}
|
||||
|
||||
|
@@ -1790,6 +1790,14 @@ wxDataViewTreeStore::InsertContainer(const wxDataViewItem& parent,
|
||||
return node->GetItem();
|
||||
}
|
||||
|
||||
bool wxDataViewTreeStore::IsContainer( const wxDataViewItem& item ) const
|
||||
{
|
||||
wxDataViewTreeStoreNode *node = FindNode( item );
|
||||
if (!node) return false;
|
||||
|
||||
return node->IsContainer();
|
||||
}
|
||||
|
||||
wxDataViewItem wxDataViewTreeStore::GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
|
||||
{
|
||||
wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
|
||||
@@ -1963,14 +1971,6 @@ wxDataViewItem wxDataViewTreeStore::GetParent( const wxDataViewItem &item ) cons
|
||||
return parent->GetItem();
|
||||
}
|
||||
|
||||
bool wxDataViewTreeStore::IsContainer( const wxDataViewItem &item ) const
|
||||
{
|
||||
wxDataViewTreeStoreNode *node = FindNode( item );
|
||||
if (!node) return false;
|
||||
|
||||
return node->IsContainer();
|
||||
}
|
||||
|
||||
unsigned int wxDataViewTreeStore::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const
|
||||
{
|
||||
wxDataViewTreeStoreContainerNode *node = FindContainerNode( item );
|
||||
|
Reference in New Issue
Block a user