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
54 VTeletextView::~VTeletextView()
56 LogNT::getInstance()->debug("VTeletextView", "destruct");
58 BoxStack::getInstance()->update(pv);
59 ttdecoder->unRegisterTeletextView(this);
62 void VTeletextView::draw(bool completedraw, bool onlyfirstline)
64 LogNT::getInstance()->error("VTeletextView", "Start draw");
68 Boxx* drawtarget = NULL;
70 for (y = 0; y < 25; y++)
81 ox = this->getScreenX();
82 oy = this->getScreenY();
85 for (x = 0; x < 40; x++)
87 if (ttdecoder->isDirty(x, y) || completedraw)
89 cTeletextChar c = ttdecoder->getChar(x, y);
91 //Skip Blinking and conceal
92 drawtarget->drawTTChar(ox, oy, x, y, c);
93 ttdecoder->setChar(x, y, c);
96 // LogNT::getInstance()->error("VTeletextView", "Line {}", y);
97 if (onlyfirstline) break;
99 // LogNT::getInstance()->error("VTeletextView", "Start end");
102 int VTeletextView::handleCommand(int command)
104 if (subtitlemode) return BoxStack::DROP_THROUGH; //Ok we are in subtitle mode, we are a slave of the player
108 return BoxStack::COMMAND_HANDLED;
110 if(player) player->tellSubtitlesOSDVisible(false); // Only on liveTV
111 return BoxStack::DELETE_ME;
123 // key in teletext page
125 return BoxStack::COMMAND_HANDLED;
129 return BoxStack::DROP_THROUGH;
132 void VTeletextView::doKey(int command)
137 if (command == 9) return; //not allowed
139 pagenums[0] = static_cast<char>(command + 48);
144 else if (keyindigit == 2)
146 page |= command << 4;
147 pagenums[0] = static_cast<char>(48 + ((page & 0xF00) >> 8));
148 pagenums[1] = static_cast<char>(command + 48);
152 else if (keyindigit == 3)
155 pagenums[0] = static_cast<char>(48 + ((page & 0xF00) >> 8));
156 pagenums[1] = static_cast<char>(48 + ((page & 0x0F0) >> 4));
157 pagenums[2] = static_cast<char>(48 + command);
159 ttdecoder->setPage(page);
162 ttdecoder->setKeyinDigits(pagenums, true);
164 toupdate.w = 16 * 40;
165 if (Video::getInstance()->getFormat() == Video::PAL)
177 BoxStack::getInstance()->update(this, &toupdate);
180 void VTeletextView::processMessage(Message* m)
182 if (m->message == Message::TELETEXTUPDATE)
185 BoxStack::getInstance()->update(this);
186 BoxStack::getInstance()->update(pv);
188 else if (m->message == Message::TELETEXTUPDATEFIRSTLINE)
191 toupdate.w = 16 * 40;
192 if (Video::getInstance()->getFormat() == Video::PAL)
204 BoxStack::getInstance()->update(this, &toupdate);