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 FXICONLIST_H
00025
#define FXICONLIST_H
00026
00027
#ifndef FXSCROLLAREA_H
00028
#include "FXScrollArea.h"
00029
#endif
00030
00031
namespace FX {
00032
00033
00034
00035
enum {
00036
ICONLIST_EXTENDEDSELECT = 0,
00037
ICONLIST_SINGLESELECT = 0x00100000,
00038
ICONLIST_BROWSESELECT = 0x00200000,
00039
ICONLIST_MULTIPLESELECT = 0x00300000,
00040
ICONLIST_AUTOSIZE = 0x00400000,
00041
ICONLIST_DETAILED = 0,
00042
ICONLIST_MINI_ICONS = 0x00800000,
00043
ICONLIST_BIG_ICONS = 0x01000000,
00044
ICONLIST_ROWS = 0,
00045
ICONLIST_COLUMNS = 0x02000000,
00046 ICONLIST_NORMAL =
ICONLIST_EXTENDEDSELECT
00047 };
00048
00049
00050
class FXIcon;
00051
class FXHeader;
00052
class FXFont;
00053
class FXIconList;
00054
class FXFileList;
00055
00056
00057
00058
class FXAPI FXIconItem :
public FXObject {
00059 FXDECLARE(FXIconItem)
00060 friend class FXIconList;
00061 friend class FXFileList;
00062 protected:
00063 FXString label;
00064 FXIcon *bigIcon;
00065 FXIcon *miniIcon;
00066 void *data;
00067 FXuint state;
00068 protected:
00069 FXIconItem():bigIcon(NULL),miniIcon(NULL),data(NULL),state(0){}
00070
virtual void draw(
const FXIconList* list,
FXDC& dc,FXint x,FXint y,FXint w,FXint h)
const;
00071
virtual FXint hitItem(
const FXIconList* list,FXint rx,FXint ry,FXint rw=1,FXint rh=1)
const;
00072
protected:
00073
virtual void drawBigIcon(
const FXIconList* list,
FXDC& dc,FXint x,FXint y,FXint w,FXint h)
const;
00074
virtual void drawMiniIcon(
const FXIconList* list,
FXDC& dc,FXint x,FXint y,FXint w,FXint h)
const;
00075
virtual void drawDetails(
const FXIconList* list,
FXDC& dc,FXint x,FXint y,FXint w,FXint h)
const;
00076
protected:
00077
enum {
00078 SELECTED = 1,
00079 FOCUS = 2,
00080 DISABLED = 4,
00081 DRAGGABLE = 8,
00082 BIGICONOWNED = 16,
00083 MINIICONOWNED = 32
00084 };
00085
public:
00086 FXIconItem(
const FXString& text,FXIcon* bi=NULL,FXIcon* mi=NULL,
void* ptr=NULL):label(text),bigIcon(bi),miniIcon(mi),data(ptr),state(0){}
00087
virtual void setText(
const FXString& txt){ label=txt; }
00088
const FXString& getText()
const {
return label; }
00089
virtual void setBigIcon(FXIcon* icn){ bigIcon=icn; }
00090 FXIcon* getBigIcon()
const {
return bigIcon; }
00091
virtual void setMiniIcon(FXIcon* icn){ miniIcon=icn; }
00092 FXIcon* getMiniIcon()
const {
return miniIcon; }
00093
void setData(
void* ptr){ data=ptr; }
00094
void* getData()
const {
return data; }
00095
virtual void setFocus(FXbool focus);
00096 FXbool hasFocus()
const {
return (state&FOCUS)!=0; }
00097
virtual void setSelected(FXbool selected);
00098 FXbool isSelected()
const {
return (state&SELECTED)!=0; }
00099
virtual void setEnabled(FXbool enabled);
00100 FXbool isEnabled()
const {
return (state&DISABLED)==0; }
00101
virtual void setDraggable(FXbool draggable);
00102 FXbool isDraggable()
const {
return (state&DRAGGABLE)!=0; }
00103
virtual void setIconOwned(FXuint owned=(BIGICONOWNED|MINIICONOWNED));
00104 FXuint isIconOwned()
const {
return (state&(BIGICONOWNED|MINIICONOWNED)); }
00105
virtual FXint getWidth(
const FXIconList* list)
const;
00106
virtual FXint getHeight(
const FXIconList* list)
const;
00107
virtual void create();
00108
virtual void detach();
00109
virtual void destroy();
00110
virtual void save(FXStream& store)
const;
00111
virtual void load(FXStream& store);
00112
virtual ~FXIconItem();
00113 };
00114
00115
00116
00117
typedef FXint (*FXIconListSortFunc)(
const FXIconItem*,
const FXIconItem*);
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
class FXAPI FXIconList :
public FXScrollArea {
00141 FXDECLARE(FXIconList)
00142
protected:
00143
FXHeader *header;
00144 FXIconItem **items;
00145 FXint nitems;
00146 FXint nrows;
00147 FXint ncols;
00148 FXint anchor;
00149 FXint current;
00150 FXint extent;
00151 FXint cursor;
00152
FXFont *font;
00153 FXIconListSortFunc sortfunc;
00154 FXColor textColor;
00155 FXColor selbackColor;
00156 FXColor seltextColor;
00157 FXint itemWidth;
00158 FXint itemHeight;
00159 FXint itemSpace;
00160 FXint anchorx;
00161 FXint anchory;
00162 FXint currentx;
00163 FXint currenty;
00164 FXint grabx;
00165 FXint graby;
00166
FXString lookup;
00167
FXString help;
00168 FXbool state;
00169
protected:
00170 FXIconList();
00171
virtual FXIconItem *createItem(
const FXString& text,
FXIcon *big,
FXIcon* mini,
void* ptr);
00172
virtual void moveContents(FXint x,FXint y);
00173
void drawLasso(FXint x0,FXint y0,FXint x1,FXint y1);
00174
void recompute();
00175
void getrowscols(FXint& nr,FXint& nc,FXint w,FXint h)
const;
00176
void lassoChanged(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh,FXbool notify);
00177
private:
00178 FXIconList(
const FXIconList&);
00179 FXIconList &operator=(
const FXIconList&);
00180
public:
00181
long onPaint(
FXObject*,FXSelector,
void*);
00182
long onEnter(
FXObject*,FXSelector,
void*);
00183
long onLeave(
FXObject*,FXSelector,
void*);
00184
long onUngrabbed(
FXObject*,FXSelector,
void*);
00185
long onKeyPress(
FXObject*,FXSelector,
void*);
00186
long onKeyRelease(
FXObject*,FXSelector,
void*);
00187
long onLeftBtnPress(
FXObject*,FXSelector,
void*);
00188
long onLeftBtnRelease(
FXObject*,FXSelector,
void*);
00189
long onRightBtnPress(
FXObject*,FXSelector,
void*);
00190
long onRightBtnRelease(
FXObject*,FXSelector,
void*);
00191
long onMotion(
FXObject*,FXSelector,
void*);
00192
long onQueryTip(
FXObject*,FXSelector,
void*);
00193
long onQueryHelp(
FXObject*,FXSelector,
void*);
00194
long onTipTimer(
FXObject*,FXSelector,
void*);
00195
long onCmdSelectAll(
FXObject*,FXSelector,
void*);
00196
long onCmdDeselectAll(
FXObject*,FXSelector,
void*);
00197
long onCmdSelectInverse(
FXObject*,FXSelector,
void*);
00198
long onCmdArrangeByRows(
FXObject*,FXSelector,
void*);
00199
long onUpdArrangeByRows(
FXObject*,FXSelector,
void*);
00200
long onCmdArrangeByColumns(
FXObject*,FXSelector,
void*);
00201
long onUpdArrangeByColumns(
FXObject*,FXSelector,
void*);
00202
long onCmdShowDetails(
FXObject*,FXSelector,
void*);
00203
long onUpdShowDetails(
FXObject*,FXSelector,
void*);
00204
long onCmdShowBigIcons(
FXObject*,FXSelector,
void*);
00205
long onUpdShowBigIcons(
FXObject*,FXSelector,
void*);
00206
long onCmdShowMiniIcons(
FXObject*,FXSelector,
void*);
00207
long onUpdShowMiniIcons(
FXObject*,FXSelector,
void*);
00208
long onHeaderChanged(
FXObject*,FXSelector,
void*);
00209
long onHeaderResize(
FXObject*,FXSelector,
void*);
00210
long onFocusIn(
FXObject*,FXSelector,
void*);
00211
long onFocusOut(
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 onAutoScroll(
FXObject*,FXSelector,
void*);
00217
long onLookupTimer(
FXObject*,FXSelector,
void*);
00218
long onCmdSetValue(
FXObject*,FXSelector,
void*);
00219 long onCmdGetIntValue(
FXObject*,FXSelector,
void*);
00220
long onCmdSetIntValue(
FXObject*,FXSelector,
void*);
00221
public:
00222 static FXint ascending(
const FXIconItem* a,
const FXIconItem* b);
00223
static FXint descending(
const FXIconItem* a,
const FXIconItem* b);
00224
static FXint ascendingCase(
const FXIconItem* a,
const FXIconItem* b);
00225 static FXint descendingCase(
const FXIconItem* a,
const FXIconItem* b);
00226
public:
00227
enum {
00228 ID_SHOW_DETAILS=FXScrollArea::ID_LAST,
00229 ID_SHOW_MINI_ICONS,
00230 ID_SHOW_BIG_ICONS,
00231 ID_ARRANGE_BY_ROWS,
00232 ID_ARRANGE_BY_COLUMNS,
00233 ID_HEADER_CHANGE,
00234 ID_LOOKUPTIMER,
00235 ID_SELECT_ALL,
00236 ID_DESELECT_ALL,
00237 ID_SELECT_INVERSE,
00238 ID_LAST
00239 };
00240
public:
00241
00242
00243 FXIconList(
FXComposite *p,
FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=ICONLIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00244
00245
00246
virtual void create();
00247
00248
00249
virtual void detach();
00250
00251
00252
virtual void recalc();
00253
00254
00255
virtual void layout();
00256
00257
00258
virtual FXint getContentWidth();
00259
00260
00261
virtual FXint getContentHeight();
00262
00263
00264
virtual FXbool canFocus() const;
00265
00266
00267 virtual
void setFocus();
00268
00269
00270 virtual
void killFocus();
00271
00272
00273 virtual FXint getViewportHeight();
00274
00275
00276 virtual
void resize(FXint w,FXint h);
00277
00278
00279 virtual
void position(FXint x,FXint y,FXint w,FXint h);
00280
00281
00282 FXint getNumItems()
const {
return nitems; }
00283
00284
00285 FXint getNumRows()
const {
return nrows; }
00286
00287
00288 FXint getNumCols()
const {
return ncols; }
00289
00290
00291 FXHeader* getHeader()
const {
return header; }
00292
00293
00294 void appendHeader(
const FXString& text,
FXIcon *icon=NULL,FXint size=1);
00295
00296
00297 void removeHeader(FXint index);
00298
00299
00300
void setHeaderText(FXint index,
const FXString& text);
00301
00302
00303
FXString getHeaderText(FXint index)
const;
00304
00305
00306
void setHeaderIcon(FXint index,
FXIcon *icon);
00307
00308
00309
FXIcon* getHeaderIcon(FXint index)
const;
00310
00311
00312
void setHeaderSize(FXint index,FXint size);
00313
00314
00315 FXint getHeaderSize(FXint index)
const;
00316
00317
00318 FXint getNumHeaders() const;
00319
00320
00321 FXIconItem *getItem(FXint index) const;
00322
00323
00324 FXint setItem(FXint index,FXIconItem* item,FXbool notify=FALSE);
00325
00326
00327 FXint setItem(FXint index,const
FXString& text,
FXIcon *big=NULL,
FXIcon* mini=NULL,
void* ptr=NULL,FXbool notify=FALSE);
00328
00329
00330 FXint insertItem(FXint index,FXIconItem* item,FXbool notify=FALSE);
00331
00332
00333 FXint insertItem(FXint index,const
FXString& text,
FXIcon *big=NULL,
FXIcon* mini=NULL,
void* ptr=NULL,FXbool notify=FALSE);
00334
00335
00336 FXint appendItem(FXIconItem* item,FXbool notify=FALSE);
00337
00338
00339 FXint appendItem(const
FXString& text,
FXIcon *big=NULL,
FXIcon* mini=NULL,
void* ptr=NULL,FXbool notify=FALSE);
00340
00341
00342 FXint prependItem(FXIconItem* item,FXbool notify=FALSE);
00343
00344
00345 FXint prependItem(const
FXString& text,
FXIcon *big=NULL,
FXIcon* mini=NULL,
void* ptr=NULL,FXbool notify=FALSE);
00346
00347
00348 FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=FALSE);
00349
00350
00351
void removeItem(FXint index,FXbool notify=FALSE);
00352
00353
00354
void clearItems(FXbool notify=FALSE);
00355
00356
00357 FXint getItemWidth()
const {
return itemWidth; }
00358
00359
00360 FXint getItemHeight()
const {
return itemHeight; }
00361
00362
00363 FXint getItemAt(FXint x,FXint y)
const;
00364
00365
00366
00367
00368
00369 FXint findItem(
const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP)
const;
00370
00371
00372
void makeItemVisible(FXint index);
00373
00374
00375
void setItemText(FXint index,
const FXString& text);
00376
00377
00378 FXString getItemText(FXint index)
const;
00379
00380
00381 void setItemBigIcon(FXint index,
FXIcon* icon);
00382
00383
00384
FXIcon* getItemBigIcon(FXint index)
const;
00385
00386
00387 void setItemMiniIcon(FXint index,
FXIcon* icon);
00388
00389
00390 FXIcon* getItemMiniIcon(FXint index)
const;
00391
00392
00393
void setItemData(FXint index,
void* ptr);
00394
00395
00396 void* getItemData(FXint index)
const;
00397
00398
00399 FXbool isItemSelected(FXint index)
const;
00400
00401
00402 FXbool isItemCurrent(FXint index)
const;
00403
00404
00405 FXbool isItemVisible(FXint index)
const;
00406
00407
00408 FXbool isItemEnabled(FXint index)
const;
00409
00410
00411 FXint hitItem(FXint index,FXint x,FXint y,FXint ww=1,FXint hh=1)
const;
00412
00413
00414 void updateItem(FXint index)
const;
00415
00416
00417 FXbool enableItem(FXint index);
00418
00419
00420 FXbool disableItem(FXint index);
00421
00422
00423
virtual FXbool selectItem(FXint index,FXbool notify=FALSE);
00424
00425
00426
virtual FXbool deselectItem(FXint index,FXbool notify=FALSE);
00427
00428
00429 virtual FXbool toggleItem(FXint index,FXbool notify=FALSE);
00430
00431
00432
virtual FXbool selectInRectangle(FXint x,FXint y,FXint w,FXint h,FXbool notify=FALSE);
00433
00434
00435
virtual FXbool extendSelection(FXint index,FXbool notify=FALSE);
00436
00437
00438
virtual FXbool killSelection(FXbool notify=FALSE);
00439
00440
00441 virtual void setCurrentItem(FXint index,FXbool notify=FALSE);
00442
00443
00444 FXint getCurrentItem()
const {
return current; }
00445
00446
00447
void setAnchorItem(FXint index);
00448
00449
00450 FXint getAnchorItem()
const {
return anchor; }
00451
00452
00453 FXint getCursorItem()
const {
return cursor; }
00454
00455
00456
void sortItems();
00457
00458
00459 FXIconListSortFunc getSortFunc()
const {
return sortfunc; }
00460
00461
00462
void setSortFunc(FXIconListSortFunc func){ sortfunc=func; }
00463
00464
00465
void setFont(FXFont* fnt);
00466
00467
00468 FXFont* getFont()
const {
return font; }
00469
00470
00471 FXColor getTextColor()
const {
return textColor; }
00472
00473
00474
void setTextColor(FXColor clr);
00475
00476
00477 FXColor getSelBackColor()
const {
return selbackColor; }
00478
00479
00480
void setSelBackColor(FXColor clr);
00481
00482
00483 FXColor getSelTextColor()
const {
return seltextColor; }
00484
00485
00486
void setSelTextColor(FXColor clr);
00487
00488
00489
void setItemSpace(FXint s);
00490
00491
00492 FXint getItemSpace()
const {
return itemSpace; }
00493
00494
00495 FXuint getListStyle() const;
00496
00497
00498
void setListStyle(FXuint style);
00499
00500
00501
void setHelpText(const FXString& text);
00502
00503
00504 FXString getHelpText()
const {
return help; }
00505
00506
00507
virtual void save(FXStream& store)
const;
00508
00509
00510
virtual void load(FXStream& store);
00511
00512
00513
virtual ~FXIconList();
00514 };
00515
00516 }
00517
00518
#endif