--[[
	MOD/addons/SenHack v1/lua/client/libs/panel/dlabel.lua [#7593 (#7593), 2788878728, UID:2452326509]
	(ARP)konrad50024 | STEAM_0:0:36097632 <92.234.95.154:27005> | [11.05.14 04:00:17PM]
	===BadFile===
]]

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

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

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

	DLabel
--]]

local PANEL = {}

g.AccessorFunc( PANEL, "m_bIsMenuComponent", 		"IsMenu", 			g.FORCE_BOOL )

g.AccessorFunc( PANEL, "m_colText", 				"TextColor" )
g.AccessorFunc( PANEL, "m_colTextStyle", 			"TextStyleColor" )
g.AccessorFunc( PANEL, "m_FontName", 				"Font" )
g.AccessorFunc( PANEL, "m_bAutoStretchVertical", 	"AutoStretchVertical", 		g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bDisabled", 			"Disabled", 				g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bDoubleClicking", 		"DoubleClickingEnabled", 	g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bBackground", 			"PaintBackground",			g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bBackground", 			"DrawBackground", 			g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bIsToggle", 			"IsToggle", 				g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bToggle", 				"Toggle", 					g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bBright", 				"Bright", 					g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bDark", 				"Dark", 					g.FORCE_BOOL )
g.AccessorFunc( PANEL, "m_bHighlight", 			"Highlight", 				g.FORCE_BOOL )

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

	self:SetIsToggle( false )
	self:SetToggle( false )
	self:SetDisabled( false );
	self:SetMouseInputEnabled( false )
	self:SetKeyboardInputEnabled( false )
	self:SetDoubleClickingEnabled( true )

	-- Nicer default height
	self:SetTall( 20 )
	
	-- This turns off the engine drawing
	self:SetPaintBackgroundEnabled( false )
	self:SetPaintBorderEnabled( false )
	
	self:SetFont( "DermaDefault" )	
	
end

function PANEL:SetFont( strFont )

	self.m_FontName = strFont
	self:SetFontInternal( self.m_FontName )	
	self:ApplySchemeSettings()

end

function PANEL:ApplySchemeSettings()

	self:SetFontInternal( self.m_FontName )
	self:UpdateColours( self:GetSkin() );
	
	local col = self.m_colTextStyle
	if ( self.m_colText ) then col = self.m_colText end

	self:SetFGColor( col.r, col.g, col.b, col.a )

end

function PANEL:PerformLayout()

	self:ApplySchemeSettings()
	
	if ( self.m_bAutoStretchVertical ) then
		self:SizeToContentsY()
	end

end


PANEL.SetColor = PANEL.SetTextColor

--[[---------------------------------------------------------
	SetColor
-----------------------------------------------------------]]
function PANEL:GetColor()

	return self.m_colTextStyle

end


--[[---------------------------------------------------------
	Exited
-----------------------------------------------------------]]
function PANEL:OnCursorEntered()
	
	self:InvalidateLayout( true )
	
end

--[[---------------------------------------------------------
	Entered
-----------------------------------------------------------]]
function PANEL:OnCursorExited()

	self:InvalidateLayout( true )
	
end

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

	if ( self:GetDisabled() ) then return end
	
	if ( mousecode == MOUSE_LEFT && !g.dragndrop.IsDragging() && self.m_bDoubleClicking ) then
	
		if ( self.LastClickTime && g.SysTime() - self.LastClickTime < 0.2 ) then
		
			self:DoDoubleClickInternal()
			self:DoDoubleClick()	
			return 
			
		end
		
		self.LastClickTime = SysTime()
	end
	
	-- If we're selectable and have shift held down then go up
	-- the parent until we find a selection canvas and start box selection
	if ( self:IsSelectable() && mousecode == MOUSE_LEFT ) then
	
		if ( g.input.IsShiftDown() ) then 
			return self:StartBoxSelection()
		end
		
	end
	
	self:MouseCapture( true )
	self.Depressed = true
	self:OnDepressed();
	self:InvalidateLayout();
	
	--
	-- Tell DragNDrop that we're down, and might start getting dragged!
	--
	self:DragMousePress( mousecode );

end

function PANEL:OnDepressed()

end

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

	self:MouseCapture( false )
	
	if ( self:GetDisabled() ) then return end
	if ( !self.Depressed ) then return end
	
	self.Depressed = nil
	self:OnReleased();
	self:InvalidateLayout();
	--
	-- If we were being dragged then don't do the default behaviour!
	--
	if ( self:DragMouseRelease( mousecode ) ) then
		return
	end
	
	if ( self:IsSelectable() && mousecode == g.MOUSE_LEFT ) then
			
		local canvas = self:GetSelectionCanvas()
		if ( canvas ) then
			canvas:UnselectAll()
		end
		
	end
	
	if ( !self.Hovered ) then return end

	--
	-- For the purposes of these callbacks we want to 
	-- keep depressed true. This helps us out in controls
	-- like the checkbox in the properties dialog. Because
	-- the properties dialog will only manualloy change the value
	-- if IsEditing() is true - and the only way to work out if
	-- a label/button based control is editing is when it's depressed.
	--
	self.Depressed = true

	if ( mousecode == g.MOUSE_RIGHT ) then
		self:DoRightClick()
	end
	
	if ( mousecode == g.MOUSE_LEFT ) then	
		self:DoClickInternal()
		self:DoClick()
	end

	if ( mousecode == g.MOUSE_MIDDLE ) then
		self:DoMiddleClick()
	end

	self.Depressed = nil

end

function PANEL:OnReleased()

end

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

end

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

end

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

	self:Toggle()

end

function PANEL:Toggle()

	if ( !self:GetIsToggle() ) then return end
	
	self.m_bToggle = !self.m_bToggle
	self:OnToggled( self.m_bToggle )

end

function PANEL:OnToggled( bool )

end


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

end

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

end

--[[---------------------------------------------------------
	DoDoubleClickInternal
-----------------------------------------------------------]]
function PANEL:DoDoubleClickInternal()
	
end

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

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

end

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