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

Method UpdateVisibleItems

SOUI/src/control/STreeView.cpp:788–899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

786 }
787
788 void STreeView::UpdateVisibleItems()
789 {
790 if(!m_adapter) return;
791 HTREEITEM hItem = m_tvItemLocator->Position2Item(m_siVer.nPos);
792 if (hItem == ITvAdapter::ITEM_NULL)
793 {
794 //如果没有可显示的,则移除所有item
795 m_visible_items.RemoveAll();
796 m_pVisibleMap->RemoveAll();
797 return;
798 }
799
800 CSize szOldView;
801 szOldView.cx = m_tvItemLocator->GetTotalWidth();
802 szOldView.cy = m_tvItemLocator->GetTotalHeight();
803
804 VISIBLEITEMSMAP *pMapOld = m_pVisibleMap;
805 m_pVisibleMap = new VISIBLEITEMSMAP;
806
807 CRect rcClient = GetClientRect();
808 CRect rcContainer=rcClient;
809 rcContainer.MoveToXY(0,0);
810 rcContainer.bottom=10000;
811
812 int nOffset = m_tvItemLocator->Item2Position(hItem) - m_siVer.nPos;
813
814 m_visible_items.RemoveAll();
815 while(hItem != ITvAdapter::ITEM_NULL)
816 {
817 VISIBLEITEMSMAP::CPair *pFind = pMapOld->Lookup(hItem);
818 ItemInfo ii;
819 ii.nType = m_adapter->getViewType(hItem);
820 if(pFind && pFind->m_value.nType == ii.nType)
821 {//re use the previous item;
822 ii = pFind->m_value;
823 pMapOld->RemoveKey(hItem);
824 }else
825 {
826 SList<SItemPanel *> *lstRecycle = m_itemRecycle.GetAt(ii.nType);
827 if(lstRecycle->IsEmpty())
828 {//创建一个新的列表项
829 ii.pItem = SItemPanel::Create(this,pugi::xml_node(),this);
830 ii.pItem->GetEventSet()->subscribeEvent(EventItemPanelClick::EventID,Subscriber(&STreeView::OnItemClick,this));
831 ii.pItem->GetEventSet()->subscribeEvent(EventItemPanelDbclick::EventID,Subscriber(&STreeView::OnItemDblClick,this));
832 }else
833 {
834 ii.pItem = lstRecycle->RemoveHead();
835 }
836 ii.pItem->SetItemIndex(hItem);
837 }
838 m_pVisibleMap->SetAt(hItem,ii);
839 ii.pItem->SetVisible(TRUE);
840
841 if(hItem == m_hSelected)
842 ii.pItem->ModifyItemState(WndState_Check,0);
843 else
844 ii.pItem->ModifyItemState(0,WndState_Check);
845

Callers

nothing calls this directly

Calls 15

GetClientRectFunction · 0.85
SubscriberFunction · 0.85
CRectClass · 0.85
MoveToXYMethod · 0.80
LookupMethod · 0.80
getViewTypeMethod · 0.80
RemoveKeyMethod · 0.80
RemoveHeadMethod · 0.80
ModifyItemStateMethod · 0.80
DoColorizeMethod · 0.80
GetItemIndentMethod · 0.80
SetItemWidthMethod · 0.80

Tested by

no test coverage detected