Mercurial > wow > itemauditor
comparison Libs/AceGUI-3.0/widgets/AceGUIWidget-Frame.lua @ 0:169f5211fc7f
First public revision.
At this point ItemAuditor watches mail for auctions sold or purchased, watches for buy/sell (money and 1 item type change) and conversions/tradeskills. Milling isn't working yet because there is too much time between the first event and the last event.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Thu, 20 May 2010 19:22:19 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:169f5211fc7f |
---|---|
1 local AceGUI = LibStub("AceGUI-3.0") | |
2 | |
3 -- Lua APIs | |
4 local pairs, assert, type = pairs, assert, type | |
5 | |
6 -- WoW APIs | |
7 local CreateFrame, UIParent = CreateFrame, UIParent | |
8 | |
9 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded | |
10 -- List them here for Mikk's FindGlobals script | |
11 -- GLOBALS: CLOSE | |
12 | |
13 ---------------- | |
14 -- Main Frame -- | |
15 ---------------- | |
16 --[[ | |
17 Events : | |
18 OnClose | |
19 | |
20 ]] | |
21 do | |
22 local Type = "Frame" | |
23 local Version = 9 | |
24 | |
25 local FrameBackdrop = { | |
26 bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", | |
27 edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", | |
28 tile = true, tileSize = 32, edgeSize = 32, | |
29 insets = { left = 8, right = 8, top = 8, bottom = 8 } | |
30 } | |
31 | |
32 local PaneBackdrop = { | |
33 bgFile = "Interface\\ChatFrame\\ChatFrameBackground", | |
34 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", | |
35 tile = true, tileSize = 16, edgeSize = 16, | |
36 insets = { left = 3, right = 3, top = 5, bottom = 3 } | |
37 } | |
38 | |
39 local function frameOnClose(this) | |
40 this.obj:Fire("OnClose") | |
41 end | |
42 | |
43 local function closeOnClick(this) | |
44 this.obj:Hide() | |
45 end | |
46 | |
47 local function frameOnMouseDown(this) | |
48 AceGUI:ClearFocus() | |
49 end | |
50 | |
51 local function titleOnMouseDown(this) | |
52 this:GetParent():StartMoving() | |
53 AceGUI:ClearFocus() | |
54 end | |
55 | |
56 local function frameOnMouseUp(this) | |
57 local frame = this:GetParent() | |
58 frame:StopMovingOrSizing() | |
59 local self = frame.obj | |
60 local status = self.status or self.localstatus | |
61 status.width = frame:GetWidth() | |
62 status.height = frame:GetHeight() | |
63 status.top = frame:GetTop() | |
64 status.left = frame:GetLeft() | |
65 end | |
66 | |
67 local function sizerseOnMouseDown(this) | |
68 this:GetParent():StartSizing("BOTTOMRIGHT") | |
69 AceGUI:ClearFocus() | |
70 end | |
71 | |
72 local function sizersOnMouseDown(this) | |
73 this:GetParent():StartSizing("BOTTOM") | |
74 AceGUI:ClearFocus() | |
75 end | |
76 | |
77 local function sizereOnMouseDown(this) | |
78 this:GetParent():StartSizing("RIGHT") | |
79 AceGUI:ClearFocus() | |
80 end | |
81 | |
82 local function SetTitle(self,title) | |
83 self.titletext:SetText(title) | |
84 end | |
85 | |
86 local function SetStatusText(self,text) | |
87 self.statustext:SetText(text) | |
88 end | |
89 | |
90 local function Hide(self) | |
91 self.frame:Hide() | |
92 end | |
93 | |
94 local function Show(self) | |
95 self.frame:Show() | |
96 end | |
97 | |
98 local function OnAcquire(self) | |
99 self.frame:SetParent(UIParent) | |
100 self.frame:SetFrameStrata("FULLSCREEN_DIALOG") | |
101 self:ApplyStatus() | |
102 end | |
103 | |
104 local function OnRelease(self) | |
105 self.status = nil | |
106 for k in pairs(self.localstatus) do | |
107 self.localstatus[k] = nil | |
108 end | |
109 end | |
110 | |
111 -- called to set an external table to store status in | |
112 local function SetStatusTable(self, status) | |
113 assert(type(status) == "table") | |
114 self.status = status | |
115 self:ApplyStatus() | |
116 end | |
117 | |
118 local function ApplyStatus(self) | |
119 local status = self.status or self.localstatus | |
120 local frame = self.frame | |
121 self:SetWidth(status.width or 700) | |
122 self:SetHeight(status.height or 500) | |
123 if status.top and status.left then | |
124 frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top) | |
125 frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0) | |
126 else | |
127 frame:SetPoint("CENTER",UIParent,"CENTER") | |
128 end | |
129 end | |
130 | |
131 local function OnWidthSet(self, width) | |
132 local content = self.content | |
133 local contentwidth = width - 34 | |
134 if contentwidth < 0 then | |
135 contentwidth = 0 | |
136 end | |
137 content:SetWidth(contentwidth) | |
138 content.width = contentwidth | |
139 end | |
140 | |
141 | |
142 local function OnHeightSet(self, height) | |
143 local content = self.content | |
144 local contentheight = height - 57 | |
145 if contentheight < 0 then | |
146 contentheight = 0 | |
147 end | |
148 content:SetHeight(contentheight) | |
149 content.height = contentheight | |
150 end | |
151 | |
152 local function Constructor() | |
153 local frame = CreateFrame("Frame",nil,UIParent) | |
154 local self = {} | |
155 self.type = "Frame" | |
156 | |
157 self.Hide = Hide | |
158 self.Show = Show | |
159 self.SetTitle = SetTitle | |
160 self.OnRelease = OnRelease | |
161 self.OnAcquire = OnAcquire | |
162 self.SetStatusText = SetStatusText | |
163 self.SetStatusTable = SetStatusTable | |
164 self.ApplyStatus = ApplyStatus | |
165 self.OnWidthSet = OnWidthSet | |
166 self.OnHeightSet = OnHeightSet | |
167 | |
168 self.localstatus = {} | |
169 | |
170 self.frame = frame | |
171 frame.obj = self | |
172 frame:SetWidth(700) | |
173 frame:SetHeight(500) | |
174 frame:SetPoint("CENTER",UIParent,"CENTER",0,0) | |
175 frame:EnableMouse() | |
176 frame:SetMovable(true) | |
177 frame:SetResizable(true) | |
178 frame:SetFrameStrata("FULLSCREEN_DIALOG") | |
179 frame:SetScript("OnMouseDown", frameOnMouseDown) | |
180 | |
181 frame:SetBackdrop(FrameBackdrop) | |
182 frame:SetBackdropColor(0,0,0,1) | |
183 frame:SetScript("OnHide",frameOnClose) | |
184 frame:SetMinResize(400,200) | |
185 frame:SetToplevel(true) | |
186 | |
187 local closebutton = CreateFrame("Button",nil,frame,"UIPanelButtonTemplate") | |
188 closebutton:SetScript("OnClick", closeOnClick) | |
189 closebutton:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-27,17) | |
190 closebutton:SetHeight(20) | |
191 closebutton:SetWidth(100) | |
192 closebutton:SetText(CLOSE) | |
193 | |
194 self.closebutton = closebutton | |
195 closebutton.obj = self | |
196 | |
197 local statusbg = CreateFrame("Frame",nil,frame) | |
198 statusbg:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",15,15) | |
199 statusbg:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-132,15) | |
200 statusbg:SetHeight(24) | |
201 statusbg:SetBackdrop(PaneBackdrop) | |
202 statusbg:SetBackdropColor(0.1,0.1,0.1) | |
203 statusbg:SetBackdropBorderColor(0.4,0.4,0.4) | |
204 self.statusbg = statusbg | |
205 | |
206 local statustext = statusbg:CreateFontString(nil,"OVERLAY","GameFontNormal") | |
207 self.statustext = statustext | |
208 statustext:SetPoint("TOPLEFT",statusbg,"TOPLEFT",7,-2) | |
209 statustext:SetPoint("BOTTOMRIGHT",statusbg,"BOTTOMRIGHT",-7,2) | |
210 statustext:SetHeight(20) | |
211 statustext:SetJustifyH("LEFT") | |
212 statustext:SetText("") | |
213 | |
214 local title = CreateFrame("Frame",nil,frame) | |
215 self.title = title | |
216 title:EnableMouse() | |
217 title:SetScript("OnMouseDown",titleOnMouseDown) | |
218 title:SetScript("OnMouseUp", frameOnMouseUp) | |
219 | |
220 | |
221 local titlebg = frame:CreateTexture(nil,"OVERLAY") | |
222 titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") | |
223 titlebg:SetTexCoord(0.31,0.67,0,0.63) | |
224 titlebg:SetPoint("TOP",frame,"TOP",0,12) | |
225 titlebg:SetWidth(100) | |
226 titlebg:SetHeight(40) | |
227 | |
228 local titlebg_l = frame:CreateTexture(nil,"OVERLAY") | |
229 titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") | |
230 titlebg_l:SetTexCoord(0.21,0.31,0,0.63) | |
231 titlebg_l:SetPoint("RIGHT",titlebg,"LEFT",0,0) | |
232 titlebg_l:SetWidth(30) | |
233 titlebg_l:SetHeight(40) | |
234 | |
235 local titlebg_right = frame:CreateTexture(nil,"OVERLAY") | |
236 titlebg_right:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") | |
237 titlebg_right:SetTexCoord(0.67,0.77,0,0.63) | |
238 titlebg_right:SetPoint("LEFT",titlebg,"RIGHT",0,0) | |
239 titlebg_right:SetWidth(30) | |
240 titlebg_right:SetHeight(40) | |
241 | |
242 title:SetAllPoints(titlebg) | |
243 local titletext = title:CreateFontString(nil,"OVERLAY","GameFontNormal") | |
244 titletext:SetPoint("TOP",titlebg,"TOP",0,-14) | |
245 | |
246 self.titletext = titletext | |
247 | |
248 local sizer_se = CreateFrame("Frame",nil,frame) | |
249 sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) | |
250 sizer_se:SetWidth(25) | |
251 sizer_se:SetHeight(25) | |
252 sizer_se:EnableMouse() | |
253 sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown) | |
254 sizer_se:SetScript("OnMouseUp", frameOnMouseUp) | |
255 self.sizer_se = sizer_se | |
256 | |
257 local line1 = sizer_se:CreateTexture(nil, "BACKGROUND") | |
258 self.line1 = line1 | |
259 line1:SetWidth(14) | |
260 line1:SetHeight(14) | |
261 line1:SetPoint("BOTTOMRIGHT", -8, 8) | |
262 line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") | |
263 local x = 0.1 * 14/17 | |
264 line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) | |
265 | |
266 local line2 = sizer_se:CreateTexture(nil, "BACKGROUND") | |
267 self.line2 = line2 | |
268 line2:SetWidth(8) | |
269 line2:SetHeight(8) | |
270 line2:SetPoint("BOTTOMRIGHT", -8, 8) | |
271 line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") | |
272 local x = 0.1 * 8/17 | |
273 line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) | |
274 | |
275 local sizer_s = CreateFrame("Frame",nil,frame) | |
276 sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0) | |
277 sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) | |
278 sizer_s:SetHeight(25) | |
279 sizer_s:EnableMouse() | |
280 sizer_s:SetScript("OnMouseDown",sizersOnMouseDown) | |
281 sizer_s:SetScript("OnMouseUp", frameOnMouseUp) | |
282 self.sizer_s = sizer_s | |
283 | |
284 local sizer_e = CreateFrame("Frame",nil,frame) | |
285 sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25) | |
286 sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) | |
287 sizer_e:SetWidth(25) | |
288 sizer_e:EnableMouse() | |
289 sizer_e:SetScript("OnMouseDown",sizereOnMouseDown) | |
290 sizer_e:SetScript("OnMouseUp", frameOnMouseUp) | |
291 self.sizer_e = sizer_e | |
292 | |
293 --Container Support | |
294 local content = CreateFrame("Frame",nil,frame) | |
295 self.content = content | |
296 content.obj = self | |
297 content:SetPoint("TOPLEFT",frame,"TOPLEFT",17,-27) | |
298 content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-17,40) | |
299 | |
300 AceGUI:RegisterAsContainer(self) | |
301 return self | |
302 end | |
303 | |
304 AceGUI:RegisterWidgetType(Type,Constructor,Version) | |
305 end |