bool CListUI::ExpandItem(int iIndex, bool bExpand /*= true*/) { if( !m_ListInfo.bExpandable ) return false; if( m_iExpandedItem >= 0 ) { CControlUI* pControl = GetItem(m_iExpandedItem); if( pControl != NULL ) { IListItemUI* pItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pItem != NULL ) pItem->Expand(false); } m_iExpandedItem = -1; } if( bExpand ) { CControlUI* pControl = GetItem(iIndex); if( pControl == NULL ) return false; if( !pControl->IsVisible() ) return false; IListItemUI* pItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pItem == NULL ) return false; m_iExpandedItem = iIndex; if( !pItem->Expand(true) ) { m_iExpandedItem = -1; return false; } } UpdateLayout(); return true; }
bool CComboUI::SelectItem(int iIndex, bool bTakeFocus) { if( iIndex == m_iCurSel ) return true; int iOldSel = m_iCurSel; if( m_iCurSel >= 0 ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]); if( !pControl ) return false; IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) pListItem->Select(false); m_iCurSel = -1; } if( iIndex < 0 ) return false; if( m_items.GetSize() == 0 ) return false; if( iIndex >= m_items.GetSize() ) iIndex = m_items.GetSize() - 1; CControlUI* pControl = static_cast<CControlUI*>(m_items[iIndex]); if( !pControl || !pControl->IsEnabled() ) return false; IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem == NULL ) return false; m_iCurSel = iIndex; if( m_pWindow != NULL || bTakeFocus ) pControl->SetFocus(); pListItem->Select(true); if( m_pManager != NULL ) m_pManager->SendNotify(this, DUI_MSGTYPE_ITEMSELECT, m_iCurSel, iOldSel); Invalidate(); return true; }
bool CListUI::SelectItem(int iIndex) { if( iIndex == m_iCurSel ) return true; // We should first unselect the currently selected item if( m_iCurSel >= 0 ) { CControlUI* pControl = GetItem(m_iCurSel); if( pControl != NULL ) { IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) pListItem->Select(false); } } // Now figure out if the control can be selected // TODO: Redo old selected if failure CControlUI* pControl = GetItem(iIndex); if( pControl == NULL ) return false; if( !pControl->IsVisible() ) return false; if( !pControl->IsEnabled() ) return false; IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem == NULL ) return false; m_iCurSel = iIndex; if( !pListItem->Select(true) ) { m_iCurSel = -1; return false; } pControl->SetFocus(); if( m_pManager != NULL ) { m_pManager->SendNotify(pControl, _T("itemclick")); m_pManager->SendNotify(this, _T("itemselect")); } Invalidate(); return true; }
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 CGroupsUI::SelectItem(int iIndex, bool bTakeFocus) { if( iIndex == m_iCurSel ) return true; // We should first unselect the currently selected item if( m_iCurSel >= 0 ) { CControlUI* pControl = GetItemAt(m_iCurSel); if( pControl != NULL) { IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) { CListContainerElementUI* pFriendListItem = static_cast<CListContainerElementUI*>(pControl); Node* node = (Node*)pControl->GetTag(); if ((pFriendListItem != NULL) && (node != NULL) && !node->folder()) { // pFriendListItem->SetFixedHeight(kFriendListItemNormalHeight); // CContainerUI* pOperatorPannel = static_cast<CContainerUI*>(paint_manager_.FindSubControlByName(pFriendListItem, kOperatorPannelControlName)); // if (pOperatorPannel != NULL) // { // pOperatorPannel->SetVisible(false); // } } pListItem->Select(false); } } m_iCurSel = -1; } if( iIndex < 0 ) return false; if (!__super::SelectItem(iIndex, bTakeFocus)) return false; CControlUI* pControl = GetItemAt(m_iCurSel); if( pControl != NULL) { CListContainerElementUI* pFriendListItem = static_cast<CListContainerElementUI*>(pControl); Node* node = (Node*)pControl->GetTag(); if ((pFriendListItem != NULL) && (node != NULL) && !node->folder()) { // pFriendListItem->SetFixedHeight(kFriendListItemSelectedHeight); // CContainerUI* pOperatorPannel = static_cast<CContainerUI*>(paint_manager_.FindSubControlByName(pFriendListItem, kOperatorPannelControlName)); // if (pOperatorPannel != NULL) // { // pOperatorPannel->SetVisible(true); // } //pFriendListItem->SetBkImage() } } 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 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 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 NavigatorPanelUI::SelectItem(int idx) { if (idx == m_curSel) return true; if (m_curSel >= 0) { ControlUI* ctrl = GetItem(m_curSel); IListItemUI* listItem = static_cast<IListItemUI*>(ctrl->GetInterface("ListItem")); if (listItem != NULL) listItem->Select(false); } m_curSel = idx; if (m_curSel >= 0) { ControlUI* ctrl = GetItem(m_curSel); IListItemUI* listItem = static_cast<IListItemUI*>(ctrl->GetInterface("ListItem")); if (listItem == NULL) return false; listItem->Select(true); if (m_mgr != NULL) m_mgr->SendNotify(ctrl, "itemclick"); } if (m_mgr != NULL) m_mgr->SendNotify(this, "itemselect"); Invalidate(); return true; }
bool CNavigatorPanelUI::SelectItem(int iIndex) { if (iIndex == m_iCurSel) return true; if (m_iCurSel >= 0) { CControlUI* pControl = GetItem(m_iCurSel); IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if (pListItem != NULL) pListItem->Select(false); } m_iCurSel = iIndex; if (m_iCurSel >= 0) { CControlUI* pControl = GetItem(m_iCurSel); IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if (pListItem == NULL) return false; pListItem->Select(true); if (m_pManager != NULL) m_pManager->SendNotify(pControl, _T("itemclick")); } if (m_pManager != NULL) m_pManager->SendNotify(this, _T("itemselect")); Invalidate(); return true; }
bool CUIComboBox::SetItemData(int nItem, DWORD_PTR dwData) { if( nItem < 0 || nItem >= (int)m_items.GetSize()) { return false; } CUIControl* pControl = static_cast<CUIControl*>(m_items[nItem]); if (pControl == NULL) { return false; } IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem == NULL ) { return false; } return pListItem->SetItemData(dwData); }
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::SetCurSel(int iIndex) { if( iIndex == m_iCurSel ) return true; if( m_iCurSel >= 0 ) { CUIControl* pControl = static_cast<CUIControl*>(m_items[m_iCurSel]); IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem != NULL ) pListItem->Select(false); m_iCurSel = -1; } if( m_items.GetSize() == 0 ) return false; if( iIndex < 0 ) iIndex = 0; if( iIndex >= m_items.GetSize() ) iIndex = m_items.GetSize() - 1; CUIControl* pControl = static_cast<CUIControl*>(m_items[iIndex]); if( !pControl->IsVisible() ) return false; if( !pControl->IsEnabled() ) return false; IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pListItem == NULL ) return false; m_iCurSel = iIndex; pControl->SetFocus(); pListItem->Select(true); CUIContainer* pContainer = dynamic_cast<CUIContainer*>(pListItem->GetOwner()); if (pContainer) { RECT rcItem = pControl->GetPos(); RECT rcList = pContainer->GetPos(); int iPos = pContainer->GetScrollPos(); if( rcItem.top < rcList.top || rcItem.bottom > rcList.bottom ) { int dx = 0; if( rcItem.top < rcList.top ) dx = rcItem.top - rcList.top; if( rcItem.bottom > rcList.bottom ) dx = rcItem.bottom - rcList.bottom; pContainer->SetScrollPos(pContainer->GetScrollPos() + dx); } } Invalidate(); 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; }
void CDropDownUI::DoPaint(HDC hDC, const RECT& rcPaint) { // Paint the nice frame int cy = m_rcItem.bottom - m_rcItem.top; ::SetRect(&m_rcButton, m_rcItem.right - cy, m_rcItem.top, m_rcItem.right, m_rcItem.bottom); RECT rcText = { m_rcItem.left, m_rcItem.top, m_rcButton.left + 1, m_rcItem.bottom }; if( !IsEnabled() ) { CBlueRenderEngineUI::DoPaintFrame(hDC, m_pManager, rcText, UICOLOR_CONTROL_BORDER_DISABLED, UICOLOR__INVALID, UICOLOR__INVALID); } else { CBlueRenderEngineUI::DoPaintFrame(hDC, m_pManager, rcText, UICOLOR_CONTROL_BORDER_NORMAL, UICOLOR_CONTROL_BORDER_NORMAL, UICOLOR__INVALID); } // Paint dropdown edit box ::InflateRect(&rcText, -1, -1); if( m_iCurSel >= 0 ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]); IListItemUI* pElement = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pElement != NULL ) { // Render item with specific draw-style pElement->DrawItem(hDC, rcText, UIDRAWSTYLE_INPLACE | (m_bFocused ? UIDRAWSTYLE_FOCUS : 0)); } else { // Allow non-listitems to render as well. RECT rcOldPos = pControl->GetPos(); pControl->SetPos(rcText); pControl->DoPaint(hDC, rcText); pControl->SetPos(rcOldPos); } } else { CBlueRenderEngineUI::DoFillRect(hDC, m_pManager, rcText, UICOLOR_CONTROL_BACKGROUND_NORMAL); } // Paint dropdown button RECT rcPadding = { 0 }; CBlueRenderEngineUI::DoPaintButton(hDC, m_pManager, m_rcButton, _T("<i 6>"), rcPadding, m_uButtonState, 0); }
void CComboBoxUI::PaintText(HDC hDC) { RECT rcText = m_rcItem; rcText.left += m_rcTextPadding.left; rcText.right -= m_rcTextPadding.right; rcText.top += m_rcTextPadding.top; rcText.bottom -= m_rcTextPadding.bottom; rcText.right -= m_nArrowWidth; // add this line than CComboUI::PaintText(HDC hDC) if( m_iCurSel >= 0 ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]); IListItemUI* pElement = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pElement != NULL ) { pElement->DrawItemText(hDC, rcText); } else { RECT rcOldPos = pControl->GetPos(); pControl->SetPos(rcText); pControl->DoPaint(hDC, rcText); pControl->SetPos(rcOldPos); } } }