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