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