00001 #include "SdlArs.h"
00002
00003 namespace Ars
00004 {
00005
00006 XCheckBox::XCheckBox(void )
00007 {
00008 }
00009
00010 XCheckBox::~XCheckBox( void )
00011 {
00012 }
00013
00014 const bool XCheckBox::SetupWindow( const Message &msg )
00015 {
00016 XLabel::SetupWindow( msg );
00017
00018 MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_BUTTONDOWN);
00019 MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_BUTTONUP);
00020 MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_MOVE);
00021 MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_LCLICK);
00022
00023 return true;
00024 }
00025
00026 void XCheckBox::Draw( void )
00027 {
00028 XRect r( GetWindowRect() );
00029
00031 x += Height();
00032 const unsigned long stateBak = GetStates();
00033 ResetState( VALIGN_MASK|HALIGN_MASK );
00034 SetState( S_ALIGN_LEFT );
00035 XLabel::Draw();
00036 SetState( stateBak );
00037 x -= Height();
00038
00039
00040 r.SetRight( r.x + r.Height() );
00041
00042 r.Grow( (r.Height() - GetFontSize()) / (-2) );
00043 DrawSunken( r , GetBgColor() );
00044 r.Grow( -1 );
00045
00046 DrawRect( r , true , GetFgColor().FadeColor( 32 ) , GetFgColor().FadeColor( 64 ) );
00047
00048 if( GetStates() & S_CHECKED )
00049 {
00050 DrawLine( r.TopLeft() , r.BottomRight() , GetFgColor().FadeColor( -32 ) );
00051 DrawLine( r.TopLeft() + XPoint( 1 , 0 ) , r.BottomRight() + XPoint( 0 , -1 ) , GetFgColor().FadeColor( 32 ) );
00052 DrawLine( r.TopRight() , r.BottomLeft() , GetFgColor().FadeColor( -32 ) );
00053 DrawLine( r.TopRight() + XPoint( 0 , 1 ) , r.BottomLeft() + XPoint( 1 , 0 ) , GetFgColor().FadeColor( 32 ) );
00054 }
00055 }
00056
00057 const bool XCheckBox::evMouseButtonUp( const MouseMessage &msg )
00058 {
00059 bool ans = XLabel::evMouseButtonUp( msg );
00060
00061 if( ans )
00062 ArsSendMessage( CtrlMessage( Message::CTRL_LCLICK, this, this, 0 ) );
00063
00064 return ans;
00065 }
00066
00067 const bool XCheckBox::evMouseLClick( const CtrlMessage &msg )
00068 {
00069 bool ans = XLabel::evMouseLClick( msg );
00070
00071 if( (GetStates() & S_DISABLED) != S_DISABLED )
00072 {
00073 if( msg.Destination() == this )
00074 {
00075 ArsSendMessage( CtrlMessage( Message::CTRL_VALUECHANGE , GetParent() , this , ToggleCheck() ) );
00076 ans = true;
00077 }
00078 }
00079 return ans;
00080 }
00081
00082 }