00001
00002
00003
00004 #ifndef _CC708_WINDOW_
00005 #define _CC708_WINDOW_
00006
00007 #include <vector>
00008 using namespace std;
00009
00010 #include <QString>
00011 #include <QMutex>
00012 #include <QColor>
00013
00014 #include "mythtvexp.h"
00015
00016 extern const uint k708JustifyLeft;
00017 extern const uint k708JustifyRight;
00018 extern const uint k708JustifyCenter;
00019 extern const uint k708JustifyFull;
00020
00021 extern const uint k708EffectSnap;
00022 extern const uint k708EffectFade;
00023 extern const uint k708EffectWipe;
00024
00025 extern const uint k708BorderNone;
00026 extern const uint k708BorderRaised;
00027 extern const uint k708BorderDepressed;
00028 extern const uint k708BorderUniform;
00029 extern const uint k708BorderShadowLeft;
00030 extern const uint k708BorderShadowRight;
00031
00032 extern const uint k708DirLeftToRight;
00033 extern const uint k708DirRightToLeft;
00034 extern const uint k708DirTopToBottom;
00035 extern const uint k708DirBottomToTop;
00036
00037 extern const uint k708AttrSizeSmall;
00038 extern const uint k708AttrSizeStandard;
00039 extern const uint k708AttrSizeLarge;
00040
00041 extern const uint k708AttrOffsetSubscript;
00042 extern const uint k708AttrOffsetNormal;
00043 extern const uint k708AttrOffsetSuperscript;
00044
00045 extern const uint k708AttrFontDefault;
00046 extern const uint k708AttrFontMonospacedSerif;
00047 extern const uint k708AttrFontProportionalSerif;
00048 extern const uint k708AttrFontMonospacedSansSerif;
00049 extern const uint k708AttrFontProportionalSansSerif;
00050 extern const uint k708AttrFontCasual;
00051 extern const uint k708AttrFontCursive;
00052 extern const uint k708AttrFontSmallCaps;
00053
00054 extern const uint k708AttrEdgeNone;
00055 extern const uint k708AttrEdgeRaised;
00056 extern const uint k708AttrEdgeDepressed;
00057 extern const uint k708AttrEdgeUniform;
00058 extern const uint k708AttrEdgeLeftDropShadow;
00059 extern const uint k708AttrEdgeRightDropShadow;
00060
00061 extern const uint k708AttrColorBlack;
00062 extern const uint k708AttrColorWhite;
00063
00064 extern const uint k708AttrOpacitySolid;
00065 extern const uint k708AttrOpacityFlash;
00066 extern const uint k708AttrOpacityTranslucent;
00067 extern const uint k708AttrOpacityTransparent;
00068
00069 class CC708CharacterAttribute
00070 {
00071 public:
00072
00073
00074 uint pen_size;
00075 uint offset;
00076 uint text_tag;
00077 uint font_tag;
00078 uint edge_type;
00079 uint underline;
00080 uint italics;
00081 uint boldface;
00082
00083 uint fg_color;
00084 uint fg_opacity;
00085 uint bg_color;
00086 uint bg_opacity;
00087 uint edge_color;
00088
00089 bool override_fg_color;
00090 QColor actual_fg_color;
00091
00092 CC708CharacterAttribute(bool isItalic, bool isBold, bool isUnderline,
00093 QColor fgColor) :
00094 pen_size(k708AttrSizeStandard),
00095 offset(k708AttrOffsetNormal),
00096 text_tag(0),
00097 font_tag(0),
00098 edge_type(k708AttrEdgeNone),
00099 underline(isUnderline),
00100 italics(isItalic),
00101 boldface(isBold),
00102 fg_color(k708AttrColorWhite),
00103 fg_opacity(k708AttrOpacitySolid),
00104 bg_color(k708AttrColorBlack),
00105 bg_opacity(k708AttrOpacitySolid),
00106 edge_color(k708AttrColorBlack),
00107 override_fg_color(true),
00108 actual_fg_color(fgColor)
00109 {
00110 }
00111 CC708CharacterAttribute(void) : override_fg_color(false) {}
00112
00113
00114 uint FontIndex(void) const
00115 {
00116 return (((font_tag & 0x7) * 6) + ((italics) ? 3 : 0) +
00117 (pen_size & 0x3));
00118 }
00119 static QColor ConvertToQColor(uint eia708color);
00120 QColor GetFGColor(void) const
00121 {
00122 QColor fg = (override_fg_color ?
00123 actual_fg_color : ConvertToQColor(fg_color));
00124 fg.setAlpha(GetFGAlpha());
00125 return fg;
00126 }
00127 QColor GetBGColor(void) const
00128 {
00129 QColor bg = ConvertToQColor(bg_color);
00130 bg.setAlpha(GetBGAlpha());
00131 return bg;
00132 }
00133 QColor GetEdgeColor(void) const { return ConvertToQColor(edge_color); }
00134
00135 uint GetFGAlpha(void) const
00136 {
00137
00138 static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
00139 return alpha[fg_opacity & 0x3];
00140 }
00141
00142 uint GetBGAlpha(void) const
00143 {
00144
00145 static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
00146 return alpha[bg_opacity & 0x3];
00147 }
00148
00149 bool operator==(const CC708CharacterAttribute &other) const;
00150 bool operator!=(const CC708CharacterAttribute &other) const
00151 { return !(*this == other); }
00152 };
00153
00154 class CC708Pen
00155 {
00156 public:
00157 CC708Pen() : row(0), column(0) {}
00158 void SetPenStyle(uint style);
00159 void SetAttributes(int pen_size,
00160 int offset, int text_tag, int font_tag,
00161 int edge_type, int underline, int italics)
00162 {
00163 attr.pen_size = pen_size;
00164 attr.offset = offset;
00165 attr.text_tag = text_tag;
00166 attr.font_tag = font_tag;
00167 attr.edge_type = edge_type;
00168 attr.underline = underline;
00169 attr.italics = italics;
00170 attr.boldface = 0;
00171 }
00172 public:
00173 CC708CharacterAttribute attr;
00174
00175 uint row;
00176 uint column;
00177 };
00178
00179 class CC708Window;
00180 class CC708Character
00181 {
00182 public:
00183 CC708Character() : character(' ') {}
00184 CC708Character(const CC708Window &win);
00185 CC708CharacterAttribute attr;
00186 QChar character;
00187 };
00188
00189 class CC708String
00190 {
00191 public:
00192 uint x;
00193 uint y;
00194 QString str;
00195 CC708CharacterAttribute attr;
00196 };
00197
00198 class MTV_PUBLIC CC708Window
00199 {
00200 public:
00201 CC708Window();
00202 ~CC708Window();
00203
00204 void DefineWindow(int priority, int visible,
00205 int anchor_point, int relative_pos,
00206 int anchor_vertical, int anchor_horizontal,
00207 int row_count, int column_count,
00208 int row_lock, int column_lock,
00209 int pen_style, int window_style);
00210 void Clear(void);
00211 void SetWindowStyle(uint);
00212
00213 void AddChar(QChar);
00214 void IncrPenLocation(void);
00215 void DecrPenLocation(void);
00216 void SetPenLocation(uint, uint);
00217 void LimitPenLocation(void);
00218
00219 bool IsPenValid(void) const
00220 {
00221 return ((pen.row < true_row_count) &&
00222 (pen.column < true_column_count));
00223 }
00224 CC708Character &GetCCChar(void) const;
00225 vector<CC708String*> GetStrings(void) const;
00226
00227 QColor GetFillColor(void) const
00228 {
00229 QColor fill = CC708CharacterAttribute::ConvertToQColor(fill_color);
00230 fill.setAlpha(GetFillAlpha());
00231 return fill;
00232 }
00233 uint GetFillAlpha(void) const
00234 {
00235
00236 static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
00237 return alpha[fill_opacity & 0x3];
00238 }
00239
00240 private:
00241 void Scroll(int row, int col);
00242
00243 public:
00244 uint priority;
00245 uint visible;
00246 enum {
00247 kAnchorUpperLeft = 0, kAnchorUpperCenter, kAnchorUpperRight,
00248 kAnchorCenterLeft = 3, kAnchorCenter, kAnchorCenterRight,
00249 kAnchorLowerLeft = 6, kAnchorLowerCenter, kAnchorLowerRight,
00250 };
00251 uint anchor_point;
00252 uint relative_pos;
00253 uint anchor_vertical;
00254 uint anchor_horizontal;
00255 uint row_count;
00256 uint column_count;
00257 uint row_lock;
00258 uint column_lock;
00259 uint pen_style;
00260 uint window_style;
00261
00262 uint fill_color;
00263 uint fill_opacity;
00264 uint border_color;
00265 uint border_type;
00266 uint scroll_dir;
00267 uint print_dir;
00268 uint effect_dir;
00269 uint display_effect;
00270 uint effect_speed;
00271 uint justify;
00272 uint word_wrap;
00273
00274 uint true_row_count;
00275 uint true_column_count;
00276 CC708Character *text;
00277 CC708Pen pen;
00278
00280 bool exists;
00281 bool changed;
00282
00283 mutable QMutex lock;
00284 };
00285
00286 class CC708Service
00287 {
00288 public:
00289 CC708Service() { current_window = 0; }
00290
00291 public:
00292 uint current_window;
00293 CC708Window windows[8];
00294 };
00295
00296 #endif // _CC708_WINDOW_