--===================================================
--
--				GHM_Text
--  			GHM_Text.lua
--
--	          EditBox object for GHM
--
-- 	  (c)2012 The Gryphonheart Team
--			All rights reserved
--===================================================

local DEFAULT_WIDTH = 300;
local DEFUALT_HEIGHT = 20;
local count = 1;

function GHM_Text(parent, main, profile)
	local frame = CreateFrame("Frame", "GHM_Text" .. count, parent, "GHM_Text_Template");
	count = count + 1;
	
	local font = "Fonts\\FRIZQT__.TTF"
	local fontSize = 11

	-- declaration and initialization
	profile = profile or {};

	-- setup
	local labelFrame = _G[frame:GetName() .. "Label"];
	
	
	if profile.font then
		font = profile.font
		labelFrame:SetFont(font, fontSize);
	end

	if profile.fontSize then
		fontSize = profile.fontSize
		labelFrame:SetFont(font, fontSize);
	end

	labelFrame:SetText("");
	frame.color = "white"; -- default
	if profile.color == "white" then
		--labelFrame:SetTextColor(1, 1, 1);
		frame.color = "white";
	elseif profile.color == "yellow" then
		--labelFrame:SetTextColor(1,0.8196079,0);
		frame.color = "yellow";
	end

	if profile.align == "c" then
		labelFrame:SetJustifyH("CENTER");
	elseif profile.align == "r" then
		labelFrame:SetJustifyH("RIGHT");
	else
		labelFrame:SetJustifyH("LEFT");
	end
	
	if profile.shadow == true then
		labelFrame:SetShadowColor(0,0,0,0.75)
		labelFrame:SetShadowOffset(2,-2)
	end
	
	if profile.outline == true then
		labelFrame:SetFont(font, fontSize,"OUTLINE")
	end
	
	labelFrame:SetWordWrap(true)
	labelFrame:SetNonSpaceWrap(false)



	--[[
	local width = profile.width or labelFrame:GetWidth();
	frame:SetWidth(width);
	labelFrame:SetWidth(width);

	if profile.singleLine == true then
		frame:SetHeight(labelFrame:GetHeight());
	else
		frame:SetHeight(labelFrame:GetHeight());
	end
	              --]]



	frame.Force = function(self, text)
		if self ~= frame then return frame.Force(frame, self); end

		labelFrame:SetText(text);

		if profile.width then
			frame:SetWidth(profile.width);
			labelFrame:SetWidth(profile.width);

			frame:SetHeight(labelFrame:GetHeight()+15)
		else
			frame:SetWidth(labelFrame:GetWidth());
			frame:SetHeight(labelFrame:GetHeight());
		end
	end
	frame.Force(profile.text);

	GHM_FramePositioning(frame,profile,parent);

	if type(profile.OnLoad) == "function" then
		profile.OnLoad(frame);
	end

	frame:Show();
	--GHM_TempBG(frame);

	return frame;
end

