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