hlsdk-xash3d/game_shared/vgui_checkbutton2.h

81 lines
1.9 KiB
C
Raw Permalink Normal View History

//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
2016-06-04 15:24:23 +02:00
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef VGUI_CHECKBUTTON2_H
2021-06-20 00:53:07 +02:00
#define VGUI_CHECKBUTTON2_H
#ifdef _WIN32
#pragma once
#endif
2016-06-04 15:24:23 +02:00
#include "VGUI_Label.h"
#include "VGUI_ImagePanel.h"
2016-06-04 15:24:23 +02:00
#include "vgui_defaultinputsignal.h"
namespace vgui
{
class CCheckButton2;
class ICheckButton2Handler
{
public:
virtual void StateChanged( CCheckButton2 *pButton ) = 0;
2016-06-04 15:24:23 +02:00
};
// VGUI checkbox class.
// - Provides access to the checkbox images.
// - Provides an easy callback mechanism for state changes.
// - Default background is invisible, and default text color is white.
class CCheckButton2 : public Panel, public CDefaultInputSignal
{
public:
CCheckButton2();
~CCheckButton2();
2016-06-04 15:24:23 +02:00
// Initialize the button with these.
void SetImages( char const *pChecked, char const *pUnchecked );
void SetImages( Image *pChecked, Image *pUnchecked ); // If you use this, the button will never delete the images.
2016-06-04 15:24:23 +02:00
void DeleteImages();
// The checkbox can be to the left or the right of the text (default is left).
void SetCheckboxLeft( bool bLeftAlign );
2016-06-04 15:24:23 +02:00
bool GetCheckboxLeft();
2016-06-04 15:24:23 +02:00
// Set the label text.
void SetText( char const *pText, ... );
void SetTextColor( int r, int g, int b, int a );
2016-06-04 15:24:23 +02:00
// You can register for change notification here.
void SetHandler( ICheckButton2Handler *pHandler );
2016-06-04 15:24:23 +02:00
// Get/set the check state.
bool IsChecked();
void SetChecked( bool bChecked );
2016-06-04 15:24:23 +02:00
// Panel overrides.
virtual void internalMousePressed( MouseCode code );
2016-06-04 15:24:23 +02:00
protected:
void SetupControls();
// InputSignal overrides.
virtual void mousePressed( MouseCode code, Panel *panel );
2016-06-04 15:24:23 +02:00
public:
ICheckButton2Handler *m_pHandler;
bool m_bCheckboxLeft;
Label m_Label;
ImagePanel m_CheckboxPanel;
Image *m_pChecked;
Image *m_pUnchecked;
bool m_bOwnImages;
bool m_bChecked;
};
}
#endif // VGUI_CHECKBUTTON2_H