MythTV  master
cc708window.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 // Copyright (c) 2003-2005, Daniel Kristjansson
3 
4 #ifndef _CC708_WINDOW_
5 #define _CC708_WINDOW_
6 
7 #include <vector>
8 using namespace std;
9 
10 #include <QString>
11 #include <QMutex>
12 #include <QColor>
13 
14 #include "mythtvexp.h"
15 
16 extern const uint k708JustifyLeft;
17 extern const uint k708JustifyRight;
18 extern const uint k708JustifyCenter;
19 extern const uint k708JustifyFull;
20 
21 extern const uint k708EffectSnap;
22 extern const uint k708EffectFade;
23 extern const uint k708EffectWipe;
24 
25 extern const uint k708BorderNone;
26 extern const uint k708BorderRaised;
27 extern const uint k708BorderDepressed;
28 extern const uint k708BorderUniform;
29 extern const uint k708BorderShadowLeft;
30 extern const uint k708BorderShadowRight;
31 
32 extern const uint k708DirLeftToRight;
33 extern const uint k708DirRightToLeft;
34 extern const uint k708DirTopToBottom;
35 extern const uint k708DirBottomToTop;
36 
37 extern const uint k708AttrSizeSmall;
38 extern const uint k708AttrSizeStandard;
39 extern const uint k708AttrSizeLarge;
40 
41 extern const uint k708AttrOffsetSubscript;
42 extern const uint k708AttrOffsetNormal;
43 extern const uint k708AttrOffsetSuperscript;
44 
45 extern const uint k708AttrFontDefault;
50 extern const uint k708AttrFontCasual;
51 extern const uint k708AttrFontCursive;
52 extern const uint k708AttrFontSmallCaps;
53 
54 extern const uint k708AttrEdgeNone;
55 extern const uint k708AttrEdgeRaised;
56 extern const uint k708AttrEdgeDepressed;
57 extern const uint k708AttrEdgeUniform;
58 extern const uint k708AttrEdgeLeftDropShadow;
60 
61 extern const uint k708AttrColorBlack;
62 extern const uint k708AttrColorWhite;
63 
64 extern const uint k708AttrOpacitySolid;
65 extern const uint k708AttrOpacityFlash;
66 extern const uint k708AttrOpacityTranslucent;
67 extern const uint k708AttrOpacityTransparent;
68 
69 const int k708MaxWindows = 8;
70 const int k708MaxRows = 16; // 4-bit field in DefineWindow
71 const int k708MaxColumns = 64; // 6-bit field in DefineWindow
72 
74 {
75  public:
84 
90 
91  QColor actual_fg_color; // if !isValid(), then convert fg_color
92 
93  CC708CharacterAttribute(bool isItalic = false,
94  bool isBold = false,
95  bool isUnderline = false,
96  QColor fgColor = QColor()) :
97  pen_size(k708AttrSizeStandard),
98  offset(k708AttrOffsetNormal),
99  text_tag(0), // "dialog", ignored
100  font_tag(0), // system font
101  edge_type(k708AttrEdgeNone),
102  underline(isUnderline),
103  italics(isItalic),
104  boldface(isBold),
105  fg_color(k708AttrColorWhite), // will be overridden
106  fg_opacity(k708AttrOpacitySolid), // solid
107  bg_color(k708AttrColorBlack),
108  bg_opacity(k708AttrOpacitySolid),
109  edge_color(k708AttrColorBlack),
110  actual_fg_color(fgColor)
111  {
112  }
113 
114  static QColor ConvertToQColor(uint eia708color);
115  QColor GetFGColor(void) const
116  {
117  QColor fg = (actual_fg_color.isValid() ?
118  actual_fg_color : ConvertToQColor(fg_color));
119  fg.setAlpha(GetFGAlpha());
120  return fg;
121  }
122  QColor GetBGColor(void) const
123  {
124  QColor bg = ConvertToQColor(bg_color);
125  bg.setAlpha(GetBGAlpha());
126  return bg;
127  }
128  QColor GetEdgeColor(void) const { return ConvertToQColor(edge_color); }
129 
130  uint GetFGAlpha(void) const
131  {
132  //SOLID=0, FLASH=1, TRANSLUCENT=2, and TRANSPARENT=3.
133  static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
134  return alpha[fg_opacity & 0x3];
135  }
136 
137  uint GetBGAlpha(void) const
138  {
139  //SOLID=0, FLASH=1, TRANSLUCENT=2, and TRANSPARENT=3.
140  static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
141  return alpha[bg_opacity & 0x3];
142  }
143 
144  bool operator==(const CC708CharacterAttribute &other) const;
145  bool operator!=(const CC708CharacterAttribute &other) const
146  { return !(*this == other); }
147 };
148 
149 class CC708Pen
150 {
151  public:
152  CC708Pen() : row(0), column(0) {}
153  void SetPenStyle(uint style);
154  void SetAttributes(int pen_size,
155  int offset, int text_tag, int font_tag,
156  int edge_type, int underline, int italics)
157  {
158  attr.pen_size = pen_size;
159  attr.offset = offset;
160  attr.text_tag = text_tag;
161  attr.font_tag = font_tag;
162  attr.edge_type = edge_type;
163  attr.underline = underline;
164  attr.italics = italics;
165  attr.boldface = 0;
166  }
167  public:
169 
172 };
173 
174 class CC708Window;
176 {
177  public:
178  CC708Character() : character(' ') {}
179  explicit CC708Character(const CC708Window &win);
181  QChar character;
182 };
183 
185 {
186  public:
189  QString str;
191 };
192 
194 {
195  public:
196  CC708Window();
197  ~CC708Window();
198 
199  void DefineWindow(int priority, int visible,
200  int anchor_point, int relative_pos,
201  int anchor_vertical, int anchor_horizontal,
202  int row_count, int column_count,
203  int row_lock, int column_lock,
204  int pen_style, int window_style);
205  void Resize(uint new_rows, uint new_columns);
206  void Clear(void);
207  void SetWindowStyle(uint);
208 
209  void AddChar(QChar);
210  void IncrPenLocation(void);
211  void DecrPenLocation(void);
212  void SetPenLocation(uint, uint);
213  void LimitPenLocation(void);
214 
215  bool IsPenValid(void) const
216  {
217  return ((pen.row < true_row_count) &&
218  (pen.column < true_column_count));
219  }
220  CC708Character &GetCCChar(void) const;
221  vector<CC708String*> GetStrings(void) const;
222  void DisposeStrings(vector<CC708String*> &strings) const;
223  QColor GetFillColor(void) const
224  {
225  QColor fill = CC708CharacterAttribute::ConvertToQColor(fill_color);
226  fill.setAlpha(GetFillAlpha());
227  return fill;
228  }
229  uint GetFillAlpha(void) const
230  {
231  //SOLID=0, FLASH=1, TRANSLUCENT=2, and TRANSPARENT=3.
232  static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
233  return alpha[fill_opacity & 0x3];
234  }
235 
236  private:
237  void Scroll(int row, int col);
238 
239  public:
241  private:
242  bool m_visible;
243  public:
244  enum {
245  kAnchorUpperLeft = 0, kAnchorUpperCenter, kAnchorUpperRight,
246  kAnchorCenterLeft = 3, kAnchorCenter, kAnchorCenterRight,
247  kAnchorLowerLeft = 6, kAnchorLowerCenter, kAnchorLowerRight,
248  };
259 
271 
272  // These are akin to the capacity of a vector, which is always >=
273  // the current size.
276 
279 
280  private:
282  bool m_exists;
283  bool m_changed;
284 
285  public:
286  bool GetExists(void) const { return m_exists; }
287  bool GetVisible(void) const { return m_visible; }
288  bool GetChanged(void) const { return m_changed; }
289  void SetExists(bool value)
290  {
291  if (m_exists != value)
292  SetChanged();
293  m_exists = value;
294  }
295  void SetVisible(bool value)
296  {
297  if (m_visible != value)
298  SetChanged();
299  m_visible = value;
300  }
301  void SetChanged(void)
302  {
303  m_changed = true;
304  }
305  void ResetChanged(void)
306  {
307  m_changed = false;
308  }
309  mutable QMutex lock;
310 };
311 
313 {
314  public:
315  CC708Service() { current_window = 0; }
316 
317  public:
320 };
321 
322 #endif // _CC708_WINDOW_
void SetVisible(bool value)
Definition: cc708window.h:295
bool operator!=(const CC708CharacterAttribute &other) const
Definition: cc708window.h:145
const uint k708AttrOffsetSubscript
Definition: cc708window.cpp:81
const uint k708AttrOpacitySolid
uint row
Definition: cc708window.h:170
uint true_column_count
Definition: cc708window.h:275
uint fill_opacity
Definition: cc708window.h:261
const uint k708AttrFontMonospacedSansSerif
Definition: cc708window.cpp:88
QMutex lock
Definition: cc708window.h:309
uint true_row_count
Definition: cc708window.h:274
uint column_count
Definition: cc708window.h:254
uint effect_speed
Definition: cc708window.h:268
const uint k708AttrEdgeRaised
Definition: cc708window.cpp:95
const uint k708AttrFontProportionalSerif
Definition: cc708window.cpp:87
const uint k708AttrEdgeNone
Definition: cc708window.cpp:94
QColor GetEdgeColor(void) const
Definition: cc708window.h:128
const uint k708JustifyRight
Definition: cc708window.cpp:57
uint display_effect
Definition: cc708window.h:267
const uint k708AttrSizeSmall
Definition: cc708window.cpp:77
uint anchor_horizontal
Definition: cc708window.h:252
uint anchor_point
Definition: cc708window.h:249
const int k708MaxRows
Definition: cc708window.h:70
uint border_type
Definition: cc708window.h:263
unsigned int uint
Definition: compat.h:140
CC708CharacterAttribute(bool isItalic=false, bool isBold=false, bool isUnderline=false, QColor fgColor=QColor())
Definition: cc708window.h:93
const uint k708DirRightToLeft
Definition: cc708window.cpp:73
const uint k708AttrColorWhite
void SetAttributes(int pen_size, int offset, int text_tag, int font_tag, int edge_type, int underline, int italics)
Definition: cc708window.h:154
bool m_changed
Definition: cc708window.h:283
uint relative_pos
Definition: cc708window.h:250
const uint k708EffectWipe
Definition: cc708window.cpp:63
const uint k708EffectSnap
Definition: cc708window.cpp:61
const uint k708AttrFontDefault
Definition: cc708window.cpp:85
const uint k708AttrFontSmallCaps
Definition: cc708window.cpp:92
void SetExists(bool value)
Definition: cc708window.h:289
const uint k708AttrEdgeUniform
Definition: cc708window.cpp:97
const uint k708BorderUniform
Definition: cc708window.cpp:68
CC708Pen pen
Definition: cc708window.h:278
uint scroll_dir
Definition: cc708window.h:264
#define MTV_PUBLIC
Definition: mythtvexp.h:15
const uint k708AttrSizeLarge
Definition: cc708window.cpp:79
const uint k708AttrOffsetSuperscript
Definition: cc708window.cpp:83
const uint k708BorderDepressed
Definition: cc708window.cpp:67
bool m_visible
Definition: cc708window.h:242
const uint k708DirLeftToRight
Definition: cc708window.cpp:72
const uint k708DirTopToBottom
Definition: cc708window.cpp:74
uint current_window
Definition: cc708window.h:318
QString str
Definition: cc708window.h:189
const uint k708BorderShadowRight
Definition: cc708window.cpp:70
bool GetVisible(void) const
Definition: cc708window.h:287
uint pen_style
Definition: cc708window.h:257
const uint k708AttrFontCursive
Definition: cc708window.cpp:91
uint fill_color
Definition: cc708window.h:260
uint GetFGAlpha(void) const
Definition: cc708window.h:130
static QColor ConvertToQColor(uint eia708color)
uint column_lock
Definition: cc708window.h:256
const uint k708BorderNone
Definition: cc708window.cpp:65
QColor GetFGColor(void) const
Definition: cc708window.h:115
CC708CharacterAttribute attr
Definition: cc708window.h:190
const uint k708AttrOpacityFlash
void SetChanged(void)
Definition: cc708window.h:301
bool GetChanged(void) const
Definition: cc708window.h:288
uint effect_dir
Definition: cc708window.h:266
uint GetBGAlpha(void) const
Definition: cc708window.h:137
const uint k708AttrFontCasual
Definition: cc708window.cpp:90
uint row_count
Definition: cc708window.h:253
const int k708MaxColumns
Definition: cc708window.h:71
const uint k708EffectFade
Definition: cc708window.cpp:62
const uint k708JustifyCenter
Definition: cc708window.cpp:58
const uint k708BorderShadowLeft
Definition: cc708window.cpp:69
CC708CharacterAttribute attr
Definition: cc708window.h:168
const uint k708BorderRaised
Definition: cc708window.cpp:66
const uint k708AttrOffsetNormal
Definition: cc708window.cpp:82
bool operator==(const DialogCode &a, const QDialog::DialogCode &b)
Definition: mythdialogs.h:38
QColor GetBGColor(void) const
Definition: cc708window.h:122
const uint k708JustifyLeft
Definition: cc708window.cpp:56
CC708CharacterAttribute attr
Definition: cc708window.h:180
const uint k708AttrEdgeLeftDropShadow
Definition: cc708window.cpp:98
bool IsPenValid(void) const
Definition: cc708window.h:215
const uint k708AttrSizeStandard
Definition: cc708window.cpp:78
uint column
Definition: cc708window.h:171
const uint k708AttrColorBlack
const uint k708JustifyFull
Definition: cc708window.cpp:59
CC708Character * text
Definition: cc708window.h:277
const uint k708AttrEdgeRightDropShadow
Definition: cc708window.cpp:99
uint word_wrap
Definition: cc708window.h:270
const int k708MaxWindows
Definition: cc708window.h:69
uint anchor_vertical
Definition: cc708window.h:251
uint border_color
Definition: cc708window.h:262
bool GetExists(void) const
Definition: cc708window.h:286
uint window_style
Definition: cc708window.h:258
#define Clear(a)
const uint k708DirBottomToTop
Definition: cc708window.cpp:75
QColor GetFillColor(void) const
Definition: cc708window.h:223
void ResetChanged(void)
Definition: cc708window.h:305
uint GetFillAlpha(void) const
Definition: cc708window.h:229
uint print_dir
Definition: cc708window.h:265
const uint k708AttrOpacityTransparent
bool m_exists
set to false when DeleteWindow is called on the window.
Definition: cc708window.h:282
const uint k708AttrOpacityTranslucent
const uint k708AttrFontProportionalSansSerif
Definition: cc708window.cpp:89
const uint k708AttrFontMonospacedSerif
Definition: cc708window.cpp:86
const uint k708AttrEdgeDepressed
Definition: cc708window.cpp:96