Go to the documentation of this file. 1 #include <QFontMetrics>
16 #define LOC QString("TeletextScreen: ")
34 for (
int j = 0; j < 14; j++)
40 return QLatin1Char(ch);
46 m_fontStretch(FontStretch)
79 QImage::Format_ARGB32);
98 if (!image || !it.value())
102 image->
Assign(*(it.value()));
103 auto *uiimage =
new MythUIImage(
this, QString(
"ttrow%1").arg(row));
106 uiimage->SetImage(image);
117 visible = visible.united(img->
GetArea());
120 if (visible.isEmpty())
123 QRect bounding = visible.boundingRect();
124 bounding = bounding.translated(
m_safeArea.topLeft());
126 int left =
m_safeArea.left() - bounding.left();
145 static const float kTextPadding = 0.96F;
155 int max_width = (int)((
float)
m_colWidth * kTextPadding);
169 if (font.averageCharWidth() <= max_width ||
m_fontStretch < 50)
291 default:
return "Unknown";
297 LOG(VB_VBI, LOG_DEBUG, QString(
"SetForegroundColor(%1)")
305 LOG(VB_VBI, LOG_DEBUG, QString(
"SetBackgroundColor(%1)")
315 unsigned char last_ch =
' ';
327 unsigned char ch = page[i] & 0x7F;
343 bool seperation =
false;
344 bool conceal =
false;
346 bool doubleheight =
false;
350 bool startbox =
false;
351 bool withinbox =
false;
352 uint flof_link_count = 0;
353 uint old_bgcolor = bgcolor;
357 for (
uint x = 0; x < 8; x++)
365 old_bgcolor = bgcolor;
374 bgcolor = old_bgcolor;
382 unsigned char ch = page[x] & 0x7F;
385 case 0x00:
case 0x01:
case 0x02:
case 0x03:
386 case 0x04:
case 0x05:
case 0x06:
case 0x07:
391 flof_link_count += (row == 25) ? 1 : 0;
407 doubleheight =
false;
413 case 0x10:
case 0x11:
case 0x12:
case 0x13:
414 case 0x14:
case 0x15:
case 0x16:
case 0x17:
452 if ((ch >= 0x80) && (ch <=0x9f))
463 if (flof_link_count && (flof_link_count <= 6))
469 bool has_flof = ttpage->
floflink[flof_link_count - 1] != 0;
470 ch = (has_flof) ? ch :
' ';
474 uint newfgcolor = fgcolor;
475 uint newbgcolor = bgcolor;
479 if ((row != 0) || (x > 7))
490 if ((mosaic) && (ch < 0x40 || ch > 0x5F))
503 Q_UNUSED(seperation);
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);
687 s_initialised =
true;
688 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
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