void NumericStepper::setValue(int v) { if(v == m_value) return; m_value = v; char buf[128]= {0}; sprintf(buf,"%d",m_value); m_labNum->setString(buf); executeValueChangedHandler(this,m_value); }
void CProgressBar::changeValueAndExecuteEvent(int nValue, bool bExeEvent) { #if 1 CCAssert(m_nMinValue >= 0 && m_nMaxValue >= 0 && m_nMinValue < m_nMaxValue, "err"); #endif int nOldValue = m_nValue; nValue = MAX(nValue, m_nMinValue); nValue = MIN(nValue, m_nMaxValue); m_nValue = nValue; CCRect tScissorRect; getScissorRectByPercentage(tScissorRect); switch( m_eDirection ) { case eProgressBarDirectionLeftToRight: { m_pProgressSprite->setAnchorPoint(CCPoint(0.0f, 0.5f)); m_pProgressSprite->setPosition(CCPoint(m_tCenterPoint.x - m_tProgressSize.width / 2, m_tCenterPoint.y)); } break; case eProgressBarDirectionBottomToTop: { m_pProgressSprite->setAnchorPoint(CCPoint(0.5f, 0.0f)); m_pProgressSprite->setPosition(CCPoint(m_tCenterPoint.x, m_tCenterPoint.y - m_tProgressSize.height / 2)); } break; case eProgressBarDirectionRightToLeft: { m_pProgressSprite->setAnchorPoint(CCPoint(1.0f, 0.5f)); m_pProgressSprite->setPosition(CCPoint(m_tCenterPoint.x + m_tProgressSize.width / 2, m_tCenterPoint.y)); } break; case eProgressBarDirectionTopToBottom: { m_pProgressSprite->setAnchorPoint(CCPoint(0.5f, 1.0f)); m_pProgressSprite->setPosition(CCPoint(m_tCenterPoint.x, m_tCenterPoint.y + m_tProgressSize.height / 2)); } break; default: break; } m_pProgressSprite->setTextureRect(tScissorRect); if( bExeEvent && nOldValue != nValue ) { executeValueChangedHandler(this, nValue); } }