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 /mp/src/vgui2/vgui_controls/ScrollableEditablePanel.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 'mp/src/vgui2/vgui_controls/ScrollableEditablePanel.cpp')
| -rw-r--r-- | mp/src/vgui2/vgui_controls/ScrollableEditablePanel.cpp | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/mp/src/vgui2/vgui_controls/ScrollableEditablePanel.cpp b/mp/src/vgui2/vgui_controls/ScrollableEditablePanel.cpp index 5d753b04..d734dba5 100644 --- a/mp/src/vgui2/vgui_controls/ScrollableEditablePanel.cpp +++ b/mp/src/vgui2/vgui_controls/ScrollableEditablePanel.cpp @@ -1,86 +1,86 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================
-
-#include "vgui_controls/ScrollableEditablePanel.h"
-#include "vgui_controls/ScrollBar.h"
-#include "vgui_controls/ScrollBarSlider.h"
-#include "vgui_controls/Button.h"
-#include "KeyValues.h"
-
-// NOTE: This has to be the last file included!
-#include "tier0/memdbgon.h"
-
-
-using namespace vgui;
-
-ScrollableEditablePanel::ScrollableEditablePanel( vgui::Panel *pParent, vgui::EditablePanel *pChild, const char *pName ) :
- BaseClass( pParent, pName )
-{
- m_pChild = pChild;
- m_pChild->SetParent( this );
-
- m_pScrollBar = new vgui::ScrollBar( this, "VerticalScrollBar", true );
- m_pScrollBar->SetWide( 16 );
- m_pScrollBar->SetAutoResize( PIN_TOPRIGHT, AUTORESIZE_DOWN, 0, 0, -16, 0 );
- m_pScrollBar->AddActionSignalTarget( this );
-}
-
-void ScrollableEditablePanel::ApplySettings( KeyValues *pInResourceData )
-{
- BaseClass::ApplySettings( pInResourceData );
-
- KeyValues *pScrollbarKV = pInResourceData->FindKey( "Scrollbar" );
- if ( pScrollbarKV )
- {
- m_pScrollBar->ApplySettings( pScrollbarKV );
- }
-}
-
-void ScrollableEditablePanel::PerformLayout()
-{
- BaseClass::PerformLayout();
-
- m_pChild->SetWide( GetWide() - m_pScrollBar->GetWide() );
- m_pScrollBar->SetRange( 0, m_pChild->GetTall() );
- m_pScrollBar->SetRangeWindow( GetTall() );
-
- if ( m_pScrollBar->GetSlider() )
- {
- m_pScrollBar->GetSlider()->SetFgColor( GetFgColor() );
- }
- if ( m_pScrollBar->GetButton(0) )
- {
- m_pScrollBar->GetButton(0)->SetFgColor( GetFgColor() );
- }
- if ( m_pScrollBar->GetButton(1) )
- {
- m_pScrollBar->GetButton(1)->SetFgColor( GetFgColor() );
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Called when the scroll bar moves
-//-----------------------------------------------------------------------------
-void ScrollableEditablePanel::OnScrollBarSliderMoved()
-{
- InvalidateLayout();
-
- int nScrollAmount = m_pScrollBar->GetValue();
- m_pChild->SetPos( 0, -nScrollAmount );
-}
-
-//-----------------------------------------------------------------------------
-// respond to mouse wheel events
-//-----------------------------------------------------------------------------
-void ScrollableEditablePanel::OnMouseWheeled(int delta)
-{
- int val = m_pScrollBar->GetValue();
- val -= (delta * 50);
- m_pScrollBar->SetValue( val );
-}
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include "vgui_controls/ScrollableEditablePanel.h" +#include "vgui_controls/ScrollBar.h" +#include "vgui_controls/ScrollBarSlider.h" +#include "vgui_controls/Button.h" +#include "KeyValues.h" + +// NOTE: This has to be the last file included! +#include "tier0/memdbgon.h" + + +using namespace vgui; + +ScrollableEditablePanel::ScrollableEditablePanel( vgui::Panel *pParent, vgui::EditablePanel *pChild, const char *pName ) : + BaseClass( pParent, pName ) +{ + m_pChild = pChild; + m_pChild->SetParent( this ); + + m_pScrollBar = new vgui::ScrollBar( this, "VerticalScrollBar", true ); + m_pScrollBar->SetWide( 16 ); + m_pScrollBar->SetAutoResize( PIN_TOPRIGHT, AUTORESIZE_DOWN, 0, 0, -16, 0 ); + m_pScrollBar->AddActionSignalTarget( this ); +} + +void ScrollableEditablePanel::ApplySettings( KeyValues *pInResourceData ) +{ + BaseClass::ApplySettings( pInResourceData ); + + KeyValues *pScrollbarKV = pInResourceData->FindKey( "Scrollbar" ); + if ( pScrollbarKV ) + { + m_pScrollBar->ApplySettings( pScrollbarKV ); + } +} + +void ScrollableEditablePanel::PerformLayout() +{ + BaseClass::PerformLayout(); + + m_pChild->SetWide( GetWide() - m_pScrollBar->GetWide() ); + m_pScrollBar->SetRange( 0, m_pChild->GetTall() ); + m_pScrollBar->SetRangeWindow( GetTall() ); + + if ( m_pScrollBar->GetSlider() ) + { + m_pScrollBar->GetSlider()->SetFgColor( GetFgColor() ); + } + if ( m_pScrollBar->GetButton(0) ) + { + m_pScrollBar->GetButton(0)->SetFgColor( GetFgColor() ); + } + if ( m_pScrollBar->GetButton(1) ) + { + m_pScrollBar->GetButton(1)->SetFgColor( GetFgColor() ); + } +} + + +//----------------------------------------------------------------------------- +// Called when the scroll bar moves +//----------------------------------------------------------------------------- +void ScrollableEditablePanel::OnScrollBarSliderMoved() +{ + InvalidateLayout(); + + int nScrollAmount = m_pScrollBar->GetValue(); + m_pChild->SetPos( 0, -nScrollAmount ); +} + +//----------------------------------------------------------------------------- +// respond to mouse wheel events +//----------------------------------------------------------------------------- +void ScrollableEditablePanel::OnMouseWheeled(int delta) +{ + int val = m_pScrollBar->GetValue(); + val -= (delta * 50); + m_pScrollBar->SetValue( val ); +} + |