Tercio@23: --[[----------------------------------------------------------------------------- Tercio@23: BlizOptionsGroup Container Tercio@23: Simple container widget for the integration of AceGUI into the Blizzard Interface Options Tercio@23: -------------------------------------------------------------------------------]] Tercio@23: local Type, Version = "BlizOptionsGroup", 21 Tercio@23: local AceGUI = LibStub and LibStub("AceGUI-3.0", true) Tercio@23: if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end Tercio@23: Tercio@23: -- Lua APIs Tercio@23: local pairs = pairs Tercio@23: Tercio@23: -- WoW APIs Tercio@23: local CreateFrame = CreateFrame Tercio@23: Tercio@23: --[[----------------------------------------------------------------------------- Tercio@23: Scripts Tercio@23: -------------------------------------------------------------------------------]] Tercio@23: Tercio@23: local function OnShow(frame) Tercio@23: frame.obj:Fire("OnShow") Tercio@23: end Tercio@23: Tercio@23: local function OnHide(frame) Tercio@23: frame.obj:Fire("OnHide") Tercio@23: end Tercio@23: Tercio@23: --[[----------------------------------------------------------------------------- Tercio@23: Support functions Tercio@23: -------------------------------------------------------------------------------]] Tercio@23: Tercio@23: local function okay(frame) Tercio@23: frame.obj:Fire("okay") Tercio@23: end Tercio@23: Tercio@23: local function cancel(frame) Tercio@23: frame.obj:Fire("cancel") Tercio@23: end Tercio@23: Tercio@23: local function default(frame) Tercio@23: frame.obj:Fire("default") Tercio@23: end Tercio@23: Tercio@23: local function refresh(frame) Tercio@23: frame.obj:Fire("refresh") Tercio@23: end Tercio@23: Tercio@23: --[[----------------------------------------------------------------------------- Tercio@23: Methods Tercio@23: -------------------------------------------------------------------------------]] Tercio@23: Tercio@23: local methods = { Tercio@23: ["OnAcquire"] = function(self) Tercio@23: self:SetName() Tercio@23: self:SetTitle() Tercio@23: end, Tercio@23: Tercio@23: -- ["OnRelease"] = nil, Tercio@23: Tercio@23: ["OnWidthSet"] = function(self, width) Tercio@23: local content = self.content Tercio@23: local contentwidth = width - 63 Tercio@23: if contentwidth < 0 then Tercio@23: contentwidth = 0 Tercio@23: end Tercio@23: content:SetWidth(contentwidth) Tercio@23: content.width = contentwidth Tercio@23: end, Tercio@23: Tercio@23: ["OnHeightSet"] = function(self, height) Tercio@23: local content = self.content Tercio@23: local contentheight = height - 26 Tercio@23: if contentheight < 0 then Tercio@23: contentheight = 0 Tercio@23: end Tercio@23: content:SetHeight(contentheight) Tercio@23: content.height = contentheight Tercio@23: end, Tercio@23: Tercio@23: ["SetName"] = function(self, name, parent) Tercio@23: self.frame.name = name Tercio@23: self.frame.parent = parent Tercio@23: end, Tercio@23: Tercio@23: ["SetTitle"] = function(self, title) Tercio@23: local content = self.content Tercio@23: content:ClearAllPoints() Tercio@23: if not title or title == "" then Tercio@23: content:SetPoint("TOPLEFT", 10, -10) Tercio@23: self.label:SetText("") Tercio@23: else Tercio@23: content:SetPoint("TOPLEFT", 10, -40) Tercio@23: self.label:SetText(title) Tercio@23: end Tercio@23: content:SetPoint("BOTTOMRIGHT", -10, 10) Tercio@23: end Tercio@23: } Tercio@23: Tercio@23: --[[----------------------------------------------------------------------------- Tercio@23: Constructor Tercio@23: -------------------------------------------------------------------------------]] Tercio@23: local function Constructor() Tercio@23: local frame = CreateFrame("Frame") Tercio@23: frame:Hide() Tercio@23: Tercio@23: -- support functions for the Blizzard Interface Options Tercio@23: frame.okay = okay Tercio@23: frame.cancel = cancel Tercio@23: frame.default = default Tercio@23: frame.refresh = refresh Tercio@23: Tercio@23: frame:SetScript("OnHide", OnHide) Tercio@23: frame:SetScript("OnShow", OnShow) Tercio@23: Tercio@23: local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") Tercio@23: label:SetPoint("TOPLEFT", 10, -15) Tercio@23: label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45) Tercio@23: label:SetJustifyH("LEFT") Tercio@23: label:SetJustifyV("TOP") Tercio@23: Tercio@23: --Container Support Tercio@23: local content = CreateFrame("Frame", nil, frame) Tercio@23: content:SetPoint("TOPLEFT", 10, -10) Tercio@23: content:SetPoint("BOTTOMRIGHT", -10, 10) Tercio@23: Tercio@23: local widget = { Tercio@23: label = label, Tercio@23: frame = frame, Tercio@23: content = content, Tercio@23: type = Type Tercio@23: } Tercio@23: for method, func in pairs(methods) do Tercio@23: widget[method] = func Tercio@23: end Tercio@23: Tercio@23: return AceGUI:RegisterAsContainer(widget) Tercio@23: end Tercio@23: Tercio@23: AceGUI:RegisterWidgetType(Type, Constructor, Version)