WoWInterface SVN PocketPlot

[/] [trunk/] [PocketPlot/] [libs/] [AceGUI-3.0/] [widgets/] [AceGUIContainer-Window.lua] - Blame information for rev 86

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 65 Seerah-39096
local AceGUI = LibStub("AceGUI-3.0")
2 Seerah-39096
 
3 Seerah-39096
-- Lua APIs
4 Seerah-39096
local pairs, assert, type = pairs, assert, type
5 Seerah-39096
 
6 Seerah-39096
-- WoW APIs
7 Seerah-39096
local PlaySound = PlaySound
8 Seerah-39096
local CreateFrame, UIParent = CreateFrame, UIParent
9 Seerah-39096
 
10 Seerah-39096
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
11 Seerah-39096
-- List them here for Mikk's FindGlobals script
12 Seerah-39096
-- GLOBALS: GameFontNormal
13 Seerah-39096
 
14 Seerah-39096
----------------
15 Seerah-39096
-- Main Frame --
16 Seerah-39096
----------------
17 Seerah-39096
--[[
18 Seerah-39096
        Events :
19 Seerah-39096
                OnClose
20 Seerah-39096
 
21 Seerah-39096
]]
22 Seerah-39096
do
23 Seerah-39096
        local Type = "Window"
24 86 Seerah-39096
        local Version = 6
25 65 Seerah-39096
 
26 84 Seerah-39096
        local function frameOnShow(this)
27 Seerah-39096
                this.obj:Fire("OnShow")
28 Seerah-39096
        end
29 Seerah-39096
 
30 65 Seerah-39096
        local function frameOnClose(this)
31 Seerah-39096
                this.obj:Fire("OnClose")
32 Seerah-39096
        end
33 Seerah-39096
 
34 Seerah-39096
        local function closeOnClick(this)
