bool NavigatorPanelUI::Add(ControlUI* ctrl) { IListItemUI* listItem = static_cast<IListItemUI*>(ctrl->GetInterface("ListItem")); if (listItem != NULL) { listItem->SetOwner(this); listItem->SetIndex(m_items.Count()); } return ContainerUI::Add(ctrl); }
bool CNavigatorPanelUI::Add(CControlUI* pControl) { IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if (pListItem != NULL) { pListItem->SetOwner(this); pListItem->SetIndex(m_items.GetSize()); } return CContainerUI::Add(pControl); }
bool CComboUI::AddAt(CControlUI* pControl, int iIndex) { if (!CContainerUI::AddAt(pControl, iIndex)) return false; // The list items should know about us IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) { pListItem->SetOwner(this); pListItem->SetIndex(iIndex); } for(int i = iIndex + 1; i < GetCount(); ++i) { CControlUI* p = GetItemAt(i); pListItem = static_cast<IListItemUI*>(p->GetInterface(_T("ListItem"))); if( pListItem != NULL ) { pListItem->SetIndex(i); } } if( m_iCurSel >= iIndex ) m_iCurSel += 1; return true; }
bool CUIComboBox::Add(CUIControl* pControl) { if (m_pWindow) { return false; } IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) { pListItem->SetOwner(this); pListItem->SetIndex(m_items.GetSize()); } return CUIContainer::Add(pControl); }
bool CListUI::Add(CControlUI* pControl) { // Override the Add() method so we can add items specifically to // the intended widgets. Headers and footers are assumed to be // answer the correct interface so we can add multiple list headers/footers. if( pControl->GetInterface(_T("ListHeader")) != NULL ) return CVerticalLayoutUI::Add(pControl); if( pControl->GetInterface(_T("ListFooter")) != NULL ) return CVerticalLayoutUI::Add(pControl); // We also need to recognize header sub-items if( _tcsstr(pControl->GetClass(), _T("Header")) != NULL ) return m_pHeader->Add(pControl); if( _tcsstr(pControl->GetClass(), _T("Footer")) != NULL ) return m_pFooter->Add(pControl); // The list items should know about us IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) { pListItem->SetOwner(this); pListItem->SetIndex(GetCount()); } return m_pList->Add(pControl); }
bool CComboUI::RemoveAt(int iIndex) { if (!CContainerUI::RemoveAt(iIndex)) return false; for(int i = iIndex; i < GetCount(); ++i) { CControlUI* p = GetItemAt(i); IListItemUI* pListItem = static_cast<IListItemUI*>(p->GetInterface(_T("ListItem"))); if( pListItem != NULL ) pListItem->SetIndex(i); } if( iIndex == m_iCurSel && m_iCurSel >= 0 ) { int iSel = m_iCurSel; m_iCurSel = -1; SelectItem(FindSelectable(iSel, false)); } else if( iIndex < m_iCurSel ) m_iCurSel -= 1; return true; }
bool CComboUI::SetItemIndex(CControlUI* pControl, int iIndex) { int iOrginIndex = GetItemIndex(pControl); if( iOrginIndex == -1 ) return false; if( iOrginIndex == iIndex ) return true; IListItemUI* pSelectedListItem = NULL; if( m_iCurSel >= 0 ) pSelectedListItem = static_cast<IListItemUI*>(GetItemAt(m_iCurSel)->GetInterface(_T("ListItem"))); if( !CContainerUI::SetItemIndex(pControl, iIndex) ) return false; int iMinIndex = min(iOrginIndex, iIndex); int iMaxIndex = max(iOrginIndex, iIndex); for(int i = iMinIndex; i < iMaxIndex + 1; ++i) { CControlUI* p = GetItemAt(i); IListItemUI* pListItem = static_cast<IListItemUI*>(p->GetInterface(_T("ListItem"))); if( pListItem != NULL ) { pListItem->SetIndex(i); } } if( m_iCurSel >= 0 && pSelectedListItem != NULL ) m_iCurSel = pSelectedListItem->GetIndex(); return true; }