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