1 Star 0 Fork 0

yoyojacky/CSMoE

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
ToggleButton.cpp 2.75 KB
Copy Edit Raw Blame History
//========= Copyright ?1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include <vgui/KeyCode.h>
#include "ToggleButton.h"
#include <tier1/KeyValues.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
using namespace vgui2;
DECLARE_BUILD_FACTORY_DEFAULT_TEXT( ToggleButton, ToggleButton );
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
ToggleButton::ToggleButton(Panel *parent, const char *panelName, const char* text) : Button(parent, panelName, text)
{
SetButtonActivationType(ACTIVATE_ONPRESSED);
}
//-----------------------------------------------------------------------------
// Purpose: Turns double-click into normal click
//-----------------------------------------------------------------------------
void ToggleButton::OnMouseDoublePressed(MouseCode code)
{
OnMousePressed(code);
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Color ToggleButton::GetButtonFgColor()
{
if (IsSelected())
{
// highlight the text when depressed
return _selectedColor;
}
else
{
return BaseClass::GetButtonFgColor();
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool ToggleButton::CanBeDefaultButton(void)
{
return false;
}
//-----------------------------------------------------------------------------
// Purpose: Toggles the state of the button
//-----------------------------------------------------------------------------
void ToggleButton::DoClick()
{
if (IsSelected())
{
ForceDepressed(false);
}
else if (!IsSelected())
{
ForceDepressed(true);
}
SetSelected(!IsSelected());
FireActionSignal();
// post a button toggled message
KeyValues *msg = new KeyValues("ButtonToggled");
msg->SetInt("state", (int)IsSelected());
PostActionSignal(msg);
Repaint();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void ToggleButton::ApplySchemeSettings(IScheme *pScheme)
{
BaseClass::ApplySchemeSettings(pScheme);
_selectedColor = GetSchemeColor("ToggleButton.SelectedTextColor", GetSchemeColor("BrightControlText", pScheme), pScheme);
}
void ToggleButton::OnKeyCodePressed(KeyCode code)
{
if (code != KEY_ENTER)
{
BaseClass::OnKeyCodePressed(code);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yoyojacky/CSMoE.git
git@gitee.com:yoyojacky/CSMoE.git
yoyojacky
CSMoE
CSMoE
master

Search