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