WoWInterface SVN HealMeNow

[/] [trunk/] [Libs/] [AceGUI-3.0/] [widgets/] [AceGUIWidget-DropDownGroup.lua] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 SeiferTim-84726
local AceGUI = LibStub("AceGUI-3.0")
2 SeiferTim-84726
 
3 SeiferTim-84726
--[[
4 SeiferTim-84726
        Selection Group controls all have an interface to select a group for thier contents
5 SeiferTim-84726
        None of them will auto size to thier contents, and should usually be used with a scrollframe
6 SeiferTim-84726
        unless you know that the controls will fit inside
7 SeiferTim-84726
]]
8 SeiferTim-84726
 
9 SeiferTim-84726
--------------------------
10 SeiferTim-84726
-- Dropdown Group               --
11 SeiferTim-84726
--------------------------
12 SeiferTim-84726
--[[
13 SeiferTim-84726
        Events :
14 SeiferTim-84726
                OnGroupSelected
15 SeiferTim-84726
 
16 SeiferTim-84726
]]
17 SeiferTim-84726
do
18 SeiferTim-84726
        local Type = "DropdownGroup"
19 SeiferTim-84726
        local Version = 9
20 SeiferTim-84726
 
21 SeiferTim-84726
        local function OnAcquire(self)
22 SeiferTim-84726
                self.dropdown:SetText("")
23 SeiferTim-84726
        end
24 SeiferTim-84726
 
25 SeiferTim-84726
        local function OnRelease(self)
26 SeiferTim-84726
                self.frame:ClearAllPoints()
27 SeiferTim-84726
                self.frame:Hide()
28 SeiferTim-84726
                self.dropdown.list = nil
29 SeiferTim-84726
                self.status = nil
30 SeiferTim-84726
                for k in pairs(self.localstatus) do
31 SeiferTim-84726
                        self.localstatus[k] = nil
32 SeiferTim-84726
                end
33 SeiferTim-84726
        end
34 SeiferTim-84726
 
35 SeiferTim-84726
        local PaneBackdrop  = {
36 SeiferTim-84726
                bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
37 SeiferTim-84726
                edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
38 SeiferTim-84726
                tile = true, tileSize = 16, edgeSize = 16,
39 SeiferTim-84726
                insets = { left = 3, right = 3, top = 5, bottom = 3 }
40 SeiferTim-84726
        }
41 SeiferTim-84726
 
42 SeiferTim-84726
        local function SetTitle(self,title)
43 SeiferTim-84726
                self.titletext:SetText(title)
44 SeiferTim-84726
        end
45 SeiferTim-84726
 
46 SeiferTim-84726
 
47 SeiferTim-84726
        local function SelectedGroup(self,event,value)
48 SeiferTim-84726
                local group = self.parentgroup
49 SeiferTim-84726
                local status = group.status or group.localstatus
50 SeiferTim-84726
                status.selected = value
51 SeiferTim-84726
                self.parentgroup:Fire("OnGroupSelected", value)
52 SeiferTim-84726
        end
53 SeiferTim-84726
 
54 SeiferTim-84726
        local function SetGroupList(self,list)
55 SeiferTim-84726
                self.dropdown:SetList(list)
56 SeiferTim-84726
        end
57 SeiferTim-84726
 
58 SeiferTim-84726
        -- called to set an external table to store status in
59 SeiferTim-84726
        local function SetStatusTable(self, status)
60 SeiferTim-84726
                assert(type(status) == "table")
61 SeiferTim-84726
                self.status = status
62 SeiferTim-84726
        end
63 SeiferTim-84726
 
64 SeiferTim-84726
        local function SetGroup(self,group)
65 SeiferTim-84726
                self.dropdown:SetValue(group)
66 SeiferTim-84726
                local status = self.status or self.localstatus
67 SeiferTim-84726
                status.selected = group
68 SeiferTim-84726
                self:Fire("OnGroupSelected", group)
69 SeiferTim-84726
        end
70 SeiferTim-84726
 
71 SeiferTim-84726
        local function OnWidthSet(self, width)
72 SeiferTim-84726
                local content = self.content
73 SeiferTim-84726
                local contentwidth = width - 26
74 SeiferTim-84726
                if contentwidth < 0 then
75 SeiferTim-84726
                        contentwidth = 0
76 SeiferTim-84726
                end
77 SeiferTim-84726
                content:SetWidth(contentwidth)
78 SeiferTim-84726
                content.width = contentwidth
79 SeiferTim-84726
        end
80 SeiferTim-84726
 
81 SeiferTim-84726
 
82 SeiferTim-84726
        local function OnHeightSet(self, height)
