00001 #include "SdlArs.h"
00002
00003 namespace Ars
00004 {
00005
00006 XProgress::XProgress( void )
00007 : m_iMin(0),m_iMax(100),m_iProgress(0),BarColor( 0 , 0 , 0 )
00008 {
00009 }
00010
00011
00012 XProgress::~XProgress(void)
00013 {
00014
00015 }
00016
00017 void XProgress::Init( icstring &aStr )
00018 {
00019 XLabel::Init( aStr );
00020
00021 icstring tmp = Rsrc::FindCrdOf( aStr , "min_max" );
00022 m_iMin = max( 0 , Rsrc::GetInt( tmp ) );
00023 m_iMax = max( 1 , Rsrc::GetInt( tmp ) );
00024
00025 tmp = Rsrc::FindCrdOf( aStr , "barColor" );
00026 BarColor = Rsrc::GetColor( tmp , GetFgColor().FadeColor( 32 ) );
00027 }
00028
00029 const bool XProgress::SetupWindow( const Message &msg )
00030 {
00031 XLabel::SetupWindow( msg );
00032
00033 SetProgress( 0 );
00034
00035 return false;
00036 }
00037
00038 void XProgress::SetProgress( const int iProgress , const bool aNow )
00039 {
00040 m_iProgress = min( m_iMax , iProgress );
00041
00042 char tmp[50];
00043 sprintf( tmp , "%d %%" , (m_iProgress * 100) / m_iMax );
00044 SetWndText( tmp );
00045
00046 UpdateWindow( aNow );
00047 }
00048
00049 void XProgress::Draw( void )
00050 {
00051 XRect SubRect( *this );
00052 SubRect.Grow( -1 );
00053 if( m_iProgress > m_iMin )
00054 {
00055 SubRect.w = static_cast<unsigned int>( SubRect.w * (static_cast<double>(m_iProgress - m_iMin) / (m_iMax - m_iMin) ) );
00056 DrawRect( SubRect , true , BarColor , BarColor );
00057 DrawRaised( SubRect , BarColor );
00058 }
00059
00060 XLabel::Draw();
00061 }
00062
00063 }
00064