00001 #ifndef MYTHUI_TYPES_H_
00002 #define MYTHUI_TYPES_H_
00003
00004 #include <qobject.h>
00005 #include <qimage.h>
00006 #include <qobjectlist.h>
00007 #include <qptrlist.h>
00008 #include <qvaluevector.h>
00009 #include <qfont.h>
00010
00011 #include "xmlparsebase.h"
00012
00013 class MythImage;
00014 class MythPainter;
00015 class MythGestureEvent;
00016 class FontMap;
00017 class MythFontProperties;
00018
00022 class MythUIType : public QObject, public XMLParseBase
00023 {
00024 Q_OBJECT
00025
00026 public:
00027 MythUIType(QObject *parent, const char *name);
00028 virtual ~MythUIType();
00029
00030 void AddChild(MythUIType *child);
00031 MythUIType *GetChild(const char *name, const char *inherits = 0);
00032 virtual MythUIType *GetChildAt(const QPoint &p);
00033 QValueVector<MythUIType *> *GetAllChildren(void);
00034
00035 void DeleteAllChildren(void);
00036
00037
00038 bool NeedsRedraw(void);
00039 void SetRedraw();
00040
00041 void SetChildNeedsRedraw(MythUIType *child);
00042
00043
00044 bool CanTakeFocus(void);
00045 void SetCanTakeFocus(bool set = true);
00046
00047
00048 virtual void Pulse(void);
00049
00050 void Draw(MythPainter *p, int xoffset, int yoffset, int alphaMod = 255,
00051 QRect clipRegion = QRect());
00052
00053 virtual void SetPosition(int x, int y);
00054 virtual void SetPosition(const QPoint &pos);
00055 virtual void SetArea(const QRect &rect);
00056 virtual QRect GetArea(void) const;
00057
00058 virtual QRegion GetDirtyArea(void) const;
00059
00060 QString cutDown(const QString &data, QFont *font,
00061 bool multiline = false, int overload_width = -1,
00062 int overload_height = -1);
00063
00064 bool IsVisible(void);
00065 void SetVisible(bool visible);
00066
00067 void MoveTo(QPoint destXY, QPoint speedXY);
00068
00069 void AdjustAlpha(int mode, int alphachange, int minalpha = 0,
00070 int maxalpha = 255);
00071 void SetAlpha(int newalpha);
00072 int GetAlpha(void);
00073
00074 virtual bool keyPressEvent(QKeyEvent *);
00075 virtual void gestureEvent(MythUIType *origtype, MythGestureEvent *ge);
00076
00077 MythFontProperties *GetFont(const QString &text);
00078 bool AddFont(const QString &text, MythFontProperties *fontProp);
00079
00080 protected:
00081 virtual void customEvent(QCustomEvent *);
00082
00083 public slots:
00084 void LoseFocus();
00085 bool TakeFocus();
00086 void Activate();
00087 void Hide(void);
00088 void Show(void);
00089 void Refresh(void);
00090
00091 signals:
00092 void RequestUpdate();
00093 void RequestUpdate(const QRect &);
00094 void RequestRegionUpdate(const QRect &);
00095 void TakingFocus();
00096 void LosingFocus();
00097 void Showing();
00098 void Hiding();
00099 void FinishedMoving();
00100 void FinishedFading();
00101
00102 protected:
00103 virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset,
00104 int alphaMod, QRect clipRegion);
00105
00106 void AddFocusableChildrenToList(QPtrList<MythUIType> &focusList);
00107 void HandleAlphaPulse();
00108 void HandleMovementPulse();
00109
00110 int CalcAlpha(int alphamod);
00111
00112 QFont CreateQFont(const QString &face, int pointSize = 12,
00113 int weight = QFont::Normal, bool italic = FALSE);
00114 QRect NormRect(const QRect &rect);
00115 QPoint NormPoint(const QPoint &point);
00116 int NormX(const int width);
00117 int NormY(const int height);
00118
00119 virtual bool ParseElement(QDomElement &element);
00120 virtual void CopyFrom(MythUIType *base);
00121 virtual void CreateCopy(MythUIType *parent);
00122 virtual void Finalize(void);
00123
00124 QValueVector<MythUIType *> m_ChildrenList;
00125
00126 bool m_Visible;
00127 bool m_HasFocus;
00128 bool m_CanHaveFocus;
00129
00130 QRect m_Area;
00131
00132 QRegion m_DirtyRegion;
00133 bool m_NeedsRedraw;
00134
00135 int m_Alpha;
00136 int m_AlphaChangeMode;
00137 int m_AlphaChange;
00138 int m_AlphaMin;
00139 int m_AlphaMax;
00140
00141 bool m_Moving;
00142 QPoint m_XYDestination;
00143 QPoint m_XYSpeed;
00144
00145 FontMap *m_Fonts;
00146
00147 MythUIType *m_Parent;
00148
00149 friend class XMLParseBase;
00150 };
00151
00152
00153 #endif