//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFRichText::OnTick() { if ( !IsVisible() ) return; if ( m_pDownArrow && m_pUpArrow && m_pLine && m_pBox ) { if ( _vertScrollBar && _vertScrollBar->IsVisible() ) { _vertScrollBar->SetZPos( 500 ); // turn off painting the vertical scrollbar _vertScrollBar->SetPaintBackgroundEnabled( false ); _vertScrollBar->SetPaintBorderEnabled( false ); _vertScrollBar->SetPaintEnabled( false ); _vertScrollBar->SetScrollbarButtonsVisible( false ); // turn on our own images SetScrollBarImagesVisible ( true ); // set the alpha on the up arrow int nMin, nMax; _vertScrollBar->GetRange( nMin, nMax ); int nScrollPos = _vertScrollBar->GetValue(); int nRangeWindow = _vertScrollBar->GetRangeWindow(); int nBottom = nMax - nRangeWindow; if ( nBottom < 0 ) { nBottom = 0; } // set the alpha on the up arrow int nAlpha = ( nScrollPos - nMin <= 0 ) ? 90 : 255; m_pUpArrow->SetAlpha( nAlpha ); // set the alpha on the down arrow nAlpha = ( nScrollPos >= nBottom ) ? 90 : 255; m_pDownArrow->SetAlpha( nAlpha ); ScrollBarSlider *pSlider = _vertScrollBar->GetSlider(); if ( pSlider && pSlider->GetRangeWindow() > 0 ) { int x, y, w, t, min, max; m_pLine->GetBounds( x, y, w, t ); pSlider->GetNobPos( min, max ); m_pBox->SetBounds( x, y + min, w, ( max - min ) ); } } else { // turn off our images SetScrollBarImagesVisible ( false ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void ScrollBar::UpdateSliderImages( void ) { if ( m_pUpArrow && m_pDownArrow ) { // set the alpha on the up arrow int nMin, nMax; GetRange( nMin, nMax ); int nScrollPos = GetValue(); int nRangeWindow = GetRangeWindow(); int nBottom = nMax - nRangeWindow; if ( nBottom < 0 ) { nBottom = 0; } // set the alpha on the up arrow int nAlpha = ( nScrollPos - nMin <= 0 ) ? 90 : 255; m_pUpArrow->SetAlpha( nAlpha ); // set the alpha on the down arrow nAlpha = ( nScrollPos >= nBottom ) ? 90 : 255; m_pDownArrow->SetAlpha( nAlpha ); } if ( m_pLine && m_pBox ) { ScrollBarSlider *pSlider = GetSlider(); if ( pSlider && pSlider->GetRangeWindow() > 0 ) { int x, y, w, t, min, max; m_pLine->GetBounds( x, y, w, t ); // If our slider needs layout, force it to do it now if ( pSlider->IsLayoutInvalid() ) { pSlider->InvalidateLayout( true ); } pSlider->GetNobPos( min, max ); if ( IsVertical() ) { m_pBox->SetBounds( x, y + min, w, ( max - min ) ); } else { m_pBox->SetBounds( x + min, 0, (max-min), t ); } } } }