本文整理汇总了C++中Rect::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::IsValid方法的具体用法?C++ Rect::IsValid怎么用?C++ Rect::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::IsValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Paint
//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() );
}
}
}