This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
MyGameFramework/lib/gwen/controls/gwen_checkbox.cpp
Gered c5cdddbeaa initial commit
current versions of all of my basic framework sources, build configurations/scripts, and supporting assets
2013-01-31 12:53:05 -05:00

60 lines
786 B
C++

/*
GWEN
Copyright (c) 2010 Facepunch Studios
See license in Gwen.h
*/
#include "gwen_checkbox.h"
using namespace Gwen;
using namespace Gwen::Controls;
GWEN_CONTROL_CONSTRUCTOR( CheckBox )
{
SetSize( 15, 15 );
m_bChecked = true;
Toggle();
}
void CheckBox::Render( Skin::Base* skin )
{
skin->DrawCheckBox( this, m_bChecked, IsDepressed() );
}
void CheckBox::OnPress()
{
if ( IsDisabled())
return;
if ( IsChecked() && !AllowUncheck() )
return;
Toggle();
}
void CheckBox::OnCheckStatusChanged()
{
if ( IsChecked() )
{
onChecked.Call( this );
}
else
{
onUnChecked.Call( this );
}
onCheckChanged.Call( this );
}
void CheckBox::SetChecked( bool bChecked )
{
if ( m_bChecked == bChecked ) return;
m_bChecked = bChecked;
OnCheckStatusChanged();
}