-
Notifications
You must be signed in to change notification settings - Fork 345
/
teletextscreen.h
191 lines (167 loc) · 5.89 KB
/
teletextscreen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#ifndef TELETEXTSCREEN_H
#define TELETEXTSCREEN_H
#include <QFont>
#include "mythscreentype.h"
#include "teletextdecoder.h"
#include "mythplayer.h"
typedef enum
{
kTTColorBlack = 0,
kTTColorRed = 1,
kTTColorGreen = 2,
kTTColorYellow = 3,
kTTColorBlue = 4,
kTTColorMagenta = 5,
kTTColorCyan = 6,
kTTColorWhite = 7,
kTTColorTransparent = 8,
} TTColor;
class TTKey
{
public:
static const uint k0 = 0;
static const uint k1 = 1;
static const uint k2 = 2;
static const uint k3 = 3;
static const uint k4 = 4;
static const uint k5 = 5;
static const uint k6 = 6;
static const uint k7 = 7;
static const uint k8 = 8;
static const uint k9 = 9;
static const uint kNextPage = 10;
static const uint kPrevPage = 11;
static const uint kNextSubPage = 12;
static const uint kPrevSubPage = 13;
static const uint kHold = 14;
static const uint kTransparent = 15;
static const uint kFlofRed = 16;
static const uint kFlofGreen = 17;
static const uint kFlofYellow = 18;
static const uint kFlofBlue = 19;
static const uint kFlofWhite = 20;
static const uint kRevealHidden = 21;
};
#define TP_SUPPRESS_HEADER 0x01
#define TP_UPDATE_INDICATOR 0x02
#define TP_INTERRUPTED_SEQ 0x04
#define TP_INHIBIT_DISPLAY 0x08
#define TP_MAGAZINE_SERIAL 0x10
#define TP_ERASE_PAGE 0x20
#define TP_NEWSFLASH 0x40
#define TP_SUBTITLE 0x80
class TeletextSubPage
{
public:
int pagenum; ///< the wanted page
int subpagenum; ///< the wanted subpage
int lang; ///< language code
int flags; ///< misc flags
uint8_t data[25][40]; ///< page data
int flof; ///< page has FastText links
int floflink[6]; ///< FastText links (FLOF)
bool subtitle; ///< page is subtitle page
bool active; ///< data has arrived since page last cleared
};
typedef map<int, TeletextSubPage> int_to_subpage_t;
class TeletextPage
{
public:
int pagenum;
int current_subpage;
int_to_subpage_t subpages;
};
typedef map<int, TeletextPage> int_to_page_t;
class TeletextMagazine
{
public:
mutable QMutex lock;
int current_page;
int current_subpage;
TeletextSubPage loadingpage;
int_to_page_t pages;
};
class TeletextScreen: public MythScreenType, public TeletextViewer
{
static bool InitialiseFont(void);
public:
TeletextScreen(MythPlayer *player, const char * name, int fontStretch);
virtual ~TeletextScreen();
// MythScreenType methods
virtual bool Create(void);
virtual void Pulse(void);
// TeletextViewer interface methods
virtual void KeyPress(uint key);
virtual void SetPage(int page, int subpage);
virtual void SetDisplaying(bool display);
virtual void Reset(void);
virtual void AddPageHeader(int page, int subpage, const uint8_t *buf,
int vbimode, int lang, int flags);
virtual void AddTeletextData(int magazine, int row,
const uint8_t* buf, int vbimode);
private:
void CleanUp();
void OptimiseDisplayedArea(void);
QImage* GetRowImage(int row, QRect &rect);
void SetForegroundColor(int color);
void SetBackgroundColor(int color);
void DrawBackground(int x, int y);
void DrawRect(int row, const QRect);
void DrawCharacter(int x, int y, QChar ch, int doubleheight = 0);
void DrawMosaic(int x, int y, int code, int doubleheight);
void DrawLine(const uint8_t *page, uint row, int lang);
void DrawHeader(const uint8_t *page, int lang);
void DrawStatus(void);
void DrawPage(void);
void NewsFlash(void) {};
void PageUpdated(int page, int subpage);
void HeaderUpdated(uint8_t *page, int lang);
const TeletextSubPage *FindSubPage(int page, int subpage, int dir=0) const
{ return FindSubPageInternal(page, subpage, dir); }
TeletextSubPage *FindSubPage(int page, int subpage, int dir = 0)
{ return (TeletextSubPage*) FindSubPageInternal(page, subpage, dir); }
const TeletextPage *FindPage(int page, int dir = 0) const
{ return (TeletextPage*) FindPageInternal(page, dir); }
TeletextPage *FindPage(int page, int dir = 0)
{ return (TeletextPage*) FindPageInternal(page, dir); }
const TeletextSubPage *FindSubPageInternal(int,int,int) const;
const TeletextPage *FindPageInternal(int,int) const;
MythPlayer *m_player;
QRect m_safeArea;
int m_colWidth;
int m_rowHeight;
QMutex m_lock;
int m_fetchpage;
int m_fetchsubpage;
QColor m_bgColor;
// currently displayed page:
mutable int m_curpage;
mutable int m_cursubpage;
mutable bool m_curpage_showheader;
mutable bool m_curpage_issubtitle;
int m_pageinput[3];
bool m_transparent;
bool m_revealHidden;
bool m_displaying;
uint8_t m_header[40];
mutable bool m_header_changed;
mutable bool m_page_changed;
TeletextMagazine m_magazines[8];
unsigned char m_bitswap[256];
QHash<int, QImage*> m_rowImages;
int m_fontStretch;
int m_fontHeight;
public:
static const QColor kColorBlack;
static const QColor kColorRed;
static const QColor kColorGreen;
static const QColor kColorYellow;
static const QColor kColorBlue;
static const QColor kColorMagenta;
static const QColor kColorCyan;
static const QColor kColorWhite;
static const QColor kColorTransp;
static const int kTeletextColumns;
static const int kTeletextRows;
};
#endif // TELETEXTSCREEN_H