代码拉取完成,页面将自动刷新
//===== Copyright ?1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#include <stdarg.h>
#include <stdio.h>
#include <vgui/ISurface.h>
#include <vgui/IScheme.h>
#include <tier1/KeyValues.h>
#include "Image.h"
#include "ExpandButton.h"
#include "TextImage.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
using namespace vgui2;
DECLARE_BUILD_FACTORY( ExpandButton );
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
ExpandButton::ExpandButton( Panel *parent, const char *panelName ) : ToggleButton( parent, panelName, "" )
{
m_bExpandable = true;
m_hFont = INVALID_FONT;
}
//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
ExpandButton::~ExpandButton()
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void ExpandButton::ApplySchemeSettings(IScheme *pScheme)
{
BaseClass::ApplySchemeSettings(pScheme);
m_Color = GetSchemeColor( "ExpandButton.Color", pScheme );
m_hFont = pScheme->GetFont("Marlett", IsProportional() );
// don't draw a background
SetPaintBackgroundEnabled(false);
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
IBorder *ExpandButton::GetBorder(bool depressed, bool armed, bool selected, bool keyfocus)
{
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: Expand the button
//-----------------------------------------------------------------------------
void ExpandButton::SetSelected(bool state)
{
if ( m_bExpandable && ( state != IsSelected() ) )
{
// send a message saying we've been checked
KeyValues *msg = new KeyValues("Expanded", "state", (int)state);
PostActionSignal(msg);
BaseClass::SetSelected(state);
}
}
//-----------------------------------------------------------------------------
// Purpose: sets whether or not the state of the check can be changed
//-----------------------------------------------------------------------------
void ExpandButton::SetExpandable(bool state)
{
m_bExpandable = state;
Repaint();
}
void ExpandButton::Paint()
{
surface()->DrawSetTextFont( m_hFont );
wchar_t code = IsSelected( ) ? L'6' : L'4';
wchar_t pString[2] = { code, 0 };
// draw selected check
int tw, th, w, h;
GetSize( w, h );
surface()->GetTextSize( m_hFont, pString, tw, th );
surface()->DrawSetTextColor( m_Color );
surface()->DrawSetTextPos( ( w - tw ) / 2, ( h - th ) / 2 );
surface()->DrawUnicodeChar( code );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void ExpandButton::OnExpanded(Panel *panel)
{
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。