]> git.vomp.tv Git - vompclient.git/blob - wbutton.cc
11 CWFs
[vompclient.git] / wbutton.cc
1 /*
2     Copyright 2004-2020 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #include "colour.h"
21
22 #include "wbutton.h"
23
24 WButton::WButton()
25 {
26   setSize(70, 21/*fontHeight*/);
27 }
28
29 void WButton::setText(const char* takeText)
30 {
31   mytext = takeText;
32 }
33
34 void WButton::setActive(UCHAR tactive)
35 {
36   dimmed = false;
37   active = tactive;
38 }
39
40 void WButton::dim()
41 {
42   // a bolt on for now - an active but dimmed state
43   dimmed = true;
44   active = false;
45 }
46
47 void WButton::draw()
48 {
49   if (dimmed)
50   {
51     fillColour(DrawStyle::BLACK);
52     drawTextCentre(mytext.c_str(), area.w / 2, 0, DrawStyle::SELECTHIGHLIGHT);
53   }
54   else if (active)
55   {
56     fillColour(DrawStyle::SELECTHIGHLIGHT);
57     drawTextCentre(mytext.c_str(), area.w / 2, 0, DrawStyle::DARKTEXT);
58   }
59   else
60   {
61     fillColour(DrawStyle::BUTTONBACKGROUND);
62     drawTextCentre(mytext.c_str(), area.w / 2, 0, DrawStyle::LIGHTTEXT);
63   }
64 }
65
66 void WButton::setTag(int newTag)
67 {
68   tag = newTag;
69 }
70
71 int WButton::getTag()
72 {
73   return tag;
74 }
75
76 // Sorry, I've broken these in the boxx upgrade - chris // FIXME so fix it
77
78 bool WButton::mouseMove(int x, int y)
79 {
80   if (    (x - getRootBoxOffsetX()) >= 0
81        && (y - getRootBoxOffsetY()) >= 0
82        && (x - getRootBoxOffsetX()) <= static_cast<int>(area.w)
83        && (y - getRootBoxOffsetY()) <= static_cast<int>(area.h)
84        && !active
85      )
86   {
87     setActive(1);
88     return true;
89   }
90   return false;
91 }
92
93 bool WButton::mouseLBDOWN(int x, int y)
94 {
95   if (    (x - getRootBoxOffsetX()) >= 0
96        && (y - getRootBoxOffsetY()) >= 0
97        && (x - getRootBoxOffsetX()) <= static_cast<int>(area.w)
98        && (y - getRootBoxOffsetY()) <= static_cast<int>(area.h)
99        && active
100      )
101   {
102     return true;
103   }
104   return false;
105 }