35 86 Seerah-39096
                PlaySound(PlaySoundKitID and "gsTitleOptionExit" or 799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
36 65 Seerah-39096
                this.obj:Hide()
37 Seerah-39096
        end
38 Seerah-39096
 
39 Seerah-39096
        local function frameOnMouseDown(this)
40 Seerah-39096
                AceGUI:ClearFocus()
41 Seerah-39096
        end
42 Seerah-39096
 
43 Seerah-39096
        local function titleOnMouseDown(this)
44 Seerah-39096
                this:GetParent():StartMoving()
45 Seerah-39096
                AceGUI:ClearFocus()
46 Seerah-39096
        end
47 Seerah-39096
 
48 Seerah-39096
        local function frameOnMouseUp(this)
49 Seerah-39096
                local frame = this:GetParent()
50 Seerah-39096
                frame:StopMovingOrSizing()
51 Seerah-39096
                local self = frame.obj
52 Seerah-39096
                local status = self.status or self.localstatus
53 Seerah-39096
                status.width = frame:GetWidth()
54 Seerah-39096
                status.height = frame:GetHeight()
55 Seerah-39096
                status.top = frame:GetTop()
56 Seerah-39096
                status.left = frame:GetLeft()
57 Seerah-39096
        end
58 Seerah-39096
 
59 Seerah-39096
        local function sizerseOnMouseDown(this)
60 Seerah-39096
                this:GetParent():StartSizing("BOTTOMRIGHT")
61 Seerah-39096
                AceGUI:ClearFocus()
62 Seerah-39096
        end
63 Seerah-39096
 
64 Seerah-39096
        local function sizersOnMouseDown(this)
65 Seerah-39096
                this:GetParent():StartSizing("BOTTOM")
66 Seerah-39096
                AceGUI:ClearFocus()
67 Seerah-39096
        end
68 Seerah-39096
 
69 Seerah-39096
        local function sizereOnMouseDown(this)
70 Seerah-39096
                this:GetParent():StartSizing("RIGHT")
71 Seerah-39096
                AceGUI:ClearFocus()
72 Seerah-39096
        end
73 Seerah-39096
 
74 Seerah-39096
        local function sizerOnMouseUp(this)
75 Seerah-39096
                this:GetParent():StopMovingOrSizing()
76 Seerah-39096
        end
77 Seerah-39096
 
78 Seerah-39096
        local function SetTitle(self,title)
79 Seerah-39096
                self.titletext:SetText(title)
80 Seerah-39096
        end
81 Seerah-39096
 
82 Seerah-39096
        local function SetStatusText(self,text)
83 Seerah-39096
                -- self.statustext:SetText(text)
84 Seerah-39096
        end
85 Seerah-39096
 
86 Seerah-39096
        local function Hide(self)
87 Seerah-39096
                self.frame:Hide()
88 Seerah-39096
        end
89 Seerah-39096
 
90 Seerah-39096
        local function Show(self)
91 Seerah-39096
                self.frame:Show()
92 Seerah-39096
        end
93 Seerah-39096
 
94 Seerah-39096
        local function OnAcquire(self)
95 Seerah-39096
                self.frame:SetParent(UIParent)
96 Seerah-39096
                self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
97 Seerah-39096
                self:ApplyStatus()
98 Seerah-39096
                self:EnableResize(true)
99 Seerah-39096
                self:Show()
100 Seerah-39096
        end
101 Seerah-39096
 
102 Seerah-39096
        local function OnRelease(self)
103 Seerah-39096
                self.status = nil
104 Seerah-39096
                for k in pairs(self.localstatus) do
105 Seerah-39096
                        self.localstatus[k] = nil
106 Seerah-39096
                end
107 Seerah-39096
        end
108 Seerah-39096
 
109 Seerah-39096
        -- called to set an external table to store status in
110 Seerah-39096
        local function SetStatusTable(self, status)
111 Seerah-39096
                assert(type(status) == "table")
112 Seerah-39096
                self.status = status
113 Seerah-39096
                self:ApplyStatus()
114 Seerah-39096
        end
115 Seerah-39096
 
116 Seerah-39096
        local function ApplyStatus(self)
117 Seerah-39096
                local status = self.status or self.localstatus
118 Seerah-39096
                local frame = self.frame
119 Seerah-39096
                self:SetWidth(status.width or 700)
120 Seerah-39096
                self:SetHeight(status.height or 500)
121 Seerah-39096
                if status.top and status.left then
122 Seerah-39096
                        frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
123 Seerah-39096
                        frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
124 Seerah-39096
                else
125 Seerah-39096
                        frame:SetPoint("CENTER",UIParent,"CENTER")
126 Seerah-39096
                end
127 Seerah-39096
        end
128 Seerah-39096
 
129 Seerah-39096
        local function OnWidthSet(self, width)
130 Seerah-39096
                local content = self.content
131 Seerah-39096
                local contentwidth = width - 34
132 Seerah-39096
                if contentwidth < 0 then
133 Seerah-39096
                        contentwidth = 0
134 Seerah-39096
                end
135 Seerah-39096
                content:SetWidth(contentwidth)
136 Seerah-39096
                content.width = contentwidth
137 Seerah-39096
        end
138 Seerah-39096
 
139 Seerah-39096
 
140 Seerah-39096
        local function OnHeightSet(self, height)
141 Seerah-39096
                local content = self.content
142 Seerah-39096
                local contentheight = height - 57
143 Seerah-39096
                if contentheight < 0 then
144 Seerah-39096
                        contentheight = 0
145 Seerah-39096
                end
146 Seerah-39096
                content:SetHeight(contentheight)
147 Seerah-39096
                content.height = contentheight
148 Seerah-39096
        end
149 Seerah-39096
 
150 Seerah-39096
        local function EnableResize(self, state)
151 Seerah-39096
                local func = state and "Show" or "Hide"
152 Seerah-39096
                self.sizer_se[func](self.sizer_se)
153 Seerah-39096
                self.sizer_s[func](self.sizer_s)
154 Seerah-39096
                self.sizer_e[func](self.sizer_e)
155 Seerah-39096
        end
156 Seerah-39096
 
157 Seerah-39096
        local function Constructor()
158 Seerah-39096
                local frame = CreateFrame("Frame",nil,UIParent)
159 Seerah-39096
                local self = {}
160 Seerah-39096
                self.type = "Window"
161 Seerah-39096
 
162 Seerah-39096
                self.Hide = Hide
163 Seerah-39096
                self.Show = Show
164 Seerah-39096
                self.SetTitle =  SetTitle
165 Seerah-39096
                self.OnRelease = OnRelease
166 Seerah-39096
                self.OnAcquire = OnAcquire
167 Seerah-39096
                self.SetStatusText = SetStatusText
168 Seerah-39096
                self.SetStatusTable = SetStatusTable
169 Seerah-39096
                self.ApplyStatus = ApplyStatus
170 Seerah-39096
                self.OnWidthSet = OnWidthSet
171 Seerah-39096
                self.OnHeightSet = OnHeightSet
172 Seerah-39096
                self.EnableResize = EnableResize
173 Seerah-39096
 
174 Seerah-39096
                self.localstatus = {}
175 Seerah-39096
 
176 Seerah-39096
                self.frame = frame
177 Seerah-39096
                frame.obj = self
178 Seerah-39096
                frame:SetWidth(700)
179 Seerah-39096
                frame:SetHeight(500)
180 Seerah-39096
                frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
181 Seerah-39096
                frame:EnableMouse()
182 Seerah-39096
                frame:SetMovable(true)
183 Seerah-39096
                frame:SetResizable(true)
184 Seerah-39096
                frame:SetFrameStrata("FULLSCREEN_DIALOG")
185 Seerah-39096
                frame:SetScript("OnMouseDown", frameOnMouseDown)
186 Seerah-39096
 
187 84 Seerah-39096
                frame:SetScript("OnShow",frameOnShow)
188 65 Seerah-39096
                frame:SetScript("OnHide",frameOnClose)
189 Seerah-39096
                frame:SetMinResize(240,240)
190 Seerah-39096
                frame:SetToplevel(true)
191 Seerah-39096
 
192 Seerah-39096
                local titlebg = frame:CreateTexture(nil, "BACKGROUND")
193 Seerah-39096
                titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]])
