1 local AceGUI
= LibStub("AceGUI-3.0")
5 local CreateFrame
, UIParent
= CreateFrame
, UIParent
7 --------------------------
9 --------------------------
14 local function OnAcquire(self
)
15 -- restore default values
20 local function OnRelease(self
)
21 self
.frame
:ClearAllPoints()
23 self
:SetDisabled(false)
26 local function Button_OnClick(this
, ...)
27 this
.obj
:Fire("OnClick", ...)
31 local function Button_OnEnter(this
)
32 this
.obj
:Fire("OnEnter")
35 local function Button_OnLeave(this
)
36 this
.obj
:Fire("OnLeave")
39 local function SetText(self
, text
)
40 self
.text
:SetText(text
or "")
43 local function SetDisabled(self
, disabled
)
44 self
.disabled
= disabled
52 local function Constructor()
53 local num
= AceGUI
:GetNextWidgetNum(Type
)
54 local name
= "AceGUI30Button"..num
55 local frame
= CreateFrame("Button",name
,UIParent
,"UIPanelButtonTemplate2")
61 local left
= _G
[name
.. "Left"]
62 local right
= _G
[name
.. "Right"]
63 local middle
= _G
[name
.. "Middle"]
65 left
:SetPoint("TOP", frame
, "TOP", 0, 0)
66 left
:SetPoint("BOTTOM", frame
, "BOTTOM", 0, 0)
68 right
:SetPoint("TOP", frame
, "TOP", 0, 0)
69 right
:SetPoint("BOTTOM", frame
, "BOTTOM", 0, 0)
71 middle
:SetPoint("TOP", frame
, "TOP", 0, 0)
72 middle
:SetPoint("BOTTOM", frame
, "BOTTOM", 0, 0)
74 local text
= frame
:GetFontString()
77 text
:SetPoint("TOPLEFT",frame
,"TOPLEFT", 15, -1)
78 text
:SetPoint("BOTTOMRIGHT",frame
,"BOTTOMRIGHT", -15, 1)
79 text
:SetJustifyV("MIDDLE")
81 frame
:SetScript("OnClick",Button_OnClick
)
82 frame
:SetScript("OnEnter",Button_OnEnter
)
83 frame
:SetScript("OnLeave",Button_OnLeave
)
85 self
.SetText
= SetText
86 self
.SetDisabled
= SetDisabled
88 frame
:EnableMouse(true)
93 self
.OnRelease
= OnRelease
94 self
.OnAcquire
= OnAcquire
99 AceGUI
:RegisterAsWidget(self
)
103 AceGUI
:RegisterWidgetType(Type
,Constructor
,Version
)