00001
00002
00003
00004 #ifndef _CC708_WINDOW_
00005 #define _CC708_WINDOW_
00006
00007 #include <vector>
00008 using namespace std;
00009
00010 #include <qstring.h>
00011 #include <qmutex.h>
00012 #include <qcolor.h>
00013
00014 class CC708CharacterAttribute
00015 {
00016 public:
00017 uint pen_size;
00018 uint offset;
00019 uint text_tag;
00020 uint font_tag;
00021 uint edge_type;
00022 uint underline;
00023 uint italics;
00024
00025 uint fg_color;
00026 uint fg_opacity;
00027 uint bg_color;
00028 uint bg_opacity;
00029 uint edge_color;
00030
00031 uint FontIndex(void) const
00032 {
00033 return (((font_tag & 0x7) * 6) + ((italics) ? 3 : 0) +
00034 (pen_size & 0x3));
00035 }
00036 static QColor ConvertToQColor(uint eia708color);
00037 QColor GetFGColor(void) const { return ConvertToQColor(fg_color); }
00038 QColor GetBGColor(void) const { return ConvertToQColor(bg_color); }
00039 QColor GetEdgeColor(void) const { return ConvertToQColor(edge_color); }
00040
00041 uint GetFGAlpha(void) const
00042 {
00043
00044 static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
00045 return alpha[fg_opacity & 0x3];
00046 }
00047
00048 uint GetBGAlpha(void) const
00049 {
00050
00051 static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
00052 return alpha[bg_opacity & 0x3];
00053 }
00054
00055 bool operator==(const CC708CharacterAttribute &other) const;
00056 bool operator!=(const CC708CharacterAttribute &other) const
00057 { return !(*this == other); }
00058 };
00059
00060 class CC708Pen
00061 {
00062 public:
00063 void SetPenStyle(uint style);
00064 void SetAttributes(int pen_size,
00065 int offset, int text_tag, int font_tag,
00066 int edge_type, int underline, int italics)
00067 {
00068 attr.pen_size = pen_size;
00069 attr.offset = offset;
00070 attr.text_tag = text_tag;
00071 attr.font_tag = font_tag;
00072 attr.edge_type = edge_type;
00073 attr.underline = underline;
00074 attr.italics = italics;
00075 }
00076 public:
00077 CC708CharacterAttribute attr;
00078
00079 uint row;
00080 uint column;
00081 };
00082
00083 class CC708Window;
00084 class CC708Character
00085 {
00086 public:
00087 CC708Character() : character(' ') {}
00088 CC708Character(const CC708Window &win);
00089 CC708CharacterAttribute attr;
00090 QChar character;
00091 };
00092
00093 class CC708String
00094 {
00095 public:
00096 uint x;
00097 uint y;
00098 QString str;
00099 CC708CharacterAttribute attr;
00100 };
00101
00102 class CC708Window
00103 {
00104 public:
00105 CC708Window();
00106 ~CC708Window();
00107
00108 void DefineWindow(int priority, int visible,
00109 int anchor_point, int relative_pos,
00110 int anchor_vertical, int anchor_horizontal,
00111 int row_count, int column_count,
00112 int row_lock, int column_lock,
00113 int pen_style, int window_style);
00114 void Clear(void);
00115 void SetWindowStyle(uint);
00116
00117 void AddChar(QChar);
00118 void IncrPenLocation(void);
00119 void SetPenLocation(uint, uint);
00120 void LimitPenLocation(void);
00121
00122 bool IsPenValid(void) const
00123 {
00124 return ((pen.row < true_row_count) &&
00125 (pen.column < true_column_count));
00126 }
00127 CC708Character &GetCCChar(void) const;
00128 vector<CC708String*> GetStrings(void) const;
00129
00130 uint GetFillAlpha(void) const
00131 {
00132
00133 static uint alpha[4] = { 0xff, 0xff, 0x7f, 0x00, };
00134 return alpha[fill_opacity & 0x3];
00135 }
00136
00137 private:
00138 void Scroll(int row, int col);
00139
00140 public:
00141 uint priority;
00142 uint visible;
00143 enum {
00144 kAnchorUpperLeft = 0, kAnchorUpperCenter, kAnchorUpperRight,
00145 kAnchorCenterLeft = 3, kAnchorCenter, kAnchorCenterRight,
00146 kAnchorLowerLeft = 6, kAnchorLowerCenter, kAnchorLowerRight,
00147 };
00148 uint anchor_point;
00149 uint relative_pos;
00150 uint anchor_vertical;
00151 uint anchor_horizontal;
00152 uint row_count;
00153 uint column_count;
00154 uint row_lock;
00155 uint column_lock;
00156 uint pen_style;
00157 uint window_style;
00158
00159 uint fill_color;
00160 uint fill_opacity;
00161 uint border_color;
00162 uint border_type;
00163 uint scroll_dir;
00164 uint print_dir;
00165 uint effect_dir;
00166 uint display_effect;
00167 uint effect_speed;
00168 uint justify;
00169 uint word_wrap;
00170
00171 uint true_row_count;
00172 uint true_column_count;
00173 CC708Character *text;
00174 CC708Pen pen;
00175
00177 bool exists;
00178
00179 mutable QMutex lock;
00180 };
00181
00182 class CC708Service
00183 {
00184 public:
00185 CC708Service() { current_window = 0; }
00186
00187 public:
00188 uint current_window;
00189 CC708Window windows[8];
00190 };
00191
00192 #endif // _CC708_WINDOW_