]> git.vomp.tv Git - vompclient.git/blob - src/vinfo.cc
Enable clang compiler and mold linker when cross compiling
[vompclient.git] / src / vinfo.cc
1 /*
2     Copyright 2004-2005 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, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "vinfo.h"
22
23 #include "input.h"
24 #include "colour.h"
25 #include "i18n.h"
26 #include "boxstack.h"
27
28 VInfo::VInfo()
29 {
30   exitable = 0;
31   dropThrough = 0;
32
33   setTitleBarOn(1);
34   setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
35
36   MessageQueue::getInstance()->addReceiver(this);
37 }
38
39 VInfo::~VInfo()
40 {
41   MessageQueue::getInstance()->removeReceiver(this);
42 }
43
44 void VInfo::setExitable()
45 {
46   exitable = 1;
47 }
48
49 void VInfo::setDropThrough()
50 {
51   dropThrough = 1;
52 }
53
54 void VInfo::setMainText(const char* takeText)
55 {
56   mainText = takeText;
57   mainTextType = NORMAL;
58 }
59
60 void VInfo::setOneLiner(const char* takeText)
61 {
62   mainText = takeText;
63   mainTextType = ONELINER;
64 }
65
66 void VInfo::setOneLiner(const std::string& takeText)
67 {
68   mainText = takeText;
69   mainTextType = ONELINER;
70 }
71
72 void VInfo::draw()
73 {
74   TBBoxx::draw();
75
76   if (mainText.size())
77   {
78     if (mainTextType == NORMAL)
79     {
80       drawPara(mainText.c_str() /* FIXME */, 10, 45, DrawStyle::LIGHTTEXT);
81     }
82
83     if (mainTextType == ONELINER)
84     {
85       if (titleBarOn) drawTextCentre(mainText, area.w / 2, 75, DrawStyle::LIGHTTEXT);
86       else drawTextCentre(mainText, area.w / 2, 55, DrawStyle::LIGHTTEXT);
87     }
88   }
89 }
90
91 int VInfo::handleCommand(int command)
92 {
93   if (dropThrough) return BoxStack::DROP_THROUGH;
94
95   switch(command)
96   {
97     case Input::OK:
98     case Input::BACK:
99     {
100       if (exitable) return BoxStack::DELETE_ME;
101     }
102   }
103
104   return BoxStack::ABANDON_COMMAND;
105 }
106
107 void VInfo::okButton()
108 {
109   okbutton.setPosition((area.w / 2) - 30, area.h - 50);
110   okbutton.setText(tr("OK"));
111   okbutton.setActive(1);
112   add(&okbutton);
113 }
114
115 void VInfo::processMessage(Message* m)
116 {
117   if (m->message == Message::MOUSE_LBDOWN)
118   {
119     Input::sendInputKey(Input::OK);
120   }
121 }