| 252 | } |
| 253 | |
| 254 | bool CComboUI::SelectItem(int iIndex, bool bTakeFocus) |
| 255 | { |
| 256 | if( m_pWindow != NULL ) m_pWindow->Close(); |
| 257 | if( iIndex == m_iCurSel ) return true; |
| 258 | int iOldSel = m_iCurSel; |
| 259 | if( m_iCurSel >= 0 ) { |
| 260 | CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]); |
| 261 | if( !pControl ) return false; |
| 262 | IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); |
| 263 | if( pListItem != NULL ) pListItem->Select(false); |
| 264 | m_iCurSel = -1; |
| 265 | } |
| 266 | if( iIndex < 0 ) return false; |
| 267 | if( m_items.GetSize() == 0 ) return false; |
| 268 | if( iIndex >= m_items.GetSize() ) iIndex = m_items.GetSize() - 1; |
| 269 | CControlUI* pControl = static_cast<CControlUI*>(m_items[iIndex]); |
| 270 | if( !pControl || !pControl->IsVisible() || !pControl->IsEnabled() ) return false; |
| 271 | IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); |
| 272 | if( pListItem == NULL ) return false; |
| 273 | m_iCurSel = iIndex; |
| 274 | if( m_pWindow != NULL || bTakeFocus ) pControl->SetFocus(); |
| 275 | pListItem->Select(true); |
| 276 | if( m_pManager != NULL ) m_pManager->SendNotify(this, DUI_MSGTYPE_ITEMSELECT, m_iCurSel, iOldSel); |
| 277 | Invalidate(); |
| 278 | |
| 279 | return true; |
| 280 | } |
| 281 | |
| 282 | bool CComboUI::SetItemIndex(CControlUI* pControl, int iIndex) |
| 283 | { |
no test coverage detected