annotate Libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.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 BlizOptionsGroup Container
Xiiph@0 3 Simple container widget for the integration of AceGUI into the Blizzard Interface Options
Xiiph@0 4 -------------------------------------------------------------------------------]]
Xiiph@0 5 local Type, Version = "BlizOptionsGroup", 20
Xiiph@0 6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
Xiiph@0 7 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
Xiiph@0 8
Xiiph@0 9 -- Lua APIs
Xiiph@0 10 local pairs = pairs
Xiiph@0 11
Xiiph@0 12 -- WoW APIs
Xiiph@0 13 local CreateFrame = CreateFrame
Xiiph@0 14
Xiiph@0 15 --[[-----------------------------------------------------------------------------
Xiiph@0 16 Scripts
Xiiph@0 17 -------------------------------------------------------------------------------]]
Xiiph@0 18
Xiiph@0 19 local function OnShow(frame)
Xiiph@0 20 frame.obj:Fire("OnShow")
Xiiph@0 21 end
Xiiph@0 22
Xiiph@0 23 local function OnHide(frame)
Xiiph@0 24 frame.obj:Fire("OnHide")
Xiiph@0 25 end
Xiiph@0 26
Xiiph@0 27 --[[-----------------------------------------------------------------------------
Xiiph@0 28 Support functions
Xiiph@0 29 -------------------------------------------------------------------------------]]
Xiiph@0 30
Xiiph@0 31 local function okay(frame)
Xiiph@0 32 frame.obj:Fire("okay")
Xiiph@0 33 end
Xiiph@0 34
Xiiph@0 35 local function cancel(frame)
Xiiph@0 36 frame.obj:Fire("cancel")
Xiiph@0 37 end
Xiiph@0 38
Xiiph@0 39 local function defaults(frame)
Xiiph@0 40 frame.obj:Fire("defaults")
Xiiph@0 41 end
Xiiph@0 42
Xiiph@0 43 --[[-----------------------------------------------------------------------------
Xiiph@0 44 Methods
Xiiph@0 45 -------------------------------------------------------------------------------]]
Xiiph@0 46
Xiiph@0 47 local methods = {
Xiiph@0 48 ["OnAcquire"] = function(self)
Xiiph@0 49 self:SetName()
Xiiph@0 50 self:SetTitle()
Xiiph@0 51 end,
Xiiph@0 52
Xiiph@0 53 -- ["OnRelease"] = nil,
Xiiph@0 54
Xiiph@0 55 ["OnWidthSet"] = function(self, width)
Xiiph@0 56 local content = self.content
Xiiph@0 57 local contentwidth = width - 63
Xiiph@0 58 if contentwidth < 0 then
Xiiph@0 59 contentwidth = 0
Xiiph@0 60 end
Xiiph@0 61 content:SetWidth(contentwidth)
Xiiph@0 62 content.width = contentwidth
Xiiph@0 63 end,
Xiiph@0 64
Xiiph@0 65 ["OnHeightSet"] = function(self, height)
Xiiph@0 66 local content = self.content
Xiiph@0 67 local contentheight = height - 26
Xiiph@0 68 if contentheight < 0 then
Xiiph@0 69 contentheight = 0
Xiiph@0 70 end
Xiiph@0 71 content:SetHeight(contentheight)
Xiiph@0 72 content.height = contentheight
Xiiph@0 73 end,
Xiiph@0 74
Xiiph@0 75 ["SetName"] = function(self, name, parent)
Xiiph@0 76 self.frame.name = name
Xiiph@0 77 self.frame.parent = parent
Xiiph@0 78 end,
Xiiph@0 79
Xiiph@0 80 ["SetTitle"] = function(self, title)
Xiiph@0 81 local content = self.content
Xiiph@0 82 content:ClearAllPoints()
Xiiph@0 83 if not title or title == "" then
Xiiph@0 84 content:SetPoint("TOPLEFT", 10, -10)
Xiiph@0 85 self.label:SetText("")
Xiiph@0 86 else
Xiiph@0 87 content:SetPoint("TOPLEFT", 10, -40)
Xiiph@0 88 self.label:SetText(title)
Xiiph@0 89 end
Xiiph@0 90 content:SetPoint("BOTTOMRIGHT", -10, 10)
Xiiph@0 91 end
Xiiph@0 92 }
Xiiph@0 93
Xiiph@0 94 --[[-----------------------------------------------------------------------------
Xiiph@0 95 Constructor
Xiiph@0 96 -------------------------------------------------------------------------------]]
Xiiph@0 97 local function Constructor()
Xiiph@0 98 local frame = CreateFrame("Frame")
Xiiph@0 99 frame:Hide()
Xiiph@0 100
Xiiph@0 101 -- support functions for the Blizzard Interface Options
Xiiph@0 102 frame.okay = okay
Xiiph@0 103 frame.cancel = cancel
Xiiph@0 104 frame.defaults = defaults
Xiiph@0 105
Xiiph@0 106 frame:SetScript("OnHide", OnHide)
Xiiph@0 107 frame:SetScript("OnShow", OnShow)
Xiiph@0 108
Xiiph@0 109 local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
Xiiph@0 110 label:SetPoint("TOPLEFT", 10, -15)
Xiiph@0 111 label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
Xiiph@0 112 label:SetJustifyH("LEFT")
Xiiph@0 113 label:SetJustifyV("TOP")
Xiiph@0 114
Xiiph@0 115 --Container Support
Xiiph@0 116 local content = CreateFrame("Frame", nil, frame)
Xiiph@0 117 content:SetPoint("TOPLEFT", 10, -10)
Xiiph@0 118 content:SetPoint("BOTTOMRIGHT", -10, 10)
Xiiph@0 119
Xiiph@0 120 local widget = {
Xiiph@0 121 label = label,
Xiiph@0 122 frame = frame,
Xiiph@0 123 content = content,
Xiiph@0 124 type = Type
Xiiph@0 125 }
Xiiph@0 126 for method, func in pairs(methods) do
Xiiph@0 127 widget[method] = func
Xiiph@0 128 end
Xiiph@0 129
Xiiph@0 130 return AceGUI:RegisterAsContainer(widget)
Xiiph@0 131 end
Xiiph@0 132
Xiiph@0 133 AceGUI:RegisterWidgetType(Type, Constructor, Version)