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