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

Method UpdateScrollBar

SOUI/src/control/STreeView.cpp:703–786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

701 }
702
703 void STreeView::UpdateScrollBar()
704 {
705 CSize szView;
706 szView.cx = m_tvItemLocator->GetTotalWidth();
707 szView.cy = m_tvItemLocator->GetTotalHeight();
708
709 CRect rcClient;
710 SWindow::GetClientRect(&rcClient);//不计算滚动条大小
711 CSize size = rcClient.Size();
712 // 关闭滚动条
713 m_wBarVisible = SSB_NULL;
714
715 if (size.cy<szView.cy || (size.cy<szView.cy+GetSbWidth() && size.cx<szView.cx))
716 {
717 // 需要纵向滚动条
718 m_wBarVisible |= SSB_VERT;
719 m_siVer.nMin = 0;
720 m_siVer.nMax = szView.cy-1;
721 m_siVer.nPage = rcClient.Height();
722
723 if (size.cx-GetSbWidth() < szView.cx && !m_adapter->isViewWidthMatchParent())
724 {
725 // 需要横向滚动条
726 m_wBarVisible |= SSB_HORZ;
727 m_siVer.nPage=size.cy-GetSbWidth() > 0 ? size.cy-GetSbWidth() : 0;//注意同时调整纵向滚动条page信息
728
729 m_siHoz.nMin = 0;
730 m_siHoz.nMax = szView.cx-1;
731 m_siHoz.nPage = (size.cx-GetSbWidth()) > 0 ? (size.cx-GetSbWidth()) : 0;
732 }
733 else
734 {
735 // 不需要横向滚动条
736 m_siHoz.nPage = size.cx;
737 m_siHoz.nMin = 0;
738 m_siHoz.nMax = m_siHoz.nPage-1;
739 m_siHoz.nPos = 0;
740 }
741 }
742 else
743 {
744 // 不需要纵向滚动条
745 m_siVer.nPage = size.cy;
746 m_siVer.nMin = 0;
747 m_siVer.nMax = size.cy-1;
748 m_siVer.nPos = 0;
749
750 if (size.cx < szView.cx && !m_adapter->isViewWidthMatchParent())
751 {
752 // 需要横向滚动条
753 m_wBarVisible |= SSB_HORZ;
754 m_siHoz.nMin = 0;
755 m_siHoz.nMax = szView.cx-1;
756 m_siHoz.nPage = size.cx;
757 }
758 else
759 {
760 // 不需要横向滚动条

Callers

nothing calls this directly

Calls 7

GetClientRectFunction · 0.85
InvalidateFunction · 0.85
GetTotalWidthMethod · 0.45
GetTotalHeightMethod · 0.45
SizeMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected