/trunk/sStats/libs/AceGUI-3.0/widgets
DropdownGroup Container |
Container controlled by a dropdown on the top. |
-------------------------------------------------------------------------------]] |
local Type, Version = "DropdownGroup", 20 |
local Type, Version = "DropdownGroup", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
end |
end, |
["SetGroupList"] = function(self,list) |
self.dropdown:SetList(list) |
["SetGroupList"] = function(self,list,order) |
self.dropdown:SetList(list,order) |
end, |
["SetStatusTable"] = function(self, status) |
TreeGroup Container |
Container that uses a tree control to switch between groups. |
-------------------------------------------------------------------------------]] |
local Type, Version = "TreeGroup", 30 |
local Type, Version = "TreeGroup", 33 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
if not status.treewidth then |
status.treewidth = DEFAULT_TREE_WIDTH |
end |
if not status.treesizable then |
if status.treesizable == nil then |
status.treesizable = DEFAULT_TREE_SIZABLE |
end |
self:SetTreeWidth(status.treewidth,status.treesizable) |
local numlines = #lines |
local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18)) |
if maxlines <= 0 then return end |
local first, last |
--check if we are scrolled down too far |
if numlines - status.scrollvalue < maxlines then |
status.scrollvalue = numlines - maxlines |
end |
if self.scrollbar:GetValue() ~= status.scrollvalue then |
self.scrollbar:SetValue(status.scrollvalue) |
end |
self.noupdate = nil |
button:SetParent(treeframe) |
button:SetFrameLevel(treeframe:GetFrameLevel()+1) |
button:ClearAllPoints() |
if i == 1 then |
if buttonnum == 1 then |
if self.showscroll then |
button:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",-22,-10) |
button:SetPoint("TOPLEFT", self.treeframe, "TOPLEFT", 0, -10) |
button:SetPoint("TOPRIGHT", -22, -10) |
button:SetPoint("TOPLEFT", 0, -10) |
else |
button:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",0,-10) |
button:SetPoint("TOPLEFT", self.treeframe, "TOPLEFT", 0, -10) |
button:SetPoint("TOPRIGHT", 0, -10) |
button:SetPoint("TOPLEFT", 0, -10) |
end |
else |
button:SetPoint("TOPRIGHT", buttons[buttonnum-1], "BOTTOMRIGHT",0,0) |
end |
end, |
["GetTreeWidth"] = function(self) |
local status = self.status or self.localstatus |
return status.treewidth or DEFAULT_TREE_WIDTH |
end, |
["LayoutFinished"] = function(self, width, height) |
if self.noAutoHeight then return end |
self:SetHeight((height or 0) + 20) |
Button Widget |
Graphical Button. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Button", 20 |
local Type, Version = "Button", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
Scripts |
-------------------------------------------------------------------------------]] |
local function Button_OnClick(frame, ...) |
AceGUI:ClearFocus() |
PlaySound("igMainMenuOption") |
frame.obj:Fire("OnClick", ...) |
AceGUI:ClearFocus() |
end |
local function Control_OnEnter(frame) |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 996 2010-12-01 18:34:17Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
return self |
end |
-- Register a dummy LibStub library to retrieve the ItemBase, so other addons can use it. |
local IBLib = LibStub:NewLibrary("AceGUI-3.0-DropDown-ItemBase", ItemBase.version) |
if IBLib then |
IBLib.GetItemBase = function() return ItemBase end |
end |
--[[ |
Template for items: |
local Type, Version = "MultiLineEditBox", 24 |
local Type, Version = "MultiLineEditBox", 25 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight()) |
end |
local function OnShowFocus(frame) |
frame.obj.editBox:SetFocus() |
frame:SetScript("OnShow", nil) |
end |
local function OnFocusGained(frame) |
AceGUI:SetFocus(frame.obj) |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
self:SetMaxLetters(0) |
end, |
-- ["OnRelease"] = nil, |
["OnRelease"] = function(self) |
self:ClearFocus() |
end, |
["SetDisabled"] = function(self, disabled) |
local editBox = self.editBox |
self.button:Show() |
end |
Layout(self) |
end, |
["ClearFocus"] = function(self) |
self.editBox:ClearFocus() |
self.frame:SetScript("OnShow", nil) |
end, |
["SetFocus"] = function(self) |
self.editBox:SetFocus() |
if not self.frame:IsShown() then |
self.frame:SetScript("OnShow", OnShowFocus) |
end |
end |
} |
editBox:SetScript("OnReceiveDrag", OnReceiveDrag) |
editBox:SetScript("OnTextChanged", OnTextChanged) |
editBox:SetScript("OnTextSet", OnTextSet) |
editBox:SetScript("OnEditFocusGained", OnFocusGained) |
scrollFrame:SetScrollChild(editBox) |
TabGroup Container |
Container that uses tabs on top to switch between groups. |
-------------------------------------------------------------------------------]] |
local Type, Version = "TabGroup", 30 |
local Type, Version = "TabGroup", 32 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
local rowwidths = {} |
local rowends = {} |
-- Determine if we're on WoW 4.0.6 or not. |
local wow_406 |
do |
local _,wow_build = GetBuildInfo() |
wow_406 = tonumber(wow_build) >= 13596 |
end |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
local function Tab_SetText(frame, text) |
frame:_SetText(text) |
local width = frame.obj.frame.width or frame.obj.frame:GetWidth() or 0 |
PanelTemplates_TabResize(frame, 0, nil, width) |
if wow_406 then |
PanelTemplates_TabResize(frame, 0, nil, nil, width) |
else |
PanelTemplates_TabResize(frame, 0, nil, width) |
end |
end |
local function Tab_SetSelected(frame, selected) |
-- equal padding for each tab to fill the available width, |
-- if the used space is above 75% already |
-- the 18 pixel is the typical width of a scrollbar, so we can have a tab group inside a scrolling frame, |
-- and not have the tabs jump around funny when switching between tabs that need scrolling and those that don't |
local padding = 0 |
if not (numrows == 1 and rowwidths[1] < width*0.75) then |
if not (numrows == 1 and rowwidths[1] < width*0.75 - 18) then |
padding = (width - rowwidths[row]) / (endtab - starttab+1) |
end |
for i = starttab, endtab do |
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width) |
if wow_406 then |
PanelTemplates_TabResize(tabs[i], padding + 4, nil, nil, width) |
else |
PanelTemplates_TabResize(tabs[i], padding + 4, nil, width) |
end |
end |
starttab = endtab + 1 |
end |
--[[----------------------------------------------------------------------------- |
Icon Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "Icon", 20 |
local Type, Version = "Icon", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
else |
self.frame:Enable() |
self.label:SetTextColor(1, 1, 1) |
self.image:SetVertexColor(1, 1, 1) |
self.image:SetVertexColor(1, 1, 1, 1) |
end |
end |
} |
--[[----------------------------------------------------------------------------- |
Frame Container |
-------------------------------------------------------------------------------]] |
local Type, Version = "Frame", 21 |
local Type, Version = "Frame", 22 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
["SetTitle"] = function(self, title) |
self.titletext:SetText(title) |
self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10) |
end, |
["SetStatusText"] = function(self, text) |
localstatus = {}, |
titletext = titletext, |
statustext = statustext, |
titlebg = titlebg, |
content = content, |
frame = frame, |
type = Type |
--[[ $Id: AceGUIWidget-DropDown.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown.lua 997 2010-12-01 18:36:28Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
-- Lua APIs |
local min, max, floor = math.min, math.max, math.floor |
local select, pairs, ipairs = select, pairs, ipairs |
local select, pairs, ipairs, type = select, pairs, ipairs, type |
local tsort = table.sort |
-- WoW APIs |
do |
local widgetType = "Dropdown" |
local widgetVersion = 22 |
local widgetVersion = 24 |
--[[ Static data ]]-- |
end |
end |
local function AddListItem(self, value, text) |
local item = AceGUI:Create("Dropdown-Item-Toggle") |
local function AddListItem(self, value, text, itemType) |
if not itemType then itemType = "Dropdown-Item-Toggle" end |
local exists = AceGUI:GetWidgetVersion(itemType) |
if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end |
local item = AceGUI:Create(itemType) |
item:SetText(text) |
item.userdata.obj = self |
item.userdata.value = value |
-- exported |
local sortlist = {} |
local function SetList(self, list) |
local function SetList(self, list, order, itemType) |
self.list = list |
self.pullout:Clear() |
self.hasClose = nil |
if not list then return end |
for v in pairs(list) do |
sortlist[#sortlist + 1] = v |
if type(order) ~= "table" then |
for v in pairs(list) do |
sortlist[#sortlist + 1] = v |
end |
tsort(sortlist) |
for i, key in ipairs(sortlist) do |
AddListItem(self, key, list[key], itemType) |
sortlist[i] = nil |
end |
else |
for i, key in ipairs(order) do |
AddListItem(self, key, list[key], itemType) |
end |
end |
tsort(sortlist) |
for i, value in pairs(sortlist) do |
AddListItem(self, value, list[value]) |
sortlist[i] = nil |
end |
if self.multiselect then |
ShowMultiText(self) |
AddCloseButton(self) |
end |
-- exported |
local function AddItem(self, value, text) |
local function AddItem(self, value, text, itemType) |
if self.list then |
self.list[value] = text |
AddListItem(self, value, text) |
AddListItem(self, value, text, itemType) |
end |
end |
--[[----------------------------------------------------------------------------- |
EditBox Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "EditBox", 23 |
local Type, Version = "EditBox", 24 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
frame.obj:Fire("OnLeave") |
end |
local function Frame_OnShowFocus(frame) |
frame.obj.editbox:SetFocus() |
frame:SetScript("OnShow", nil) |
end |
local function EditBox_OnEscapePressed(frame) |
AceGUI:ClearFocus() |
end |
end |
end |
local function EditBox_OnFocusGained(frame) |
AceGUI:SetFocus(frame.obj) |
end |
local function Button_OnClick(frame) |
local editbox = frame.obj.editbox |
editbox:ClearFocus() |
self:SetMaxLetters(0) |
end, |
-- ["OnRelease"] = nil, |
["OnRelease"] = function(self) |
self:ClearFocus() |
end, |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
["SetMaxLetters"] = function (self, num) |
self.editbox:SetMaxLetters(num or 0) |
end, |
["ClearFocus"] = function(self) |
self.editbox:ClearFocus() |
self.frame:SetScript("OnShow", nil) |
end, |
["SetFocus"] = function(self) |
self.editbox:SetFocus() |
if not self.frame:IsShown() then |
self.frame:SetScript("OnShow", Frame_OnShowFocus) |
end |
end |
} |
editbox:SetScript("OnTextChanged", EditBox_OnTextChanged) |
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) |
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) |
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained) |
editbox:SetTextInsets(0, 0, 3, 3) |
editbox:SetMaxLetters(256) |
editbox:SetPoint("BOTTOMLEFT", 6, 0) |