--[[
	OubHack/vgui/oh_DToggle.lua
	(that crazy lumbee) Skezixx | (STEAM_0:0:35313849)
	===DStream===
]]

/******************************************************************************
 .d88888b.  888     888 888888b.   888    888        d8888  .d8888b.  888    d8P  
d88P" "Y88b 888     888 888  "88b  888    888       d88888 d88P  Y88b 888   d8P   
888     888 888     888 888  .88P  888    888      d88P888 888    888 888  d8P    
888     888 888     888 8888888K.  8888888888     d88P 888 888        888d88K     
888     888 888     888 888  "Y88b 888    888    d88P  888 888        8888888b    
888     888 888     888 888    888 888    888   d88P   888 888    888 888  Y88b   
Y88b. .d88P Y88b. .d88P 888   d88P 888    888  d8888888888 Y88b  d88P 888   Y88b  
 "Y88888P"   "Y88888P"  8888888P"  888    888 d88P     888  "Y8888P"  888    Y88b 
 By Oubliete and UnknownAlias
*******************************************************************************/

-- Tab used at the top of the screen.

local PANEL = {};

surface.CreateFont ("ScoreboardText", ScreenScale(5), 250, true, false, "oh_button");
surface.CreateFont ("ScoreboardText", ScreenScale(8), 250, true, false, "oh_button_med");
surface.CreateFont ("ScoreboardText", ScreenScale(6), 250, true, false, "oh_button_med_small");

function PANEL:Init()
	self.Colour = Color(0,200,0,200);
	self.Enabled = true;
	self.Text = "Enabled"
	self.Title = "NameOfTitle"
end

function PANEL:SetEnabled(active)
	if active then
		self.Colour = Color(0,200,0,200);
		self.Enabled = true;
		self:SetText("Enabled");
	else
		self.Colour = Color(200,0,0,200);
		self.Enabled = false;
		self:SetText("Disabled");
	end
end

function PANEL:SetText(name)
	self.Text = name;
end

function PANEL:OnMouseReleased()
	if self.Enabled then
		self:SetEnabled(false);
	else
		self:SetEnabled(true);
	end
	if self.DoClick and type(self.DoClick) == "function" then
		self.DoClick()
	end
end

function PANEL:OnMousePressed()
	if self.Enabled then
		self.Colour = Color(0,140,0,200);
	else
		self.Colour = Color(140,0,0,200);
	end
end

function PANEL:OnCursorEntered()
	if self.Enabled then
		self.Colour = Color(40,200,40,200);
	else
		self.Colour = Color(200,40,40,200);
	end
end

function PANEL:OnCursorExited()
	if self.Enabled then
		self.Colour = Color(0,200,0,200);
	else
		self.Colour = Color(200,0,0,200);
	end
end

function PANEL:SetTitle(title)
	self.Title = title;
end

function PANEL:Paint()
	local titlefont = "oh_button_med"
	if string.len(self.Title) > 13 then
		titlefont = "oh_button_med_small"
	end
	draw.RoundedBox(6,0,0,self:GetWide(),self:GetTall(),self.Colour);
	draw.DrawText(self.Text, "oh_button", (self:GetWide()/2),(self:GetTall()/2), Color(255, 255, 255, 255),TEXT_ALIGN_CENTER);
	draw.DrawText(self.Title, titlefont, (self:GetWide()/2),(self:GetTall()/2)-15, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER);
end
vgui.Register("oh_DToggle",PANEL,"DPanel")