83 SeiferTim-84726
                local content = self.content
84 SeiferTim-84726
                local contentheight = height - 63
85 SeiferTim-84726
                if contentheight < 0 then
86 SeiferTim-84726
                        contentheight = 0
87 SeiferTim-84726
                end
88 SeiferTim-84726
                content:SetHeight(contentheight)
89 SeiferTim-84726
                content.height = contentheight
90 SeiferTim-84726
        end
91 SeiferTim-84726
 
92 SeiferTim-84726
        local function Constructor()
93 SeiferTim-84726
                local frame = CreateFrame("Frame")
94 SeiferTim-84726
                local self = {}
95 SeiferTim-84726
                self.type = Type
96 SeiferTim-84726
 
97 SeiferTim-84726
                self.OnRelease = OnRelease
98 SeiferTim-84726
                self.OnAcquire = OnAcquire
99 SeiferTim-84726
 
100 SeiferTim-84726
                self.SetTitle = SetTitle
101 SeiferTim-84726
                self.SetGroupList = SetGroupList
102 SeiferTim-84726
                self.SetGroup = SetGroup
103 SeiferTim-84726
                self.SetStatusTable = SetStatusTable
104 SeiferTim-84726
                self.OnWidthSet = OnWidthSet
105 SeiferTim-84726
                self.OnHeightSet = OnHeightSet
106 SeiferTim-84726
 
107 SeiferTim-84726
                self.localstatus = {}
108 SeiferTim-84726
 
109 SeiferTim-84726
                self.frame = frame
110 SeiferTim-84726
                frame.obj = self
111 SeiferTim-84726
 
112 SeiferTim-84726
 
113 SeiferTim-84726
                frame:SetHeight(100)
114 SeiferTim-84726
                frame:SetWidth(100)
115 SeiferTim-84726
                frame:SetFrameStrata("FULLSCREEN_DIALOG")
116 SeiferTim-84726
 
117 SeiferTim-84726
                local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
118 SeiferTim-84726
                titletext:SetPoint("TOPLEFT",frame,"TOPLEFT",14,0)
119 SeiferTim-84726
                titletext:SetPoint("TOPRIGHT",frame,"TOPRIGHT",-14,0)
120 SeiferTim-84726
                titletext:SetJustifyH("LEFT")
121 SeiferTim-84726
                titletext:SetHeight(18)
122 SeiferTim-84726
 
123 SeiferTim-84726
 
124 SeiferTim-84726
                self.titletext = titletext
125 SeiferTim-84726
 
126 SeiferTim-84726
                local dropdown = AceGUI:Create("Dropdown")
127 SeiferTim-84726
                self.dropdown = dropdown
128 SeiferTim-84726
                dropdown.frame:SetParent(frame)
129 SeiferTim-84726
                dropdown.parentgroup = self
130 SeiferTim-84726
                dropdown:SetCallback("OnValueChanged",SelectedGroup)
131 SeiferTim-84726
 
132 SeiferTim-84726
                dropdown.frame:SetPoint("TOPLEFT",titletext,"BOTTOMLEFT",-7,3)
133 SeiferTim-84726
                dropdown.frame:Show()
134 SeiferTim-84726
                dropdown:SetLabel("")
135 SeiferTim-84726
 
136 SeiferTim-84726
                local border = CreateFrame("Frame",nil,frame)
137 SeiferTim-84726
                self.border = border
138 SeiferTim-84726
                border:SetPoint("TOPLEFT",frame,"TOPLEFT",3,-40)
139 SeiferTim-84726
                border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-3,3)
140 SeiferTim-84726
 
141 SeiferTim-84726
                border:SetBackdrop(PaneBackdrop)
142 SeiferTim-84726
                border:SetBackdropColor(0.1,0.1,0.1,0.5)
143 SeiferTim-84726
                border:SetBackdropBorderColor(0.4,0.4,0.4)
144 SeiferTim-84726
 
145 SeiferTim-84726
                --Container Support
146 SeiferTim-84726
                local content = CreateFrame("Frame",nil,border)
147 SeiferTim-84726
                self.content = content
148 SeiferTim-84726
                content.obj = self
149 SeiferTim-84726
                content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10)
150 SeiferTim-84726
                content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10)
151 SeiferTim-84726
 
152 SeiferTim-84726
                AceGUI:RegisterAsContainer(self)
153 SeiferTim-84726
                return self
154 SeiferTim-84726
        end
155 SeiferTim-84726
 
156 SeiferTim-84726
        AceGUI:RegisterWidgetType(Type,Constructor,Version)
157 SeiferTim-84726
end