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 class FXAPI FXIconList : public FXScrollArea {
00122 FXDECLARE(FXIconList)
00123 protected:
00124 FXHeader *header;
00125 FXIconItem **items;
00126 FXint nitems;
00127 FXint nrows;
00128 FXint ncols;
00129 FXint anchor;
00130 FXint current;
00131 FXint extent;
00132 FXint cursor;
00133 FXFont *font;
00134 FXIconListSortFunc sortfunc;
00135 FXColor textColor;
00136 FXColor selbackColor;
00137 FXColor seltextColor;
00138 FXint itemWidth;
00139 FXint itemHeight;
00140 FXint itemSpace;
00141 FXint anchorx;
00142 FXint anchory;
00143 FXint currentx;
00144 FXint currenty;
00145 FXint grabx;
00146 FXint graby;
00147 FXString lookup;
00148 FXString help;
00149 FXbool state;
00150 protected:
00151 FXIconList();
00152 virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr);
00153 virtual void moveContents(FXint x,FXint y);
00154 void drawLasso(FXint x0,FXint y0,FXint x1,FXint y1);
00155 void recompute();
00156 void getrowscols(FXint& nr,FXint& nc,FXint w,FXint h) const;
00157 void lassoChanged(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh,FXbool notify);
00158 private:
00159 FXIconList(const FXIconList&);
00160 FXIconList &operator=(const FXIconList&);
00161 public:
00162 long onPaint(FXObject*,FXSelector,void*);
00163 long onEnter(FXObject*,FXSelector,void*);
00164 long onLeave(FXObject*,FXSelector,void*);
00165 long onUngrabbed(FXObject*,FXSelector,void*);
00166 long onKeyPress(FXObject*,FXSelector,void*);
00167 long onKeyRelease(FXObject*,FXSelector,void*);
00168 long onLeftBtnPress(FXObject*,FXSelector,void*);
00169 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00170 long onRightBtnPress(FXObject*,FXSelector,void*);
00171 long onRightBtnRelease(FXObject*,FXSelector,void*);
00172 long onMotion(FXObject*,FXSelector,void*);
00173 long onQueryTip(FXObject*,FXSelector,void*);
00174 long onQueryHelp(FXObject*,FXSelector,void*);
00175 long onTipTimer(FXObject*,FXSelector,void*);
00176 long onCmdSelectAll(FXObject*,FXSelector,void*);
00177 long onCmdDeselectAll(FXObject*,FXSelector,void*);
00178 long onCmdSelectInverse(FXObject*,FXSelector,void*);
00179 long onCmdArrangeByRows(FXObject*,FXSelector,void*);
00180 long onUpdArrangeByRows(FXObject*,FXSelector,void*);
00181 long onCmdArrangeByColumns(FXObject*,FXSelector,void*);
00182 long onUpdArrangeByColumns(FXObject*,FXSelector,void*);
00183 long onCmdShowDetails(FXObject*,FXSelector,void*);
00184 long onUpdShowDetails(FXObject*,FXSelector,void*);
00185 long onCmdShowBigIcons(FXObject*,FXSelector,void*);
00186 long onUpdShowBigIcons(FXObject*,FXSelector,void*);
00187 long onCmdShowMiniIcons(FXObject*,FXSelector,void*);
00188 long onUpdShowMiniIcons(FXObject*,FXSelector,void*);
00189 long onHeaderChanged(FXObject*,FXSelector,void*);
00190 long onHeaderResize(FXObject*,FXSelector,void*);
00191 long onFocusIn(FXObject*,FXSelector,void*);
00192 long onFocusOut(FXObject*,FXSelector,void*);
00193 long onClicked(FXObject*,FXSelector,void*);
00194 long onDoubleClicked(FXObject*,FXSelector,void*);
00195 long onTripleClicked(FXObject*,FXSelector,void*);
00196 long onCommand(FXObject*,FXSelector,void*);
00197 long onAutoScroll(FXObject*,FXSelector,void*);
00198 long onLookupTimer(FXObject*,FXSelector,void*);
00199 long onCmdSetValue(FXObject*,FXSelector,void*);
00200 long onCmdGetIntValue(FXObject*,FXSelector,void*);
00201 long onCmdSetIntValue(FXObject*,FXSelector,void*);
00202 public:
00203 static FXint ascending(const FXIconItem* a,const FXIconItem* b);
00204 static FXint descending(const FXIconItem* a,const FXIconItem* b);
00205 static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b);
00206 static FXint descendingCase(const FXIconItem* a,const FXIconItem* b);
00207 public:
00208 enum {
00209 ID_SHOW_DETAILS=FXScrollArea::ID_LAST,
00210 ID_SHOW_MINI_ICONS,
00211 ID_SHOW_BIG_ICONS,
00212 ID_ARRANGE_BY_ROWS,
00213 ID_ARRANGE_BY_COLUMNS,
00214 ID_HEADER_CHANGE,
00215 ID_LOOKUPTIMER,
00216 ID_SELECT_ALL,
00217 ID_DESELECT_ALL,
00218 ID_SELECT_INVERSE,
00219 ID_LAST
00220 };
00221 public:
00222
00223
00224 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);
00225
00226
00227 virtual void create();
00228
00229
00230 virtual void detach();
00231
00232
00233 virtual void recalc();
00234
00235
00236 virtual void layout();
00237
00238
00239 virtual FXint getContentWidth();
00240
00241
00242 virtual FXint getContentHeight();
00243
00244
00245 virtual FXbool canFocus() const;
00246
00247
00248 virtual void setFocus();
00249
00250
00251 virtual void killFocus();
00252
00253
00254 virtual FXint getViewportHeight();
00255
00256
00257 virtual void resize(FXint w,FXint h);
00258
00259
00260 virtual void position(FXint x,FXint y,FXint w,FXint h);
00261
00262
00263 FXint getNumItems() const { return nitems; }
00264
00265
00266 FXint getNumRows() const { return nrows; }
00267
00268
00269 FXint getNumCols() const { return ncols; }
00270
00271
00272 FXHeader* getHeader() const { return header; }
00273
00274
00275 void appendHeader(const FXString& text,FXIcon *icon=NULL,FXint size=1);
00276
00277
00278 void removeHeader(FXint index);
00279
00280
00281 void setHeaderText(FXint index,const FXString& text);
00282
00283
00284 FXString getHeaderText(FXint index) const;
00285
00286
00287 void setHeaderIcon(FXint index,FXIcon *icon);
00288
00289
00290 FXIcon* getHeaderIcon(FXint index) const;
00291
00292
00293 void setHeaderSize(FXint index,FXint size);
00294
00295
00296 FXint getHeaderSize(FXint index) const;
00297
00298
00299 FXint getNumHeaders() const;
00300
00301
00302 FXIconItem *getItem(FXint index) const;
00303
00304
00305 FXint setItem(FXint index,FXIconItem* item,FXbool notify=FALSE);
00306
00307
00308 FXint setItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00309
00310
00311 FXint insertItem(FXint index,FXIconItem* item,FXbool notify=FALSE);
00312
00313
00314 FXint insertItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00315
00316
00317 FXint appendItem(FXIconItem* item,FXbool notify=FALSE);
00318
00319
00320 FXint appendItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00321
00322
00323 FXint prependItem(FXIconItem* item,FXbool notify=FALSE);
00324
00325
00326 FXint prependItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00327
00328
00329 FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=FALSE);
00330
00331
00332 void removeItem(FXint index,FXbool notify=FALSE);
00333
00334
00335 void clearItems(FXbool notify=FALSE);
00336
00337
00338 FXint getItemWidth() const { return itemWidth; }
00339
00340
00341 FXint getItemHeight() const { return itemHeight; }
00342
00343
00344 FXint getItemAt(FXint x,FXint y) const;
00345
00346
00347
00348
00349
00350 FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00351
00352
00353 void makeItemVisible(FXint index);
00354
00355
00356 void setItemText(FXint index,const FXString& text);
00357
00358
00359 FXString getItemText(FXint index) const;
00360
00361
00362 void setItemBigIcon(FXint index,FXIcon* icon);
00363
00364
00365 FXIcon* getItemBigIcon(FXint index) const;
00366
00367
00368 void setItemMiniIcon(FXint index,FXIcon* icon);
00369
00370
00371 FXIcon* getItemMiniIcon(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 FXint hitItem(FXint index,FXint x,FXint y,FXint ww=1,FXint hh=1) const;
00393
00394
00395 void updateItem(FXint index) const;
00396
00397
00398 FXbool enableItem(FXint index);
00399
00400
00401 FXbool disableItem(FXint index);
00402
00403
00404 virtual FXbool selectItem(FXint index,FXbool notify=FALSE);
00405
00406
00407 virtual FXbool deselectItem(FXint index,FXbool notify=FALSE);
00408
00409
00410 virtual FXbool toggleItem(FXint index,FXbool notify=FALSE);
00411
00412
00413 virtual FXbool selectInRectangle(FXint x,FXint y,FXint w,FXint h,FXbool notify=FALSE);
00414
00415
00416 virtual FXbool extendSelection(FXint index,FXbool notify=FALSE);
00417
00418
00419 virtual FXbool killSelection(FXbool notify=FALSE);
00420
00421
00422 virtual void setCurrentItem(FXint index,FXbool notify=FALSE);
00423
00424
00425 FXint getCurrentItem() const { return current; }
00426
00427
00428 void setAnchorItem(FXint index);
00429
00430
00431 FXint getAnchorItem() const { return anchor; }
00432
00433
00434 FXint getCursorItem() const { return cursor; }
00435
00436
00437 void sortItems();
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 void setItemSpace(FXint s);
00465
00466
00467 FXint getItemSpace() const { return itemSpace; }
00468
00469
00470 FXIconListSortFunc getSortFunc() const { return sortfunc; }
00471
00472
00473 void setSortFunc(FXIconListSortFunc func){ sortfunc=func; }
00474
00475
00476 FXuint getListStyle() const;
00477
00478
00479 void setListStyle(FXuint style);
00480
00481
00482 void setHelpText(const FXString& text);
00483
00484
00485 FXString getHelpText() const { return help; }
00486
00487
00488 virtual void save(FXStream& store) const;
00489
00490
00491 virtual void load(FXStream& store);
00492
00493
00494 virtual ~FXIconList();
00495 };
00496
00497 }
00498
00499 #endif