00001 #ifndef OSD_H
00002 #define OSD_H
00003
00004 #include <qstring.h>
00005 #include <qstringlist.h>
00006 #include <qrect.h>
00007 #include <qpoint.h>
00008 #include <qvaluevector.h>
00009 #include <ctime>
00010 #include <qmap.h>
00011 #include <qdom.h>
00012 #include <qmutex.h>
00013 #include <qobject.h>
00014 #include <qregexp.h>
00015
00016
00017 #include "themeinfo.h"
00018
00019 #include <vector>
00020 using namespace std;
00021
00022 enum OSDFunctionalType
00023 {
00024 kOSDFunctionalType_Default = 0,
00025 kOSDFunctionalType_PictureAdjust,
00026 kOSDFunctionalType_RecPictureAdjust,
00027 kOSDFunctionalType_SmartForward,
00028 kOSDFunctionalType_TimeStretchAdjust,
00029 kOSDFunctionalType_AudioSyncAdjust
00030 };
00031
00032 struct StatusPosInfo
00033 {
00034 QString desc;
00035 QString extdesc;
00036 int position;
00037 bool progBefore;
00038 bool progAfter;
00039 };
00040
00041
00042 class QImage;
00043 class TTFFont;
00044 class OSDSet;
00045 class OSDTypeImage;
00046 class OSDTypePositionIndicator;
00047 class OSDSurface;
00048 class OSDTypeText;
00049 class TV;
00050 class UDPNotifyOSDSet;
00051 class OSDListTreeType;
00052 class QKeyEvent;
00053 class OSDGenericTree;
00054 class ccText;
00055 class CC708Service;
00056 class TeletextViewer;
00057
00058 class OSD : public QObject
00059 {
00060 Q_OBJECT
00061 public:
00062 OSD();
00063 ~OSD(void);
00064
00065 void Init(const QRect &totalBounds, int frameRate,
00066 const QRect &visibleBounds, float visibleAspect, float fontScaling);
00067
00068 OSDSurface *Display(void);
00069
00070 OSDSurface *GetDisplaySurface(void);
00071
00072 void ClearAll(const QString &name);
00073 void ClearAllText(const QString &name);
00074 void SetText(const QString &name, QMap<QString, QString> &infoMap,
00075 int length);
00076 void SetInfoText(QMap<QString, QString> infoMap, int length);
00077 void SetInfoText(const QString &text, const QString &subtitle,
00078 const QString &desc, const QString &category,
00079 const QString &start, const QString &end,
00080 const QString &callsign, const QString &iconpath,
00081 int length);
00082 void SetChannumText(const QString &text, int length);
00083
00084
00085 void AddCCText(const QString &text, int x, int y, int color,
00086 bool teletextmode = false);
00087 void ClearAllCCText();
00088 void UpdateCCText(vector<ccText*> *ccbuf,
00089 int replace = 0, int scroll = 0,
00090 bool scroll_prsv = false,
00091 int scroll_yoff = 0, int scroll_ymax = 15);
00092
00093 void SetCC708Service(const CC708Service *service);
00094 void CC708Updated(void);
00095
00096
00097 TeletextViewer *GetTeletextViewer(void);
00098
00099 void SetSettingsText(const QString &text, int length);
00100
00101 void NewDialogBox(const QString &name, const QString &message,
00102 QStringList &options, int length, int sel = 0);
00103 void DialogUp(const QString &name);
00104 void DialogDown(const QString &name);
00105 bool DialogShowing(const QString &name);
00106 void TurnDialogOff(const QString &name);
00107 void DialogAbort(const QString &name);
00108 int GetDialogResponse(const QString &name);
00109
00110 void SetUpOSDClosedHandler(TV *tv);
00111
00112
00113 void ShowStatus(int pos, bool fill, QString msgtext, QString desc,
00114 int displaytime,
00115 int osdFunctionalType = kOSDFunctionalType_Default);
00116 void ShowStatus(struct StatusPosInfo posInfo,
00117 bool fill, QString msgtext, int displaytime,
00118 int osdFunctionalType = kOSDFunctionalType_Default);
00119 void UpdateStatus(struct StatusPosInfo posInfo);
00120 void EndStatus(void);
00121
00122 bool Visible(void);
00123
00124 bool HideAll(void) { return HideAllExcept(QString::null); };
00125 bool HideAllExcept(const QString &name);
00126 bool HideSet(const QString &name);
00127 bool HideSets(QStringList &name);
00128
00129 void AddSet(OSDSet *set, QString name, bool withlock = true);
00130
00131 void SetVisible(OSDSet *set, int length);
00132
00133 OSDSet *GetSet(const QString &text);
00134 TTFFont *GetFont(const QString &text);
00135
00136 void ShowEditArrow(long long number, long long totalframes, int type);
00137 void HideEditArrow(long long number, int type);
00138 void UpdateEditText(const QString &seek_amount, const QString &deletemarker,
00139 const QString &edittime, const QString &framecnt);
00140 void DoEditSlider(QMap<long long, int> deleteMap, long long curFrame,
00141 long long totalFrames);
00142
00143 int getTimeType(void) { return timeType; }
00144
00145 void Reinit(const QRect &totalBounds, int frameRate,
00146 const QRect &visibleBounds,
00147 float visibleAspect, float fontScaling);
00148
00149 void SetFrameInterval(int frint);
00150
00151 void StartNotify(UDPNotifyOSDSet *notifySet, int displaytime = 5);
00152 void ClearNotify(UDPNotifyOSDSet *notifySet);
00153
00154 bool IsRunningTreeMenu(void);
00155 bool TreeMenuHandleKeypress(QKeyEvent *e);
00156 OSDListTreeType *ShowTreeMenu(const QString &name,
00157 OSDGenericTree *treeToShow);
00158
00159 void DisableFade(void);
00160 bool IsSetDisplaying(const QString &name);
00161 bool HasSet(const QString &name);
00162 QRect GetSubtitleBounds();
00163
00164 void SetTextSubtitles(const QStringList&);
00165 void ClearTextSubtitles(void);
00166
00167 void UpdateTeletext(void);
00168
00169 float GetThemeAspect(void) { return m_themeaspect; }
00170
00171 bool HasChanged(void) const { return changed; }
00172
00173 private:
00174 bool InitDefaults(void);
00175 bool InitCC608(void);
00176 bool InitCC708(void);
00177 bool InitTeletext(void);
00178 bool InitSubtitles(void);
00179 bool InitMenu(void);
00180 bool InitInteractiveTV(void);
00181
00182 TTFFont *LoadFont(QString name, int size);
00183 QString FindTheme(QString name);
00184
00185 void HighlightDialogSelection(OSDSet *container, int num);
00186
00187 bool LoadTheme();
00188 void normalizeRect(QRect &rect);
00189 QPoint parsePoint(QString text);
00190 QColor parseColor(QString text);
00191 QRect parseRect(QString text);
00192
00193 void RemoveSet(OSDSet *set);
00194
00195 QString getFirstText(QDomElement &element);
00196 void parseFont(QDomElement &element);
00197 void parseContainer(QDomElement &element);
00198 void parseImage(OSDSet *container, QDomElement &element);
00199 void parseTextArea(OSDSet *container, QDomElement &element);
00200 void parseSlider(OSDSet *container, QDomElement &element);
00201 void parseBox(OSDSet *container, QDomElement &element);
00202 void parseEditArrow(OSDSet *container, QDomElement &element);
00203 void parsePositionRects(OSDSet *container, QDomElement &element);
00204 void parsePositionImage(OSDSet *container, QDomElement &element);
00205 void parseListTree(OSDSet *container, QDomElement &element);
00206
00207 QRect osdBounds;
00208 int frameint;
00209 bool needPillarBox;
00210
00211 QString themepath;
00212
00213 float wscale, fscale;
00214
00215 ThemeInfo *m_themeinfo;
00216 float m_themeaspect;
00217
00218 float hmult, wmult;
00219 int xoffset, yoffset, displaywidth, displayheight;
00220
00221 QMutex osdlock;
00222
00223 bool m_setsvisible;
00224
00225 int totalfadetime;
00226 int timeType;
00227
00228 QString timeFormat;
00229
00230 QMap<QString, OSDSet *> setMap;
00231 vector<OSDSet *> *setList;
00232
00233 QMap<QString, TTFFont *> fontMap;
00234
00235 QMap<QString, int> dialogResponseList;
00236
00237 OSDTypeImage *editarrowleft;
00238 OSDTypeImage *editarrowright;
00239 QRect editarrowRect;
00240
00241 OSDSurface *drawSurface;
00242 bool changed;
00243
00244 OSDListTreeType *runningTreeMenu;
00245 QString treeMenuContainer;
00246
00247
00248 QString fontname;
00249 QString ccfontname;
00250 QString cc708fontnames[16];
00251 QString fontSizeType;
00252
00253
00254 QRegExp removeHTML;
00255 };
00256
00257 #endif