From b87afd4fe89cef28e5d1e0527aeec74a4d93e4aa Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 22 Dec 2005 21:29:18 +0000 Subject: Fixed the pieces combobox to select items in the tree control when using auto-complete. git-svn-id: http://svn.leocad.org/trunk@446 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- win/Piececmb.cpp | 79 ++++++++++++-------------------------------------------- 1 file changed, 17 insertions(+), 62 deletions(-) (limited to 'win/Piececmb.cpp') diff --git a/win/Piececmb.cpp b/win/Piececmb.cpp index 4da474d..ecefb8d 100644 --- a/win/Piececmb.cpp +++ b/win/Piececmb.cpp @@ -45,7 +45,7 @@ void CPiecesCombo::OnEditupdate() return; char str[66]; - PiecesLibrary *pLib = project->GetPiecesLibrary (); + PiecesLibrary *pLib = project->GetPiecesLibrary (); CPiecesBar* pBar = (CPiecesBar*)GetParent(); PieceInfo* pInfo; @@ -81,38 +81,12 @@ void CPiecesCombo::OnEditupdate() } if (sel >= 0) - { - pInfo = pLib->GetPieceInfo(sel); - - if ((pBar->m_bGroups) && (pInfo->m_nGroups != 0)) - if ((pInfo->m_nGroups & (1 << pBar->m_nCurGroup)) == 0) - { - DWORD d = 1; - for (int k = 1; k < 32; k++) - { - if ((pInfo->m_nGroups & d) != 0) - { - pBar->m_nCurGroup = k-1; - pBar->m_wndPiecesList.UpdateList(); - k = 32; - } - else - d *= 2; - } - } + SelectPiece(pLib->GetPieceInfo(sel)); - LV_FINDINFO lvfi; - lvfi.flags = LVFI_PARAM; - lvfi.lParam = (LPARAM)pInfo; - - sel = pBar->m_wndPiecesList.FindItem (&lvfi); - pBar->m_wndPiecesList.SetItemState (sel, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); - pBar->m_wndPiecesList.EnsureVisible (sel, FALSE); - } if (strlen (newstr) > 1) { - SetWindowText (newstr); - SetEditSel (n, -1); + SetWindowText(newstr); + SetEditSel(n, -1); } } } @@ -139,13 +113,9 @@ BOOL CPiecesCombo::PreTranslateMessage(MSG* pMsg) int Index = Lib->FindCategoryIndex("Search Results"); if (Index == -1) - { Lib->AddCategory("Search Results", (const char*)str); - } else - { Lib->SetCategory(Index, "Search Results", (const char*)str); - } } } @@ -156,7 +126,7 @@ void CPiecesCombo::OnSelchange() { char str[66]; CPiecesBar* pBar = (CPiecesBar*)GetParent(); - PiecesLibrary *pLib = project->GetPiecesLibrary (); + PiecesLibrary *pLib = project->GetPiecesLibrary(); if (!GetLBText (GetCurSel(), str)) return; @@ -165,33 +135,18 @@ void CPiecesCombo::OnSelchange() { PieceInfo* pInfo = pLib->GetPieceInfo(i); - if (strcmp (str, pInfo->m_strDescription) == 0) - { - if ((pBar->m_bGroups) && (pInfo->m_nGroups != 0)) - if ((pInfo->m_nGroups & (1 << pBar->m_nCurGroup)) == 0) - { - DWORD d = 1; - for (int k = 1; k < 32; k++) - { - if ((pInfo->m_nGroups & d) != 0) - { - pBar->m_nCurGroup = k-1; - pBar->m_wndPiecesList.UpdateList(); - k = 32; - } - else - d *= 2; - } - } + if (strcmp(str, pInfo->m_strDescription) == 0) + SelectPiece(pInfo); + } +} - LV_FINDINFO lvfi; - lvfi.flags = LVFI_PARAM; - lvfi.lParam = (LPARAM)pInfo; +void CPiecesCombo::SelectPiece(PieceInfo* Info) +{ + PiecesLibrary *Lib = project->GetPiecesLibrary(); + CPiecesBar* Bar = (CPiecesBar*)GetParent(); - i = pBar->m_wndPiecesList.FindItem (&lvfi); - pBar->m_wndPiecesList.SetItemState(i,LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED); - pBar->m_wndPiecesList.EnsureVisible (i, FALSE); - return; - } - } + int Index = Lib->GetFirstCategory(Info); + + if (Index != -1) + Bar->SelectPiece(Lib->GetCategoryName(Index), Info); } -- cgit v1.2.3