]> git.vomp.tv Git - vompclient.git/blob - vinfo.cc
Fix VRecording showing graphic at bottom left when it shouldn't
[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 "input.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   MessageQueue::getInstance()->addReceiver(this);
38 }
39
40 VInfo::~VInfo()
41 {
42   MessageQueue::getInstance()->removeReceiver(this);
43   if (mainText) delete[] mainText;
44 }
45
46 void VInfo::setExitable()
47 {
48   exitable = 1;
49 }
50
51 void VInfo::setDropThrough()
52 {
53   dropThrough = 1;
54 }
55
56 void VInfo::setMainText(const char* takeText)
57 {
58   if (mainText) delete[] mainText;
59   int length = strlen(takeText);
60   mainText = new char[length + 1];
61   strcpy(mainText, takeText);
62   mainTextType = NORMAL;
63 }
64
65 void VInfo::setOneLiner(const char* takeText)
66 {
67   if (mainText) delete[] mainText;
68   int length = strlen(takeText);
69   mainText = new char[length + 1];
70   strcpy(mainText, takeText);
71   mainTextType = ONELINER;
72 }
73
74 void VInfo::draw()
75 {
76   TBBoxx::draw();
77
78   if (mainText)
79   {
80     if (mainTextType == NORMAL)
81     {
82       drawPara(mainText, 10, 45, DrawStyle::LIGHTTEXT);
83     }
84
85     if (mainTextType == ONELINER)
86     {
87       if (titleBarOn) drawTextCentre(mainText, area.w / 2, 75, DrawStyle::LIGHTTEXT);
88       else drawTextCentre(mainText, area.w / 2, 55, DrawStyle::LIGHTTEXT);
89     }
90   }
91 }
92
93 int VInfo::handleCommand(int command)
94 {
95   if (dropThrough) return BoxStack::DROP_THROUGH;
96
97   switch(command)
98   {
99     case Input::OK:
100     case Input::BACK:
101     {
102       if (exitable) return BoxStack::DELETE_ME;
103     }
104   }
105
106   return BoxStack::ABANDON_COMMAND;
107 }
108
109 void VInfo::okButton()
110 {
111   okbutton.setPosition((area.w / 2) - 30, area.h - 50);
112   okbutton.setText(tr("OK"));
113   okbutton.setActive(1);
114   add(&okbutton);
115 }
116
117 void VInfo::processMessage(Message* m)
118 {
119   if (m->message == Message::MOUSE_LBDOWN)
120   {
121     Input::sendInputKey(Input::OK);
122   }
123 }