MCPcopy Create free account
hub / github.com/SOUI2/soui / EnsureVisible

Method EnsureVisible

SOUI/src/control/STreeView.cpp:547–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545 }
546
547 void STreeView::EnsureVisible(HTREEITEM hItem)
548 {
549 //保证hItem被正确展开
550 HTREEITEM hParent = m_adapter->GetParentItem(hItem);
551 while(hParent!=ITvAdapter::ITEM_ROOT)
552 {
553 m_adapter->ExpandItem(hParent,ITvAdapter::TVC_EXPAND);
554 hParent = m_adapter->GetParentItem(hParent);
555 }
556 //滚动视图
557 int nPos = m_tvItemLocator->Item2Position(hItem);
558 int nHeight = m_tvItemLocator->GetItemHeight(hItem);
559 if(nPos + nHeight <= m_siVer.nPos)// && nPos < m_siVer.nPos + m_siVer.nPage)
560 {
561 OnScroll(TRUE,SB_THUMBPOSITION,nPos);
562 }
563 else if(nPos > m_siVer.nPos + (int)m_siVer.nPage)
564 {
565 OnScroll(TRUE,SB_THUMBPOSITION,nPos + nHeight - m_siVer.nPage);
566 }
567 int nIndent = m_tvItemLocator->GetItemIndent(hItem);
568 int nWidth = m_tvItemLocator->GetItemWidth(hItem);
569
570 if(nIndent + nWidth <= m_siVer.nPos)
571 {
572 OnScroll(FALSE,SB_THUMBPOSITION,nIndent);
573 }else if(nIndent < m_siHoz.nPos + (int)m_siHoz.nPage)
574 {
575 OnScroll(FALSE,SB_THUMBPOSITION,nIndent + nWidth - m_siHoz.nPage);
576 }
577 }
578
579 void STreeView::SetSel(HTREEITEM hItem,BOOL bNotify/*=FALSE*/)
580 {

Callers

nothing calls this directly

Calls 6

ExpandItemMethod · 0.80
GetItemIndentMethod · 0.80
GetParentItemMethod · 0.45
Item2PositionMethod · 0.45
GetItemHeightMethod · 0.45
GetItemWidthMethod · 0.45

Tested by

no test coverage detected