From ba28ade8c4423359e4ff24c56b0e082546996923 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 5 Feb 2006 22:29:21 +0000 Subject: Simple expression matching for the piece categories. git-svn-id: http://svn.leocad.org/trunk@466 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- win/Piecebar.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'win/Piecebar.cpp') diff --git a/win/Piecebar.cpp b/win/Piecebar.cpp index 0b7d154..3ec1cdb 100644 --- a/win/Piecebar.cpp +++ b/win/Piecebar.cpp @@ -1067,12 +1067,30 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { PieceInfo* Parent = (PieceInfo*)Notify->itemNew.lParam; + HTREEITEM CategoryItem = m_PiecesTree.GetParentItem(Notify->itemNew.hItem); + CString CategoryName = m_PiecesTree.GetItemText(CategoryItem); + int CategoryIndex = Lib->FindCategoryIndex((const char*)CategoryName); + PtrArray Pieces; Lib->GetPatternedPieces(Parent, Pieces); Pieces.Sort(PiecesSortFunc, NULL); HTREEITEM ParentItem = Notify->itemNew.hItem; + // Remove all children (for some reason TVE_COLLAPSERESET isn't always working). + if (m_PiecesTree.ItemHasChildren(ParentItem)) + { + HTREEITEM NextItem; + HTREEITEM ChildItem = m_PiecesTree.GetChildItem(ParentItem); + + while (ChildItem != NULL) + { + NextItem = m_PiecesTree.GetNextItem(ChildItem, TVGN_NEXT); + m_PiecesTree.DeleteItem(ChildItem); + ChildItem = NextItem; + } + } + for (int i = 0; i < Pieces.GetSize(); i++) { PieceInfo* Info = Pieces[i]; @@ -1080,6 +1098,12 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) if (!m_bSubParts && Info->IsSubPiece()) continue; + if (CategoryIndex != -1) + { + if (!Lib->PieceInCategory(Info, Lib->GetCategoryKeywords(CategoryIndex))) + continue; + } + // If both descriptions begin with the same text, only show the difference. if (!strncmp(Info->m_strDescription, Parent->m_strDescription, strlen(Parent->m_strDescription))) m_PiecesTree.InsertItem(TVIF_PARAM|TVIF_TEXT, Info->m_strDescription + strlen(Parent->m_strDescription) + 1, 0, 0, 0, 0, (LPARAM)Info, ParentItem, TVI_LAST); @@ -1090,7 +1114,6 @@ BOOL CPiecesBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) } else if (Notify->action == TVE_COLLAPSE) { - // Remove all children. m_PiecesTree.Expand(Notify->itemNew.hItem, TVE_COLLAPSE | TVE_COLLAPSERESET); } } -- cgit v1.2.3