]> git.vomp.tv Git - vompclient-marten.git/blob - vinfo.cc
Switch trunk code to new boxes
[vompclient-marten.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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "vinfo.h"
22
23 #include "remote.h"
24 #include "colour.h"
25 #include "wbutton.h"
26 #include "i18n.h"
27 #include "boxstack.h"
28
29 VInfo::VInfo()
30 {
31   mainText = NULL;
32   exitable = 0;
33   dropThrough = 0;
34   okbutton = false;
35
36   setTitleBarOn(1);
37   setTitleBarColour(Colour::TITLEBARBACKGROUND);
38 }
39
40 VInfo::~VInfo()
41 {
42   if (mainText) delete[] mainText;
43 }
44
45 void VInfo::setExitable()
46 {
47   exitable = 1;
48 }
49
50 void VInfo::setDropThrough()
51 {
52   dropThrough = 1;
53 }
54
55 void VInfo::setMainText(const char* takeText)
56 {
57   int length = strlen(takeText);
58   mainText = new char[length + 1];
59   strcpy(mainText, takeText);
60   mainTextType = NORMAL;
61 }
62
63 void VInfo::setOneLiner(const char* takeText)
64 {
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, Colour::LIGHTTEXT);
80     }
81
82     if (mainTextType == ONELINER)
83     {
84       if (titleBarOn) drawTextCentre(mainText, area.w / 2, 75, Colour::LIGHTTEXT);
85       else drawTextCentre(mainText, area.w / 2, 55, Colour::LIGHTTEXT);
86     }
87   }
88
89   if (okbutton)
90   {
91 /*
92     WButton button;
93     button.setPosition((area.w / 2) - 30, area.h - 50);
94     button.setText(tr("OK"));
95     button.setActive(1);
96     add(&button);
97     button.draw();
98 */
99   } // FIXME check
100 }
101
102 int VInfo::handleCommand(int command)
103 {
104   if (dropThrough) return 0;
105
106   switch(command)
107   {
108     case Remote::OK:
109     case Remote::BACK:
110     {
111       if (exitable) return 4;
112     }
113   }
114
115   return 1;
116 }
117
118 void VInfo::okButton()
119 {
120   okbutton = true;
121 }
122
123 void VInfo::processMessage(Message* m)
124 {
125   if (m->message == Message::MOUSE_LBDOWN)
126   {
127     BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
128   }
129 }