]> git.vomp.tv Git - vompclient-marten.git/blob - vinfo.cc
Fix bug in demuxer widescreen signaling
[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., 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   int length = strlen(takeText);
56   mainText = new char[length + 1];
57   strcpy(mainText, takeText);
58   mainTextType = NORMAL;
59 }
60
61 void VInfo::setOneLiner(const char* takeText)
62 {
63   int length = strlen(takeText);
64   mainText = new char[length + 1];
65   strcpy(mainText, takeText);
66   mainTextType = ONELINER;
67 }
68
69 void VInfo::draw()
70 {
71   TBBoxx::draw();
72
73   if (mainText)
74   {
75     if (mainTextType == NORMAL)
76     {
77       drawPara(mainText, 10, 45, DrawStyle::LIGHTTEXT);
78     }
79
80     if (mainTextType == ONELINER)
81     {
82       if (titleBarOn) drawTextCentre(mainText, area.w / 2, 75, DrawStyle::LIGHTTEXT);
83       else drawTextCentre(mainText, area.w / 2, 55, DrawStyle::LIGHTTEXT);
84     }
85   }
86 }
87
88 int VInfo::handleCommand(int command)
89 {
90   if (dropThrough) return 0;
91
92   switch(command)
93   {
94     case Remote::OK:
95     case Remote::BACK:
96     {
97       if (exitable) return 4;
98     }
99   }
100
101   return 1;
102 }
103
104 void VInfo::okButton()
105 {
106   okbutton.setPosition((area.w / 2) - 30, area.h - 50);
107   okbutton.setText(tr("OK"));
108   okbutton.setActive(1);
109   add(&okbutton);
110 }
111
112 void VInfo::processMessage(Message* m)
113 {
114   if (m->message == Message::MOUSE_LBDOWN)
115   {
116     BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press
117   }
118 }