1 --[[-----------------------------------------------------------------------------
3 -------------------------------------------------------------------------------]]
4 local Type, Version = "Icon", 21
5 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
9 local select, pairs, print = select, pairs, print
12 local CreateFrame, UIParent, GetBuildInfo = CreateFrame, UIParent, GetBuildInfo
14 --[[-----------------------------------------------------------------------------
16 -------------------------------------------------------------------------------]]
17 local function Control_OnEnter(frame)
18 frame.obj:Fire("OnEnter")
21 local function Control_OnLeave(frame)
22 frame.obj:Fire("OnLeave")
25 local function Button_OnClick(frame, button)
26 frame.obj:Fire("OnClick", button)
30 --[[-----------------------------------------------------------------------------
32 -------------------------------------------------------------------------------]]
34 ["OnAcquire"] = function(self)
39 self:SetImageSize(64, 64)
40 self:SetDisabled(false)
43 -- ["OnRelease"] = nil,
45 ["SetLabel"] = function(self, text)
46 if text and text ~= "" then
48 self.label:SetText(text)
49 self:SetHeight(self.image:GetHeight() + 25)
52 self:SetHeight(self.image:GetHeight() + 10)
56 ["SetImage"] = function(self, path, ...)
57 local image = self.image
58 image:SetTexture(path)
60 if image:GetTexture() then
61 local n = select("#", ...)
62 if n == 4 or n == 8 then
63 image:SetTexCoord(...)
65 image:SetTexCoord(0, 1, 0, 1)
70 ["SetImageSize"] = function(self, width, height)
71 self.image:SetWidth(width)
72 self.image:SetHeight(height)
73 --self.frame:SetWidth(width + 30)
74 if self.label:IsShown() then
75 self:SetHeight(height + 25)
77 self:SetHeight(height + 10)
81 ["SetDisabled"] = function(self, disabled)
82 self.disabled = disabled
85 self.label:SetTextColor(0.5, 0.5, 0.5)
86 self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
89 self.label:SetTextColor(1, 1, 1)
90 self.image:SetVertexColor(1, 1, 1, 1)
95 --[[-----------------------------------------------------------------------------
97 -------------------------------------------------------------------------------]]
98 local function Constructor()
99 local frame = CreateFrame("Button", nil, UIParent)
102 frame:EnableMouse(true)
103 frame:SetScript("OnEnter", Control_OnEnter)
104 frame:SetScript("OnLeave", Control_OnLeave)
105 frame:SetScript("OnClick", Button_OnClick)
107 local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight")
108 label:SetPoint("BOTTOMLEFT")
109 label:SetPoint("BOTTOMRIGHT")
110 label:SetJustifyH("CENTER")
111 label:SetJustifyV("TOP")
114 local image = frame:CreateTexture(nil, "BACKGROUND")
117 image:SetPoint("TOP", 0, -5)
119 local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
120 highlight:SetAllPoints(image)
121 highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight")
122 highlight:SetTexCoord(0, 1, 0.23, 0.77)
123 highlight:SetBlendMode("ADD")
131 for method, func in pairs(methods) do
132 widget[method] = func
134 -- SetText is deprecated, but keep it around for a while. (say, to WoW 4.0)
135 if (select(4, GetBuildInfo()) < 40000) then
136 widget.SetText = widget.SetLabel
138 widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end
141 return AceGUI:RegisterAsWidget(widget)
144 AceGUI:RegisterWidgetType(Type, Constructor, Version)