19#define LOC QString("TeletextScreen: ")
37 for (
int j = 0; j < 14; j++)
43 return QLatin1Char(ch);
49 m_fontStretch(FontStretch)
82 QImage::Format_ARGB32);
103 if (!image || !it.value())
107 image->
Assign(*(it.value()));
108 auto *uiimage =
new MythUIImage(
this, QString(
"ttrow%1").arg(row));
111 uiimage->SetImage(image);
122 visible = visible.united(img->
GetArea());
125 if (visible.isEmpty())
128 QRect bounding = visible.boundingRect();
129 bounding = bounding.translated(
m_safeArea.topLeft());
131 int left =
m_safeArea.left() - bounding.left();
150 static const float kTextPadding = 0.96F;
160 int max_width = (int)((
float)
m_colWidth * kTextPadding);
162 max_width = std::min(max_width,
m_colWidth - 2);
172 if (font.averageCharWidth() <= max_width ||
m_fontStretch < 50)
294 default:
return "Unknown";
300 LOG(VB_VBI, LOG_DEBUG, QString(
"SetForegroundColor(%1)")
308 LOG(VB_VBI, LOG_DEBUG, QString(
"SetBackgroundColor(%1)")
318 unsigned char last_ch =
' ';
330 unsigned char ch = page[i] & 0x7F;
346 [[maybe_unused]]
bool seperation =
false;
347 bool conceal =
false;
348 [[maybe_unused]]
bool flash =
false;
349 bool doubleheight =
false;
350 [[maybe_unused]]
bool blink =
false;
353 bool startbox =
false;
354 bool withinbox =
false;
355 uint flof_link_count = 0;
356 uint old_bgcolor = bgcolor;
360 for (
uint x = 0; x < 8; x++)
368 old_bgcolor = bgcolor;
370 bgcolor = bgcolor & ~kTTColorTransparent;
377 bgcolor = old_bgcolor;
385 unsigned char ch = page[x] & 0x7F;
386 bool reserved =
false;
389 case 0x00:
case 0x01:
case 0x02:
case 0x03:
390 case 0x04:
case 0x05:
case 0x06:
case 0x07:
395 flof_link_count += (row == 25) ? 1 : 0;
411 doubleheight =
false;
417 case 0x10:
case 0x11:
case 0x12:
case 0x13:
418 case 0x14:
case 0x15:
case 0x16:
case 0x17:
451 if ((ch >= 0x80) && (ch <=0x9f))
463 ch = (hold && mosaic && !reserved) ? last_ch :
' ';
466 if (flof_link_count && (flof_link_count <= 6))
472 bool has_flof = ttpage->
floflink[flof_link_count - 1] != 0;
473 ch = (has_flof) ? ch :
' ';
477 uint newfgcolor = fgcolor;
478 uint newbgcolor = bgcolor;
482 if ((row != 0) || (x > 7))
493 if ((mosaic) && (ch < 0x40 || ch > 0x5F))
529 QPainter painter(image);
532 painter.drawText(rect, Qt::AlignCenter, line);
544 QPainter painter(image);
547 painter.drawText(rect, Qt::AlignCenter, line);
573 QBrush bgfill = QBrush(
m_bgColor, Qt::SolidPattern);
574 QPainter painter(image);
575 painter.setBrush(bgfill);
576 painter.setPen(QPen(Qt::NoPen));
577 painter.drawRect(rect);
587 int dx = (int)round((
double)
m_colWidth / 2) + 1;
589 dy = (doubleheight) ? (2 * dy) : dy;
592 DrawRect(row, QRect(x, y + (2*dy), dx, dy));
594 DrawRect(row, QRect(x + dx, y + (2*dy), dx, dy));
598 DrawRect(row, QRect(x + dx, y, dx, dy));
600 DrawRect(row, QRect(x, y + dy, dx, dy));
602 DrawRect(row, QRect(x + dx, y + dy, dx, dy));
611 for (
int i = 0; i < 40; ++i)
623 QString str = QObject::tr(
"Page Not Available",
624 "Requested Teletext page not available");
625 for (
int i = 0; (i < 30) && i < str.length(); i++)
636 for (
int x = 0; x < 11; x++)
645 if (str[x * 3] ==
'*')
662 static bool s_initialised =
false;
679 mythfont->SetFace(newfont);
689 s_initialised =
true;
690 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)
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
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 MythFontProperties * gTTFont
static QChar cvt_char(char ch, int lang)
static QColor ttcolortoqcolor(int ttcolor)
static int gTTBackgroundAlpha
const std::array< const std::array< const uint8_t, 16 >, 1+8+8 > lang_chars