================ CPathTreeCtrl::SearchTree Search the three using the search string. Adds the matched tree items to the result tree. Returns the number of items added to the result tree. ================ */
| 187 | ================ |
| 188 | */ |
| 189 | int CPathTreeCtrl::SearchTree( treeItemCompare_t compare, void *data, CPathTreeCtrl &result ) { |
| 190 | idPathTreeStack stack, searchStack; |
| 191 | HTREEITEM item, child; |
| 192 | idStr name; |
| 193 | int id, numItems; |
| 194 | |
| 195 | numItems = 0; |
| 196 | result.DeleteAllItems(); |
| 197 | stack.PushRoot( NULL ); |
| 198 | |
| 199 | item = GetRootItem(); |
| 200 | searchStack.PushRoot( item ); |
| 201 | id = 0; |
| 202 | |
| 203 | while( searchStack.Num() > 0 ) { |
| 204 | |
| 205 | for ( child = GetChildItem( item ); child; child = GetChildItem( child ) ) { |
| 206 | searchStack.Push( item, GetItemText( item ) ); |
| 207 | item = child; |
| 208 | } |
| 209 | |
| 210 | name = searchStack.TopName(); |
| 211 | name += GetItemText( item ); |
| 212 | id = GetItemData( item ); |
| 213 | |
| 214 | if ( compare( data, item, name ) ) { |
| 215 | result.AddPathToTree( name, id, stack ); |
| 216 | numItems++; |
| 217 | } |
| 218 | |
| 219 | for ( item = GetNextSiblingItem( item ); item == NULL; ) { |
| 220 | item = GetNextSiblingItem( searchStack.TopItem() ); |
| 221 | searchStack.Pop(); |
| 222 | if ( searchStack.Num() <= 0 ) { |
| 223 | return numItems; |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | return numItems; |
| 229 | } |
| 230 | |
| 231 | BEGIN_MESSAGE_MAP(CPathTreeCtrl,CTreeCtrl) |
| 232 | //{{AFX_MSG_MAP(CPathTreeCtrl) |
no test coverage detected