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