ScrollableControl::ScrollableControl() { _vScrollBar = new ScrollBar(); GetVerticalScrollBar()->SetAlignment(ALIGNMENT_VCENTER_RIGHT); GetVerticalScrollBar()->SetOrientation(ORIENTATION_VERTICAL); GetVerticalScrollBar()->onValueChanged.bind(this, &ScrollableControl::OnVerticalValueChanged); GetVerticalScrollBar()->Hide(); AddChild(GetVerticalScrollBar()); _hScrollBar = new ScrollBar(); GetHorizontalScrollBar()->SetAlignment(ALIGNMENT_BOTTOM_HCENTER); GetHorizontalScrollBar()->SetOrientation(ORIENTATION_HORIZONTAL); GetHorizontalScrollBar()->onValueChanged.bind(this, &ScrollableControl::OnHorizontalValueChanged); GetHorizontalScrollBar()->Hide(); AddChild(GetHorizontalScrollBar()); }
void CContainerUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcsicmp(pstrName, _T("inset")) == 0 ) { RECT rcInset = { 0 }; LPTSTR pstr = NULL; rcInset.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcInset.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetInset(rcInset); } else if( _tcsicmp(pstrName, _T("mousechild")) == 0 ) SetMouseChildEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("vscrollbar")) == 0 ) { EnableScrollBar(_tcsicmp(pstrValue, _T("true")) == 0, GetHorizontalScrollBar() != NULL); } else if( _tcsicmp(pstrName, _T("vscrollbarstyle")) == 0 ) { m_sVerticalScrollBarStyle = pstrValue; EnableScrollBar(TRUE, GetHorizontalScrollBar() != NULL); if( GetVerticalScrollBar() ) { LPCTSTR pStyle = m_pManager->GetStyle(m_sVerticalScrollBarStyle); if( pStyle ) { GetVerticalScrollBar()->ApplyAttributeList(pStyle); } else { GetVerticalScrollBar()->ApplyAttributeList(pstrValue); } } } //else if( _tcsicmp(pstrName, _T("vscrollbarstyle")) == 0 ) { // EnableScrollBar(true, GetHorizontalScrollBar() != NULL); // if( GetVerticalScrollBar() ) GetVerticalScrollBar()->ApplyAttributeList(pstrValue); //} else if( _tcsicmp(pstrName, _T("hscrollbar")) == 0 ) { EnableScrollBar(GetVerticalScrollBar() != NULL, _tcsicmp(pstrValue, _T("true")) == 0); } else if( _tcsicmp(pstrName, _T("hscrollbarstyle")) == 0 ) { m_sHorizontalScrollBarStyle = pstrValue; EnableScrollBar(TRUE, GetHorizontalScrollBar() != NULL); if( GetHorizontalScrollBar() ) { LPCTSTR pStyle = m_pManager->GetStyle(m_sHorizontalScrollBarStyle); if( pStyle ) { GetHorizontalScrollBar()->ApplyAttributeList(pStyle); } else { GetHorizontalScrollBar()->ApplyAttributeList(pstrValue); } } } //else if( _tcsicmp(pstrName, _T("hscrollbarstyle")) == 0 ) { // EnableScrollBar(GetVerticalScrollBar() != NULL, true); // if( GetHorizontalScrollBar() ) GetHorizontalScrollBar()->ApplyAttributeList(pstrValue); //} else if( _tcsicmp(pstrName, _T("childpadding")) == 0 ) SetChildPadding(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("scrollstepsize")) == 0 ) SetScrollStepSize(_ttoi(pstrValue)); else CControlUI::SetAttribute(pstrName, pstrValue); }
void ScrollableControl::SetWidth(SizeType width) { if (GetWidth() == width) return; Button::SetWidth(width); GetHorizontalScrollBar()->SetWidth(width); }