]> git.vomp.tv Git - vompclient.git/blob - vinfo.cc
More compiler warning fixes
[vompclient.git] / 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 "remote.h"
24 #include "colour.h"
25 #include "i18n.h"
26 #include "boxstack.h"
27
28 VInfo::VInfo()
29 {
30   mainText = NULL;
31   exitable = 0;
32   dropThrough = 0;
33
34   setTitleBarOn(1);
35   setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
36 }
37
38 VInfo::~VInfo()
39 {
40   if (mainText) delete[] mainText;
41 }
42
43 void VInfo::setExitable()
44 {
45   exitable = 1;
46 }
47
48 void VInfo::setDropThrough()
49 {
50   dropThrough = 1;
51 }
52
53 void VInfo::setMainText(const char* takeText)
54 {
55   if (mainText) delete[] mainText;
56   int length = strlen(takeText);
57   mainText = new char[length + 1];
58   strcpy(mainText, takeText);
59   mainTextType = NORMAL;
60 }
61
62 void VInfo::setOneLiner(const char* takeText)
63 {
64   if (mainText) delete[] mainText;
65   int length = strlen(takeText);
66   mainText = new char[length + 1];
67   strcpy(mainText, takeText);
68   mainTextType = ONELINER;
69 }
70
71 void VInfo::draw()
72 {
73   TBBoxx::draw();
74
75   if (mainText)
76   {
77     if (mainTextType == NORMAL)
78     {
79       drawPara(mainText, 10, 45, DrawStyle::LIGHTTEXT);
80     }
81
82     if (mainTextType == ONELINER)
83     {
84       if (titleBarOn) drawTextCentre(mainText, area.w / 2, 75, DrawStyle::LIGHTTEXT);
85       else drawTextCentre(mainText, area.w / 2, 55, DrawStyle::LIGHTTEXT);
86     }
87   }
88 }
89
90 int VInfo::handleCommand(int command)
91 {
92   if (dropThrough) return 0;
93
94   switch(command)
95   {
96     case Remote::OK:
97     case Remote::BACK:
98     {
99       if (exitable) return 4;
100     }
101   }
102
103   return 1;
104 }
105
106 void VInfo::okButton()
107 {
108   okbutton.setPosition((area.w / 2) - 30, area.h - 50);
109   okbutton.setText(tr("OK"));
110   okbutton.setActive(1);
111   add(&okbutton);
112 }
113
114 void VInfo::processMessage(Message* m)
115 {
116   if (m->message == Message::MOUSE_LBDOWN)
117   {
118     BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
119   }
120 }