mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-29 17:46:29 +03:00
107 lines
2.3 KiB
C++
107 lines
2.3 KiB
C++
#include "cuimenucheckbox.hpp"
|
|
#include "cuimenu.hpp"
|
|
|
|
namespace EE { namespace UI {
|
|
|
|
cUIMenuCheckBox::cUIMenuCheckBox( cUIMenuCheckBox::CreateParams& Params ) :
|
|
cUIMenuItem( Params ),
|
|
mActive( false ),
|
|
mSkinActive( NULL ),
|
|
mSkinInactive( NULL )
|
|
{
|
|
ApplyDefaultTheme();
|
|
}
|
|
|
|
cUIMenuCheckBox::~cUIMenuCheckBox() {
|
|
}
|
|
|
|
Uint32 cUIMenuCheckBox::Type() const {
|
|
return UI_TYPE_MENUCHECKBOX;
|
|
}
|
|
|
|
bool cUIMenuCheckBox::IsType( const Uint32& type ) const {
|
|
return cUIMenuCheckBox::Type() == type ? true : cUIMenuItem::IsType( type );
|
|
}
|
|
|
|
void cUIMenuCheckBox::SetTheme( cUITheme * Theme ) {
|
|
cUIControl::SetTheme( Theme, "menuitem" );
|
|
|
|
mSkinActive = Theme->GetByName( Theme->Abbr() + "_" + "menucheckbox_active" );
|
|
mSkinInactive = Theme->GetByName( Theme->Abbr() + "_" + "menucheckbox_inactive" );
|
|
|
|
Active( mActive );
|
|
|
|
DoAfterSetTheme();
|
|
}
|
|
|
|
const bool& cUIMenuCheckBox::Active() const {
|
|
return mActive;
|
|
}
|
|
|
|
const bool& cUIMenuCheckBox::IsActive() const {
|
|
return Active();
|
|
}
|
|
|
|
void cUIMenuCheckBox::Active( const bool& active ) {
|
|
bool oActive = mActive;
|
|
mActive = active;
|
|
|
|
if ( mActive ) {
|
|
if ( NULL != mSkinActive ) {
|
|
if ( mSkinState->GetState() == cUISkinState::StateSelected )
|
|
Icon( mSkinActive->GetShape( cUISkinState::StateMouseEnter ) );
|
|
else
|
|
Icon( mSkinActive->GetShape( cUISkinState::StateNormal ) );
|
|
} else
|
|
mIcon->Shape( NULL );
|
|
} else {
|
|
if ( NULL != mSkinInactive )
|
|
if ( mSkinState->GetState() == cUISkinState::StateSelected )
|
|
Icon( mSkinInactive->GetShape( cUISkinState::StateMouseEnter ) );
|
|
else
|
|
Icon( mSkinInactive->GetShape( cUISkinState::StateNormal ) );
|
|
else
|
|
mIcon->Shape( NULL );
|
|
}
|
|
|
|
if ( oActive != active ) {
|
|
cUIMenu * Menu = reinterpret_cast<cUIMenu*> ( Parent() );
|
|
|
|
if ( !Menu->CheckControlSize( this ) ) {
|
|
if ( NULL != Icon()->Shape() ) {
|
|
Padding( eeRecti( 0, 0, 0, 0 ) );
|
|
}
|
|
}
|
|
|
|
OnValueChange();
|
|
}
|
|
}
|
|
|
|
void cUIMenuCheckBox::SwitchActive() {
|
|
Active( !mActive );
|
|
}
|
|
|
|
Uint32 cUIMenuCheckBox::OnMouseUp( const eeVector2i &Pos, Uint32 Flags ) {
|
|
cUIMenuItem::OnMouseUp( Pos, Flags );
|
|
|
|
if ( Parent()->Visible() && ( Flags & EE_BUTTONS_LRM ) )
|
|
SwitchActive();
|
|
|
|
return 1;
|
|
}
|
|
|
|
void cUIMenuCheckBox::OnStateChange() {
|
|
cUIMenuItem::OnStateChange();
|
|
|
|
Active( mActive );
|
|
}
|
|
|
|
bool cUIMenuCheckBox::InheritsFrom( const Uint32 Type ) {
|
|
if ( Type == UI_TYPE_MENUITEM )
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
}}
|