annotate Libs/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua @ 6:f10c8a083d2a

The ALPHA help request popup should pop when the addon is enabled for every 15th time. I really would like some data to. The timer to start opening mail when you open the mailbox will now use the initial mail opening delay.
author Zerotorescue
date Wed, 08 Sep 2010 00:48:37 +0200
parents 823e33465b6e
children
rev   line source
Zerotorescue@0 1 --[[-----------------------------------------------------------------------------
Zerotorescue@0 2 BlizOptionsGroup Container
Zerotorescue@0 3 Simple container widget for the integration of AceGUI into the Blizzard Interface Options
Zerotorescue@0 4 -------------------------------------------------------------------------------]]
Zerotorescue@0 5 local Type, Version = "BlizOptionsGroup", 20
Zerotorescue@0 6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
Zerotorescue@0 7 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
Zerotorescue@0 8
Zerotorescue@0 9 -- Lua APIs
Zerotorescue@0 10 local pairs = pairs
Zerotorescue@0 11
Zerotorescue@0 12 -- WoW APIs
Zerotorescue@0 13 local CreateFrame = CreateFrame
Zerotorescue@0 14
Zerotorescue@0 15 --[[-----------------------------------------------------------------------------
Zerotorescue@0 16 Scripts
Zerotorescue@0 17 -------------------------------------------------------------------------------]]
Zerotorescue@0 18
Zerotorescue@0 19 local function OnShow(frame)
Zerotorescue@0 20 frame.obj:Fire("OnShow")
Zerotorescue@0 21 end
Zerotorescue@0 22
Zerotorescue@0 23 local function OnHide(frame)
Zerotorescue@0 24 frame.obj:Fire("OnHide")
Zerotorescue@0 25 end
Zerotorescue@0 26
Zerotorescue@0 27 --[[-----------------------------------------------------------------------------
Zerotorescue@0 28 Support functions
Zerotorescue@0 29 -------------------------------------------------------------------------------]]
Zerotorescue@0 30
Zerotorescue@0 31 local function okay(frame)
Zerotorescue@0 32 frame.obj:Fire("okay")
Zerotorescue@0 33 end
Zerotorescue@0 34
Zerotorescue@0 35 local function cancel(frame)
Zerotorescue@0 36 frame.obj:Fire("cancel")
Zerotorescue@0 37 end
Zerotorescue@0 38
Zerotorescue@0 39 local function defaults(frame)
Zerotorescue@0 40 frame.obj:Fire("defaults")
Zerotorescue@0 41 end
Zerotorescue@0 42
Zerotorescue@0 43 --[[-----------------------------------------------------------------------------
Zerotorescue@0 44 Methods
Zerotorescue@0 45 -------------------------------------------------------------------------------]]
Zerotorescue@0 46
Zerotorescue@0 47 local methods = {
Zerotorescue@0 48 ["OnAcquire"] = function(self)
Zerotorescue@0 49 self:SetName()
Zerotorescue@0 50 self:SetTitle()
Zerotorescue@0 51 end,
Zerotorescue@0 52
Zerotorescue@0 53 -- ["OnRelease"] = nil,
Zerotorescue@0 54
Zerotorescue@0 55 ["OnWidthSet"] = function(self, width)
Zerotorescue@0 56 local content = self.content
Zerotorescue@0 57 local contentwidth = width - 63
Zerotorescue@0 58 if contentwidth < 0 then
Zerotorescue@0 59 contentwidth = 0
Zerotorescue@0 60 end
Zerotorescue@0 61 content:SetWidth(contentwidth)
Zerotorescue@0 62 content.width = contentwidth
Zerotorescue@0 63 end,
Zerotorescue@0 64
Zerotorescue@0 65 ["OnHeightSet"] = function(self, height)
Zerotorescue@0 66 local content = self.content
Zerotorescue@0 67 local contentheight = height - 26
Zerotorescue@0 68 if contentheight < 0 then
Zerotorescue@0 69 contentheight = 0
Zerotorescue@0 70 end
Zerotorescue@0 71 content:SetHeight(contentheight)
Zerotorescue@0 72 content.height = contentheight
Zerotorescue@0 73 end,
Zerotorescue@0 74
Zerotorescue@0 75 ["SetName"] = function(self, name, parent)
Zerotorescue@0 76 self.frame.name = name
Zerotorescue@0 77 self.frame.parent = parent
Zerotorescue@0 78 end,
Zerotorescue@0 79
Zerotorescue@0 80 ["SetTitle"] = function(self, title)
Zerotorescue@0 81 local content = self.content
Zerotorescue@0 82 content:ClearAllPoints()
Zerotorescue@0 83 if not title or title == "" then
Zerotorescue@0 84 content:SetPoint("TOPLEFT", 10, -10)
Zerotorescue@0 85 self.label:SetText("")
Zerotorescue@0 86 else
Zerotorescue@0 87 content:SetPoint("TOPLEFT", 10, -40)
Zerotorescue@0 88 self.label:SetText(title)
Zerotorescue@0 89 end
Zerotorescue@0 90 content:SetPoint("BOTTOMRIGHT", -10, 10)
Zerotorescue@0 91 end
Zerotorescue@0 92 }
Zerotorescue@0 93
Zerotorescue@0 94 --[[-----------------------------------------------------------------------------
Zerotorescue@0 95 Constructor
Zerotorescue@0 96 -------------------------------------------------------------------------------]]
Zerotorescue@0 97 local function Constructor()
Zerotorescue@0 98 local frame = CreateFrame("Frame")
Zerotorescue@0 99 frame:Hide()
Zerotorescue@0 100
Zerotorescue@0 101 -- support functions for the Blizzard Interface Options
Zerotorescue@0 102 frame.okay = okay
Zerotorescue@0 103 frame.cancel = cancel
Zerotorescue@0 104 frame.defaults = defaults
Zerotorescue@0 105
Zerotorescue@0 106 frame:SetScript("OnHide", OnHide)
Zerotorescue@0 107 frame:SetScript("OnShow", OnShow)
Zerotorescue@0 108
Zerotorescue@0 109 local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
Zerotorescue@0 110 label:SetPoint("TOPLEFT", 10, -15)
Zerotorescue@0 111 label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
Zerotorescue@0 112 label:SetJustifyH("LEFT")
Zerotorescue@0 113 label:SetJustifyV("TOP")
Zerotorescue@0 114
Zerotorescue@0 115 --Container Support
Zerotorescue@0 116 local content = CreateFrame("Frame", nil, frame)
Zerotorescue@0 117 content:SetPoint("TOPLEFT", 10, -10)
Zerotorescue@0 118 content:SetPoint("BOTTOMRIGHT", -10, 10)
Zerotorescue@0 119
Zerotorescue@0 120 local widget = {
Zerotorescue@0 121 label = label,
Zerotorescue@0 122 frame = frame,
Zerotorescue@0 123 content = content,
Zerotorescue@0 124 type = Type
Zerotorescue@0 125 }
Zerotorescue@0 126 for method, func in pairs(methods) do
Zerotorescue@0 127 widget[method] = func
Zerotorescue@0 128 end
Zerotorescue@0 129
Zerotorescue@0 130 return AceGUI:RegisterAsContainer(widget)
Zerotorescue@0 131 end
Zerotorescue@0 132
Zerotorescue@0 133 AceGUI:RegisterWidgetType(Type, Constructor, Version)