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
00153 typedef FXObjectListOf<FXListItem> FXListItemList;
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 class FXAPI FXList : public FXScrollArea {
00170 FXDECLARE(FXList)
00171 protected:
00172 FXListItemList items;
00173 FXint anchor;
00174 FXint current;
00175 FXint extent;
00176 FXint cursor;
00177 FXint viewable;
00178 FXFont *font;
00179 FXColor textColor;
00180 FXColor selbackColor;
00181 FXColor seltextColor;
00182 FXint listWidth;
00183 FXint listHeight;
00184 FXint visible;
00185 FXString help;
00186 FXListSortFunc sortfunc;
00187 FXint grabx;
00188 FXint graby;
00189 FXString lookup;
00190 FXbool state;
00191 protected:
00192 FXList();
00193 void recompute();
00194 virtual FXListItem *createItem(const FXString& text,FXIcon* icon,void* ptr);
00195 private:
00196 FXList(const FXList&);
00197 FXList &operator=(const FXList&);
00198 public:
00199 long onPaint(FXObject*,FXSelector,void*);
00200 long onEnter(FXObject*,FXSelector,void*);
00201 long onLeave(FXObject*,FXSelector,void*);
00202 long onUngrabbed(FXObject*,FXSelector,void*);
00203 long onKeyPress(FXObject*,FXSelector,void*);
00204 long onKeyRelease(FXObject*,FXSelector,void*);
00205 long onLeftBtnPress(FXObject*,FXSelector,void*);
00206 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00207 long onRightBtnPress(FXObject*,FXSelector,void*);
00208 long onRightBtnRelease(FXObject*,FXSelector,void*);
00209 long onMotion(FXObject*,FXSelector,void*);
00210 long onFocusIn(FXObject*,FXSelector,void*);
00211 long onFocusOut(FXObject*,FXSelector,void*);
00212 long onAutoScroll(FXObject*,FXSelector,void*);
00213 long onClicked(FXObject*,FXSelector,void*);
00214 long onDoubleClicked(FXObject*,FXSelector,void*);
00215 long onTripleClicked(FXObject*,FXSelector,void*);
00216 long onCommand(FXObject*,FXSelector,void*);
00217 long onQueryTip(FXObject*,FXSelector,void*);
00218 long onQueryHelp(FXObject*,FXSelector,void*);
00219 long onTipTimer(FXObject*,FXSelector,void*);
00220 long onLookupTimer(FXObject*,FXSelector,void*);
00221 long onCmdSetValue(FXObject*,FXSelector,void*);public:
00222 long onCmdGetIntValue(FXObject*,FXSelector,void*);
00223 long onCmdSetIntValue(FXObject*,FXSelector,void*);
00224 public:
00225 static FXint ascending(const FXListItem* a,const FXListItem* b);
00226 static FXint descending(const FXListItem* a,const FXListItem* b);
00227 static FXint ascendingCase(const FXListItem* a,const FXListItem* b);
00228 static FXint descendingCase(const FXListItem* a,const FXListItem* b);
00229 public:
00230 enum {
00231 ID_LOOKUPTIMER=FXScrollArea::ID_LAST,
00232 ID_LAST
00233 };
00234 public:
00235
00236
00237 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);
00238
00239
00240 virtual void create();
00241
00242
00243 virtual void detach();
00244
00245
00246 virtual void layout();
00247
00248
00249 virtual FXint getDefaultWidth();
00250
00251
00252 virtual FXint getDefaultHeight();
00253
00254
00255 virtual FXint getContentWidth();
00256
00257
00258 virtual FXint getContentHeight();
00259
00260
00261 virtual void recalc();
00262
00263
00264 virtual bool canFocus() const;
00265
00266
00267 virtual void setFocus();
00268
00269
00270 virtual void killFocus();
00271
00272
00273 FXint getNumItems() const { return items.no(); }
00274
00275
00276 FXint getNumVisible() const { return visible; }
00277
00278
00279 void setNumVisible(FXint nvis);
00280
00281
00282 FXListItem *getItem(FXint index) const;
00283
00284
00285 FXint setItem(FXint index,FXListItem* item,FXbool notify=FALSE);
00286
00287
00288 FXint setItem(FXint index,const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00289
00290
00291 FXint fillItems(const FXchar** strings,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00292
00293
00294 FXint fillItems(const FXString& strings,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00295
00296
00297 FXint insertItem(FXint index,FXListItem* item,FXbool notify=FALSE);
00298
00299
00300 FXint insertItem(FXint index,const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00301
00302
00303 FXint appendItem(FXListItem* item,FXbool notify=FALSE);
00304
00305
00306 FXint appendItem(const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00307
00308
00309 FXint prependItem(FXListItem* item,FXbool notify=FALSE);
00310
00311
00312 FXint prependItem(const FXString& text,FXIcon *icon=NULL,void* ptr=NULL,FXbool notify=FALSE);
00313
00314
00315 FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=FALSE);
00316
00317
00318 FXListItem* extractItem(FXint index,FXbool notify=FALSE);
00319
00320
00321 void removeItem(FXint index,FXbool notify=FALSE);
00322
00323
00324 void clearItems(FXbool notify=FALSE);
00325
00326
00327 FXint getItemWidth(FXint index) const;
00328
00329
00330 FXint getItemHeight(FXint index) const;
00331
00332
00333 virtual FXint getItemAt(FXint x,FXint y) const;
00334
00335
00336 FXint hitItem(FXint index,FXint x,FXint y) const;
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348 FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00349
00350
00351
00352
00353
00354
00355
00356
00357 FXint findItemByData(const void *ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00358
00359
00360 virtual void makeItemVisible(FXint index);
00361
00362
00363 void setItemText(FXint index,const FXString& text);
00364
00365
00366 FXString getItemText(FXint index) const;
00367
00368
00369 void setItemIcon(FXint index,FXIcon* icon,FXbool owned=FALSE);
00370
00371
00372 FXIcon* getItemIcon(FXint index) const;
00373
00374
00375 void setItemData(FXint index,void* ptr);
00376
00377
00378 void* getItemData(FXint index) const;
00379
00380
00381 FXbool isItemSelected(FXint index) const;
00382
00383
00384 FXbool isItemCurrent(FXint index) const;
00385
00386
00387 FXbool isItemVisible(FXint index) const;
00388
00389
00390 FXbool isItemEnabled(FXint index) const;
00391
00392
00393 void updateItem(FXint index) const;
00394
00395
00396 virtual FXbool enableItem(FXint index);
00397
00398
00399 virtual FXbool disableItem(FXint index);
00400
00401
00402 virtual FXbool selectItem(FXint index,FXbool notify=FALSE);
00403
00404
00405 virtual FXbool deselectItem(FXint index,FXbool notify=FALSE);
00406
00407
00408 virtual FXbool toggleItem(FXint index,FXbool notify=FALSE);
00409
00410
00411 virtual FXbool extendSelection(FXint index,FXbool notify=FALSE);
00412
00413
00414 virtual FXbool killSelection(FXbool notify=FALSE);
00415
00416
00417 virtual void setCurrentItem(FXint index,FXbool notify=FALSE);
00418
00419
00420 FXint getCurrentItem() const { return current; }
00421
00422
00423 void setAnchorItem(FXint index);
00424
00425
00426 FXint getAnchorItem() const { return anchor; }
00427
00428
00429 FXint getCursorItem() const { return cursor; }
00430
00431
00432 void sortItems();
00433
00434
00435 FXListSortFunc getSortFunc() const { return sortfunc; }
00436
00437
00438 void setSortFunc(FXListSortFunc func){ sortfunc=func; }
00439
00440
00441 void setFont(FXFont* fnt);
00442
00443
00444 FXFont* getFont() const { return font; }
00445
00446
00447 FXColor getTextColor() const { return textColor; }
00448
00449
00450 void setTextColor(FXColor clr);
00451
00452
00453 FXColor getSelBackColor() const { return selbackColor; }
00454
00455
00456 void setSelBackColor(FXColor clr);
00457
00458
00459 FXColor getSelTextColor() const { return seltextColor; }
00460
00461
00462 void setSelTextColor(FXColor clr);
00463
00464
00465 FXuint getListStyle() const;
00466
00467
00468 void setListStyle(FXuint style);
00469
00470
00471 void setHelpText(const FXString& text);
00472
00473
00474 const FXString& getHelpText() const { return help; }
00475
00476
00477 virtual void save(FXStream& store) const;
00478
00479
00480 virtual void load(FXStream& store);
00481
00482
00483 virtual ~FXList();
00484 };
00485
00486 }
00487
00488 #endif