00001 #ifndef MYTHUI_TYPES_H_
00002 #define MYTHUI_TYPES_H_
00003
00004 #include <QObject>
00005 #include <QRegion>
00006 #include <QMap>
00007 #include <QList>
00008 #include <QFont>
00009 #include <QColor>
00010
00011 #include "xmlparsebase.h"
00012 #include "mythuianimation.h"
00013 #include "mythrect.h"
00014 #include "mythgesture.h"
00015 #include "mythmedia.h"
00016
00017 class MythImage;
00018 class MythPainter;
00019 class MythGestureEvent;
00020 class FontMap;
00021 class MythFontProperties;
00022
00023 class QEvent;
00024 class QKeyEvent;
00025
00026 class MythUIText;
00027 class MythUIButton;
00028 class MythUIButtonList;
00029 class MythUIButtonListItem;
00030 class MythUIImage;
00031 class MythUICheckBox;
00032 class MythUISpinBox;
00033 class MythUITextEdit;
00034 class MythUIProgressBar;
00035 class MythUIWebBrowser;
00036
00037 typedef QHash<QString,QString> InfoMap;
00038
00064 class MUI_PUBLIC MythUIType : public QObject, public XMLParseBase
00065 {
00066 Q_OBJECT
00067
00068 public:
00069 MythUIType(QObject *parent, const QString &name);
00070 virtual ~MythUIType();
00071
00072 virtual void Reset(void);
00073
00074 void AddChild(MythUIType *child);
00075 MythUIType *GetChild(const QString &name) const;
00076 MythUIType *GetChildAt(const QPoint &p, bool recursive=true,
00077 bool focusable=true) const;
00078 QList<MythUIType *> *GetAllChildren(void);
00079
00080 void DeleteChild(const QString &name);
00081 void DeleteChild(MythUIType *child);
00082 void DeleteAllChildren(void);
00083
00084
00085 bool NeedsRedraw(void) const;
00086 void ResetNeedsRedraw(void);
00087 void SetRedraw(void);
00088
00089 void SetChildNeedsRedraw(MythUIType *child);
00090
00091
00092 bool CanTakeFocus(void) const;
00093 void SetCanTakeFocus(bool set = true);
00094 void SetFocusOrder(int);
00095
00096 bool IsEnabled(void) const { return m_Enabled; }
00097 void SetEnabled(bool enable);
00098
00099 bool MoveToTop(void);
00100 bool MoveChildToTop(MythUIType *child);
00101
00102 void ActivateAnimations(MythUIAnimation::Trigger trigger);
00103 QList<MythUIAnimation*>* GetAnimations(void) { return &m_animations; }
00104
00105
00106 virtual void Pulse(void);
00107
00108 void Draw(MythPainter *p, int xoffset, int yoffset, int alphaMod = 255,
00109 QRect clipRegion = QRect());
00110
00113 void SetPosition(int x, int y);
00114 virtual void SetPosition(const MythPoint &pos);
00115 virtual MythPoint GetPosition(void) const;
00116 virtual void SetSize(const QSize &size);
00117 virtual void SetMinSize(const MythPoint &size);
00118 virtual QSize GetMinSize(void) const;
00119 virtual void SetArea(const MythRect &rect);
00120 virtual void AdjustMinArea(int delta_x, int delta_y,
00121 int delta_w, int delta_h);
00122 virtual void VanishSibling(void);
00123 virtual void SetMinAreaParent(MythRect actual_area, MythRect full_area,
00124 MythUIType *child);
00125 virtual void SetMinArea(const MythRect & rect);
00126 virtual MythRect GetArea(void) const;
00127 virtual MythRect GetFullArea(void) const;
00128 virtual void RecalculateArea(bool recurse = true);
00129 void ExpandArea(const MythRect &rect);
00130
00131 virtual QRegion GetDirtyArea(void) const;
00132
00133 bool IsVisible(bool recurse = false) const;
00134 void SetVisible(bool visible);
00135
00136 void MoveTo(QPoint destXY, QPoint speedXY);
00137
00138 void AdjustAlpha(int mode, int alphachange, int minalpha = 0,
00139 int maxalpha = 255);
00140 void SetAlpha(int newalpha);
00141 int GetAlpha(void) const;
00142
00143 virtual bool keyPressEvent(QKeyEvent *);
00144 virtual bool gestureEvent(MythGestureEvent *);
00145 virtual void mediaEvent(MythMediaEvent *);
00146
00147 MythFontProperties *GetFont(const QString &text) const;
00148 bool AddFont(const QString &text, MythFontProperties *fontProp);
00149
00150 void SetHelpText(const QString &text) { m_helptext = text; }
00151 QString GetHelpText(void) const { return m_helptext; }
00152
00153 void SetXMLLocation(const QString &filename, int where)
00154 { m_xmlLocation = QString("%1:%2").arg(filename).arg(where); }
00155 QString GetXMLLocation(void) const { return m_xmlLocation; }
00156
00157 bool IsDeferredLoading(bool recurse = false) const;
00158 void SetDeferLoad(bool defer) { m_deferload = defer; }
00159 virtual void LoadNow(void);
00160
00161 bool ContainsPoint(const QPoint &point) const;
00162
00163 virtual MythPainter *GetPainter(void);
00164 void SetPainter(MythPainter *painter) { m_Painter = painter; }
00165
00166 void SetCentre(UIEffects::Centre centre);
00167 void SetZoom(float zoom);
00168 void SetHorizontalZoom(float zoom);
00169 void SetVerticalZoom(float zoom);
00170 void SetAngle(float angle);
00171 void SetDependIsDefault(bool isDefault);
00172 void SetReverseDependence(bool reverse);
00173 void SetDependsMap(QMap<QString, QString> dependsMap);
00174 QMap<QString, QString> GetDependsMap() const { return m_dependsMap; }
00175
00176 protected:
00177 virtual void customEvent(QEvent *);
00178
00179 public slots:
00180 void LoseFocus();
00181 bool TakeFocus();
00182 void Activate();
00183 void Hide(void);
00184 void Show(void);
00185 void Refresh(void);
00186 void UpdateDependState(bool isDefault);
00187
00188 signals:
00189 void RequestUpdate();
00190 void RequestUpdate(const QRect &);
00191 void RequestRegionUpdate(const QRect &);
00192 void TakingFocus();
00193 void LosingFocus();
00194 void Showing();
00195 void Hiding();
00196 void Enabling();
00197 void Disabling();
00198 void FinishedMoving();
00199 void FinishedFading();
00200 void DependChanged(bool isDefault);
00201
00202 protected:
00203 virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset,
00204 int alphaMod, QRect clipRegion);
00205
00206 void AddFocusableChildrenToList(QMap<int, MythUIType *> &focusList);
00207 void HandleAlphaPulse();
00208 void HandleMovementPulse();
00209
00210 int CalcAlpha(int alphamod);
00211
00212 int NormX(const int width);
00213 int NormY(const int height);
00214
00215 void ConnectDependants(bool recurse = false);
00216
00217 virtual bool ParseElement(
00218 const QString &filename, QDomElement &element, bool showWarnings);
00219 virtual void CopyFrom(MythUIType *base);
00220 virtual void CreateCopy(MythUIType *parent);
00221 virtual void Finalize(void);
00222
00223 QList<MythUIType *> m_ChildrenList;
00224 QMap<QString, QString> m_dependsMap;
00225
00226 bool m_Visible;
00227 bool m_HasFocus;
00228 bool m_CanHaveFocus;
00229 bool m_Enabled;
00230 bool m_EnableInitiator;
00231 bool m_Initiator;
00232 bool m_Vanish;
00233 bool m_Vanished;
00234 bool m_IsDependDefault;
00235 bool m_ReverseDepend;
00236
00237 int m_focusOrder;
00238
00239 MythRect m_Area;
00240 MythRect m_MinArea;
00241 MythPoint m_MinSize;
00242
00243
00244 QRegion m_DirtyRegion;
00245 bool m_NeedsRedraw;
00246
00247 UIEffects m_Effects;
00248
00249 int m_AlphaChangeMode;
00250 int m_AlphaChange;
00251 int m_AlphaMin;
00252 int m_AlphaMax;
00253
00254 bool m_Moving;
00255 QPoint m_XYDestination;
00256 QPoint m_XYSpeed;
00257
00258 FontMap *m_Fonts;
00259
00260 MythUIType *m_Parent;
00261 MythPainter *m_Painter;
00262
00263 QList<MythUIAnimation*> m_animations;
00264 QString m_helptext;
00265 QString m_xmlLocation;
00266
00267 bool m_deferload;
00268
00269 QColor m_BorderColor;
00270
00271 friend class XMLParseBase;
00272 };
00273
00274
00275 #endif