00001 #include "SdlArs.h"
00002
00003
00004
00005
00006 Ars::Window *cbObjCreate( const icstring &name )
00007 {
00008 Ars::Window *ans = 0;
00009
00010 if( name == "Button" )
00011 ans = new Ars::XButton();
00012 else if( name == "BTNIMG" )
00013 ans = new Ars::XButtonImage();
00014 else if( name == "CheckBox" )
00015 ans = new Ars::XCheckBox();
00016 else if( name == "DROPDOWN" )
00017 ans = new Ars::XDropDown();
00018 else if( name == "EDITBOX" )
00019 ans = new Ars::XEditBox();
00020 else if( name == "GROUPBOX" )
00021 ans = new Ars::XGroupBox();
00022 else if( name == "BOX" )
00023 ans = new Ars::XBox();
00024 else if( name == "LABEL" )
00025 ans = new Ars::XLabel();
00026 else if( name == "LISTBOX" )
00027 ans = new Ars::XListBox();
00028 else if( name == "IMAGE" )
00029 ans = new Ars::XImage();
00030 else if( name == "SCROLL" )
00031 ans = new Ars::XScrollBar();
00032 else if( name == "PROGRESS" )
00033 ans = new Ars::XProgress();
00034 else if( name == "MPEG" )
00035 ans = new Ars::XMPEG();
00036 else if( name == "TextBox" )
00037 ans = new Ars::XTextBox();
00038
00039 return ans;
00040 }
00041
00043 namespace Ars
00044 {
00045 static int idCnt = 0x10000000;
00046
00047 Thing::Thing( void )
00048 : XRect( 0 , 0 , 0 , 0 ) , obId( ++idCnt ) , states( S_NONE ) , flags( F_NONE )
00049 , fg( 0 ,0 ,0 ) , bg( 0xd0 , 0xd0 , 0xd0 )
00050 {
00051 Cfg::Handler &h = Cfg::GetCfg();
00052 fg = h.GetCfgColorHex( "Ars" , "text_color" , fg );
00053 bg = h.GetCfgColorHex( "Ars" , "back_color" , bg );
00054 }
00055
00056 void Thing::Init( icstring &aStr )
00057 {
00058 XRect r;
00059
00060 icstring coordStr = Rsrc::FindCrdOf( aStr , "coord" );
00061 if( !coordStr.empty() )
00062 {
00063 ExprIntParser p;
00064 string buffer = Rsrc::FindCrdOf( coordStr , "x" ).c_str();
00065 if( buffer.empty() )
00066 r.x = Rsrc::GetInt( aStr , 0 );
00067 else
00068 r.x = p.Apply( p.Eval( buffer ) );
00069 buffer = Rsrc::FindCrdOf( coordStr , "y" ).c_str();
00070 if( buffer.empty() )
00071 r.y = Rsrc::GetInt( aStr , 0 );
00072 else
00073 r.y = p.Apply( p.Eval( buffer ) );
00074 buffer = Rsrc::FindCrdOf( coordStr , "w" ).c_str();
00075 if( buffer.empty() )
00076 r.w = Rsrc::GetInt( aStr , 0 );
00077 else
00078 r.w = p.Apply( p.Eval( buffer ) );
00079 buffer = Rsrc::FindCrdOf( coordStr , "h" ).c_str();
00080 if( buffer.empty() )
00081 r.h = Rsrc::GetInt( aStr , 0 );
00082 else
00083 r.h = p.Apply( p.Eval( buffer ) );
00084 }
00085 else
00086 {
00087 r.x = Rsrc::GetInt( aStr , 0 );
00088 r.y = Rsrc::GetInt( aStr , 0 );
00089 r.w = Rsrc::GetInt( aStr , 0 );
00090 r.h = Rsrc::GetInt( aStr , 0 );
00091 }
00092
00093 if( r.Right() >= Ars::ArsApplication::scrW )
00094 r.w = (Ars::ArsApplication::scrW - 1) - r.x;
00095 if( r.Bottom() >= Ars::ArsApplication::scrH )
00096 r.h = (Ars::ArsApplication::scrH - 1) - r.y;
00097
00098 SetWindowRect( r );
00099
00100 Cfg::Handler &h = Cfg::GetCfg();
00101
00102
00103 icstring tmp = Rsrc::FindCrdOf( aStr , "fg" );
00104 SetFgColor( Rsrc::GetColor( tmp , fg ) );
00105 tmp = Rsrc::FindCrdOf( aStr , "bg" );
00106 SetBgColor( Rsrc::GetColor( tmp , bg ) );
00107
00108
00109 tmp = Rsrc::FindCrdOf( aStr , "flags" );
00110 SetFlags( Rsrc::GetMnemo( tmp , ArsApplication::Mnemo_f , GetFlags() ) );
00111 tmp = Rsrc::FindCrdOf( aStr , "states" );
00112 SetState( Rsrc::GetMnemo( tmp , ArsApplication::Mnemo_s , GetStates() ) );
00113
00114 tmp = Rsrc::FindCrdOf( aStr , "id" );
00115 obId = Rsrc::GetInt( tmp , obId );
00116 }
00117
00118 }