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