Go to the documentation of this file.
3 #include <QFontMetrics>
18 #define LOC QString("TeletextScreen: ")
36 for (
int j = 0; j < 14; j++)
42 return QLatin1Char(ch);
48 m_fontStretch(FontStretch)
81 QImage::Format_ARGB32);
102 if (!image || !it.value())
106 image->
Assign(*(it.value()));
107 auto *uiimage =
new MythUIImage(
this, QString(
"ttrow%1").arg(row));
110 uiimage->SetImage(image);
121 visible = visible.united(img->
GetArea());
124 if (visible.isEmpty())
127 QRect bounding = visible.boundingRect();
128 bounding = bounding.translated(
m_safeArea.topLeft());
130 int left =
m_safeArea.left() - bounding.left();
149 static const float kTextPadding = 0.96F;
159 int max_width = (int)((
float)
m_colWidth * kTextPadding);
161 max_width = std::min(max_width,
m_colWidth - 2);
171 if (font.averageCharWidth() <= max_width ||
m_fontStretch < 50)
293 default:
return "Unknown";
299 LOG(VB_VBI, LOG_DEBUG, QString(
"SetForegroundColor(%1)")
307 LOG(VB_VBI, LOG_DEBUG, QString(
"SetBackgroundColor(%1)")
317 unsigned char last_ch =
' ';
329 unsigned char ch = page[i] & 0x7F;
345 [[maybe_unused]]
bool seperation =
false;
346 bool conceal =
false;
347 [[maybe_unused]]
bool flash =
false;
348 bool doubleheight =
false;
349 [[maybe_unused]]
bool blink =
false;
352 bool startbox =
false;
353 bool withinbox =
false;
354 uint flof_link_count = 0;
355 uint old_bgcolor = bgcolor;
359 for (
uint x = 0; x < 8; x++)
367 old_bgcolor = bgcolor;
376 bgcolor = old_bgcolor;
384 unsigned char ch = page[x] & 0x7F;
387 case 0x00:
case 0x01:
case 0x02:
case 0x03:
388 case 0x04:
case 0x05:
case 0x06:
case 0x07:
393 flof_link_count += (row == 25) ? 1 : 0;
409 doubleheight =
false;
415 case 0x10:
case 0x11:
case 0x12:
case 0x13:
416 case 0x14:
case 0x15:
case 0x16:
case 0x17:
454 if ((ch >= 0x80) && (ch <=0x9f))
465 if (flof_link_count && (flof_link_count <= 6))
471 bool has_flof = ttpage->
floflink[flof_link_count - 1] != 0;
472 ch = (has_flof) ? ch :
' ';
476 uint newfgcolor = fgcolor;
477 uint newbgcolor = bgcolor;
481 if ((row != 0) || (x > 7))
492 if ((mosaic) && (ch < 0x40 || ch > 0x5F))
528 QPainter painter(image);
531 painter.drawText(rect, Qt::AlignCenter, line);
543 QPainter painter(image);
546 painter.drawText(rect, Qt::AlignCenter, line);
572 QBrush bgfill = QBrush(
m_bgColor, Qt::SolidPattern);
573 QPainter painter(image);
574 painter.setBrush(bgfill);
575 painter.setPen(QPen(Qt::NoPen));
576 painter.drawRect(rect);
586 int dx = (int)round((
double)
m_colWidth / 2) + 1;
588 dy = (doubleheight) ? (2 * dy) : dy;
591 DrawRect(row, QRect(x, y + (2*dy), dx, dy));
593 DrawRect(row, QRect(x + dx, y + (2*dy), dx, dy));
597 DrawRect(row, QRect(x + dx, y, dx, dy));
599 DrawRect(row, QRect(x, y + dy, dx, dy));
601 DrawRect(row, QRect(x + dx, y + dy, dx, dy));
610 for (
int i = 0; i < 40; ++i)
622 QString str = QObject::tr(
"Page Not Available",
623 "Requested Teletext page not available");
624 for (
int i = 0; (i < 30) && i < str.length(); i++)
635 for (
int x = 0; x < 11; x++)
644 if (str[x * 3] ==
'*')
661 static bool s_initialised =
false;
678 mythfont->SetFace(newfont);
688 s_initialised =
true;
689 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loaded main subtitle font '%1'")
virtual TeletextReader * GetTeletextReader(uint=0)
void SetHeaderChanged(bool changed)
void SetDisplaying(bool display)
bool IsSubtitle(void) const
MythVideoOutput * GetVideoOutput(void)
bool IsTransparent(void) const
Image widget, displays a single image or multiple images in sequence.
void DrawCharacter(int x, int y, QChar ch, bool doubleheight=false)
bool KeyPress(const QString &Key, bool &Exit)
std::array< int, 6 > floflink
FastText links (FLOF)
static const QColor kColorWhite
static int GetTeletextBackgroundAlpha(void)
void SetPage(int page, int subpage)
static int gTTBackgroundAlpha
static const int kTeletextColumns
void DrawMosaic(int x, int y, int code, bool doubleheight)
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...
void Pulse() override
Pulse is called 70 times a second to trigger a single frame of an animation.
static const QColor kColorRed
const std::array< const std::array< const uint8_t, 16 >, 1+8+8 > lang_chars
static const int kTeletextRows
bool subtitle
page is subtitle page
virtual void SetArea(const MythRect &rect)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Screen in which all other widgets are contained and rendered.
void SetColor(const QColor &color)
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
void DeleteAllChildren(void)
Delete all child widgets.
void SetBackgroundColor(int color)
QHash< int, QImage * > m_rowImages
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
static QString TTColorToString(int ttcolor)
static constexpr uint8_t TP_NEWSFLASH
static const QColor kColorCyan
bool PageChanged(void) const
static QString GetTeletextFontName(void)
void SetShowHeader(bool show)
static void SetForegroundColor(int color)
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
std::array< uint8_t, 40 > tt_line_array
void SetPage(int page, int subpage)
~TeletextScreen() override
void OptimiseDisplayedArea()
int DecrRef(void) override
Decrements reference count and deletes on 0.
QList< MythUIType * > m_childrenList
bool RevealHidden(void) const
void DrawHeader(const tt_line_array &page, int lang)
void SetIsSubtitle(bool sub)
The base class on which all widgets and screens are based.
static QColor ttcolortoqcolor(int ttcolor)
bool KeyPress(const QString &Key, bool &Exit)
void SetPageChanged(bool changed)
static MythFontProperties * gTTFont
static const QColor kColorGreen
bool isBlank(unsigned char median, float stddev, unsigned char maxmedian, float maxstddev)
static QChar cvt_char(char ch, int lang)
static constexpr uint8_t TP_SUPPRESS_HEADER
void DrawRect(int row, QRect rect)
QRect GetSafeRect()
Returns a QRect describing an area of the screen on which it is 'safe' to render the On Screen Displa...
TeletextSubPage * FindSubPage(void)
void DrawBackground(int x, int y)
static const QColor kColorBlue
static constexpr uint8_t TP_SUBTITLE
static const QColor kColorMagenta
static bool InitialiseFont()
TeletextScreen(MythPlayer *Player, MythPainter *Painter, const QString &Name, int FontStretch)
int subpagenum
the wanted subpage
TeletextReader * m_teletextReader
QImage * GetRowImage(int row, QRect &rect)
void Assign(const QImage &img)
void SetSubPage(int subpage)
void DrawLine(const tt_line_array &page, uint row, int lang)
static const QColor kColorBlack
static const QColor kColorYellow
int GetPageInput(uint num) const
tt_line_array GetHeader(void)
std::array< tt_line_array, 25 > data
page data