00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXLIST_H
00022 #define FXLIST_H
00023
00024 #ifndef FXSCROLLAREA_H
00025 #include "FXScrollArea.h"
00026 #endif
00027
00028 namespace FX {
00029
00030
00032 enum {
00033 LIST_EXTENDEDSELECT = 0,
00034 LIST_SINGLESELECT = 0x00100000,
00035 LIST_BROWSESELECT = 0x00200000,
00036 LIST_MULTIPLESELECT = 0x00300000,
00037 LIST_AUTOSELECT = 0x00400000,
00038 LIST_NORMAL = LIST_EXTENDEDSELECT
00039 };
00040
00041
00042 class FXIcon;
00043 class FXFont;
00044 class FXList;
00045
00046
00048 class FXAPI FXListItem : public FXObject {
00049 FXDECLARE(FXListItem)
00050 friend class FXList;
00051 protected:
00052 FXString label;
00053 FXIcon *icon;
00054 void *data;
00055 FXuint state;
00056 FXint x,y;
00057 private:
00058 FXListItem(const FXListItem&);
00059 FXListItem& operator=(const FXListItem&);
00060 protected:
00061 FXListItem():icon(NULL),data(NULL),state(0),x(0),y(0){}
00062 virtual void draw(const FXList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00063 virtual FXint hitItem(const FXList* list,FXint x,FXint y) const;
00064 public:
00065 enum {
00066 SELECTED = 1,
00067 FOCUS = 2,
00068 DISABLED = 4,
00069 DRAGGABLE = 8,
00070 ICONOWNED = 16
00071 };
00072 public:
00073
00075 FXListItem(const FXString& text,FXIcon* ic=NULL,void* ptr=NULL):label(text),icon(ic),data(ptr),state(0),x(0),y(0){}
00076
00078 virtual void setText(const FXString& txt);
00079
00081 const FXString& getText() const { return label; }
00082
00084 virtual void setIcon(FXIcon* icn,FXbool owned=false);
00085
00087 FXIcon* getIcon() const { return icon; }
00088
00090 void setData(void* ptr){ data=ptr; }
00091
00093 void* getData() const { return data; }
00094
00096 virtual void setFocus(FXbool focus);
00097
00099 FXbool hasFocus() const { return (state&FOCUS)!=0; }
00100
00102 virtual void setSelected(FXbool selected);
00103
00105 FXbool isSelected() const { return (state&SELECTED)!=0; }
00106
00108 virtual void setEnabled(FXbool enabled);
00109
00111 FXbool isEnabled() const { return (state&DISABLED)==0; }
00112
00114 virtual void setDraggable(FXbool draggable);
00115
00117 FXbool isDraggable() const { return (state&DRAGGABLE)!=0; }
00118
00120 virtual FXString getTipText() const;
00121
00123 virtual FXint getWidth(const FXList* list) const;
00124
00126 virtual FXint getHeight(const FXList* list) const;
00127
00129 virtual void create();
00130
00132 virtual void detach();
00133
00135 virtual void destroy();
00136
00138 virtual void save(FXStream& store) const;
00139
00141 virtual void load(FXStream& store);
00142
00144 virtual ~FXListItem();
00145 };
00146
00147
00149 typedef FXint (*FXListSortFunc)(const FXListItem*,const FXListItem*);
00150
00151
00153
00154
00156 typedef FXObjectListOf<FXListItem> FXListItemList;
00157
00158
00172 class FXAPI FXList : public FXScrollArea {
00173 FXDECLARE(FXList)
00174 protected:
00175 FXListItemList items;
00176 FXint anchor;
00177 FXint current;
00178 FXint extent;
00179 FXint viewable;
00180 FXFont *font;
00181 FXColor textColor;
00182 FXColor selbackColor;
00183 FXColor seltextColor;
00184 FXint listWidth;
00185 FXint listHeight;
00186 FXint visible;
00187 FXString help;
00188 FXListSortFunc sortfunc;
00189 FXint grabx;
00190 FXint graby;
00191 FXString lookup;
00192 FXbool state;
00193 protected:
00194 FXList();
00195 void recompute();
00196 virtual FXListItem *createItem(const FXString& text,FXIcon* icon,void* ptr);
00197 private:
00198 FXList(const FXList&);
00199 FXList &operator=(const FXList&);
00200 public:
00201 long onPaint(FXObject*,FXSelector,void*);
00202 long onEnter(FXObject*,FXSelector,void*);
00203 long onLeave(FXObject*,FXSelector,void*);
00204 long onUngrabbed(FXObject*,FXSelector,void*);
00205 long onKeyPress(FXObject*,FXSelector,void*);
00206 long onKeyRelease(FXObject*,FXSelector,void*);
00207 long onLeftBtnPress(FXObject*,FXSelector,void*);
00208 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00209 long onRightBtnPress(FXObject*,FXSelector,void*);
00210 long onRightBtnRelease(FXObject*,FXSelector,void*);
00211 long onMotion(FXObject*,FXSelector,void*);
00212 long onFocusIn(FXObject*,FXSelector,void*);
00213 long onFocusOut(FXObject*,FXSelector,void*);
00214 long onAutoScroll(FXObject*,FXSelector,void*);
00215 long onClicked(FXObject*,FXSelector,void*);
00216 long onDoubleClicked(FXObject*,FXSelector,void*);
00217 long onTripleClicked(FXObject*,FXSelector,void*);
00218 long onCommand(FXObject*,FXSelector,void*);
00219 long onQueryTip(FXObject*,FXSelector,void*);
00220 long onQueryHelp(FXObject*,FXSelector,void*);
00221 long onTipTimer(FXObject*,FXSelector,void*);
00222 long onLookupTimer(FXObject*,FXSelector,void*);
00223 long onCmdSetValue(FXObject*,FXSelector,void*);public:
00224 long onCmdGetIntValue(FXObject*,FXSelector,void*);
00225 long onCmdSetIntValue(FXObject*,FXSelector,void*);
00226 public:
00227 static FXint ascending(const FXListItem* a,const FXListItem* b);
00228 static FXint descending(const FXListItem* a,const FXListItem* b);
00229 static FXint ascendingCase(const FXListItem* a,const FXListItem* b);
00230 static FXint descendingCase(const FXListItem* a,const FXListItem* b);
00231 public:
00232 enum {
00233 ID_LOOKUPTIMER=FXScrollArea::ID_LAST,
00234 ID_LAST
00235 };
00236 public:
00237
00239 FXList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=LIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00240
00242 virtual void create();
00243
00245 virtual void detach();
00246
00248 virtual void layout();
00249
00251 virtual FXint getDefaultWidth();
00252
00254 virtual FXint getDefaultHeight();
00255
00257 virtual FXint getContentWidth();
00258
00260 virtual FXint getContentHeight();
00261
00263 virtual void recalc();
00264
00266 virtual FXbool canFocus() const;
00267
00269 virtual void setFocus();
00270
00272 virtual void killFocus();
00273
00275 FXint getNumItems() const { return items.no(); }
00276
00278 FXint getNumVisible() const { return visible; }
00279
00281 void setNumVisible(FXint nvis);
00282
00284 FXListItem *getItem(FXint index) const;
00285
00287 FXint setItem(FXint index,FXListItem* item,FXbool notify=false);
00288
00290 FXint setItem(FXint index,const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=false);
00291
00293 FXint fillItems(const FXchar** strings,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=false);
00294
00296 FXint fillItems(const FXString& strings,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=false);
00297
00299 FXint insertItem(FXint index,FXListItem* item,FXbool notify=false);
00300
00302 FXint insertItem(FXint index,const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=false);
00303
00305 FXint appendItem(FXListItem* item,FXbool notify=false);
00306
00308 FXint appendItem(const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=false);
00309
00311 FXint prependItem(FXListItem* item,FXbool notify=false);
00312
00314 FXint prependItem(const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=false);
00315
00317 FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=false);
00318
00320 FXListItem* extractItem(FXint index,FXbool notify=false);
00321
00323 void removeItem(FXint index,FXbool notify=false);
00324
00326 void clearItems(FXbool notify=false);
00327
00329 FXint getItemWidth(FXint index) const;
00330
00332 FXint getItemHeight(FXint index) const;
00333
00335 virtual FXint getItemAt(FXint x,FXint y) const;
00336
00338 FXint hitItem(FXint index,FXint x,FXint y) const;
00339
00350 FXint findItem(const FXString& string,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00351
00359 FXint findItemByData(const void *ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00360
00362 virtual void makeItemVisible(FXint index);
00363
00365 void setItemText(FXint index,const FXString& text);
00366
00368 FXString getItemText(FXint index) const;
00369
00371 void setItemIcon(FXint index,FXIcon* icon,FXbool owned=false);
00372
00374 FXIcon* getItemIcon(FXint index) const;
00375
00377 void setItemData(FXint index,void* ptr);
00378
00380 void* getItemData(FXint index) const;
00381
00383 FXbool isItemSelected(FXint index) const;
00384
00386 FXbool isItemCurrent(FXint index) const;
00387
00389 FXbool isItemVisible(FXint index) const;
00390
00392 FXbool isItemEnabled(FXint index) const;
00393
00395 void updateItem(FXint index) const;
00396
00398 virtual FXbool enableItem(FXint index);
00399
00401 virtual FXbool disableItem(FXint index);
00402
00404 virtual FXbool selectItem(FXint index,FXbool notify=false);
00405
00407 virtual FXbool deselectItem(FXint index,FXbool notify=false);
00408
00410 virtual FXbool toggleItem(FXint index,FXbool notify=false);
00411
00413 virtual FXbool extendSelection(FXint index,FXbool notify=false);
00414
00416 virtual FXbool killSelection(FXbool notify=false);
00417
00419 virtual void setCurrentItem(FXint index,FXbool notify=false);
00420
00422 FXint getCurrentItem() const { return current; }
00423
00425 void setAnchorItem(FXint index);
00426
00428 FXint getAnchorItem() const { return anchor; }
00429
00431 void sortItems();
00432
00434 FXListSortFunc getSortFunc() const { return sortfunc; }
00435
00437 void setSortFunc(FXListSortFunc func){ sortfunc=func; }
00438
00440 void setFont(FXFont* fnt);
00441
00443 FXFont* getFont() const { return font; }
00444
00446 FXColor getTextColor() const { return textColor; }
00447
00449 void setTextColor(FXColor clr);
00450
00452 FXColor getSelBackColor() const { return selbackColor; }
00453
00455 void setSelBackColor(FXColor clr);
00456
00458 FXColor getSelTextColor() const { return seltextColor; }
00459
00461 void setSelTextColor(FXColor clr);
00462
00464 FXuint getListStyle() const;
00465
00467 void setListStyle(FXuint style);
00468
00470 void setHelpText(const FXString& text);
00471
00473 const FXString& getHelpText() const { return help; }
00474
00476 virtual void save(FXStream& store) const;
00477
00479 virtual void load(FXStream& store);
00480
00482 virtual ~FXList();
00483 };
00484
00485 }
00486
00487 #endif