Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXIconList.h
1 /********************************************************************************
2 * *
3 * I c o n L i s t W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1999,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXICONLIST_H
22 #define FXICONLIST_H
23 
24 #ifndef FXSCROLLAREA_H
25 #include "FXScrollArea.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  ICONLIST_EXTENDEDSELECT = 0,
34  ICONLIST_SINGLESELECT = 0x00100000,
35  ICONLIST_BROWSESELECT = 0x00200000,
36  ICONLIST_MULTIPLESELECT = 0x00300000,
37  ICONLIST_AUTOSIZE = 0x00400000,
38  ICONLIST_DETAILED = 0,
39  ICONLIST_MINI_ICONS = 0x00800000,
40  ICONLIST_BIG_ICONS = 0x01000000,
41  ICONLIST_ROWS = 0,
42  ICONLIST_COLUMNS = 0x02000000,
43  ICONLIST_NORMAL = ICONLIST_EXTENDEDSELECT
44  };
45 
46 
47 class FXIcon;
48 class FXHeader;
49 class FXFont;
50 class FXIconList;
51 class FXFileList;
52 
53 
55 class FXAPI FXIconItem : public FXObject {
56  FXDECLARE(FXIconItem)
57  friend class FXIconList;
58  friend class FXFileList;
59 protected:
60  FXString label; // Text of item
61  FXIcon *bigIcon; // Big icon shown in big icon mode
62  FXIcon *miniIcon; // Mini icon shown in mini icon mode
63  FXptr data; // User data pointer
64  FXuint state; // State flags
65 private:
66  FXIconItem(const FXIconItem&);
67  FXIconItem& operator=(const FXIconItem&);
68 protected:
69  FXIconItem():bigIcon(NULL),miniIcon(NULL),data(NULL),state(0){}
70  virtual void draw(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
71  virtual FXint hitItem(const FXIconList* list,FXint rx,FXint ry,FXint rw=1,FXint rh=1) const;
72 protected:
73  virtual void drawBigIcon(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
74  virtual void drawMiniIcon(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
75  virtual void drawDetails(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
76 public:
77  enum {
78  SELECTED = 1,
79  FOCUS = 2,
80  DISABLED = 4,
81  DRAGGABLE = 8,
82  BIGICONOWNED = 16,
83  MINIICONOWNED = 32
84  };
85 public:
86 
88  FXIconItem(const FXString& text,FXIcon* bi=NULL,FXIcon* mi=NULL,FXptr ptr=NULL):label(text),bigIcon(bi),miniIcon(mi),data(ptr),state(0){}
89 
91  virtual void setText(const FXString& txt);
92 
94  const FXString& getText() const { return label; }
95 
97  virtual void setBigIcon(FXIcon* icn,FXbool owned=false);
98 
100  FXIcon* getBigIcon() const { return bigIcon; }
101 
103  virtual void setMiniIcon(FXIcon* icn,FXbool owned=false);
104 
106  FXIcon* getMiniIcon() const { return miniIcon; }
107 
109  void setData(FXptr ptr){ data=ptr; }
110 
112  FXptr getData() const { return data; }
113 
115  virtual void setFocus(FXbool focus);
116 
118  FXbool hasFocus() const { return (state&FOCUS)!=0; }
119 
121  virtual void setSelected(FXbool selected);
122 
124  FXbool isSelected() const { return (state&SELECTED)!=0; }
125 
127  virtual void setEnabled(FXbool enabled);
128 
130  FXbool isEnabled() const { return (state&DISABLED)==0; }
131 
133  virtual void setDraggable(FXbool draggable);
134 
136  FXbool isDraggable() const { return (state&DRAGGABLE)!=0; }
137 
139  virtual FXString getTipText() const;
140 
142  virtual FXint getWidth(const FXIconList* list) const;
143 
145  virtual FXint getHeight(const FXIconList* list) const;
146 
148  virtual void create();
149 
151  virtual void detach();
152 
154  virtual void destroy();
155 
157  virtual void save(FXStream& store) const;
158 
160  virtual void load(FXStream& store);
161 
163  virtual ~FXIconItem();
164  };
165 
166 
168 typedef FXint (*FXIconListSortFunc)(const FXIconItem*,const FXIconItem*);
169 
170 
172 typedef FXObjectListOf<FXIconItem> FXIconItemList;
173 
174 
200 class FXAPI FXIconList : public FXScrollArea {
201  FXDECLARE(FXIconList)
202 protected:
203  FXHeader *header; // Header control
204  FXIconItemList items; // Item list
205  FXint nrows; // Number of rows
206  FXint ncols; // Number of columns
207  FXint anchor; // Anchor item
208  FXint current; // Current item
209  FXint extent; // Extent item
210  FXint viewable; // Visible item
211  FXFont *font; // Font
212  FXIconListSortFunc sortfunc; // Item sort function
213  FXColor textColor; // Text color
214  FXColor selbackColor; // Selected back color
215  FXColor seltextColor; // Selected text color
216  FXint itemSpace; // Space for item label
217  FXint itemWidth; // Item width
218  FXint itemHeight; // Item height
219  FXint anchorx; // Rectangular selection
220  FXint anchory;
221  FXint currentx;
222  FXint currenty;
223  FXint grabx; // Grab point x
224  FXint graby; // Grab point y
225  FXString lookup; // Lookup string
226  FXString help; // Help text
227  FXbool state; // State of item
228 protected:
229  FXIconList();
230  void recompute();
231  void startLasso(FXint ax,FXint ay);
232  void updateLasso(FXint cx,FXint cy);
233  void endLasso();
234  void getrowscols(FXint& nr,FXint& nc,FXint w,FXint h) const;
235  void lassoChanged(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh,FXbool notify);
236  virtual void moveContents(FXint x,FXint y);
237  virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,FXptr ptr);
238  static FXint compareSection(const FXchar *p,const FXchar* q,FXint s);
239  static FXint compareSectionCase(const FXchar *p,const FXchar* q,FXint s);
240 private:
241  FXIconList(const FXIconList&);
242  FXIconList &operator=(const FXIconList&);
243 public:
244  long onPaint(FXObject*,FXSelector,void*);
245  long onEnter(FXObject*,FXSelector,void*);
246  long onLeave(FXObject*,FXSelector,void*);
247  long onUngrabbed(FXObject*,FXSelector,void*);
248  long onKeyPress(FXObject*,FXSelector,void*);
249  long onKeyRelease(FXObject*,FXSelector,void*);
250  long onLeftBtnPress(FXObject*,FXSelector,void*);
251  long onLeftBtnRelease(FXObject*,FXSelector,void*);
252  long onRightBtnPress(FXObject*,FXSelector,void*);
253  long onRightBtnRelease(FXObject*,FXSelector,void*);
254  long onMotion(FXObject*,FXSelector,void*);
255  long onQueryTip(FXObject*,FXSelector,void*);
256  long onQueryHelp(FXObject*,FXSelector,void*);
257  long onTipTimer(FXObject*,FXSelector,void*);
258  long onCmdSelectAll(FXObject*,FXSelector,void*);
259  long onCmdDeselectAll(FXObject*,FXSelector,void*);
260  long onCmdSelectInverse(FXObject*,FXSelector,void*);
261  long onCmdArrangeByRows(FXObject*,FXSelector,void*);
262  long onUpdArrangeByRows(FXObject*,FXSelector,void*);
263  long onCmdArrangeByColumns(FXObject*,FXSelector,void*);
264  long onUpdArrangeByColumns(FXObject*,FXSelector,void*);
265  long onCmdShowDetails(FXObject*,FXSelector,void*);
266  long onUpdShowDetails(FXObject*,FXSelector,void*);
267  long onCmdShowBigIcons(FXObject*,FXSelector,void*);
268  long onUpdShowBigIcons(FXObject*,FXSelector,void*);
269  long onCmdShowMiniIcons(FXObject*,FXSelector,void*);
270  long onUpdShowMiniIcons(FXObject*,FXSelector,void*);
271  long onChgHeader(FXObject*,FXSelector,void*);
272  long onClkHeader(FXObject*,FXSelector,void*);
273  long onFocusIn(FXObject*,FXSelector,void*);
274  long onFocusOut(FXObject*,FXSelector,void*);
275  long onClicked(FXObject*,FXSelector,void*);
276  long onDoubleClicked(FXObject*,FXSelector,void*);
277  long onTripleClicked(FXObject*,FXSelector,void*);
278  long onCommand(FXObject*,FXSelector,void*);
279  long onAutoScroll(FXObject*,FXSelector,void*);
280  long onLookupTimer(FXObject*,FXSelector,void*);
281  long onCmdSetValue(FXObject*,FXSelector,void*);
282  long onCmdGetIntValue(FXObject*,FXSelector,void*);
283  long onCmdSetIntValue(FXObject*,FXSelector,void*);
284 public:
285  static FXint ascending(const FXIconItem* a,const FXIconItem* b);
286  static FXint descending(const FXIconItem* a,const FXIconItem* b);
287  static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b);
288  static FXint descendingCase(const FXIconItem* a,const FXIconItem* b);
289 public:
290  enum {
291  ID_LOOKUPTIMER=FXScrollArea::ID_LAST,
292  ID_HEADER,
293  ID_SHOW_DETAILS,
294  ID_SHOW_MINI_ICONS,
295  ID_SHOW_BIG_ICONS,
296  ID_ARRANGE_BY_ROWS,
297  ID_ARRANGE_BY_COLUMNS,
298  ID_SELECT_ALL,
299  ID_DESELECT_ALL,
300  ID_SELECT_INVERSE,
301  ID_LAST
302  };
303 public:
304 
306  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);
307 
309  virtual void create();
310 
312  virtual void detach();
313 
315  virtual void recalc();
316 
318  virtual void layout();
319 
321  virtual FXint getContentWidth();
322 
324  virtual FXint getContentHeight();
325 
327  virtual FXint getVisibleY() const;
328 
330  virtual FXint getVisibleHeight() const;
331 
333  virtual FXbool canFocus() const;
334 
336  virtual void setFocus();
337 
339  virtual void killFocus();
340 
342  virtual void resize(FXint w,FXint h);
343 
345  virtual void position(FXint x,FXint y,FXint w,FXint h);
346 
348  FXint getNumItems() const { return (FXint)items.no(); }
349 
351  FXint getNumRows() const { return nrows; }
352 
354  FXint getNumCols() const { return ncols; }
355 
357  FXHeader* getHeader() const { return header; }
358 
360  void setHeaders(const FXchar** strings,FXint size=1);
361 
363  void setHeaders(const FXString& strings,FXint size=1);
364 
366  void appendHeader(const FXString& text,FXIcon *icon=NULL,FXint size=1);
367 
369  void removeHeader(FXint index);
370 
372  void setHeaderText(FXint index,const FXString& text);
373 
375  FXString getHeaderText(FXint index) const;
376 
378  void setHeaderIcon(FXint index,FXIcon *icon);
379 
381  FXIcon* getHeaderIcon(FXint index) const;
382 
384  void setHeaderSize(FXint index,FXint size);
385 
387  FXint getHeaderSize(FXint index) const;
388 
390  FXint getNumHeaders() const;
391 
393  FXIconItem *getItem(FXint index) const;
394 
396  FXint setItem(FXint index,FXIconItem* item,FXbool notify=false);
397 
399  FXint setItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,FXptr ptr=NULL,FXbool notify=false);
400 
402  FXint fillItems(const FXchar** strings,FXIcon *big=NULL,FXIcon* mini=NULL,FXptr ptr=NULL,FXbool notify=false);
403 
405  FXint fillItems(const FXString* strings,FXIcon *big=NULL,FXIcon* mini=NULL,FXptr ptr=NULL,FXbool notify=false);
406 
408  FXint fillItems(const FXString& strings,FXIcon *big=NULL,FXIcon* mini=NULL,FXptr ptr=NULL,FXbool notify=false);
409 
411  FXint insertItem(FXint index,FXIconItem* item,FXbool notify=false);
412 
414  FXint insertItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,FXptr ptr=NULL,FXbool notify=false);
415 
417  FXint appendItem(FXIconItem* item,FXbool notify=false);
418 
420  FXint appendItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,FXptr ptr=NULL,FXbool notify=false);
421 
423  FXint prependItem(FXIconItem* item,FXbool notify=false);
424 
426  FXint prependItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,FXptr ptr=NULL,FXbool notify=false);
427 
429  FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=false);
430 
432  FXIconItem* extractItem(FXint index,FXbool notify=false);
433 
435  void removeItem(FXint index,FXbool notify=false);
436 
438  void clearItems(FXbool notify=false);
439 
441  FXint getItemWidth() const { return itemWidth; }
442 
444  FXint getItemHeight() const { return itemHeight; }
445 
447  virtual FXint getItemAt(FXint x,FXint y) const;
448 
459  FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
460 
468  FXint findItemByData(FXptr ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
469 
471  virtual void makeItemVisible(FXint index);
472 
474  void setItemText(FXint index,const FXString& text);
475 
477  FXString getItemText(FXint index) const;
478 
480  void setItemBigIcon(FXint index,FXIcon* icon,FXbool owned=false);
481 
483  FXIcon* getItemBigIcon(FXint index) const;
484 
486  void setItemMiniIcon(FXint index,FXIcon* icon,FXbool owned=false);
487 
489  FXIcon* getItemMiniIcon(FXint index) const;
490 
492  void setItemData(FXint index,FXptr ptr);
493 
495  FXptr getItemData(FXint index) const;
496 
498  FXbool isItemSelected(FXint index) const;
499 
501  FXbool isItemCurrent(FXint index) const;
502 
504  FXbool isItemVisible(FXint index) const;
505 
507  FXbool isItemEnabled(FXint index) const;
508 
510  FXint hitItem(FXint index,FXint x,FXint y,FXint ww=1,FXint hh=1) const;
511 
513  void updateItem(FXint index) const;
514 
516  virtual FXbool enableItem(FXint index);
517 
519  virtual FXbool disableItem(FXint index);
520 
522  virtual FXbool selectItem(FXint index,FXbool notify=false);
523 
525  virtual FXbool deselectItem(FXint index,FXbool notify=false);
526 
528  virtual FXbool toggleItem(FXint index,FXbool notify=false);
529 
531  virtual FXbool selectInRectangle(FXint x,FXint y,FXint w,FXint h,FXbool notify=false);
532 
534  virtual FXbool extendSelection(FXint index,FXbool notify=false);
535 
537  virtual FXbool selectAll(FXbool notify=false);
538 
540  virtual FXbool killSelection(FXbool notify=false);
541 
543  virtual void setCurrentItem(FXint index,FXbool notify=false);
544 
546  FXint getCurrentItem() const { return current; }
547 
549  void setAnchorItem(FXint index);
550 
552  FXint getAnchorItem() const { return anchor; }
553 
555  void sortItems();
556 
558  FXIconListSortFunc getSortFunc() const { return sortfunc; }
559 
561  void setSortFunc(FXIconListSortFunc func){ sortfunc=func; }
562 
564  void setFont(FXFont* fnt);
565 
567  FXFont* getFont() const { return font; }
568 
570  FXColor getTextColor() const { return textColor; }
571 
573  void setTextColor(FXColor clr);
574 
576  FXColor getSelBackColor() const { return selbackColor; }
577 
579  void setSelBackColor(FXColor clr);
580 
582  FXColor getSelTextColor() const { return seltextColor; }
583 
585  void setSelTextColor(FXColor clr);
586 
588  void setItemSpace(FXint s);
589 
591  FXint getItemSpace() const { return itemSpace; }
592 
594  FXuint getListStyle() const;
595 
597  void setListStyle(FXuint style);
598 
600  void setHelpText(const FXString& text);
601 
603  const FXString& getHelpText() const { return help; }
604 
606  virtual void save(FXStream& store) const;
607 
609  virtual void load(FXStream& store);
610 
612  virtual ~FXIconList();
613  };
614 
615 }
616 
617 #endif

Copyright © 1997-2016 Jeroen van der Zijp