lotrointerface.com
Search Downloads

LoTROInterface SVN SequenceBars

[/] [trunk/] [Thurallor/] [Common/] [UI/] [RadioButton.lua] - Blame information for rev 16

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

Line No. Rev Author Line
1 2 Thurallor-7095
RadioButton = class(Turbine.UI.Control);
2 Thurallor-7095
 
3 16 Thurallor-7095
function RadioButton:Constructor(parent, text, checked, disabled)
4 2 Thurallor-7095
    Turbine.UI.Control.Constructor(self);
5 Thurallor-7095
 
6 Thurallor-7095
    self:SetParent(parent);
7 Thurallor-7095
 
8 Thurallor-7095
    self.icon = Turbine.UI.Control();
9 Thurallor-7095
    self.icon:SetParent(self);
10 Thurallor-7095
    self.icon:SetSize(10, 10);
11 6 Thurallor-7095
    self.icon:SetBlendMode(Turbine.UI.BlendMode.Overlay);
12 2 Thurallor-7095
    self.icon.MouseClick = function()
13 Thurallor-7095
        self:MouseClick();
14 Thurallor-7095
    end
15 Thurallor-7095
 
16 Thurallor-7095
    self.text = Turbine.UI.Label();
17 Thurallor-7095
    self.text:SetParent(self);
18 Thurallor-7095
    self.text:SetText(text);
19 Thurallor-7095
    self.text:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft);
20 Thurallor-7095
    self.text.MouseClick = function()
21 Thurallor-7095
        self:MouseClick();
22 Thurallor-7095
    end
23 Thurallor-7095
 
24 16 Thurallor-7095
    self:SetForeColor(Turbine.UI.Color(1, 1, 1, 1));
25 2 Thurallor-7095
    self:SetChecked(checked);
26 16 Thurallor-7095
    self:SetEnabled(not disabled);
27 2 Thurallor-7095
end
28 Thurallor-7095
 
29 Thurallor-7095
-- This is a static function (not associated with a specific instance).
30 Thurallor-7095
function RadioButton.LinkPeers(peers)
31 Thurallor-7095
    for p = 1, #peers, 1 do
32 Thurallor-7095
        peers[p].peerGroup = peers;
33 Thurallor-7095
    end
34 Thurallor-7095
end
35 Thurallor-7095
 
36 Thurallor-7095
function RadioButton:SetSize(width, height)
37 Thurallor-7095
    Turbine.UI.Control.SetSize(self, width, height);
38 12 Thurallor-7095
    self.icon:SetTop(math.floor((height - self.icon:GetHeight()) / 2));
39 2 Thurallor-7095
    self.text:SetLeft(self.icon:GetWidth() + 1);
40 Thurallor-7095
    self.text:SetHeight(height);
41 Thurallor-7095
    self.text:SetWidth(width - self.text:GetLeft());
42 Thurallor-7095
end
43 Thurallor-7095
 
44 Thurallor-7095
function RadioButton:SetText(text)
45 Thurallor-7095
    self.text:SetText(text);
46 Thurallor-7095
end
47 Thurallor-7095
 
48 6 Thurallor-7095
function RadioButton:SetForeColor(color)
49 16 Thurallor-7095
    self.foreColor = color;
50 6 Thurallor-7095
    self.text:SetForeColor(color);
51 Thurallor-7095
end
52 Thurallor-7095
 
53 2 Thurallor-7095
function RadioButton:SetFont(font)
54 Thurallor-7095
    self.text:SetFont(font);
55 Thurallor-7095
    self.text:SetText(self.text:GetText());
56 Thurallor-7095
end
57 Thurallor-7095
 
58 Thurallor-7095
function RadioButton:MouseClick()
59 16 Thurallor-7095
    if (self.enabled) then
60 Thurallor-7095
        for p = 1, #self.peerGroup, 1 do
61 Thurallor-7095
            self.peerGroup[p]:SetChecked(false);
62 Thurallor-7095
        end
63 Thurallor-7095
        self:SetChecked(true);
64 Thurallor-7095
        if (self.Clicked ~= nil) then
65 Thurallor-7095
            self:Clicked();
66 Thurallor-7095
        end
67 2 Thurallor-7095
    end
68 Thurallor-7095
end
69 Thurallor-7095
 
70 Thurallor-7095
function RadioButton:SetChecked(checked)
71 Thurallor-7095
    self.checked = checked;
72 Thurallor-7095
    if (checked) then
73 Thurallor-7095
        self.icon:SetBackground(0x41000199);
74 Thurallor-7095
    else
75 Thurallor-7095
        self.icon:SetBackground(0x4100019A);
76 Thurallor-7095
    end
77 Thurallor-7095
end
78 Thurallor-7095
 
79 Thurallor-7095
function RadioButton:IsChecked()
80 Thurallor-7095
    return self.checked;
81 Thurallor-7095
end
82 Thurallor-7095
 
83 16 Thurallor-7095
function RadioButton:SetEnabled(enabled)
84 Thurallor-7095
    self.enabled = enabled;
85 Thurallor-7095
    if (enabled) then
86 Thurallor-7095
        self.text:SetForeColor(self.foreColor);
87 Thurallor-7095
    else
88 Thurallor-7095
        self.text:SetForeColor(Turbine.UI.Color(1, 0.25, 0.25, 0.25));
89 Thurallor-7095
    end
90 Thurallor-7095
end
91 Thurallor-7095
 
92 Thurallor-7095
function RadioButton:IsEnabled()
93 Thurallor-7095
    return self.enabled;
94 Thurallor-7095
end
95 Thurallor-7095
 
96 Thurallor-7095
 
97 2 Thurallor-7095
if (not Thurallor.UI) then
98 Thurallor-7095
    Thurallor.UI = {};
99 Thurallor-7095
end
100 Thurallor-7095
Thurallor.UI.RadioButton = RadioButton;

All times are GMT -5. The time now is 11:03 PM.


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