summaryrefslogtreecommitdiff
path: root/vgui2/dme_controls/BaseAttributeChoicePanel.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /vgui2/dme_controls/BaseAttributeChoicePanel.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'vgui2/dme_controls/BaseAttributeChoicePanel.cpp')
-rw-r--r--vgui2/dme_controls/BaseAttributeChoicePanel.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/vgui2/dme_controls/BaseAttributeChoicePanel.cpp b/vgui2/dme_controls/BaseAttributeChoicePanel.cpp
new file mode 100644
index 0000000..3440a7f
--- /dev/null
+++ b/vgui2/dme_controls/BaseAttributeChoicePanel.cpp
@@ -0,0 +1,91 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+
+#include "dme_controls/BaseAttributeChoicePanel.h"
+#include "tier1/KeyValues.h"
+#include "vgui_controls/ComboBox.h"
+#include "datamodel/dmelement.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+
+using namespace vgui;
+
+
+//-----------------------------------------------------------------------------
+// Constructor
+//-----------------------------------------------------------------------------
+CBaseAttributeChoicePanel::CBaseAttributeChoicePanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
+ BaseClass( parent, info ), m_pData( 0 )
+{
+ SetDropEnabled( false );
+ m_pData = new vgui::ComboBox( this, "AttributeValue", 10, false );
+ m_pData->SetEnabled( !HasFlag( FATTRIB_READONLY ) );
+ m_pData->AddActionSignalTarget( this );
+}
+
+
+//-----------------------------------------------------------------------------
+// Called after the constructor is finished
+//-----------------------------------------------------------------------------
+void CBaseAttributeChoicePanel::PostConstructor()
+{
+ BaseClass::PostConstructor();
+ PopulateComboBox( m_pData );
+ Refresh();
+}
+
+
+void CBaseAttributeChoicePanel::ApplySchemeSettings( IScheme *pScheme )
+{
+ BaseClass::ApplySchemeSettings( pScheme );
+ HFont font = pScheme->GetFont( "DmePropertyVerySmall", IsProportional() );
+ m_pData->SetFont(font);
+}
+
+vgui::Panel *CBaseAttributeChoicePanel::GetDataPanel()
+{
+ return static_cast< vgui::Panel * >( m_pData );
+}
+
+
+//-----------------------------------------------------------------------------
+// Called when it is time to set the attribute from the combo box state
+//-----------------------------------------------------------------------------
+void CBaseAttributeChoicePanel::Apply( )
+{
+ KeyValues *kv = m_pData->GetActiveItemUserData();
+ SetAttributeFromComboBox( m_pData, kv );
+}
+
+
+//-----------------------------------------------------------------------------
+// Called when it is time to set the combo box from the attribute
+//-----------------------------------------------------------------------------
+void CBaseAttributeChoicePanel::Refresh()
+{
+ SetComboBoxFromAttribute( m_pData );
+}
+
+
+//-----------------------------------------------------------------------------
+// Called when the text in the panel changes
+//-----------------------------------------------------------------------------
+void CBaseAttributeChoicePanel::OnTextChanged( Panel *panel )
+{
+ if ( IsAutoApply() )
+ {
+ Apply();
+ }
+ else
+ {
+ SetDirty(true);
+ }
+}
+