//see os::View void ProgressBar::Paint( const Rect & cUpdateRect ) { //get normalized bounds //bounds to floor //draw frame with those bounds Rect cBounds = GetNormalizedBounds(); cBounds.Floor(); //set the fgcolor to black //then fill the whole rect with black SetFgColor(0,0,0); FillRect(cBounds); //now lets set the appropriate color if (HasFocus()) SetFgColor(get_default_color(COL_FOCUS)); else SetFgColor(get_default_color(COL_ICON_SELECTED)); //lets create the bar length //then make it look correct float vBarLength = ( m->m_eOrientation == HORIZONTAL ) ? cBounds.Width() : cBounds.Height( ); vBarLength = ceil( ( vBarLength - 3.0f ) * m->m_vProgress ); //bar length becomes the ceil of the (bar length - 3) * progress Rect cBarFrame = cBounds; cBarFrame.Resize( 1.0f, 1.0f, -1.0f, -1.0f ); Rect cRestFrame = cBarFrame; if( vBarLength < 1.0f ) //so if bar length is not valid { FillRect( cRestFrame, GetBgColor() ); } else { //lets calculate the correct bar length if( m->m_eOrientation == HORIZONTAL ) { cBarFrame.right = cBarFrame.left + vBarLength; if( cBarFrame.right > cBounds.right - 2.0f ) { cBarFrame.right = cBounds.right - 2.0f; } cRestFrame.left = cBarFrame.right + 1.0f; } else { cBarFrame.top = cBarFrame.bottom - vBarLength; if( cBarFrame.right < cBounds.right + 2.0f ) { cBarFrame.top = cBounds.top + 2.0f; } cRestFrame.bottom = cBarFrame.top - 1.0f; } //if bar length is valid if( vBarLength >= 1.0f ) { FillRect( cBarFrame, GetFgColor() ); } //if the rest of the frame is valid if( cRestFrame.IsValid() ) { FillRect( cRestFrame, GetBgColor() ); } } }