Mercurial > wow > itemauditor
comparison Libs/AceGUI-3.0/widgets/AceGUIWidget-BlizOptionsGroup.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 | |
| 4 ------------- | |
| 5 -- Widgets -- | |
| 6 ------------- | |
| 7 --[[ | |
| 8 Widgets must provide the following functions | |
| 9 Acquire() - Called when the object is aquired, should set everything to a default hidden state | |
| 10 Release() - Called when the object is Released, should remove any anchors and hide the Widget | |
| 11 | |
| 12 And the following members | |
| 13 frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes | |
| 14 type - the type of the object, same as the name given to :RegisterWidget() | |
| 15 | |
| 16 Widgets contain a table called userdata, this is a safe place to store data associated with the wigdet | |
| 17 It will be cleared automatically when a widget is released | |
| 18 Placing values directly into a widget object should be avoided | |
| 19 | |
| 20 If the Widget can act as a container for other Widgets the following | |
| 21 content - frame or derivitive that children will be anchored to | |
| 22 | |
| 23 The Widget can supply the following Optional Members | |
| 24 | |
| 25 | |
| 26 ]] | |
| 27 | |
| 28 ---------------------------------- | |
| 29 -- Blizzard Options Group -- | |
| 30 ---------------------------------- | |
| 31 --[[ | |
| 32 Group Designed to be added to the bliz interface options panel | |
| 33 ]] | |
| 34 | |
| 35 -- WoW APIs | |
| 36 local CreateFrame = CreateFrame | |
| 37 | |
| 38 do | |
| 39 local Type = "BlizOptionsGroup" | |
| 40 local Version = 10 | |
| 41 | |
| 42 local function OnAcquire(self) | |
| 43 | |
| 44 end | |
| 45 | |
| 46 local function OnRelease(self) | |
| 47 self.frame:ClearAllPoints() | |
| 48 self.frame:Hide() | |
| 49 self:SetName() | |
| 50 end | |
| 51 | |
| 52 local function okay(this) | |
| 53 this.obj:Fire("okay") | |
| 54 end | |
| 55 | |
| 56 local function cancel(this) | |
| 57 this.obj:Fire("cancel") | |
| 58 end | |
| 59 | |
| 60 local function defaults(this) | |
| 61 this.obj:Fire("defaults") | |
| 62 end | |
| 63 | |
| 64 local function SetName(self, name, parent) | |
| 65 self.frame.name = name | |
| 66 self.frame.parent = parent | |
| 67 end | |
| 68 | |
| 69 local function OnShow(this) | |
| 70 this.obj:Fire("OnShow") | |
| 71 end | |
| 72 | |
| 73 local function OnHide(this) | |
| 74 this.obj:Fire("OnHide") | |
| 75 end | |
| 76 | |
| 77 local function OnWidthSet(self, width) | |
| 78 local content = self.content | |
| 79 local contentwidth = width - 63 | |
| 80 if contentwidth < 0 then | |
| 81 contentwidth = 0 | |
| 82 end | |
| 83 content:SetWidth(contentwidth) | |
| 84 content.width = contentwidth | |
| 85 end | |
| 86 | |
| 87 | |
| 88 local function OnHeightSet(self, height) | |
| 89 local content = self.content | |
| 90 local contentheight = height - 26 | |
| 91 if contentheight < 0 then | |
| 92 contentheight = 0 | |
| 93 end | |
| 94 content:SetHeight(contentheight) | |
| 95 content.height = contentheight | |
| 96 end | |
| 97 | |
| 98 local function SetTitle(self, title) | |
| 99 local content = self.content | |
| 100 content:ClearAllPoints() | |
| 101 if not title or title == "" then | |
| 102 content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",10,-10) | |
| 103 self.label:SetText("") | |
| 104 else | |
| 105 content:SetPoint("TOPLEFT",self.frame,"TOPLEFT",10,-40) | |
| 106 self.label:SetText(title) | |
| 107 end | |
| 108 content:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",-10,10) | |
| 109 end | |
| 110 | |
| 111 local function Constructor() | |
| 112 local frame = CreateFrame("Frame") | |
| 113 local self = {} | |
| 114 self.type = Type | |
| 115 | |
| 116 self.OnRelease = OnRelease | |
| 117 self.OnAcquire = OnAcquire | |
| 118 self.frame = frame | |
| 119 self.SetName = SetName | |
| 120 | |
| 121 self.OnWidthSet = OnWidthSet | |
| 122 self.OnHeightSet = OnHeightSet | |
| 123 self.SetTitle = SetTitle | |
| 124 | |
| 125 frame.obj = self | |
| 126 frame.okay = okay | |
| 127 frame.cancel = cancel | |
| 128 frame.defaults = defaults | |
| 129 | |
| 130 frame:Hide() | |
| 131 frame:SetScript("OnHide",OnHide) | |
| 132 frame:SetScript("OnShow",OnShow) | |
| 133 | |
| 134 local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalLarge") | |
| 135 self.label = label | |
| 136 label:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -15) | |
| 137 label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45) | |
| 138 label:SetJustifyH("LEFT") | |
| 139 label:SetJustifyV("TOP") | |
| 140 | |
| 141 --Container Support | |
| 142 local content = CreateFrame("Frame",nil,frame) | |
| 143 self.content = content | |
| 144 content.obj = self | |
| 145 content:SetPoint("TOPLEFT",frame,"TOPLEFT",15,-10) | |
| 146 content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-10,10) | |
| 147 | |
| 148 AceGUI:RegisterAsContainer(self) | |
| 149 return self | |
| 150 end | |
| 151 | |
| 152 AceGUI:RegisterWidgetType(Type,Constructor,Version) | |
| 153 end |
