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,2024 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(nullptr),miniIcon(nullptr),data(nullptr),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=nullptr,FXIcon* mi=nullptr,FXptr ptr=nullptr):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 onMouseWheel(FXObject*,FXSelector,void*);
255  long onMotion(FXObject*,FXSelector,void*);
256  long onQueryTip(FXObject*,FXSelector,void*);
257  long onQueryHelp(FXObject*,FXSelector,void*);
258  long onTipTimer(FXObject*,FXSelector,void*);
259  long onCmdSelectAll(FXObject*,FXSelector,void*);
260  long onCmdDeselectAll(FXObject*,FXSelector,void*);
261  long onCmdSelectInverse(FXObject*,FXSelector,void*);
262  long onCmdArrangeByRows(FXObject*,FXSelector,void*);
263  long onUpdArrangeByRows(FXObject*,FXSelector,void*);
264  long onCmdArrangeByColumns(FXObject*,FXSelector,void*);
265  long onUpdArrangeByColumns(FXObject*,FXSelector,void*);
266  long onCmdShowDetails(FXObject*,FXSelector,void*);
267  long onUpdShowDetails(FXObject*,FXSelector,void*);
268  long onCmdShowBigIcons(FXObject*,FXSelector,void*);
269  long onUpdShowBigIcons(FXObject*,FXSelector,void*);
270  long onCmdShowMiniIcons(FXObject*,FXSelector,void*);
271  long onUpdShowMiniIcons(FXObject*,FXSelector,void*);
272  long onChgHeader(FXObject*,FXSelector,void*);
273  long onClkHeader(FXObject*,FXSelector,void*);
274  long onFocusIn(FXObject*,FXSelector,void*);
275  long onFocusOut(FXObject*,FXSelector,void*);
276  long onClicked(FXObject*,FXSelector,void*);
277  long onDoubleClicked(FXObject*,FXSelector,void*);
278  long onTripleClicked(FXObject*,FXSelector,void*);
279  long onCommand(FXObject*,FXSelector,void*);
280  long onAutoScroll(FXObject*,FXSelector,void*);
281  long onLookupTimer(FXObject*,FXSelector,void*);
282  long onCmdSetValue(FXObject*,FXSelector,void*);
283  long onCmdGetIntValue(FXObject*,FXSelector,void*);
284  long onCmdSetIntValue(FXObject*,FXSelector,void*);
285 public:
286  static FXint ascending(const FXIconItem* a,const FXIconItem* b);
287  static FXint descending(const FXIconItem* a,const FXIconItem* b);
288  static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b);
289  static FXint descendingCase(const FXIconItem* a,const FXIconItem* b);
290 public:
291  enum {
292  ID_LOOKUPTIMER=FXScrollArea::ID_LAST,
293  ID_HEADER,
294  ID_SHOW_DETAILS,
295  ID_SHOW_MINI_ICONS,
296  ID_SHOW_BIG_ICONS,
297  ID_ARRANGE_BY_ROWS,
298  ID_ARRANGE_BY_COLUMNS,
299  ID_SELECT_ALL,
300  ID_DESELECT_ALL,
301  ID_SELECT_INVERSE,
302  ID_LAST
303  };
304 public:
305 
307  FXIconList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=ICONLIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
308 
310  virtual void create();
311 
313  virtual void detach();
314 
316  virtual void recalc();
317 
319  virtual void layout();
320 
322  virtual FXint getContentWidth();
323 
325  virtual FXint getContentHeight();
326 
328  virtual FXint getVisibleY() const;
329 
331  virtual FXint getVisibleHeight() const;
332 
334  virtual FXbool canFocus() const;
335 
337  virtual void setFocus();
338 
340  virtual void killFocus();
341 
343  virtual void resize(FXint w,FXint h);
344 
346  virtual void position(FXint x,FXint y,FXint w,FXint h);
347 
349  FXint getNumItems() const { return (FXint)items.no(); }
350 
352  FXint getNumRows() const { return nrows; }
353 
355  FXint getNumCols() const { return ncols; }
356 
358  FXHeader* getHeader() const { return header; }
359 
361  void setHeaders(const FXchar** strings,FXint size=1);
362 
364  void setHeaders(const FXString& strings,FXint size=1);
365 
367  void appendHeader(const FXString& text,FXIcon *icon=nullptr,FXint size=1);
368 
370  void removeHeader(FXint index);
371 
373  void setHeaderText(FXint index,const FXString& text);
374 
376  FXString getHeaderText(FXint index) const;
377 
379  void setHeaderIcon(FXint index,FXIcon *icon);
380 
382  FXIcon* getHeaderIcon(FXint index) const;
383 
385  void setHeaderSize(FXint index,FXint size);
386 
388  FXint getHeaderSize(FXint index) const;
389 
391  FXint getNumHeaders() const;
392 
394  FXIconItem *getItem(FXint index) const;
395 
397  FXint setItem(FXint index,FXIconItem* item,FXbool notify=false);
398 
400  FXint setItem(FXint index,const FXString& text,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false);
401 
403  FXint fillItems(const FXchar** strings,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false);
404 
406  FXint fillItems(const FXString* strings,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false);
407 
409  FXint fillItems(const FXString& strings,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false);
410 
412  FXint insertItem(FXint index,FXIconItem* item,FXbool notify=false);
413 
415  FXint insertItem(FXint index,const FXString& text,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false);
416 
418  FXint appendItem(FXIconItem* item,FXbool notify=false);
419 
421  FXint appendItem(const FXString& text,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false);
422 
424  FXint prependItem(FXIconItem* item,FXbool notify=false);
425 
427  FXint prependItem(const FXString& text,FXIcon *big=nullptr,FXIcon* mini=nullptr,FXptr ptr=nullptr,FXbool notify=false);
428 
430  FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=false);
431 
433  FXIconItem* extractItem(FXint index,FXbool notify=false);
434 
436  void removeItem(FXint index,FXbool notify=false);
437 
439  void clearItems(FXbool notify=false);
440 
442  FXint getItemWidth() const { return itemWidth; }
443 
445  FXint getItemHeight() const { return itemHeight; }
446 
448  virtual FXint getItemAt(FXint x,FXint y) const;
449 
460  FXint findItem(const FXString& string,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
461 
469  FXint findItemByData(FXptr ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
470 
472  virtual void makeItemVisible(FXint index);
473 
475  void setItemText(FXint index,const FXString& text);
476 
478  FXString getItemText(FXint index) const;
479 
481  void setItemBigIcon(FXint index,FXIcon* icon,FXbool owned=false);
482 
484  FXIcon* getItemBigIcon(FXint index) const;
485 
487  void setItemMiniIcon(FXint index,FXIcon* icon,FXbool owned=false);
488 
490  FXIcon* getItemMiniIcon(FXint index) const;
491 
493  void setItemData(FXint index,FXptr ptr);
494 
496  FXptr getItemData(FXint index) const;
497 
499  FXbool isItemSelected(FXint index) const;
500 
502  FXbool isItemCurrent(FXint index) const;
503 
505  FXbool isItemVisible(FXint index) const;
506 
508  FXbool isItemEnabled(FXint index) const;
509 
511  FXint hitItem(FXint index,FXint x,FXint y,FXint ww=1,FXint hh=1) const;
512 
514  void updateItem(FXint index) const;
515 
517  virtual FXbool enableItem(FXint index);
518 
520  virtual FXbool disableItem(FXint index);
521 
523  virtual FXbool selectItem(FXint index,FXbool notify=false);
524 
526  virtual FXbool deselectItem(FXint index,FXbool notify=false);
527 
529  virtual FXbool toggleItem(FXint index,FXbool notify=false);
530 
532  virtual FXbool selectInRectangle(FXint x,FXint y,FXint w,FXint h,FXbool notify=false);
533 
535  virtual FXbool extendSelection(FXint index,FXbool notify=false);
536 
538  virtual FXbool selectAll(FXbool notify=false);
539 
541  virtual FXbool killSelection(FXbool notify=false);
542 
544  virtual void setCurrentItem(FXint index,FXbool notify=false);
545 
547  FXint getCurrentItem() const { return current; }
548 
550  void setAnchorItem(FXint index);
551 
553  FXint getAnchorItem() const { return anchor; }
554 
556  void sortItems();
557 
559  FXIconListSortFunc getSortFunc() const { return sortfunc; }
560 
562  void setSortFunc(FXIconListSortFunc func){ sortfunc=func; }
563 
565  void setFont(FXFont* fnt);
566 
568  FXFont* getFont() const { return font; }
569 
571  FXColor getTextColor() const { return textColor; }
572 
574  void setTextColor(FXColor clr);
575 
577  FXColor getSelBackColor() const { return selbackColor; }
578 
580  void setSelBackColor(FXColor clr);
581 
583  FXColor getSelTextColor() const { return seltextColor; }
584 
586  void setSelTextColor(FXColor clr);
587 
589  void setItemSpace(FXint s);
590 
592  FXint getItemSpace() const { return itemSpace; }
593 
595  FXuint getListStyle() const;
596 
598  void setListStyle(FXuint style);
599 
601  void setHelpText(const FXString& text);
602 
604  const FXString& getHelpText() const { return help; }
605 
607  virtual void save(FXStream& store) const;
608 
610  virtual void load(FXStream& store);
611 
613  virtual ~FXIconList();
614  };
615 
616 }
617 
618 #endif
FXptr getData() const
Get item&#39;s user data.
Definition: FXIconList.h:112
FXint getItemWidth() const
Return item width.
Definition: FXIconList.h:442
FXColor getTextColor() const
Return normal text color.
Definition: FXIconList.h:571
void setData(FXptr ptr)
Change item&#39;s user data.
Definition: FXIconList.h:109
FXFont * getFont() const
Return text font.
Definition: FXIconList.h:568
FXIconItem(const FXString &text, FXIcon *bi=nullptr, FXIcon *mi=nullptr, FXptr ptr=nullptr)
Construct new item with given text, icons, and user-data.
Definition: FXIconList.h:88
FXint getAnchorItem() const
Return anchor item index, or -1 if none.
Definition: FXIconList.h:553
FXint getNumCols() const
Return number of columns.
Definition: FXIconList.h:355
A File List widget provides an icon rich view of the file system.
Definition: FXFileList.h:131
FXint getNumItems() const
Return number of items.
Definition: FXIconList.h:349
Base composite.
Definition: FXComposite.h:32
Header control may be placed over a table or list to provide a resizable captions above a number of c...
Definition: FXHeader.h:198
FXbool isSelected() const
Return true if this item is selected.
Definition: FXIconList.h:124
FXColor getSelBackColor() const
Return selected text background.
Definition: FXIconList.h:577
FXint getItemSpace() const
Return maximum item space.
Definition: FXIconList.h:592
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
FXColor getSelTextColor() const
Return selected text color.
Definition: FXIconList.h:583
FXbool hasFocus() const
Return true if item has focus.
Definition: FXIconList.h:118
Abstract Device Context.
Definition: FXDC.h:153
FXIcon * getMiniIcon() const
Return item&#39;s mini icon.
Definition: FXIconList.h:106
Definition: FX4Splitter.h:28
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
void setSortFunc(FXIconListSortFunc func)
Change sort function.
Definition: FXIconList.h:562
const FXString & getText() const
Return item&#39;s text label.
Definition: FXIconList.h:94
Icon item.
Definition: FXIconList.h:55
FXint getCurrentItem() const
Return current item index, or -1 if none.
Definition: FXIconList.h:547
FXival no() const
Return number of objects.
Definition: FXObjectList.h:59
The scroll area widget manages a content area and a viewport area through which the content is viewed...
Definition: FXScrollArea.h:69
A Icon List Widget displays a list of items, each with a text and optional icon.
Definition: FXIconList.h:200
const FXString & getHelpText() const
Get the status line help text for this widget.
Definition: FXIconList.h:604
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:138
FXIconListSortFunc getSortFunc() const
Return sort function.
Definition: FXIconList.h:559
FXbool isDraggable() const
Return true if this item is draggable.
Definition: FXIconList.h:136
FXbool isEnabled() const
Return true if this item is enabled.
Definition: FXIconList.h:130
FXint getItemHeight() const
Return item height.
Definition: FXIconList.h:445
FXIcon * getBigIcon() const
Return item&#39;s big icon.
Definition: FXIconList.h:100
Font class.
Definition: FXFont.h:137
FXint getNumRows() const
Return number of rows.
Definition: FXIconList.h:352
FXHeader * getHeader() const
Return header control.
Definition: FXIconList.h:358
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp