]> git.vomp.tv Git - vompclient.git/blob - vchannelselect.cc
Un-hardcoded all the colours
[vompclient.git] / vchannelselect.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 "vchannelselect.h"
22
23 // this class only works as it does because the remote command
24 // values for the numbers are the numbers themselves !
25
26 VChannelSelect::VChannelSelect(VVideoLive* v, int command)
27 {
28   setDimensions(30, 53);
29   setScreenPos(80, 60);
30
31   setBackgroundColour(Colour::VIEWBACKGROUND);
32
33   first = -1;
34   second = -1;
35   third = command;
36   pos = 0;
37
38   videoLive = v;
39 }
40
41 void VChannelSelect::draw()
42 {
43   View::draw();
44
45   // draw numbers
46
47   char text[2];
48
49   switch(first)
50   {
51     case 0 ... 9:
52     {
53       sprintf(text, "%i", first);
54       drawText(text, 7, 5, Colour::LIGHTTEXT);
55       break;
56     }
57     case -1:
58     {
59       drawText("_", 7, 5, Colour::LIGHTTEXT);
60       break;
61     }
62   }
63
64   switch(second)
65   {
66     case 0 ... 9:
67     {
68       sprintf(text, "%i", second);
69       drawText(text, 20, 5, Colour::LIGHTTEXT);
70       break;
71     }
72     case -1:
73     {
74       drawText("_", 20, 5, Colour::LIGHTTEXT);
75       break;
76     }
77   }
78
79   switch(third)
80   {
81     case 0 ... 9:
82     {
83       sprintf(text, "%i", third);
84       drawText(text, 33, 5, Colour::LIGHTTEXT);
85       break;
86     }
87     case -1:
88     {
89       drawText("_", 33, 5, Colour::LIGHTTEXT);
90       break;
91     }
92   }
93 }
94
95 int VChannelSelect::handleCommand(int command)
96 {
97   switch(command)
98   {
99     case Remote::ZERO ... Remote::NINE:
100     {
101       if (pos == 1) first = second;
102       second = third;
103       third = command;
104       draw();
105       show();
106       if (pos == 1)
107       {
108         Message* m = new Message();
109         m->from = this;
110         m->to = ViewMan::getInstance();
111         m->message = Message::CLOSE_ME;
112         ViewMan::getInstance()->postMessage(m);
113
114         m = new Message();
115         m->from = this;
116         m->to = videoLive;
117         m->message = Message::CHANNEL_CHANGE;
118         m->parameter = (first * 100) + (second * 10) + third;
119         ViewMan::getInstance()->postMessage(m);
120       }
121       pos = 1;
122
123       return 2;
124     }
125   }
126
127   // allow command to drop through to other views
128   return 0;
129 }