00001 #ifndef MYTHMAINWINDOW_H_
00002 #define MYTHMAINWINDOW_H_
00003
00004 #include <QWidget>
00005
00006 #include "mythuiactions.h"
00007 #include "mythuitype.h"
00008 #include "mythscreenstack.h"
00009
00010 class QEvent;
00011
00012 class MythMediaDevice;
00013
00014 #define REG_KEY(a, b, c, d) GetMythMainWindow()->RegisterKey(a, b, c, d)
00015 #define GET_KEY(a, b) GetMythMainWindow()->GetKey(a, b)
00016 #define REG_JUMP(a, b, c, d) GetMythMainWindow()->RegisterJump(a, b, c, d)
00017 #define REG_JUMPLOC(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, true, e)
00018 #define REG_JUMPEX(a, b, c, d, e) GetMythMainWindow()->RegisterJump(a, b, c, d, e)
00019 #define REG_MEDIAPLAYER(a,b,c) GetMythMainWindow()->RegisterMediaPlugin(a, b, c)
00020
00021 typedef int (*MediaPlayCallback)(const QString &, const QString &, const QString &, const QString &, const QString &, int, int, const QString &, int, const QString &, const QString &, bool);
00022
00023 class MythMainWindowPrivate;
00024
00025 class MythPainterWindowGL;
00026 class MythPainterWindowQt;
00027 class MythPainterWindowVDPAU;
00028 class MythPainterWindowD3D9;
00029 class MythRender;
00030
00031 class MUI_PUBLIC MythMainWindow : public QWidget
00032 {
00033 Q_OBJECT
00034 friend class MythPainterWindowGL;
00035 friend class MythPainterWindowQt;
00036 friend class MythPainterWindowVDPAU;
00037 friend class MythPainterWindowD3D9;
00038
00039 public:
00040 void Init(void);
00041 void ReinitDone(void);
00042 void Show(void);
00043
00044 void AddScreenStack(MythScreenStack *stack, bool main = false);
00045 void PopScreenStack();
00046 int GetStackCount(void);
00047 MythScreenStack *GetMainStack();
00048 MythScreenStack *GetStack(const QString &stackname);
00049 MythScreenStack *GetStackAt(int pos);
00050
00051 bool TranslateKeyPress(const QString &context, QKeyEvent *e,
00052 QStringList &actions, bool allowJumps = true)
00053 MUNUSED_RESULT;
00054
00055 void ReloadKeys(void);
00056 void ClearKey(const QString &context, const QString &action);
00057 void ClearKeyContext(const QString &context);
00058 void BindKey(const QString &context, const QString &action,
00059 const QString &key);
00060 void RegisterKey(const QString &context, const QString &action,
00061 const QString &description, const QString &key);
00062 QString GetKey(const QString &context, const QString &action) const;
00063
00064 void ClearJump(const QString &destination);
00065 void BindJump(const QString &destination, const QString &key);
00066 void RegisterJump(const QString &destination, const QString &description,
00067 const QString &key, void (*callback)(void),
00068 bool exittomain = true, QString localAction = "");
00069 void ClearAllJumps();
00070
00071 void RegisterMediaPlugin(const QString &name, const QString &desc,
00072 MediaPlayCallback fn);
00073
00074 bool HandleMedia(const QString& handler, const QString& mrl,
00075 const QString& plot="", const QString& title="",
00076 const QString& subtitle="", const QString& director="",
00077 int season=0, int episode=0, const QString& inetref="",
00078 int lenMins=120, const QString& year="1895",
00079 const QString &id="", bool useBookmarks = false);
00080 void HandleTVPower(bool poweron);
00081
00082 void JumpTo(const QString &destination, bool pop = true);
00083 bool DestinationExists(const QString &destination) const;
00084 QStringList EnumerateDestinations(void) const;
00085
00086 bool IsExitingToMain(void) const;
00087
00088 static MythMainWindow *getMainWindow(const bool useDB = true);
00089 static void destroyMainWindow();
00090
00091 MythPainter *GetCurrentPainter();
00092 QWidget *GetPaintWindow();
00093 MythRender *GetRenderDevice();
00094 void ShowPainterWindow();
00095 void HidePainterWindow();
00096 void ResizePainterWindow(const QSize &size);
00097
00098 void GrabWindow(QImage &image);
00099 bool SaveScreenShot(const QImage &image, QString filename = "");
00100 bool ScreenShot(int w = 0, int h = 0, QString filename = "");
00101 void RemoteScreenShot(QString filename, int x, int y);
00102
00103 void AllowInput(bool allow);
00104
00105 QRect GetUIScreenRect();
00106 void SetUIScreenRect(QRect &rect);
00107
00108 int GetDrawInterval() const;
00109 int NormalizeFontSize(int pointSize);
00110 MythRect NormRect(const MythRect &rect);
00111 QPoint NormPoint(const QPoint &point);
00112 QSize NormSize(const QSize &size);
00113 int NormX(const int x);
00114 int NormY(const int y);
00115 void SetScalingFactors(float wmult, float hmult);
00116
00117 void StartLIRC(void);
00118
00119
00120 void attach(QWidget *child);
00121 void detach(QWidget *child);
00122
00123 QWidget *currentWidget(void);
00124
00125 uint PushDrawDisabled(void);
00126 uint PopDrawDisabled(void);
00127 void SetEffectsEnabled(bool enable);
00128 void draw(void);
00129
00130 void ResetIdleTimer(void);
00131 void PauseIdleTimer(bool pause);
00132 void EnterStandby(bool manual = true);
00133 void ExitStandby(bool manual = true);
00134
00135 public slots:
00136 void mouseTimeout();
00137 void HideMouseTimeout();
00138 void IdleTimeout();
00139
00140 protected slots:
00141 void animate();
00142 void doRemoteScreenShot(QString filename, int x, int y);
00143
00144 signals:
00145 void signalRemoteScreenShot(QString filename, int x, int y);
00146
00147 protected:
00148 MythMainWindow(const bool useDB = true);
00149 virtual ~MythMainWindow();
00150
00151 void InitKeys(void);
00152
00153 bool eventFilter(QObject *o, QEvent *e);
00154 void customEvent(QEvent *ce);
00155 void closeEvent(QCloseEvent *e);
00156
00157 void drawScreen();
00158
00159 bool event(QEvent* e);
00160
00161 void ExitToMainMenu();
00162
00163 QObject *getTarget(QKeyEvent &key);
00164
00165 void SetDrawEnabled(bool enable);
00166
00167 void LockInputDevices(bool locked);
00168
00169 void ShowMouseCursor(bool show);
00170
00171 MythMainWindowPrivate *d;
00172 };
00173
00174 MUI_PUBLIC MythMainWindow *GetMythMainWindow();
00175 MUI_PUBLIC bool HasMythMainWindow();
00176 MUI_PUBLIC void DestroyMythMainWindow();
00177
00178 MUI_PUBLIC MythPainter *GetMythPainter();
00179
00180 #endif
00181