194 Seerah-39096
                titlebg:SetPoint("TOPLEFT", 9, -6)
195 Seerah-39096
                titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
196 Seerah-39096
 
197 Seerah-39096
                local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
198 Seerah-39096
                dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
199 Seerah-39096
                dialogbg:SetPoint("TOPLEFT", 8, -24)
200 Seerah-39096
                dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
201 Seerah-39096
                dialogbg:SetVertexColor(0, 0, 0, .75)
202 Seerah-39096
 
203 Seerah-39096
                local topleft = frame:CreateTexture(nil, "BORDER")
204 Seerah-39096
                topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
205 Seerah-39096
                topleft:SetWidth(64)
206 Seerah-39096
                topleft:SetHeight(64)
207 Seerah-39096
                topleft:SetPoint("TOPLEFT")
208 Seerah-39096
                topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
209 Seerah-39096
 
210 Seerah-39096
                local topright = frame:CreateTexture(nil, "BORDER")
211 Seerah-39096
                topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
212 Seerah-39096
                topright:SetWidth(64)
213 Seerah-39096
                topright:SetHeight(64)
214 Seerah-39096
                topright:SetPoint("TOPRIGHT")
215 Seerah-39096
                topright:SetTexCoord(0.625, 0.75, 0, 1)
216 Seerah-39096
 
217 Seerah-39096
                local top = frame:CreateTexture(nil, "BORDER")
218 Seerah-39096
                top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
219 Seerah-39096
                top:SetHeight(64)
220 Seerah-39096
                top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
221 Seerah-39096
                top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
222 Seerah-39096
                top:SetTexCoord(0.25, 0.369140625, 0, 1)
223 Seerah-39096
 
224 Seerah-39096
                local bottomleft = frame:CreateTexture(nil, "BORDER")
225 Seerah-39096
                bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
226 Seerah-39096
                bottomleft:SetWidth(64)
227 Seerah-39096
                bottomleft:SetHeight(64)
228 Seerah-39096
                bottomleft:SetPoint("BOTTOMLEFT")
229 Seerah-39096
                bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
230 Seerah-39096
 
231 Seerah-39096
                local bottomright = frame:CreateTexture(nil, "BORDER")
232 Seerah-39096
                bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
233 Seerah-39096
                bottomright:SetWidth(64)
234 Seerah-39096
                bottomright:SetHeight(64)
235 Seerah-39096
                bottomright:SetPoint("BOTTOMRIGHT")
236 Seerah-39096
                bottomright:SetTexCoord(0.875, 1, 0, 1)
237 Seerah-39096
 
238 Seerah-39096
                local bottom = frame:CreateTexture(nil, "BORDER")
239 Seerah-39096
                bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
240 Seerah-39096
                bottom:SetHeight(64)
241 Seerah-39096
                bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
242 Seerah-39096
                bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
243 Seerah-39096
                bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
244 Seerah-39096
 
245 Seerah-39096
                local left = frame:CreateTexture(nil, "BORDER")
246 Seerah-39096
                left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
247 Seerah-39096
                left:SetWidth(64)
248 Seerah-39096
                left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
249 Seerah-39096
                left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
250 Seerah-39096
                left:SetTexCoord(0.001953125, 0.125, 0, 1)
251 Seerah-39096
 
252 Seerah-39096
                local right = frame:CreateTexture(nil, "BORDER")
253 Seerah-39096
                right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
