WoWInterface SVN PhanxConfigWidgets

[/] [trunk/] [PhanxConfig-Header/] [PhanxConfig-Header.lua] - Rev 191

Compare with Previous | Blame | View Log

--[[--------------------------------------------------------------------
        PhanxConfig-Header
        Simple options panel header generator. Requires LibStub.
        https://github.com/Phanx/PhanxConfig-Header

        Copyright (c) 2009-2014 Phanx <addons@phanx.net>. All rights reserved.

        Permission is granted for anyone to use, read, or otherwise interpret
        this software for any purpose, without any restrictions.

        Permission is granted for anyone to embed or include this software in
        another work not derived from this software that makes use of the
        interface provided by this software for the purpose of creating a
        package of the work and its required libraries, and to distribute such
        packages as long as the software is not modified in any way, including
        by modifying or removing any files.

        Permission is granted for anyone to modify this software or sample from
        it, and to distribute such modified versions or derivative works as long
        as neither the names of this software nor its authors are used in the
        name or title of the work or in any other way that may cause it to be
        confused with or interfere with the simultaneous use of this software.

        This software may not be distributed standalone or in any other way, in
        whole or in part, modified or unmodified, without specific prior written
        permission from the authors of this software.

        The names of this software and/or its authors may not be used to
        promote or endorse works derived from this software without specific
        prior written permission from the authors of this software.

        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
        EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
        IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
        OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
        ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
        OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------]]

local MINOR_VERSION = 172

local lib, oldminor = LibStub:NewLibrary("PhanxConfig-Header", MINOR_VERSION)
if not lib then return end

function lib:New(parent, titleText, notesText, noPrefix)
        assert(type(parent) == "table" and type(rawget(parent, 0)) == "userdata", "PhanxConfig-Header: parent must be a frame")
        if type(titleText) ~= "string" then titleText = nil end
        if type(notesText) ~= "string" then notesText = nil end

        if not titleText then
                titleText = parent.name
        end
        if titleText and not noPrefix and parent.parent then
                titleText = format("%s - %s", parent.parent, titleText)
        end

        local title = parent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
        title:SetPoint("TOPLEFT", 16, -16)
        title:SetPoint("TOPRIGHT", -16, -16)
        title:SetJustifyH("LEFT")
        title:SetText(titleText)

        local notes = parent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
        notes:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
        notes:SetPoint("TOPRIGHT", title, 0, -8)
        notes:SetHeight(32)
        notes:SetJustifyH("LEFT")
        notes:SetJustifyV("TOP")
        notes:SetNonSpaceWrap(true)
        notes:SetText(notesText)

        return title, notes
end

function lib.CreateHeader(...) return lib:New(...) end

Compare with Previous | Blame