2 Copyright 2005-2020 Chris Tallon, Marten Richter
4 This file is part of VOMP.
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
26 #include "playervideolive.h"
28 #include "vteletextview.h"
30 VTeletextView::VTeletextView(TeletextDecoderVBIEBU* TTdecoder, Boxx* playerview, PlayerVideoLive* playerObj)
32 ttdecoder = TTdecoder;
36 if (Video::getInstance()->getFormat() == Video::PAL)
39 setSize(680,22); //Only first line
46 setSize(680,18);//only first line
53 MessageQueue::getInstance()->addReceiver(this);
56 VTeletextView::~VTeletextView()
58 MessageQueue::getInstance()->removeReceiver(this);
59 LogNT::getInstance()->debug("VTeletextView", "destruct");
61 BoxStack::getInstance()->update(pv);
62 ttdecoder->unRegisterTeletextView(this);
65 void VTeletextView::draw(bool completedraw, bool onlyfirstline)
67 LogNT::getInstance()->error("VTeletextView", "Start draw");
71 Boxx* drawtarget = NULL;
73 for (y = 0; y < 25; y++)
84 ox = this->getScreenX();
85 oy = this->getScreenY();
88 for (x = 0; x < 40; x++)
90 if (ttdecoder->isDirty(x, y) || completedraw)
92 cTeletextChar c = ttdecoder->getChar(x, y);
94 //Skip Blinking and conceal
95 drawtarget->drawTTChar(ox, oy, x, y, c);
96 ttdecoder->setChar(x, y, c);
99 // LogNT::getInstance()->error("VTeletextView", "Line {}", y);
100 if (onlyfirstline) break;
102 // LogNT::getInstance()->error("VTeletextView", "Start end");
105 int VTeletextView::handleCommand(int command)
107 if (subtitlemode) return BoxStack::DROP_THROUGH; //Ok we are in subtitle mode, we are a slave of the player
111 return BoxStack::COMMAND_HANDLED;
113 if(player) player->tellSubtitlesOSDVisible(false); // Only on liveTV
114 return BoxStack::DELETE_ME;
126 // key in teletext page
128 return BoxStack::COMMAND_HANDLED;
132 return BoxStack::DROP_THROUGH;
135 void VTeletextView::doKey(int command)
140 if (command == 9) return; //not allowed
142 pagenums[0] = static_cast<char>(command + 48);
147 else if (keyindigit == 2)
149 page |= command << 4;
150 pagenums[0] = static_cast<char>(48 + ((page & 0xF00) >> 8));
151 pagenums[1] = static_cast<char>(command + 48);
155 else if (keyindigit == 3)
158 pagenums[0] = static_cast<char>(48 + ((page & 0xF00) >> 8));
159 pagenums[1] = static_cast<char>(48 + ((page & 0x0F0) >> 4));
160 pagenums[2] = static_cast<char>(48 + command);
162 ttdecoder->setPage(page);
165 ttdecoder->setKeyinDigits(pagenums, true);
167 toupdate.w = 16 * 40;
168 if (Video::getInstance()->getFormat() == Video::PAL)
180 BoxStack::getInstance()->update(this, &toupdate);
183 void VTeletextView::processMessage(Message* m)
185 if (m->message == Message::TELETEXTUPDATE)
188 BoxStack::getInstance()->update(this);
189 BoxStack::getInstance()->update(pv);
191 else if (m->message == Message::TELETEXTUPDATEFIRSTLINE)
194 toupdate.w = 16 * 40;
195 if (Video::getInstance()->getFormat() == Video::PAL)
207 BoxStack::getInstance()->update(this, &toupdate);