00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OSDLISTBTNTYPE_H
00024 #define OSDLISTBTNTYPE_H
00025
00026 #include <vector>
00027 using namespace std;
00028
00029
00030 #include <qcolor.h>
00031 #include <qptrlist.h>
00032 #include <qevent.h>
00033 #include <qmutex.h>
00034 #include <qptrvector.h>
00035
00036
00037 #include "osdtypes.h"
00038 #include "ttfont.h"
00039 #include "generictree.h"
00040
00041 class OSDListBtnType;
00042 class OSDListBtnTypeItem;
00043 typedef vector<OSDListBtnType*> OSDListBtnList;
00044 typedef vector<OSDListBtnTypeItem*> OSDListBtnItemList;
00045
00046 class OSDGenericTree : public GenericTree
00047 {
00048 public:
00049
00050 OSDGenericTree(OSDGenericTree *parent, const QString &name,
00051 const QString &action = "", int check = -1,
00052 OSDTypeImage *image = NULL, QString group = "") :
00053 GenericTree(name), m_image(image), m_action(action),
00054 m_group(group), m_checkable(check), m_parentButton(NULL)
00055 {
00056 m_group = (m_group.isEmpty()) ? action : m_group;
00057 setSelectable(!action.isEmpty());
00058 if (parent)
00059 parent->addNode(this);
00060 }
00061
00062 QString getAction(void) const { return m_action; }
00063 QString getGroup(void) const { return m_group; }
00064 int getCheckable(void) const { return m_checkable; }
00065
00066 OSDTypeImage *getImage(void) { return m_image; }
00067 OSDListBtnTypeItem *getParentButton(void) { return m_parentButton; }
00068
00069 void setParentButton(OSDListBtnTypeItem *button)
00070 { m_parentButton = button; }
00071
00072 private:
00073 OSDTypeImage *m_image;
00074 QString m_action;
00075 QString m_group;
00076 int m_checkable;
00077 OSDListBtnTypeItem *m_parentButton;
00078 };
00079
00080
00081 class OSDListTreeType : public OSDType
00082 {
00083 Q_OBJECT
00084 public:
00085 OSDListTreeType(const QString &name, const QRect &area,
00086 const QRect &levelsize, int levelspacing,
00087 float wmult, float hmult);
00088 ~OSDListTreeType();
00089
00090 bool IsVisible(void) const { return m_visible; }
00091
00092 void SetFontActive(TTFFont *font) { m_active = font; }
00093 void SetFontInactive(TTFFont *font) { m_inactive = font; }
00094
00095 void SetGroupCheckState(QString group, int newState = 0);
00096 void SetSpacing(uint spacing)
00097 { m_unbiasedspacing = (m_spacing = spacing) / m_wmult; }
00098 void SetMargin(uint margin)
00099 { m_unbiasedmargin = (m_margin = margin) / m_wmult; }
00100 void SetItemRegColor(const QColor& beg, const QColor& end, uint alpha)
00101 { m_itemRegBeg = beg; m_itemRegEnd = end; m_itemRegAlpha = alpha; }
00102 void SetItemSelColor(const QColor& beg, const QColor& end, uint alpha)
00103 { m_itemSelBeg = beg; m_itemSelEnd = end; m_itemSelAlpha = alpha; }
00104 void SetVisible(bool visible) { m_visible = visible; }
00105 void SetAsTree(OSDGenericTree *toplevel, vector<uint> *select = NULL);
00106
00107 void Reinit(float wmult, float hmult);
00108 bool HandleKeypress(QKeyEvent *e);
00109 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff);
00110
00111 signals:
00112 void itemSelected(OSDListTreeType *parent, OSDGenericTree *item);
00113 void itemEntered(OSDListTreeType *parent, OSDGenericTree *item);
00114
00115 private:
00116 void FillLevelFromTree(OSDGenericTree *item, uint levelnum);
00117 OSDListBtnType *GetLevel(uint levelnum);
00118 void EnterItem(void);
00119 void SelectItem(void);
00120
00121 OSDGenericTree *treetop;
00122 OSDGenericTree *currentpos;
00123 TTFFont *m_active;
00124 TTFFont *m_inactive;
00125
00126 OSDListBtnList listLevels;
00127
00128 QColor m_itemRegBeg;
00129 QColor m_itemRegEnd;
00130 QColor m_itemSelBeg;
00131 QColor m_itemSelEnd;
00132 uint m_itemRegAlpha;
00133 uint m_itemSelAlpha;
00134
00135 uint m_spacing;
00136 uint m_margin;
00137 int m_levelspacing;
00138
00139 QRect m_totalarea;
00140 QRect m_levelsize;
00141
00142 float m_unbiasedspacing;
00143 float m_unbiasedmargin;
00144 QRect m_unbiasedarea;
00145 QRect m_unbiasedsize;
00146
00147 float m_wmult;
00148 float m_hmult;
00149
00150 int m_depth;
00151 int m_levelnum;
00152 bool m_visible;
00153 bool m_arrowAccel;
00154 };
00155
00156 class OSDListBtnType : public OSDType
00157 {
00158 friend class OSDListBtnTypeItem;
00159 Q_OBJECT
00160
00161 public:
00162 OSDListBtnType(const QString &name, const QRect& area,
00163 float wmult, float hmult,
00164 bool showScrollArrows = false);
00165 ~OSDListBtnType();
00166
00167
00168 bool IsVisible() const { return m_visible; }
00169
00170
00171 void SetFontActive(TTFFont *font) { m_fontActive = font; }
00172 void SetFontInactive(TTFFont *font) { m_fontInactive = font; }
00173 void SetSpacing(int spacing) { m_itemSpacing = spacing; }
00174 void SetMargin(int margin) { m_itemMargin = margin; }
00175 void SetActive(bool active) { m_active = active; }
00176 void SetVisible(bool vis) { m_visible = vis; }
00177 void SetItemRegColor(const QColor& beg, const QColor& end, uint alpha)
00178 { m_itemRegBeg = beg; m_itemRegEnd = end; m_itemRegAlpha = alpha; }
00179 void SetItemSelColor(const QColor& beg, const QColor& end, uint alpha)
00180 { m_itemSelBeg = beg; m_itemSelEnd = end; m_itemSelAlpha = alpha; }
00181 void SetGroupCheckState(QString group, int newState = 0);
00182 void SetItemCurrent(const OSDListBtnTypeItem* item);
00183 void SetItemCurrent(uint pos);
00184
00185
00186 int GetCount(void) const;
00187 int GetItemPos(const OSDListBtnTypeItem* item) const;
00188 int GetItemCurrentPos() const;
00189 OSDListBtnTypeItem* GetItemCurrent(void);
00190 OSDListBtnTypeItem* GetItemFirst(void);
00191 OSDListBtnTypeItem* GetItemNext(const OSDListBtnTypeItem *item);
00192 OSDListBtnTypeItem* GetItemAt(int pos);
00193
00194
00195 void MoveDown(void);
00196 void MoveUp(void);
00197 void MovePageDown(void);
00198 void MovePageUp(void);
00199
00200
00201 void Draw(OSDSurface *surface, int fade, int maxfade, int xoff, int yoff);
00202 void Reinit(float,float) {}
00203 void Reset(void);
00204
00205 private:
00206 void Init(void);
00207 void InitItem(OSDTypeImage &osdImg, uint width, uint height,
00208 QColor beg, QColor end, int alpha);
00209 void LoadPixmap(OSDTypeImage& pix, const QString& fileName);
00210
00211 void InsertItem(OSDListBtnTypeItem *item);
00212 void RemoveItem(OSDListBtnTypeItem *item);
00213
00214 private:
00215 int m_order;
00216 QRect m_rect;
00217 QRect m_contentsRect;
00218 QRect m_arrowsRect;
00219
00220 float m_wmult;
00221 float m_hmult;
00222
00223 int m_itemHeight;
00224 int m_itemSpacing;
00225 int m_itemMargin;
00226 uint m_itemsVisible;
00227
00228 bool m_active;
00229 bool m_showScrollArrows;
00230 bool m_showUpArrow;
00231 bool m_showDnArrow;
00232 bool m_initialized;
00233 bool m_clearing;
00234 bool m_visible;
00235
00236 QColor m_itemRegBeg;
00237 QColor m_itemRegEnd;
00238 QColor m_itemSelBeg;
00239 QColor m_itemSelEnd;
00240 uint m_itemRegAlpha;
00241 uint m_itemSelAlpha;
00242
00243 OSDTypeImage m_itemRegPix;
00244 OSDTypeImage m_itemSelActPix;
00245 OSDTypeImage m_itemSelInactPix;
00246 OSDTypeImage m_upArrowRegPix;
00247 OSDTypeImage m_dnArrowRegPix;
00248 OSDTypeImage m_upArrowActPix;
00249 OSDTypeImage m_dnArrowActPix;
00250 OSDTypeImage m_arrowPix;
00251 OSDTypeImage m_checkNonePix;
00252 OSDTypeImage m_checkHalfPix;
00253 OSDTypeImage m_checkFullPix;
00254
00255 TTFFont *m_fontActive;
00256 TTFFont *m_fontInactive;
00257
00258 int m_topIndx;
00259 int m_selIndx;
00260
00261 OSDListBtnItemList m_itemList;
00262
00263 mutable QMutex m_update;
00264
00265 signals:
00266 void itemSelected(OSDListBtnTypeItem* item);
00267 };
00268
00269 class OSDListBtnTypeItem
00270 {
00271 friend class OSDListBtnType;
00272
00273 public:
00274 enum CheckState
00275 {
00276 NotChecked = 0,
00277 HalfChecked,
00278 FullChecked,
00279 };
00280
00281 OSDListBtnTypeItem(OSDListBtnType* lbtype, const QString& text,
00282 OSDTypeImage *pixmap = 0, bool checkable = false,
00283 bool showArrow = false, CheckState state = NotChecked);
00284 ~OSDListBtnTypeItem();
00285
00286 OSDListBtnType* parent(void) const { return m_parent; }
00287 QString text(void) const { return m_text; }
00288 const OSDTypeImage* pixmap(void) const { return m_pixmap; }
00289 bool checkable(void) const { return m_checkable; }
00290 CheckState state(void) const { return m_state; }
00291 QString getGroup(void) const { return m_group; }
00292 void *getData(void) { return m_data; }
00293
00294 void setData(void *data) { m_data = data; }
00295 void setGroup(QString grp) { m_group = grp; }
00296 void setChecked(CheckState state)
00297 { m_state = (m_checkable) ? state : m_state; }
00298
00299 void Reinit(float,float) {}
00300 void paint(OSDSurface *surface, TTFFont *font, int fade, int maxfade,
00301 int x, int y);
00302
00303 protected:
00304 OSDListBtnType *m_parent;
00305 OSDTypeImage *m_pixmap;
00306 void *m_data;
00307 QString m_text;
00308 QString m_group;
00309 CheckState m_state;
00310 bool m_showArrow;
00311 bool m_checkable;
00312 QRect m_checkRect;
00313 QRect m_arrowRect;
00314 QRect m_pixmapRect;
00315 QRect m_textRect;
00316 };
00317
00318
00319 #endif