/trunk
--[[ $Id: CallbackHandler-1.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ ]] |
local MAJOR, MINOR = "CallbackHandler-1.0", 5 |
--[[ $Id: CallbackHandler-1.0.lua 965 2010-08-09 00:47:52Z mikk $ ]] |
local MAJOR, MINOR = "CallbackHandler-1.0", 6 |
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) |
if not CallbackHandler then return end -- No upgrade needed |
regfunc = function(...) self[method](self,...) end |
end |
else |
-- function ref with self=object or self="addonId" |
if type(self)~="table" and type(self)~="string" then |
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2) |
-- function ref with self=object or self="addonId" or self=thread |
if type(self)~="table" and type(self)~="string" and type(self)~="thread" then |
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2) |
end |
if select("#",...)>=1 then -- this is not the same as testing for arg==nil! |
--[[----------------------------------------------------------------------------- |
EditBox Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "EditBox", 21 |
local Type, Version = "EditBox", 22 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
HideButton(self) |
end, |
["GetText"] = function(self, text) |
return self.editbox:GetText() |
end, |
["SetLabel"] = function(self, text) |
if text and text ~= "" then |
self.label:SetText(text) |
["DisableButton"] = function(self, disabled) |
self.disablebutton = disabled |
if disabled then |
HideButton(self) |
end |
end, |
["SetMaxLetters"] = function (self, num) |
ScrollFrame Container |
Plain container that scrolls its content and doesn't grow in height. |
-------------------------------------------------------------------------------]] |
local Type, Version = "ScrollFrame", 20 |
local Type, Version = "ScrollFrame", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local pairs, assert, type = pairs, assert, type |
local min, max, floor = math.min, math.max, math.floor |
local min, max, floor, abs = math.min, math.max, math.floor, math.abs |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
local status = self.status or self.localstatus |
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight() |
if height > viewheight then |
self.scrollbar:Hide() |
else |
self.scrollbar:Show() |
if self.scrollBarShown then |
local diff = height - viewheight |
local delta = 1 |
if value < 0 then |
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight() |
local offset = status.offset or 0 |
local curvalue = self.scrollbar:GetValue() |
if viewheight < height then |
-- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys |
-- No-one is going to miss 2 pixels at the bottom of the frame, anyhow! |
if viewheight < height + 2 then |
if self.scrollBarShown then |
self.scrollBarShown = nil |
self.scrollbar:Hide() |
local Type, Version = "MultiLineEditBox", 22 |
local Type, Version = "MultiLineEditBox", 23 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- GLOBALS: ACCEPT, ChatFontNormal |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
local function Layout(self) |
self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight) |
if self.labelHeight == 0 then |
self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23) |
else |
self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19) |
end |
if self.disablebutton then |
self.scrollBar:SetPoint("BOTTOM", self.frame, "BOTTOM", 0, 21) |
self.scrollBG:SetPoint("BOTTOMLEFT", 0, 4) |
else |
self.scrollBar:SetPoint("BOTTOM", self.button, "TOP", 0, 18) |
self.scrollBG:SetPoint("BOTTOMLEFT", self.button, "TOPLEFT") |
end |
end |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function OnClick(self) -- Button |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["GetText"] = function(self) |
return self.editBox:GetText() |
end, |
["OnAcquire"] = function(self) |
self.editBox:SetText("") |
self:SetDisabled(false) |
self:SetWidth(200) |
self:DisableButton(false) |
self:SetNumLines() |
self.entered = nil |
self:SetMaxLetters(0) |
end, |
["OnRelease"] = function(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end, |
-- ["OnRelease"] = nil, |
["SetDisabled"] = function(self, disabled) |
local editBox = self.editBox |
self.label:SetText(text) |
if self.labelHeight ~= 10 then |
self.labelHeight = 10 |
self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19) |
self:SetHeight(self.frame.height + 10) |
self.label:Show() |
end |
elseif self.labelHeight ~= 0 then |
self.labelHeight = 0 |
self.label:Hide() |
self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23) |
self:SetHeight(self.frame.height - 10) |
end |
Layout(self) |
end, |
["SetNumLines"] = function(self, value) |
if not value or value < 4 then |
value = 4 |
end |
self:SetHeight(value * 14 + 41 + self.labelHeight) |
self.numlines = value |
Layout(self) |
end, |
["SetText"] = function(self, text) |
self.editBox:SetText(text) |
end, |
["GetText"] = function(self) |
return self.editBox:GetText() |
end, |
["SetMaxLetters"] = function (self, num) |
self.editBox:SetMaxLetters(num or 0) |
end, |
["DisableButton"] = function(self, disabled) |
self.disablebutton = disabled |
if disabled then |
self.button:Hide() |
else |
self.button:Show() |
end |
Layout(self) |
end |
} |
label:SetHeight(10) |
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, "UIPanelButtonTemplate2") |
button:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, 4) |
button:SetPoint("BOTTOMLEFT", 0, 4) |
button:SetHeight(22) |
button:SetWidth(label:GetStringWidth() + 24) |
button:SetText(ACCEPT) |
frame = frame, |
label = label, |
labelHeight = 10, |
numlines = 4, |
scrollBar = scrollBar, |
scrollBG = scrollBG, |
scrollFrame = scrollFrame, |
type = Type |
} |
end |
button.obj, editBox.obj, scrollFrame.obj = widget, widget, widget |
AceGUI:RegisterAsWidget(widget) |
return widget |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
-- as well as associate it with a slash command. |
-- @class file |
-- @name AceConfig-3.0 |
-- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ |
-- @release $Id: AceConfig-3.0.lua 969 2010-10-07 02:11:48Z shefki $ |
--[[ |
AceConfig-3.0 |
local cfgreg = LibStub("AceConfigRegistry-3.0") |
local cfgcmd = LibStub("AceConfigCmd-3.0") |
local cfgdlg = LibStub("AceConfigDialog-3.0") |
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0") |
--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true) |
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true) |
-- Lua APIs |
local pcall, error, type, pairs = pcall, error, type, pairs |
-- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly. |
-- @paramsig appName, options [, slashcmd] |
-- @param appName The application name for the config table. |
-- @param options The option table (or a function to generate one on demand) |
-- @param options The option table (or a function to generate one on demand). http://www.wowace.com/addons/ace3/pages/ace-config-3-0-options-tables/ |
-- @param slashcmd A slash command to register for the option table, or a table of slash commands. |
-- @usage |
-- local AceConfig = LibStub("AceConfig-3.0") |
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables. |
-- @class file |
-- @name AceConfigDialog-3.0 |
-- @release $Id: AceConfigDialog-3.0.lua 958 2010-07-03 10:22:29Z nevcairiel $ |
-- @release $Id: AceConfigDialog-3.0.lua 967 2010-09-25 08:20:55Z nevcairiel $ |
local LibStub = LibStub |
local MAJOR, MINOR = "AceConfigDialog-3.0", 49 |
local MAJOR, MINOR = "AceConfigDialog-3.0", 50 |
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigDialog then return end |
end |
local OrderA, OrderB = tempOrders[a] or 100, tempOrders[b] or 100 |
if OrderA == OrderB then |
local NameA = (type(tempNames[a] == "string") and tempNames[a]) or "" |
local NameB = (type(tempNames[b] == "string") and tempNames[b]) or "" |
local NameA = (type(tempNames[a]) == "string") and tempNames[a] or "" |
local NameB = (type(tempNames[b]) == "string") and tempNames[b] or "" |
return NameA:upper() < NameB:upper() |
end |
if OrderA < 0 then |