254 Seerah-39096
                right:SetWidth(64)
255 Seerah-39096
                right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
256 Seerah-39096
                right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
257 Seerah-39096
                right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
258 Seerah-39096
 
259 Seerah-39096
                local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
260 Seerah-39096
                close:SetPoint("TOPRIGHT", 2, 1)
261 Seerah-39096
                close:SetScript("OnClick", closeOnClick)
262 Seerah-39096
                self.closebutton = close
263 Seerah-39096
                close.obj = self
264 Seerah-39096
 
265 Seerah-39096
                local titletext = frame:CreateFontString(nil, "ARTWORK")
266 Seerah-39096
                titletext:SetFontObject(GameFontNormal)
267 Seerah-39096
                titletext:SetPoint("TOPLEFT", 12, -8)
268 Seerah-39096
                titletext:SetPoint("TOPRIGHT", -32, -8)
269 Seerah-39096
                self.titletext = titletext
270 Seerah-39096
 
271 Seerah-39096
                local title = CreateFrame("Button", nil, frame)
272 Seerah-39096
                title:SetPoint("TOPLEFT", titlebg)
273 Seerah-39096
                title:SetPoint("BOTTOMRIGHT", titlebg)
274 Seerah-39096
                title:EnableMouse()
275 Seerah-39096
                title:SetScript("OnMouseDown",titleOnMouseDown)
276 Seerah-39096
                title:SetScript("OnMouseUp", frameOnMouseUp)
277 Seerah-39096
                self.title = title
278 Seerah-39096
 
279 Seerah-39096
                local sizer_se = CreateFrame("Frame",nil,frame)
280 Seerah-39096
                sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
281 Seerah-39096
                sizer_se:SetWidth(25)
282 Seerah-39096
                sizer_se:SetHeight(25)
283 Seerah-39096
                sizer_se:EnableMouse()
284 Seerah-39096
                sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown)
285 Seerah-39096
                sizer_se:SetScript("OnMouseUp", sizerOnMouseUp)
286 Seerah-39096
                self.sizer_se = sizer_se
287 Seerah-39096
 
288 Seerah-39096
                local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
289 Seerah-39096
                self.line1 = line1
290 Seerah-39096
                line1:SetWidth(14)
291 Seerah-39096
                line1:SetHeight(14)
292 Seerah-39096
                line1:SetPoint("BOTTOMRIGHT", -8, 8)
293 Seerah-39096
                line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
294 Seerah-39096
                local x = 0.1 * 14/17
295 Seerah-39096
                line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
296 Seerah-39096
 
297 Seerah-39096
                local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
298 Seerah-39096
                self.line2 = line2
299 Seerah-39096
                line2:SetWidth(8)
300 Seerah-39096
                line2:SetHeight(8)
301 Seerah-39096
                line2:SetPoint("BOTTOMRIGHT", -8, 8)
302 Seerah-39096
                line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
303 Seerah-39096
                local x = 0.1 * 8/17
304 Seerah-39096
                line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
305 Seerah-39096
 
306 Seerah-39096
                local sizer_s = CreateFrame("Frame",nil,frame)
307 Seerah-39096
                sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0)
308 Seerah-39096
                sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
309 Seerah-39096
                sizer_s:SetHeight(25)
310 Seerah-39096
                sizer_s:EnableMouse()
311 Seerah-39096
                sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
312 Seerah-39096
                sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
313 Seerah-39096
                self.sizer_s = sizer_s
314 Seerah-39096
 
315 Seerah-39096
                local sizer_e = CreateFrame("Frame",nil,frame)
316 Seerah-39096
                sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
317 Seerah-39096
                sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
318 Seerah-39096
                sizer_e:SetWidth(25)
319 Seerah-39096
                sizer_e:EnableMouse()
320 Seerah-39096
                sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
321 Seerah-39096
                sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
322 Seerah-39096
                self.sizer_e = sizer_e
323 Seerah-39096
 
324 Seerah-39096
                --Container Support
325 Seerah-39096
                local content = CreateFrame("Frame",nil,frame)
326 Seerah-39096
                self.content = content
327 Seerah-39096
                content.obj = self
328 Seerah-39096
                content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
329 Seerah-39096
                content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13)
330 Seerah-39096
 
331 Seerah-39096
                AceGUI:RegisterAsContainer(self)
332 Seerah-39096
                return self
333 Seerah-39096
        end
334 Seerah-39096
 
335 Seerah-39096
        AceGUI:RegisterWidgetType(Type,Constructor,Version)
336 Seerah-39096
end