lotrointerface.com
Search Downloads

LoTROInterface SVN SequenceBars

[/] [trunk/] [Thurallor/] [Common/] [UI/] [RadioButton.lua] - Rev 2

Go to most recent revision | Compare with Previous | Blame | View Log

RadioButton = class(Turbine.UI.Control);

function RadioButton:Constructor(parent, text, checked)
    Turbine.UI.Control.Constructor(self);

    self:SetParent(parent);

    self.icon = Turbine.UI.Control();
    self.icon:SetParent(self);
    self.icon:SetSize(10, 10);
    self.icon.MouseClick = function()
        self:MouseClick();
    end
    
    self.text = Turbine.UI.Label();
    self.text:SetParent(self);
    self.text:SetText(text);
    self.text:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
    self.text.MouseClick = function()
        self:MouseClick();
    end
    
    self:SetChecked(checked);
end

-- This is a static function (not associated with a specific instance).
function RadioButton.LinkPeers(peers)
    for p = 1, #peers, 1 do
        peers[p].peerGroup = peers;
    end
end

function RadioButton:SetSize(width, height)
    Turbine.UI.Control.SetSize(self, width, height);
    self.icon:SetTop(math.floor((height - self.icon:GetHeight()) / 2) + 1);
    self.text:SetLeft(self.icon:GetWidth() + 1);
    self.text:SetHeight(height);
    self.text:SetWidth(width - self.text:GetLeft());
end

function RadioButton:SetText(text)
    self.text:SetText(text);
end

function RadioButton:SetFont(font)
    self.text:SetFont(font);
    self.text:SetText(self.text:GetText());
end

function RadioButton:MouseClick()
    for p = 1, #self.peerGroup, 1 do
        self.peerGroup[p]:SetChecked(false);
    end
    self:SetChecked(true);
    if (self.Clicked ~= nil) then
        self:Clicked();
    end
end

function RadioButton:SetChecked(checked)
    self.checked = checked;
    if (checked) then
        self.icon:SetBackground(0x41000199);
    else
        self.icon:SetBackground(0x4100019A);
    end
end

function RadioButton:IsChecked()
    return self.checked;
end

if (not Thurallor.UI) then
    Thurallor.UI = {};
end
Thurallor.UI.RadioButton = RadioButton;

Go to most recent revision | Compare with Previous | Blame


All times are GMT -5. The time now is 02:13 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui