]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
do not exceed the 80 column limit when printing the list of available libraries
[wxWidgets.git] / samples / treectrl / treetest.cpp
index 15069adaca8cba78d05f8f64a917465df8dd675c..759c7c506768422b088c16561637bf340d04fecf 100644 (file)
@@ -680,6 +680,11 @@ void MyFrame::OnToggleAlternateStates(wxCommandEvent& WXUNUSED(event))
 
     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))
@@ -1152,6 +1157,29 @@ void MyTreeCtrl::DoToggleState(const wxTreeItemId& item)
     }
 }
 
+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();
@@ -1468,6 +1496,8 @@ void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event)
     wxPoint pt = event.GetPosition();
 
     wxLogMessage(wxT("OnContextMenu at screen coords (%i, %i)"), pt.x, pt.y);
+
+    event.Skip();
 }
 
 void MyTreeCtrl::ShowMenu(wxTreeItemId id, const wxPoint& pt)