annotate Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua @ 15:21cefa363c73 tip

Last modification to ready checking broke something ... Now its fixed and ready checking is working as intended.
author Xiiph
date Fri, 25 Feb 2011 01:21:13 +0100
parents 98c6f55e6619
children
rev   line source
Xiiph@0 1 --[[-----------------------------------------------------------------------------
Xiiph@0 2 Heading Widget
Xiiph@0 3 -------------------------------------------------------------------------------]]
Xiiph@0 4 local Type, Version = "Heading", 20
Xiiph@0 5 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
Xiiph@0 6 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
Xiiph@0 7
Xiiph@0 8 -- Lua APIs
Xiiph@0 9 local pairs = pairs
Xiiph@0 10
Xiiph@0 11 -- WoW APIs
Xiiph@0 12 local CreateFrame, UIParent = CreateFrame, UIParent
Xiiph@0 13
Xiiph@0 14 --[[-----------------------------------------------------------------------------
Xiiph@0 15 Methods
Xiiph@0 16 -------------------------------------------------------------------------------]]
Xiiph@0 17 local methods = {
Xiiph@0 18 ["OnAcquire"] = function(self)
Xiiph@0 19 self:SetText()
Xiiph@0 20 self:SetFullWidth()
Xiiph@0 21 self:SetHeight(18)
Xiiph@0 22 end,
Xiiph@0 23
Xiiph@0 24 -- ["OnRelease"] = nil,
Xiiph@0 25
Xiiph@0 26 ["SetText"] = function(self, text)
Xiiph@0 27 self.label:SetText(text or "")
Xiiph@0 28 if text and text ~= "" then
Xiiph@0 29 self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0)
Xiiph@0 30 self.right:Show()
Xiiph@0 31 else
Xiiph@0 32 self.left:SetPoint("RIGHT", -3, 0)
Xiiph@0 33 self.right:Hide()
Xiiph@0 34 end
Xiiph@0 35 end
Xiiph@0 36 }
Xiiph@0 37
Xiiph@0 38 --[[-----------------------------------------------------------------------------
Xiiph@0 39 Constructor
Xiiph@0 40 -------------------------------------------------------------------------------]]
Xiiph@0 41 local function Constructor()
Xiiph@0 42 local frame = CreateFrame("Frame", nil, UIParent)
Xiiph@0 43 frame:Hide()
Xiiph@0 44
Xiiph@0 45 local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
Xiiph@0 46 label:SetPoint("TOP")
Xiiph@0 47 label:SetPoint("BOTTOM")
Xiiph@0 48 label:SetJustifyH("CENTER")
Xiiph@0 49
Xiiph@0 50 local left = frame:CreateTexture(nil, "BACKGROUND")
Xiiph@0 51 left:SetHeight(8)
Xiiph@0 52 left:SetPoint("LEFT", 3, 0)
Xiiph@0 53 left:SetPoint("RIGHT", label, "LEFT", -5, 0)
Xiiph@0 54 left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
Xiiph@0 55 left:SetTexCoord(0.81, 0.94, 0.5, 1)
Xiiph@0 56
Xiiph@0 57 local right = frame:CreateTexture(nil, "BACKGROUND")
Xiiph@0 58 right:SetHeight(8)
Xiiph@0 59 right:SetPoint("RIGHT", -3, 0)
Xiiph@0 60 right:SetPoint("LEFT", label, "RIGHT", 5, 0)
Xiiph@0 61 right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
Xiiph@0 62 right:SetTexCoord(0.81, 0.94, 0.5, 1)
Xiiph@0 63
Xiiph@0 64 local widget = {
Xiiph@0 65 label = label,
Xiiph@0 66 left = left,
Xiiph@0 67 right = right,
Xiiph@0 68 frame = frame,
Xiiph@0 69 type = Type
Xiiph@0 70 }
Xiiph@0 71 for method, func in pairs(methods) do
Xiiph@0 72 widget[method] = func
Xiiph@0 73 end
Xiiph@0 74
Xiiph@0 75 return AceGUI:RegisterAsWidget(widget)
Xiiph@0 76 end
Xiiph@0 77
Xiiph@0 78 AceGUI:RegisterWidgetType(Type, Constructor, Version)