void ScrollControl::UpdateScrollBars() { if ( !m_InnerPanel ) return; int childrenWidth = 0; int childrenHeight = 0; //Get the max size of all our children together for ( Base::List::iterator iter = m_InnerPanel->Children.begin(); iter != m_InnerPanel->Children.end(); ++iter ) { Base* pChild = *iter; childrenWidth = Utility::Max( childrenWidth, pChild->Right() ); childrenHeight = Utility::Max( childrenHeight, pChild->Bottom() ); } m_InnerPanel->SetSize( Utility::Max(Width(), childrenWidth), Utility::Max(Height(), childrenHeight)); float hg = (float)(childrenWidth + (m_VerticalScrollBar->Hidden() ? 0 : m_VerticalScrollBar->Width())); if (hg==0.f) hg = 0.00001f; float wPercent = (float)Width() / hg; hg = (float)(childrenHeight + (m_HorizontalScrollBar->Hidden() ? 0 : m_HorizontalScrollBar->Height())); if (hg==0.f) hg = 0.00001f; float hPercent = (float)Height() / hg; if ( m_bCanScrollV ) SetVScrollRequired( hPercent >= 1 ); else m_VerticalScrollBar->SetHidden( true ); if ( m_bCanScrollH ) SetHScrollRequired( wPercent >= 1 ); else m_HorizontalScrollBar->SetHidden( true ); m_VerticalScrollBar->SetContentSize( m_InnerPanel->Height() ); m_VerticalScrollBar->SetViewableContentSize( Height() - (m_HorizontalScrollBar->Hidden() ? 0 : m_HorizontalScrollBar->Height())); m_HorizontalScrollBar->SetContentSize( m_InnerPanel->Width() ); m_HorizontalScrollBar->SetViewableContentSize( Width() - (m_VerticalScrollBar->Hidden() ? 0 : m_VerticalScrollBar->Width()) ); int newInnerPanelPosX = 0; int newInnerPanelPosY = 0; if ( CanScrollV() && !m_VerticalScrollBar->Hidden() ) { newInnerPanelPosY = -( ( m_InnerPanel->Height() ) - Height() + (m_HorizontalScrollBar->Hidden() ? 0 : m_HorizontalScrollBar->Height()) ) * m_VerticalScrollBar->GetScrolledAmount(); } if ( CanScrollH() && !m_HorizontalScrollBar->Hidden() ) { newInnerPanelPosX = - ( ( m_InnerPanel->Width() ) - Width() + (m_VerticalScrollBar->Hidden() ? 0 : m_VerticalScrollBar->Width())) * m_HorizontalScrollBar->GetScrolledAmount(); } m_InnerPanel->SetPos( newInnerPanelPosX , newInnerPanelPosY ); }
Gwen::Point Base::ChildrenSize() { Gwen::Point size; for (Base::List::iterator iter = Children.begin(); iter != Children.end(); ++iter) { Base* pChild = *iter; if ( pChild->Hidden() ) continue; size.x = GwenUtil_Max( size.x, pChild->Right() ); size.y = GwenUtil_Max( size.y, pChild->Bottom() ); } return size; }
gwen::Point Base::ChildrenSize() { gwen::Point size; for ( Base::List::iterator iter = Children.begin(); iter != Children.end(); ++iter ) { Base* pChild = *iter; if ( pChild->Hidden() ) { continue; } if ( !pChild->ShouldIncludeInSize() ) { continue; } size.x = gwen::Max( size.x, pChild->Right() ); size.y = gwen::Max( size.y, pChild->Bottom() ); } return size; }