m_treeCtrl->SetAlternateStates(!alternateStates);
m_treeCtrl->CreateStateImageList();
+
+ // normal states < alternate states
+ // so we must reset broken states
+ if ( alternateStates )
+ m_treeCtrl->ResetBrokenStateImages();
}
void MyFrame::OnToggleButtons(wxCommandEvent& WXUNUSED(event))
}
}
+void MyTreeCtrl::DoResetBrokenStateImages(const wxTreeItemId& idParent,
+ wxTreeItemIdValue cookie, int state)
+{
+ wxTreeItemId id;
+
+ if ( !cookie )
+ id = GetFirstChild(idParent, cookie);
+ else
+ id = GetNextChild(idParent, cookie);
+
+ if ( !id.IsOk() )
+ return;
+
+ int curState = GetItemState(id);
+ if ( curState != wxTREE_ITEMSTATE_NONE && curState > state )
+ SetItemState(id, state);
+
+ if (ItemHasChildren(id))
+ DoResetBrokenStateImages(id, 0, state);
+
+ DoResetBrokenStateImages(idParent, cookie, state);
+}
+
void MyTreeCtrl::LogEvent(const wxChar *name, const wxTreeEvent& event)
{
wxTreeItemId item = event.GetItem();
void SetAlternateStates(bool show) { m_alternateStates = show; }
bool AlternateStates() const { return m_alternateStates; }
+ void ResetBrokenStateImages()
+ {
+ const size_t count = GetStateImageList()->GetImageCount();
+ int state = count > 0 ? count - 1 : wxTREE_ITEMSTATE_NONE;
+ DoResetBrokenStateImages(GetRootItem(), 0, state);
+ }
+
protected:
virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);
size_t depth,
size_t folder);
+ void DoResetBrokenStateImages(const wxTreeItemId& idParent,
+ wxTreeItemIdValue cookie, int state);
+
void LogEvent(const wxChar *name, const wxTreeEvent& event);
int m_imageSize; // current size of images