00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef UILISTBTNTYPE_H
00023 #define UILISTBTNTYPE_H
00024
00025 #include "uitypes.h"
00026
00027 class UIListBtnType;
00028 class UIListBtnTypeItem;
00029
00030 class MPUBLIC UIListGenericTree : public GenericTree
00031 {
00032 public:
00033
00034 UIListGenericTree(UIListGenericTree *parent, const QString &name,
00035 const QString &action = "", int check = -1,
00036 QPixmap *image = NULL);
00037 virtual ~UIListGenericTree();
00038
00039 QPixmap *getImage(void) { return m_image; }
00040 QString getAction(void) { return m_action; }
00041 int getCheck(void) { return m_check; }
00042 virtual void setCheck(int flag);
00043
00044 void setItem(UIListBtnTypeItem *item) { m_physitem = item; }
00045 UIListBtnTypeItem *getItem(void) { return m_physitem; }
00046
00047 void setText(const QString &text);
00048 void setPixmap(QPixmap *pixmap);
00049 void setDrawArrow(bool flag);
00050
00051 void RemoveFromParent(void);
00052
00053 void setActive(bool flag);
00054 bool getActive(void);
00055
00056 bool movePositionUpDown(bool flag);
00057
00058
00059 protected:
00060 QPixmap *m_image;
00061 QString m_action;
00062 int m_check;
00063
00064 UIListBtnTypeItem *m_physitem;
00065
00066 bool m_active;
00067 };
00068
00069 class MPUBLIC UIListTreeType : public UIType
00070 {
00071 Q_OBJECT
00072 public:
00073 UIListTreeType(const QString &name, const QRect &area,
00074 const QRect &levelsize, int levelspacing, int order);
00075 ~UIListTreeType();
00076
00077 void SetFontActive(fontProp *font);
00078 void SetFontInactive(fontProp *font);
00079 void SetSpacing(int spacing);
00080 void SetMargin(int margin);
00081 void SetItemRegColor(const QColor& beg, const QColor& end, uint alpha);
00082 void SetItemSelColor(const QColor& beg, const QColor& end, uint alpha);
00083
00084 void SetTree(UIListGenericTree *toplevel);
00085
00086 UIListGenericTree *GetCurrentPosition(void);
00087
00088 void Draw(QPainter *p, int order, int context);
00089 void DrawRegion(QPainter *p, QRect &area, int order, int context);
00090
00091 void Redraw(void);
00092 void RedrawCurrent(void);
00093
00094 void RefreshCurrentLevel(void);
00095
00096 enum MovementUnit { MoveItem, MovePage, MoveMax };
00097 void MoveDown(MovementUnit unit = MoveItem);
00098 void MoveDown(int count);
00099 void MoveUp(MovementUnit unit = MoveItem);
00100 void MoveUp(int count);
00101 void MoveLeft(bool do_refresh = true);
00102 bool MoveRight(bool do_refresh = true);
00103 void calculateScreenArea();
00104 void GoHome();
00105 void select();
00106 QStringList getRouteToCurrent();
00107 bool tryToSetCurrent(QStringList route);
00108 int getDepth();
00109 void setActive(bool x);
00110 bool isActive(){ return list_tree_active; }
00111 void enter();
00112 void moveAwayFrom(UIListGenericTree *node);
00113 int getNumbItemsVisible();
00114 bool incSearchStart();
00115 bool incSearchNext();
00116
00117 signals:
00118
00119 void selected(UIListGenericTree *item);
00120 void itemSelected(UIListTreeType *parent, UIListGenericTree *item);
00121 void itemEntered(UIListTreeType *parent, UIListGenericTree *item);
00122
00123 public slots:
00124 bool takeFocus();
00125 void looseFocus();
00126
00127 private:
00128 void FillLevelFromTree(UIListGenericTree *item, UIListBtnType *list);
00129 void ClearLevel(UIListBtnType *list);
00130 UIListBtnType *GetLevel(int levelnum);
00131 void SetCurrentPosition(void);
00132 void CreateLevel(int level);
00133
00134 int levels;
00135 int curlevel;
00136
00137 UIListGenericTree *treetop;
00138 UIListGenericTree *currentpos;
00139
00140 QPtrList<UIListBtnType> listLevels;
00141
00142 UIListBtnType *currentlevel;
00143
00144 fontProp *m_active;
00145 fontProp *m_inactive;
00146
00147 QColor m_itemRegBeg;
00148 QColor m_itemRegEnd;
00149 QColor m_itemSelBeg;
00150 QColor m_itemSelEnd;
00151 uint m_itemRegAlpha;
00152 uint m_itemSelAlpha;
00153
00154 int m_spacing;
00155 int m_margin;
00156
00157 QRect m_totalarea;
00158 QRect m_levelsize;
00159 int m_levelspacing;
00160
00161 bool list_tree_active;
00162 };
00163
00164 class MPUBLIC UIListBtnType : public UIType
00165 {
00166 Q_OBJECT
00167 public:
00168 UIListBtnType(const QString& name, const QRect& area, int order,
00169 bool showArrow=true, bool showScrollArrows=false);
00170 ~UIListBtnType();
00171
00172 void SetParentListTree(UIListTreeType* parent) { m_parentListTree = parent;}
00173 void SetFontActive(fontProp *font);
00174 void SetFontInactive(fontProp *font);
00175 void SetSpacing(int spacing);
00176 void SetMargin(int margin);
00177 void SetItemRegColor(const QColor& beg, const QColor& end, uint alpha);
00178 void SetItemSelColor(const QColor& beg, const QColor& end, uint alpha);
00179 void SetJustification(int justification) { m_justify = justification; }
00180
00181 void Draw(QPainter *p, int order, int context);
00182 void Draw(QPainter *p, int order, int context, bool active_on);
00183 void SetActive(bool active);
00184 void Reset();
00185 void calculateScreenArea();
00186
00187 void SetItemCurrent(UIListBtnTypeItem* item);
00188 void SetItemCurrent(int pos);
00189 UIListBtnTypeItem* GetItemCurrent();
00190 UIListBtnTypeItem* GetItemFirst();
00191 UIListBtnTypeItem* GetItemNext(UIListBtnTypeItem *item);
00192 UIListBtnTypeItem* GetItemAt(int pos);
00193
00194 bool MoveItemUpDown(UIListBtnTypeItem *item, bool flag);
00195
00196 QPtrListIterator<UIListBtnTypeItem> GetIterator();
00197
00198 int GetItemPos(UIListBtnTypeItem* item);
00199 int GetCount();
00200
00201 enum MovementUnit { MoveItem, MovePage, MoveMax };
00202 void MoveDown(MovementUnit unit=MoveItem);
00203 void MoveDown(int count);
00204 void MoveUp(MovementUnit unit=MoveItem);
00205 void MoveUp(int count);
00206 bool MoveToNamedPosition(const QString &position_name);
00207
00208 bool incSearchStart();
00209 bool incSearchNext();
00210
00211 bool IsVisible() { return m_visible; }
00212 void SetVisible(bool vis) { m_visible = vis; }
00213
00214 void SetDrawOffset(int x) { m_xdrawoffset = x; }
00215 int GetDrawOffset(void) { return m_xdrawoffset; }
00216
00217 QRect GetArea(void) { return m_rect; }
00218 uint GetNumbItemsVisible(){ return m_itemsVisible; }
00219
00220 public slots:
00221 bool takeFocus();
00222 void looseFocus();
00223
00224 private:
00225 void Init();
00226 void LoadPixmap(QPixmap& pix, const QString& fileName);
00227
00228 void InsertItem(UIListBtnTypeItem *item);
00229 void RemoveItem(UIListBtnTypeItem *item);
00230
00231 UIListTreeType *m_parentListTree;
00232
00233 QRect m_rect;
00234 QRect m_contentsRect;
00235 QRect m_arrowsRect;
00236
00237 int m_itemHeight;
00238 int m_itemSpacing;
00239 int m_itemMargin;
00240 uint m_itemsVisible;
00241
00242 int m_justify;
00243
00244 bool m_active;
00245 bool m_visible;
00246 bool m_showScrollArrows;
00247 bool m_showArrow;
00248 bool m_showUpArrow;
00249 bool m_showDnArrow;
00250
00251 QPixmap m_itemRegPix;
00252 QPixmap m_itemSelActPix;
00253 QPixmap m_itemSelInactPix;
00254 QPixmap m_upArrowRegPix;
00255 QPixmap m_dnArrowRegPix;
00256 QPixmap m_upArrowActPix;
00257 QPixmap m_dnArrowActPix;
00258 QPixmap m_arrowPix;
00259 QPixmap m_checkNonePix;
00260 QPixmap m_checkHalfPix;
00261 QPixmap m_checkFullPix;
00262
00263 QColor m_itemRegBeg;
00264 QColor m_itemRegEnd;
00265 QColor m_itemSelBeg;
00266 QColor m_itemSelEnd;
00267 uint m_itemRegAlpha;
00268 uint m_itemSelAlpha;
00269
00270 fontProp* m_fontActive;
00271 fontProp* m_fontInactive;
00272
00273 bool m_initialized;
00274 bool m_clearing;
00275
00276 UIListBtnTypeItem* m_topItem;
00277 UIListBtnTypeItem* m_selItem;
00278
00279 QPtrListIterator<UIListBtnTypeItem> *m_topIterator;
00280 QPtrListIterator<UIListBtnTypeItem> *m_selIterator;
00281
00282 int m_selPosition;
00283 int m_topPosition;
00284 int m_itemCount;
00285
00286 QPtrList<UIListBtnTypeItem> m_itemList;
00287
00288 friend class UIListBtnTypeItem;
00289
00290 int m_xdrawoffset;
00291
00292 QString m_incSearch;
00293 bool m_bIncSearchContains;
00294
00295 signals:
00296
00297 void itemSelected(UIListBtnTypeItem* item);
00298 };
00299
00300 class MPUBLIC UIListBtnTypeItem
00301 {
00302
00303 public:
00304
00305 enum CheckState {
00306 CantCheck=-1,
00307 NotChecked=0,
00308 HalfChecked,
00309 FullChecked
00310 };
00311
00312 UIListBtnTypeItem(UIListBtnType* lbtype, const QString& text,
00313 QPixmap *pixmap = 0, bool checkable = false,
00314 CheckState state = CantCheck, bool showArrow = false);
00315 ~UIListBtnTypeItem();
00316
00317 UIListBtnType *parent() const;
00318
00319 void setText(const QString &text);
00320 QString text() const;
00321
00322 void setPixmap(QPixmap *pixmap);
00323 const QPixmap *pixmap() const;
00324
00325 bool checkable() const;
00326 void setCheckable(bool flag);
00327
00328 CheckState state() const;
00329 void setChecked(CheckState state);
00330
00331 void setDrawArrow(bool flag);
00332 bool getDrawArrow(void) { return m_showArrow; }
00333
00334 void setData(void *data);
00335 void *getData();
00336
00337 void setOverrideInactive(bool flag);
00338 bool getOverrideInactive(void);
00339
00340 void setJustification(int justification) { m_justify = justification; }
00341 int getJustification(void) const { return m_justify; }
00342
00343 bool moveUpDown(bool flag);
00344
00345 void paint(QPainter *p, fontProp *font, int x, int y, bool active_on);
00346
00347 protected:
00348 void CalcDimensions(void);
00349
00350 UIListBtnType *m_parent;
00351 QString m_text;
00352 QPixmap *m_pixmap;
00353 bool m_checkable;
00354 CheckState m_state;
00355 void *m_data;
00356
00357 QRect m_checkRect;
00358 QRect m_pixmapRect;
00359 QRect m_textRect;
00360 QRect m_arrowRect;
00361
00362 bool m_showArrow;
00363
00364 bool m_overrideInactive;
00365 int m_justify;
00366
00367 friend class UIListBtnType;
00368 };
00369
00370
00371
00372 #endif