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