--[[
	MOD/addons/SenHack v1/lua/client/libs/panel/dbutton.lua [#4618 (#4618), 1021114965, UID:3350941384]
	(ARP)konrad50024 | STEAM_0:0:36097632 <92.234.95.154:27005> | [11.05.14 04:00:16PM]
	===BadFile===
]]

/* * * * * * * * * * * * * * * * 
 * 	 ______     __  __     ______     __  __     ______     ______     __  __    
 *	/\  __ \   /\ \/\ \   /\  == \   /\ \_\ \   /\  __ \   /\  ___\   /\ \/ /    
 *	\ \ \/\ \  \ \ \_\ \  \ \  __<   \ \  __ \  \ \  __ \  \ \ \____  \ \  _"-.  
 *	 \ \_____\  \ \_____\  \ \_____\  \ \_\ \_\  \ \_\ \_\  \ \_____\  \ \_\ \_\ 
 *	  \/_____/   \/_____/   \/_____/   \/_/\/_/   \/_/\/_/   \/_____/   \/_/\/_/ 
 *
 *  - Version : 3L
 *  - By Oubliette
 * * * * * * * * * * * * * * * */

--
local arg = { ... };
local g = arg[ 1 ];
local VGUI = arg[ 2 ];
--

--[[   _                                
	( )                               
   _| |   __   _ __   ___ ___     _ _ 
 /'_` | /'__`\( '__)/' _ ` _ `\ /'_` )
( (_| |(  ___/| |   | ( ) ( ) |( (_| |
`\__,_)`\____)(_)   (_) (_) (_)`\__,_) 

	DButton
	
	Default Button

--]]

local PANEL = {}

g.AccessorFunc( PANEL, "m_bBorder", 			"DrawBorder", 		g.FORCE_BOOL );
g.AccessorFunc( PANEL, "m_bDisabled", 		"Disabled", 			g.FORCE_BOOL );
g.AccessorFunc( PANEL, "m_FontName", 			"Font" )


--[[---------------------------------------------------------

-----------------------------------------------------------]]
function PANEL:Init()

	self:SetContentAlignment( 5 )
	
	--
	-- These are Lua side commands
	-- Defined above using AccessorFunc
	--
	self:SetDrawBorder( true )
	self:SetDrawBackground( true )
	
	--
	self:SetTall( 22 )
	self:SetMouseInputEnabled( true )
	self:SetKeyboardInputEnabled( true )

	self:SetCursor( "hand" )
	self:SetFont( "DermaDefault" )

end

--[[---------------------------------------------------------
	IsDown
-----------------------------------------------------------]]
function PANEL:IsDown()

	return self.Depressed

end

--[[---------------------------------------------------------

-----------------------------------------------------------]]
function PANEL:Paint( w, h )

	if ( !self.m_bBackground ) then return end

	g.surface.SetDrawColor( VGUI.Cols.BGDark );
	
	if ( self.Depressed || self:IsSelected() || self:GetToggle() ) then

		g.surface.SetDrawColor( VGUI.Cols.ButtonPressed );

	end	
	
	if ( self:GetDisabled() ) then

		g.surface.SetDrawColor( VGUI.Cols.ButtonDisabled );

	end	
	
	if ( self.Hovered ) then

		g.surface.SetDrawColor( VGUI.Cols.ButtonHovered );

	end

	g.surface.DrawRect( 0, 0, w, h );
	
	--
	-- Draw the button text
	--
	return false

end

--[[---------------------------------------------------------
	UpdateColours
-----------------------------------------------------------]]
function PANEL:UpdateColours( skin )

	if ( self:GetDisabled() )						then return self:SetTextStyleColor( VGUI.Cols.TextDisabled ) end
	if ( self.Depressed || self.m_bSelected )		then return self:SetTextStyleColor( VGUI.Cols.TextPressed ) end

	return self:SetTextStyleColor( g.Color( 0, 0, 0, 255 ) );

end

--[[---------------------------------------------------------
   Name: PerformLayout
-----------------------------------------------------------]]
function PANEL:PerformLayout()
		
	--
	-- If we have an image we have to place the image on the left
	-- and make the text align to the left, then set the inset
	-- so the text will be to the right of the icon.
	--
	if ( g.IsValid( self.m_Image ) ) then
			
		self.m_Image:SetPos( 4, (self:GetTall() - self.m_Image:GetTall()) * 0.5 )
		
		self:SetTextInset( self.m_Image:GetWide() + 16, 0 )
		
	end

	// Do something about this global call
	DLabel.PerformLayout( self )

end

--[[---------------------------------------------------------
	SetDisabled
-----------------------------------------------------------]]
function PANEL:SetDisabled( bDisabled )

	self.m_bDisabled = bDisabled	
	self:InvalidateLayout()

end

--[[---------------------------------------------------------
   Name: SetConsoleCommand
-----------------------------------------------------------]]
function PANEL:SetConsoleCommand( strName, strArgs )

	self.DoClick = function( self, val ) 
						g.RunConsoleCommand( strName, strArgs ) 
				   end

end

--[[---------------------------------------------------------
	OnMousePressed
-----------------------------------------------------------]]
function PANEL:OnMousePressed( mousecode )

	// Do something about this global call
	return DLabel.OnMousePressed( self, mousecode )

end

--[[---------------------------------------------------------
	OnMouseReleased
-----------------------------------------------------------]]
function PANEL:OnMouseReleased( mousecode )

	// Do something about this global call
	return DLabel.OnMouseReleased( self, mousecode )

end

VGUI.RegisterElement( "DButton", PANEL, "DLabel" );