annotate Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.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 select = select
Asa@0 5
Asa@0 6 -- WoW APIs
Asa@0 7 local CreateFrame, UIParent = CreateFrame, UIParent
Asa@0 8
Asa@0 9 --------------------------
Asa@0 10 -- Label --
Asa@0 11 --------------------------
Asa@0 12 do
Asa@0 13 local Type = "Icon"
Asa@0 14 local Version = 11
Asa@0 15
Asa@0 16 local function OnAcquire(self)
Asa@0 17 self:SetHeight(110)
Asa@0 18 self:SetWidth(110)
Asa@0 19 self:SetLabel("")
Asa@0 20 self:SetImage(nil)
Asa@0 21 self:SetImageSize(64, 64)
Asa@0 22 end
Asa@0 23
Asa@0 24 local function OnRelease(self)
Asa@0 25 self.frame:ClearAllPoints()
Asa@0 26 self.frame:Hide()
Asa@0 27 self:SetDisabled(false)
Asa@0 28 end
Asa@0 29
Asa@0 30 local function SetLabel(self, text)
Asa@0 31 if text and text ~= "" then
Asa@0 32 self.label:Show()
Asa@0 33 self.label:SetText(text)
Asa@0 34 self.frame:SetHeight(self.image:GetHeight() + 25)
Asa@0 35 else
Asa@0 36 self.label:Hide()
Asa@0 37 self.frame:SetHeight(self.image:GetHeight() + 10)
Asa@0 38 end
Asa@0 39 end
Asa@0 40
Asa@0 41 local function SetImage(self, path, ...)
Asa@0 42 local image = self.image
Asa@0 43 image:SetTexture(path)
Asa@0 44
Asa@0 45 if image:GetTexture() then
Asa@0 46 self.imageshown = true
Asa@0 47 local n = select('#', ...)
Asa@0 48 if n == 4 or n == 8 then
Asa@0 49 image:SetTexCoord(...)
Asa@0 50 else
Asa@0 51 image:SetTexCoord(0, 1, 0, 1)
Asa@0 52 end
Asa@0 53 else
Asa@0 54 self.imageshown = nil
Asa@0 55 end
Asa@0 56 end
Asa@0 57
Asa@0 58 local function SetImageSize(self, width, height)
Asa@0 59 self.image:SetWidth(width)
Asa@0 60 self.image:SetHeight(height)
Asa@0 61 --self.frame:SetWidth(width + 30)
Asa@0 62 if self.label:IsShown() then
Asa@0 63 self.frame:SetHeight(height + 25)
Asa@0 64 else
Asa@0 65 self.frame:SetHeight(height + 10)
Asa@0 66 end
Asa@0 67 end
Asa@0 68
Asa@0 69 local function SetDisabled(self, disabled)
Asa@0 70 self.disabled = disabled
Asa@0 71 if disabled then
Asa@0 72 self.frame:Disable()
Asa@0 73 self.label:SetTextColor(0.5,0.5,0.5)
Asa@0 74 self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
Asa@0 75 else
Asa@0 76 self.frame:Enable()
Asa@0 77 self.label:SetTextColor(1,1,1)
Asa@0 78 self.image:SetVertexColor(1, 1, 1)
Asa@0 79 end
Asa@0 80 end
Asa@0 81
Asa@0 82 local function OnClick(this, button)
Asa@0 83 this.obj:Fire("OnClick", button)
Asa@0 84 AceGUI:ClearFocus()
Asa@0 85 end
Asa@0 86
Asa@0 87 local function OnEnter(this)
Asa@0 88 this.obj.highlight:Show()
Asa@0 89 this.obj:Fire("OnEnter")
Asa@0 90 end
Asa@0 91
Asa@0 92 local function OnLeave(this)
Asa@0 93 this.obj.highlight:Hide()
Asa@0 94 this.obj:Fire("OnLeave")
Asa@0 95 end
Asa@0 96
Asa@0 97 local function Constructor()
Asa@0 98 local frame = CreateFrame("Button",nil,UIParent)
Asa@0 99 local self = {}
Asa@0 100 self.type = Type
Asa@0 101
Asa@0 102 self.OnRelease = OnRelease
Asa@0 103 self.OnAcquire = OnAcquire
Asa@0 104 self.SetLabel = SetLabel
Asa@0 105 self.frame = frame
Asa@0 106 self.SetImage = SetImage
Asa@0 107 self.SetImageSize = SetImageSize
Asa@0 108
Asa@0 109 -- SetText should be deprecated along the way
Asa@0 110 self.SetText = SetLabel
Asa@0 111 self.SetDisabled = SetDisabled
Asa@0 112
Asa@0 113 frame.obj = self
Asa@0 114
Asa@0 115 frame:SetHeight(110)
Asa@0 116 frame:SetWidth(110)
Asa@0 117 frame:EnableMouse(true)
Asa@0 118 frame:SetScript("OnClick", OnClick)
Asa@0 119 frame:SetScript("OnLeave", OnLeave)
Asa@0 120 frame:SetScript("OnEnter", OnEnter)
Asa@0 121 local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlight")
Asa@0 122 label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
Asa@0 123 label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
Asa@0 124 label:SetJustifyH("CENTER")
Asa@0 125 label:SetJustifyV("TOP")
Asa@0 126 label:SetHeight(18)
Asa@0 127 self.label = label
Asa@0 128
Asa@0 129 local image = frame:CreateTexture(nil,"BACKGROUND")
Asa@0 130 self.image = image
Asa@0 131 image:SetWidth(64)
Asa@0 132 image:SetHeight(64)
Asa@0 133 image:SetPoint("TOP",frame,"TOP",0,-5)
Asa@0 134
Asa@0 135 local highlight = frame:CreateTexture(nil,"OVERLAY")
Asa@0 136 self.highlight = highlight
Asa@0 137 highlight:SetAllPoints(image)
Asa@0 138 highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight")
Asa@0 139 highlight:SetTexCoord(0,1,0.23,0.77)
Asa@0 140 highlight:SetBlendMode("ADD")
Asa@0 141 highlight:Hide()
Asa@0 142
Asa@0 143 AceGUI:RegisterAsWidget(self)
Asa@0 144 return self
Asa@0 145 end
Asa@0 146
Asa@0 147 AceGUI:RegisterWidgetType(Type,Constructor,Version)
Asa@0 148 end
Asa@0 149