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_combobox.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

72 lines
1.5 KiB
C++

/*
GWEN
Copyright (c) 2012 Facepunch Studios
See license in Gwen.h
*/
#pragma once
#ifndef GWEN_CONTROLS_PROPERTY_COMBOBOX_H
#define GWEN_CONTROLS_PROPERTY_COMBOBOX_H
#include "gwen_baseproperty.h"
#include "../gwen_combobox.h"
namespace Gwen
{
namespace Controls
{
namespace Property
{
class GWEN_EXPORT ComboBox : public Property::Base
{
public:
GWEN_CONTROL_INLINE( ComboBox, Property::Base )
{
m_ComboBox = new Gwen::Controls::ComboBox( this );
m_ComboBox->Dock( Pos::Fill );
m_ComboBox->onSelection.Add( this, &BaseClass::OnPropertyValueChanged );
m_ComboBox->SetTabable( true );
m_ComboBox->SetKeyboardInputEnabled( true );
m_ComboBox->SetShouldDrawBackground( false );
SetHeight( 18 );
}
virtual TextObject GetPropertyValue()
{
Gwen::Controls::Label* pControl = m_ComboBox->GetSelectedItem();
if ( !pControl ) return "";
return pControl->GetName();
}
virtual void SetPropertyValue( const TextObject& v, bool bFireChangeEvents )
{
m_ComboBox->SelectItemByName( v.Get(), bFireChangeEvents );
}
virtual bool IsEditing()
{
return m_ComboBox->HasFocus();
}
virtual bool IsHovered()
{
return BaseClass::IsHovered() || m_ComboBox->IsHovered();
}
Gwen::Controls::ComboBox* GetComboBox()
{
return m_ComboBox;
}
protected:
Gwen::Controls::ComboBox* m_ComboBox;
};
}
}
}
#endif