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