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/property/gwen_checkbox.h
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

65 lines
1.4 KiB
C++

/*
GWEN
Copyright (c) 2010 Facepunch Studios
See license in Gwen.h
*/
#pragma once
#ifndef GWEN_CONTROLS_PROPERTY_CHECKBOX_H
#define GWEN_CONTROLS_PROPERTY_CHECKBOX_H
#include "gwen_baseproperty.h"
#include "../gwen_checkbox.h"
namespace Gwen
{
namespace Controls
{
namespace Property
{
class GWEN_EXPORT Checkbox : public Property::Base
{
public:
GWEN_CONTROL_INLINE( Checkbox, Property::Base )
{
m_Checkbox = new Gwen::Controls::CheckBox( this );
m_Checkbox->SetShouldDrawBackground( false );
m_Checkbox->onCheckChanged.Add( this, &BaseClass::OnPropertyValueChanged );
m_Checkbox->SetTabable( true );
m_Checkbox->SetKeyboardInputEnabled( true );
m_Checkbox->SetPos( 2, 1 );
SetHeight( 18 );
}
virtual TextObject GetPropertyValue()
{
return m_Checkbox->IsChecked() ? "1" : "0";
}
virtual void SetPropertyValue( const TextObject& v, bool bFireChangeEvents )
{
if ( v == "1" || v == "true" || v == "TRUE" || v == "yes" || v == "YES" )
return m_Checkbox->SetChecked( true );
return m_Checkbox->SetChecked( false );
}
virtual bool IsEditing()
{
return m_Checkbox->HasFocus();
}
virtual bool IsHovered()
{
return BaseClass::IsHovered() || m_Checkbox->IsHovered();
}
Gwen::Controls::CheckBox* m_Checkbox;
};
}
}
}
#endif