summaryrefslogtreecommitdiff
path: root/win/Piecebar.cpp
diff options
context:
space:
mode:
authorleo2006-02-05 22:29:21 +0000
committerleo2006-02-05 22:29:21 +0000
commitba28ade8c4423359e4ff24c56b0e082546996923 (patch)
tree17ae505bdc289565e8cd039cebd3bf372755c311 /win/Piecebar.cpp
parent5672dc0cc217ae4b4b10050e3b43b911a71148d7 (diff)
Simple expression matching for the piece categories.
git-svn-id: http://svn.leocad.org/trunk@466 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win/Piecebar.cpp')
-rw-r--r--win/Piecebar.cpp25
1 files changed, 24 insertions, 1 deletions
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<PieceInfo> 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);
}
}