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