annotate Libs/AceGUI-3.0/widgets/AceGUIWidget-Button.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 -- WoW APIs
Asa@0 4 local _G = _G
Asa@0 5 local CreateFrame, UIParent = CreateFrame, UIParent
Asa@0 6
Asa@0 7 --------------------------
Asa@0 8 -- Button --
Asa@0 9 --------------------------
Asa@0 10 do
Asa@0 11 local Type = "Button"
Asa@0 12 local Version = 12
Asa@0 13
Asa@0 14 local function OnAcquire(self)
Asa@0 15 -- restore default values
Asa@0 16 self:SetHeight(24)
Asa@0 17 self:SetWidth(200)
Asa@0 18 end
Asa@0 19
Asa@0 20 local function OnRelease(self)
Asa@0 21 self.frame:ClearAllPoints()
Asa@0 22 self.frame:Hide()
Asa@0 23 self:SetDisabled(false)
Asa@0 24 end
Asa@0 25
Asa@0 26 local function Button_OnClick(this, ...)
Asa@0 27 this.obj:Fire("OnClick", ...)
Asa@0 28 AceGUI:ClearFocus()
Asa@0 29 end
Asa@0 30
Asa@0 31 local function Button_OnEnter(this)
Asa@0 32 this.obj:Fire("OnEnter")
Asa@0 33 end
Asa@0 34
Asa@0 35 local function Button_OnLeave(this)
Asa@0 36 this.obj:Fire("OnLeave")
Asa@0 37 end
Asa@0 38
Asa@0 39 local function SetText(self, text)
Asa@0 40 self.text:SetText(text or "")
Asa@0 41 end
Asa@0 42
Asa@0 43 local function SetDisabled(self, disabled)
Asa@0 44 self.disabled = disabled
Asa@0 45 if disabled then
Asa@0 46 self.frame:Disable()
Asa@0 47 else
Asa@0 48 self.frame:Enable()
Asa@0 49 end
Asa@0 50 end
Asa@0 51
Asa@0 52 local function Constructor()
Asa@0 53 local num = AceGUI:GetNextWidgetNum(Type)
Asa@0 54 local name = "AceGUI30Button"..num
Asa@0 55 local frame = CreateFrame("Button",name,UIParent,"UIPanelButtonTemplate2")
Asa@0 56 local self = {}
Asa@0 57 self.num = num
Asa@0 58 self.type = Type
Asa@0 59 self.frame = frame
Asa@0 60
Asa@0 61 local left = _G[name .. "Left"]
Asa@0 62 local right = _G[name .. "Right"]
Asa@0 63 local middle = _G[name .. "Middle"]
Asa@0 64
Asa@0 65 left:SetPoint("TOP", frame, "TOP", 0, 0)
Asa@0 66 left:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
Asa@0 67
Asa@0 68 right:SetPoint("TOP", frame, "TOP", 0, 0)
Asa@0 69 right:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
Asa@0 70
Asa@0 71 middle:SetPoint("TOP", frame, "TOP", 0, 0)
Asa@0 72 middle:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0)
Asa@0 73
Asa@0 74 local text = frame:GetFontString()
Asa@0 75 self.text = text
Asa@0 76 text:ClearAllPoints()
Asa@0 77 text:SetPoint("TOPLEFT",frame,"TOPLEFT", 15, -1)
Asa@0 78 text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT", -15, 1)
Asa@0 79 text:SetJustifyV("MIDDLE")
Asa@0 80
Asa@0 81 frame:SetScript("OnClick",Button_OnClick)
Asa@0 82 frame:SetScript("OnEnter",Button_OnEnter)
Asa@0 83 frame:SetScript("OnLeave",Button_OnLeave)
Asa@0 84
Asa@0 85 self.SetText = SetText
Asa@0 86 self.SetDisabled = SetDisabled
Asa@0 87
Asa@0 88 frame:EnableMouse(true)
Asa@0 89
Asa@0 90 frame:SetHeight(24)
Asa@0 91 frame:SetWidth(200)
Asa@0 92
Asa@0 93 self.OnRelease = OnRelease
Asa@0 94 self.OnAcquire = OnAcquire
Asa@0 95
Asa@0 96 self.frame = frame
Asa@0 97 frame.obj = self
Asa@0 98
Asa@0 99 AceGUI:RegisterAsWidget(self)
Asa@0 100 return self
Asa@0 101 end
Asa@0 102
Asa@0 103 AceGUI:RegisterWidgetType(Type,Constructor,Version)
Asa@0 104 end