00001 #include "SdlArs.h"
00002
00003 namespace Ars
00004 {
00005
00006 XButton::XButton( void )
00007 : m_MouseButton( 0 )
00008 {
00009 }
00010
00011 XButton::~XButton( void )
00012 {
00013 }
00014
00015 const bool XButton::SetupWindow( const Message &msg )
00016 {
00017 XLabel::SetupWindow( msg );
00018
00019 MessageServer::Instance().RegisterMessageClient( this , Message::MOUSE_BUTTONDOWN );
00020 MessageServer::Instance().RegisterMessageClient( this , Message::MOUSE_BUTTONUP );
00021 MessageServer::Instance().RegisterMessageClient( this , Message::MOUSE_MOVE );
00022
00023 return true;
00024 }
00025
00026 const bool XButton::evMouseMove( const MouseMessage &msg )
00027 {
00028 bool ans = XLabel::evMouseMove( msg );
00029
00030 if( FindWindow( &msg.Point ) == this )
00031 ResetState( S_FOCUS );
00032 return ans;
00033 }
00034
00035 const bool XButton::evMouseButtonDown( const MouseMessage &msg )
00036 {
00037 bool ans = XLabel::evMouseButtonDown( msg );
00038
00039 if( (GetStates() & S_DISABLED) == 0 )
00040 if( (GetStates() & S_SELECTED) != S_SELECTED && FindWindow( &msg.Point ) == this )
00041 {
00042 ans = SetState( S_HIGHLIGHT|S_FOCUS|S_SELECTED );
00043 }
00044
00045 return ans;
00046 }
00047
00048 const bool XButton::evMouseButtonUp( const MouseMessage &msg )
00049 {
00050 bool ans = XLabel::evMouseButtonUp( msg );
00051
00052 if( (GetStates() & S_SELECTED) == S_SELECTED )
00053 {
00054 SetState( S_HIGHLIGHT|S_FOCUS );
00055 ans = ResetState( S_SELECTED ) || ans;
00056 }
00057 return ans;
00058 }
00059
00060 }