18#define LOC QString("TeletextScreen: ")
34static constexpr std::array<const std::array<const uint8_t,16>,1+8+8>
lang_chars
36 { 0, 0x23,0x24,0x40,0x5b,0x5c,0x5d,0x5e,0x5f,0x60,0x7b,0x7c,0x7d,0x7e },
40 { 0, 0xa3,0x24,0x40,0xab,0xbd,0xbb,0xac,0x23,0xad,0xbc,0xa6,0xbe,0xf7 },
42 { 0, 0x23,0x24,0xa7,0xc4,0xd6,0xdc,0x5e,0x5f,0xb0,0xe4,0xf6,0xfc,0xdf },
44 { 0, 0x23,0xa4,0xc9,0xc4,0xd6,0xc5,0xdc,0x5f,0xe9,0xe4,0xf6,0xe5,0xfc },
46 { 0, 0xa3,0x24,0xe9,0xb0,0xe7,0xbb,0xac,0x23,0xf9,0xe0,0xf2,0xe8,0xec },
48 { 0, 0xe9,0xef,0xe0,0xeb,0xea,0xf9,0xee,0x23,0xe8,0xe2,0xf4,0xfb,0xe7 },
50 { 0, 0xe7,0x24,0xa1,0xe1,0xe9,0xed,0xf3,0xfa,0xbf,0xfc,0xf1,0xe8,0xe0 },
52 { 0, 0x23,0x75,0x63,0x74,0x7a,0xfd,0xed,0x72,0xe9,0xe1,0x65,0xfa,0x73 },
54 { 0, 0xa3,0x24,0x40,0xab,0xbd,0xbb,0xac,0x23,0xad,0xbc,0xa6,0xbe,0xf7 },
58 { 0, 0x23,0xf1,0xb1,0xaf,0xa6,0xa3,0xe6,0xf3,0xea,0xbf,0xb6,0xb3,0xbc },
60 { 0, 0x23,0x24,0xa7,0xc4,0xd6,0xdc,0x5e,0x5f,0xb0,0xe4,0xf6,0xfc,0xdf },
62 { 0, 0x23,0xf5,0xa9,0xc4,0xd6,0xae,0xdc,0xd5,0xb9,0xe4,0xf6,0xbe,0xfc },
64 { 0, 0x23,0x24,0xa9,0xeb,0xea,0xae,0xe8,0xfc,0xb9,0xb1,0x75,0xbe,0x69 },
66 { 0, 0xe9,0x69,0x61,0xeb,0xec,0x75,0xee,0x23,0x65,0xe2,0xf4,0x75,0xe7 },
68 { 0, 0x23,0xcb,0xc8,0xc6,0xae,0xd0,0xa9,0xeb,0xe8,0xe6,0xae,0xf0,0xb9 },
70 { 0, 0x23,0xf9,0xe8,0xbb,0xbe,0xfd,0xed,0xf8,0xe9,0xe1,0xec,0xfa,0xb9 },
72 { 0, 0x23,0xa2,0xde,0xc2,0xaa,0xc3,0xce,0x69,0xfe,0xe2,0xba,0xe3,0xee },
77 for (
int j = 0; j < 14; j++)
83 return QLatin1Char(ch);
89 m_fontStretch(FontStretch)
109 for (
const auto & img : std::as_const(
m_rowImages))
122 QImage::Format_ARGB32);
141 if (!image || !it.value())
145 image->
Assign(*(it.value()));
146 auto *uiimage =
new MythUIImage(
this, QString(
"ttrow%1").arg(row));
149 uiimage->SetImage(image);
157 visible = visible.united(img->GetArea());
159 if (visible.isEmpty())
162 QRect bounding = visible.boundingRect();
163 bounding = bounding.translated(
m_safeArea.topLeft());
165 int left =
m_safeArea.left() - bounding.left();
170 img->SetArea(
MythRect(img->GetArea().translated(left, top)));
180 static const float kTextPadding = 0.96F;
190 int max_width = (int)((
float)
m_colWidth * kTextPadding);
192 max_width = std::min(max_width,
m_colWidth - 2);
202 if (font.averageCharWidth() <= max_width ||
m_fontStretch < 50)
324 default:
return "Unknown";
330 LOG(VB_VBI, LOG_DEBUG, QString(
"SetForegroundColor(%1)")
338 LOG(VB_VBI, LOG_DEBUG, QString(
"SetBackgroundColor(%1)")
348 unsigned char last_ch =
' ';
360 unsigned char ch = page[i] & 0x7F;
376 [[maybe_unused]]
bool seperation =
false;
377 bool conceal =
false;
378 [[maybe_unused]]
bool flash =
false;
379 bool doubleheight =
false;
380 [[maybe_unused]]
bool blink =
false;
383 bool startbox =
false;
384 bool withinbox =
false;
385 uint flof_link_count = 0;
386 uint old_bgcolor = bgcolor;
390 for (
uint x = 0; x < 8; x++)
398 old_bgcolor = bgcolor;
400 bgcolor = bgcolor & ~kTTColorTransparent;
407 bgcolor = old_bgcolor;
415 unsigned char ch = page[x] & 0x7F;
416 bool reserved =
false;
419 case 0x00:
case 0x01:
case 0x02:
case 0x03:
420 case 0x04:
case 0x05:
case 0x06:
case 0x07:
425 flof_link_count += (row == 25) ? 1 : 0;
441 doubleheight =
false;
447 case 0x10:
case 0x11:
case 0x12:
case 0x13:
448 case 0x14:
case 0x15:
case 0x16:
case 0x17:
481 if ((ch >= 0x80) && (ch <=0x9f))
493 ch = (hold && mosaic && !reserved) ? last_ch :
' ';
496 if (flof_link_count && (flof_link_count <= 6))
502 bool has_flof = ttpage->
floflink[flof_link_count - 1] != 0;
503 ch = (has_flof) ? ch :
' ';
507 uint newfgcolor = fgcolor;
508 uint newbgcolor = bgcolor;
512 if ((row != 0) || (x > 7))
523 if ((mosaic) && (ch < 0x40 || ch > 0x5F))
559 QPainter painter(image);
562 painter.drawText(rect, Qt::AlignCenter, line);
574 QPainter painter(image);
577 painter.drawText(rect, Qt::AlignCenter, line);
603 QBrush bgfill = QBrush(
m_bgColor, Qt::SolidPattern);
604 QPainter painter(image);
605 painter.setBrush(bgfill);
606 painter.setPen(QPen(Qt::NoPen));
607 painter.drawRect(rect);
617 int dx = (int)round((
double)
m_colWidth / 2) + 1;
619 dy = (doubleheight) ? (2 * dy) : dy;
622 DrawRect(row, QRect(x, y + (2*dy), dx, dy));
624 DrawRect(row, QRect(x + dx, y + (2*dy), dx, dy));
628 DrawRect(row, QRect(x + dx, y, dx, dy));
630 DrawRect(row, QRect(x, y + dy, dx, dy));
632 DrawRect(row, QRect(x + dx, y + dy, dx, dy));
641 for (
int i = 0; i < 40; ++i)
653 QString str = QObject::tr(
"Page Not Available",
654 "Requested Teletext page not available");
655 for (
int i = 0; (i < 30) && i < str.length(); i++)
666 for (
int x = 0; x < 11; x++)
675 if (str[x * 3] ==
'*')
692 static bool s_initialised =
false;
709 mythfont->SetFace(newfont);
719 s_initialised =
true;
720 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loaded main subtitle font '%1'")
void SetColor(const QColor &color)
void Assign(const QImage &img)
int DecrRef(void) override
Decrements reference count and deletes on 0.
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...
MythVideoOutput * GetVideoOutput(void)
virtual TeletextReader * GetTeletextReader(uint=0)
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Screen in which all other widgets are contained and rendered.
Image widget, displays a single image or multiple images in sequence.
The base class on which all widgets and screens are based.
virtual void SetArea(const MythRect &rect)
void DeleteAllChildren(void)
Delete all child widgets.
QList< MythUIType * > m_childrenList
QRect GetSafeRect()
Returns a QRect describing an area of the screen on which it is 'safe' to render the On Screen Displa...
static int GetTeletextBackgroundAlpha(void)
static QString GetTeletextFontName(void)
void SetShowHeader(bool show)
bool IsSubtitle(void) const
bool RevealHidden(void) const
void SetHeaderChanged(bool changed)
TeletextSubPage * FindSubPage(void)
void SetPage(int page, int subpage)
tt_line_array GetHeader(void)
void SetSubPage(int subpage)
bool PageChanged(void) const
bool KeyPress(const QString &Key, bool &Exit)
int GetPageInput(uint num) const
void SetIsSubtitle(bool sub)
void SetPageChanged(bool changed)
bool IsTransparent(void) const
void DrawLine(const tt_line_array &page, uint row, int lang)
static void SetForegroundColor(int color)
static const QColor kColorRed
static const QColor kColorMagenta
static const QColor kColorGreen
void SetPage(int page, int subpage)
static bool InitialiseFont()
bool KeyPress(const QString &Key, bool &Exit)
static const QColor kColorBlack
static const int kTeletextRows
void DrawHeader(const tt_line_array &page, int lang)
~TeletextScreen() override
TeletextScreen(MythPlayer *Player, MythPainter *Painter, const QString &Name, int FontStretch)
void Pulse() override
Pulse is called 70 times a second to trigger a single frame of an animation.
void DrawRect(int row, QRect rect)
void OptimiseDisplayedArea()
QHash< int, QImage * > m_rowImages
void DrawMosaic(int x, int y, int code, bool doubleheight)
void SetDisplaying(bool display)
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
void DrawBackground(int x, int y)
void DrawCharacter(int x, int y, QChar ch, bool doubleheight=false)
void SetBackgroundColor(int color)
TeletextReader * m_teletextReader
static const QColor kColorYellow
static const QColor kColorWhite
static const QColor kColorCyan
static const int kTeletextColumns
QImage * GetRowImage(int row, QRect &rect)
static const QColor kColorBlue
int subpagenum
the wanted subpage
std::array< int, 6 > floflink
FastText links (FLOF)
bool subtitle
page is subtitle page
std::array< tt_line_array, 25 > data
page data
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
bool isBlank(unsigned char median, float stddev, unsigned char maxmedian, float maxstddev)
static constexpr uint8_t TP_NEWSFLASH
static constexpr uint8_t TP_SUBTITLE
std::array< uint8_t, 40 > tt_line_array
static constexpr uint8_t TP_SUPPRESS_HEADER
static QString TTColorToString(int ttcolor)
static constexpr std::array< const std::array< const uint8_t, 16 >, 1+8+8 > lang_chars
static MythFontProperties * gTTFont
static QChar cvt_char(char ch, int lang)
static QColor ttcolortoqcolor(int ttcolor)
static int gTTBackgroundAlpha