MythTV  0.26-pre
osd.h
Go to the documentation of this file.
00001 #ifndef OSD_H
00002 #define OSD_H
00003 
00004 #include "mythtvexp.h"
00005 #include "programtypes.h"
00006 #include "mythscreentype.h"
00007 
00008 // Screen names are prepended with alphanumerics to force the correct ordering
00009 // when displayed. This is slightly complicated by the default windows
00010 // (e.g. osd_window) whose names are hard coded into existing themes.
00011 
00012 // menu dialogs should always be on top
00013 #define OSD_DLG_VIDEOEXIT "xx_OSD_VIDEO_EXIT"
00014 #define OSD_DLG_MENU      "xx_OSD_MENU"
00015 #define OSD_DLG_SLEEP     "xx_OSD_SLEEP"
00016 #define OSD_DLG_IDLE      "xx_OSD_IDLE"
00017 #define OSD_DLG_INFO      "xx_OSD_INFO"
00018 #define OSD_DLG_EDITING   "xx_OSD_EDITING"
00019 #define OSD_DLG_ASKALLOW  "xx_OSD_ASKALLOW"
00020 #define OSD_DLG_EDITOR    "xx_OSD_EDITOR"
00021 #define OSD_DLG_CUTPOINT  "xx_OSD_CUTPOINT"
00022 #define OSD_DLG_DELETE    "xx_OSD_DELETE"
00023 #define OSD_DLG_CONFIRM   "mythconfirmpopup"
00024 // subtitles are always painted first
00025 #define OSD_WIN_TELETEXT  "aa_OSD_TELETEXT"
00026 #define OSD_WIN_SUBTITLE  "aa_OSD_SUBTITLES"
00027 // MHEG and blu-ray overlay should cover subtitles
00028 #define OSD_WIN_INTERACT  "bb_OSD_INTERACTIVE"
00029 #define OSD_WIN_BDOVERLAY "bb_OSD_BDOVERLAY"
00030 
00031 #define kOSDFadeTime 1000
00032 
00033 class MythPlayer;
00034 class TeletextScreen;
00035 class SubtitleScreen;
00036 struct AVSubtitle;
00037 class BDOverlay;
00038 
00039 enum OSDFunctionalType
00040 {
00041     kOSDFunctionalType_Default = 0,
00042     kOSDFunctionalType_PictureAdjust,
00043     kOSDFunctionalType_SmartForward,
00044     kOSDFunctionalType_TimeStretchAdjust,
00045     kOSDFunctionalType_AudioSyncAdjust,
00046     kOSDFunctionalType_SubtitleZoomAdjust
00047 };
00048 
00049 enum OSDTimeout
00050 {
00051     kOSDTimeout_Ignore = -1, // Don't update existing timeout
00052     kOSDTimeout_None   = 0,  // Don't timeout
00053     kOSDTimeout_Short  = 1,
00054     kOSDTimeout_Med    = 2,
00055     kOSDTimeout_Long   = 3,
00056 };
00057 
00058 class MTV_PUBLIC OSDHideEvent : public QEvent
00059 {
00060   public:
00061     OSDHideEvent(enum OSDFunctionalType osdFunctionalType)
00062         : QEvent(kEventType), m_osdFunctionalType(osdFunctionalType) { }
00063 
00064     int GetFunctionalType() { return m_osdFunctionalType; }
00065 
00066     static Type kEventType;
00067 
00068   private:
00069     OSDFunctionalType m_osdFunctionalType;
00070 };
00071 
00072 class ChannelEditor : public MythScreenType
00073 {
00074     Q_OBJECT
00075 
00076   public:
00077     ChannelEditor(QObject *retobject, const char * name);
00078 
00079     virtual bool Create(void);
00080     virtual bool keyPressEvent(QKeyEvent *event);
00081 
00082     void SetText(QHash<QString,QString>&map);
00083     void GetText(QHash<QString,QString>&map);
00084 
00085   protected:
00086     MythUITextEdit *m_callsignEdit;
00087     MythUITextEdit *m_channumEdit;
00088     MythUITextEdit *m_channameEdit;
00089     MythUITextEdit *m_xmltvidEdit;
00090 
00091     QObject *m_retObject;
00092 
00093     void sendResult(int result);
00094 
00095   public slots:
00096     void Confirm();
00097     void Probe();
00098 };
00099 
00100 class MythOSDWindow : public MythScreenType
00101 {
00102     Q_OBJECT
00103   public:
00104     MythOSDWindow(MythScreenStack *parent, const QString &name,
00105                   bool themed)
00106       : MythScreenType(parent, name, true), m_themed(themed)
00107     {
00108     }
00109 
00110     virtual bool Create(void)
00111     {
00112         if (m_themed)
00113             return XMLParseBase::LoadWindowFromXML("osd.xml", objectName(),
00114                                                    this);
00115         return false;
00116     }
00117 
00118   private:
00119     bool m_themed;
00120 };
00121 
00122 class OSD
00123 {
00124   public:
00125     OSD(MythPlayer *player, QObject *parent, MythPainter *painter);
00126    ~OSD();
00127 
00128     bool    Init(const QRect &rect, float font_aspect);
00129     void    SetPainter(MythPainter *painter);
00130     QRect   Bounds(void) const { return m_Rect; }
00131     int     GetFontStretch(void) const { return m_fontStretch; }
00132     void    OverrideUIScale(void);
00133     void    RevertUIScale(void);
00134     bool    Reinit(const QRect &rect, float font_aspect);
00135     void    DisableFade(void) { m_Effects = false; }
00136     void    SetFunctionalWindow(const QString window,
00137                                 enum OSDFunctionalType type);
00138     void    SetTimeouts(int _short, int _medium, int _long);
00139 
00140     bool    IsVisible(void);
00141     void    HideAll(bool keepsubs = true, MythScreenType *except = NULL);
00142 
00143     MythScreenType *GetWindow(const QString &window);
00144     void    SetExpiry(const QString &window, enum OSDTimeout timeout,
00145                       int custom_timeout = 0);
00146     void    HideWindow(const QString &window);
00147     bool    HasWindow(const QString &window);
00148     void    ResetWindow(const QString &window);
00149     void    PositionWindow(MythScreenType *window);
00150     void    RemoveWindow(const QString &window);
00151 
00152     bool    DrawDirect(MythPainter* painter, QSize size, bool repaint = false);
00153     QRegion Draw(MythPainter* painter, QPaintDevice *device, QSize size,
00154                  QRegion &changed, int alignx = 0, int aligny = 0);
00155 
00156     void SetValues(const QString &window, QHash<QString,int> &map,
00157                    OSDTimeout timeout);
00158     void SetValues(const QString &window, QHash<QString,float> &map,
00159                    OSDTimeout timeout);
00160     void SetText(const QString &window, QHash<QString,QString> &map,
00161                  OSDTimeout timeout);
00162     void SetRegions(const QString &window, frm_dir_map_t &map,
00163                  long long total);
00164     bool IsWindowVisible(const QString &window);
00165 
00166     bool DialogVisible(QString window = QString());
00167     bool DialogHandleKeypress(QKeyEvent *e);
00168     void DialogQuit(void);
00169     void DialogShow(const QString &window, const QString &text = "",
00170                     int updatefor = 0);
00171     void DialogSetText(const QString &text);
00172     void DialogBack(QString text = "", QVariant data = 0, bool exit = false);
00173     void DialogAddButton(QString text, QVariant data,
00174                          bool menu = false, bool current = false);
00175     void DialogGetText(QHash<QString,QString> &map);
00176 
00177     TeletextScreen* InitTeletext(void);
00178     void EnableTeletext(bool enable, int page);
00179     bool TeletextAction(const QString &action);
00180     void TeletextReset(void);
00181     void TeletextClear(void);
00182 
00183     SubtitleScreen* InitSubtitles(void);
00184     void EnableSubtitles(int type, bool forced_only = false);
00185     void DisableForcedSubtitles(void);
00186     void ClearSubtitles(void);
00187     void DisplayDVDButton(AVSubtitle* dvdButton, QRect &pos);
00188 
00189     void DisplayBDOverlay(BDOverlay *overlay);
00190 
00191   private:
00192     void TearDown(void);
00193     void LoadWindows(void);
00194 
00195     void CheckExpiry(void);
00196     void SendHideEvent(void);
00197 
00198   private:
00199     MythPlayer     *m_parent;
00200     QObject        *m_ParentObject;
00201     MythPainter    *m_CurrentPainter;
00202     QRect           m_Rect;
00203     bool            m_Effects;
00204     int             m_FadeTime;
00205     MythScreenType *m_Dialog;
00206     QString         m_PulsedDialogText;
00207     QDateTime       m_NextPulseUpdate;
00208     bool            m_Refresh;
00209     int             m_Timeouts[4];
00210 
00211     bool            m_UIScaleOverride;
00212     float           m_SavedWMult;
00213     float           m_SavedHMult;
00214     QRect           m_SavedUIRect;
00215     int             m_fontStretch;
00216     int             m_savedFontStretch;
00217 
00218     enum OSDFunctionalType m_FunctionalType;
00219     QString                m_FunctionalWindow;
00220 
00221     QMap<QString, MythScreenType*>    m_Children;
00222     QHash<MythScreenType*, QDateTime> m_ExpireTimes;
00223 };
00224 
00225 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends