diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /sp/src/game/client/vgui_bitmapbutton.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'sp/src/game/client/vgui_bitmapbutton.cpp')
| -rw-r--r-- | sp/src/game/client/vgui_bitmapbutton.cpp | 240 |
1 files changed, 120 insertions, 120 deletions
diff --git a/sp/src/game/client/vgui_bitmapbutton.cpp b/sp/src/game/client/vgui_bitmapbutton.cpp index 82969803..080e11fc 100644 --- a/sp/src/game/client/vgui_bitmapbutton.cpp +++ b/sp/src/game/client/vgui_bitmapbutton.cpp @@ -1,120 +1,120 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: This is a panel which is rendered image on top of an entity
-//
-// $Revision: $
-// $NoKeywords: $
-//=============================================================================//
-#include "cbase.h"
-#pragma warning (disable: 4514)
-
-#include "vgui_bitmapimage.h"
-#include "vgui_bitmapbutton.h"
-#include <KeyValues.h>
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-//-----------------------------------------------------------------------------
-// Constructor
-//-----------------------------------------------------------------------------
-CBitmapButton::CBitmapButton( vgui::Panel *pParent, const char *pName, const char *pText ) :
- BaseClass( pParent, pName, pText )
-{
- SetPaintBackgroundEnabled( false );
- for ( int i = 0; i < BUTTON_STATE_COUNT; ++i )
- {
- m_bImageLoaded[i] = false;
- }
-}
-
-CBitmapButton::~CBitmapButton()
-{
-}
-
-
-//-----------------------------------------------------------------------------
-// initialization
-//-----------------------------------------------------------------------------
-bool CBitmapButton::Init( KeyValues* pInitData )
-{
- // Unimplemented
- Assert( 0 );
- return true;
-}
-
-
-//-----------------------------------------------------------------------------
-// initialization from build-mode dialog style .res files
-//-----------------------------------------------------------------------------
-void CBitmapButton::ApplySettings(KeyValues *pInitData)
-{
- BaseClass::ApplySettings(pInitData);
-
- COMPILE_TIME_ASSERT( BUTTON_STATE_COUNT == 4 );
- const char *pSectionName[BUTTON_STATE_COUNT] =
- {
- "enabledImage",
- "mouseOverImage",
- "pressedImage",
- "disabledImage"
- };
-
- for ( int i = 0; i < BUTTON_STATE_COUNT; ++i )
- {
- m_bImageLoaded[i] = InitializeImage(pInitData, pSectionName[i], this, &m_pImage[i] );
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Sets the image
-//-----------------------------------------------------------------------------
-void CBitmapButton::SetImage( ButtonImageType_t type, const char *pMaterialName, color32 color )
-{
- m_bImageLoaded[type] = m_pImage[type].Init( GetVPanel(), pMaterialName );
- if (m_bImageLoaded[type])
- {
- Color vcol( color.r, color.g, color.b, color.a );
- m_pImage[type].SetColor( vcol );
- }
-}
-
-bool CBitmapButton::IsImageLoaded( ButtonImageType_t type ) const
-{
- return m_bImageLoaded[type];
-}
-
-
-//-----------------------------------------------------------------------------
-// Draws the puppy
-//-----------------------------------------------------------------------------
-void CBitmapButton::Paint( void )
-{
- // Determine the image to use based on the state
- int nCurrentImage = BUTTON_ENABLED;
- if (IsArmed())
- {
- if (IsDepressed())
- {
- nCurrentImage = BUTTON_PRESSED;
- }
- else
- {
- nCurrentImage = BUTTON_ENABLED_MOUSE_OVER;
- }
- }
- else if (!IsEnabled())
- {
- nCurrentImage = BUTTON_DISABLED;
- }
-
- if (m_bImageLoaded[nCurrentImage])
- {
- m_pImage[nCurrentImage].DoPaint( GetVPanel() );
- }
-
- BaseClass::Paint();
-}
-
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: This is a panel which is rendered image on top of an entity +// +// $Revision: $ +// $NoKeywords: $ +//=============================================================================// +#include "cbase.h" +#pragma warning (disable: 4514) + +#include "vgui_bitmapimage.h" +#include "vgui_bitmapbutton.h" +#include <KeyValues.h> + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//----------------------------------------------------------------------------- +// Constructor +//----------------------------------------------------------------------------- +CBitmapButton::CBitmapButton( vgui::Panel *pParent, const char *pName, const char *pText ) : + BaseClass( pParent, pName, pText ) +{ + SetPaintBackgroundEnabled( false ); + for ( int i = 0; i < BUTTON_STATE_COUNT; ++i ) + { + m_bImageLoaded[i] = false; + } +} + +CBitmapButton::~CBitmapButton() +{ +} + + +//----------------------------------------------------------------------------- +// initialization +//----------------------------------------------------------------------------- +bool CBitmapButton::Init( KeyValues* pInitData ) +{ + // Unimplemented + Assert( 0 ); + return true; +} + + +//----------------------------------------------------------------------------- +// initialization from build-mode dialog style .res files +//----------------------------------------------------------------------------- +void CBitmapButton::ApplySettings(KeyValues *pInitData) +{ + BaseClass::ApplySettings(pInitData); + + COMPILE_TIME_ASSERT( BUTTON_STATE_COUNT == 4 ); + const char *pSectionName[BUTTON_STATE_COUNT] = + { + "enabledImage", + "mouseOverImage", + "pressedImage", + "disabledImage" + }; + + for ( int i = 0; i < BUTTON_STATE_COUNT; ++i ) + { + m_bImageLoaded[i] = InitializeImage(pInitData, pSectionName[i], this, &m_pImage[i] ); + } +} + + +//----------------------------------------------------------------------------- +// Sets the image +//----------------------------------------------------------------------------- +void CBitmapButton::SetImage( ButtonImageType_t type, const char *pMaterialName, color32 color ) +{ + m_bImageLoaded[type] = m_pImage[type].Init( GetVPanel(), pMaterialName ); + if (m_bImageLoaded[type]) + { + Color vcol( color.r, color.g, color.b, color.a ); + m_pImage[type].SetColor( vcol ); + } +} + +bool CBitmapButton::IsImageLoaded( ButtonImageType_t type ) const +{ + return m_bImageLoaded[type]; +} + + +//----------------------------------------------------------------------------- +// Draws the puppy +//----------------------------------------------------------------------------- +void CBitmapButton::Paint( void ) +{ + // Determine the image to use based on the state + int nCurrentImage = BUTTON_ENABLED; + if (IsArmed()) + { + if (IsDepressed()) + { + nCurrentImage = BUTTON_PRESSED; + } + else + { + nCurrentImage = BUTTON_ENABLED_MOUSE_OVER; + } + } + else if (!IsEnabled()) + { + nCurrentImage = BUTTON_DISABLED; + } + + if (m_bImageLoaded[nCurrentImage]) + { + m_pImage[nCurrentImage].DoPaint( GetVPanel() ); + } + + BaseClass::Paint(); +} + + |