FXIconList.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         I c o n   L i s t   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXIconList.h,v 1.95.2.4 2006/11/17 16:02:31 fox Exp $                        *
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 
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 
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 private:
00069   FXIconItem(const FXIconItem&);
00070   FXIconItem& operator=(const FXIconItem&);
00071 protected:
00072   FXIconItem():bigIcon(NULL),miniIcon(NULL),data(NULL),state(0){}
00073   virtual void draw(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00074   virtual FXint hitItem(const FXIconList* list,FXint rx,FXint ry,FXint rw=1,FXint rh=1) const;
00075 protected:
00076   virtual void drawBigIcon(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00077   virtual void drawMiniIcon(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00078   virtual void drawDetails(const FXIconList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const;
00079 public:
00080   enum {
00081     SELECTED      = 1,  
00082     FOCUS         = 2,  
00083     DISABLED      = 4,  
00084     DRAGGABLE     = 8,  
00085     BIGICONOWNED  = 16, 
00086     MINIICONOWNED = 32  
00087     };
00088 public:
00089 
00091   FXIconItem(const FXString& text,FXIcon* bi=NULL,FXIcon* mi=NULL,void* ptr=NULL):label(text),bigIcon(bi),miniIcon(mi),data(ptr),state(0){}
00092 
00094   virtual void setText(const FXString& txt);
00095 
00097   const FXString& getText() const { return label; }
00098 
00100   virtual void setBigIcon(FXIcon* icn,FXbool owned=FALSE);
00101 
00103   FXIcon* getBigIcon() const { return bigIcon; }
00104 
00106   virtual void setMiniIcon(FXIcon* icn,FXbool owned=FALSE);
00107 
00109   FXIcon* getMiniIcon() const { return miniIcon; }
00110 
00112   void setData(void* ptr){ data=ptr; }
00113 
00115   void* getData() const { return data; }
00116 
00118   virtual void setFocus(FXbool focus);
00119 
00121   FXbool hasFocus() const { return (state&FOCUS)!=0; }
00122 
00124   virtual void setSelected(FXbool selected);
00125 
00127   FXbool isSelected() const { return (state&SELECTED)!=0; }
00128 
00130   virtual void setEnabled(FXbool enabled);
00131 
00133   FXbool isEnabled() const { return (state&DISABLED)==0; }
00134 
00136   virtual void setDraggable(FXbool draggable);
00137 
00139   FXbool isDraggable() const { return (state&DRAGGABLE)!=0; }
00140 
00142   virtual FXint getWidth(const FXIconList* list) const;
00143 
00145   virtual FXint getHeight(const FXIconList* list) const;
00146 
00148   virtual void create();
00149 
00151   virtual void detach();
00152 
00154   virtual void destroy();
00155 
00157   virtual void save(FXStream& store) const;
00158 
00160   virtual void load(FXStream& store);
00161 
00163   virtual ~FXIconItem();
00164   };
00165 
00166 
00168 typedef FXint (*FXIconListSortFunc)(const FXIconItem*,const FXIconItem*);
00169 
00170 
00172 typedef FXObjectListOf<FXIconItem> FXIconItemList;
00173 
00174 
00175 #ifdef _MSC_VER
00176 #pragma warning(push)
00177 #pragma warning(disable: 4251)
00178 #endif
00179 
00200 class FXAPI FXIconList : public FXScrollArea {
00201   FXDECLARE(FXIconList)
00202 protected:
00203   FXHeader          *header;            // Header control
00204   FXIconItemList     items;     // Item list
00205   FXint              nrows;             // Number of rows
00206   FXint              ncols;             // Number of columns
00207   FXint              anchor;            // Anchor item
00208   FXint              current;           // Current item
00209   FXint              extent;            // Extent item
00210   FXint              cursor;            // Cursor item
00211   FXint              viewable;          // Visible item
00212   FXFont            *font;              // Font
00213   FXIconListSortFunc sortfunc;          // Item sort function
00214   FXColor            textColor;         // Text color
00215   FXColor            selbackColor;      // Selected back color
00216   FXColor            seltextColor;      // Selected text color
00217   FXint              itemWidth;         // Item width
00218   FXint              itemHeight;        // Item height
00219   FXint              itemSpace;         // Space for item label
00220   FXint              anchorx;           // Rectangular selection
00221   FXint              anchory;
00222   FXint              currentx;
00223   FXint              currenty;
00224   FXint              grabx;             // Grab point x
00225   FXint              graby;             // Grab point y
00226   FXString           lookup;            // Lookup string
00227   FXString           help;              // Help text
00228   FXbool             state;             // State of item
00229 protected:
00230   FXIconList();
00231   void recompute();
00232   void getrowscols(FXint& nr,FXint& nc,FXint w,FXint h) const;
00233   void drawLasso(FXint x0,FXint y0,FXint x1,FXint y1);
00234   void lassoChanged(FXint ox,FXint oy,FXint ow,FXint oh,FXint nx,FXint ny,FXint nw,FXint nh,FXbool notify);
00235   virtual void moveContents(FXint x,FXint y);
00236   virtual FXIconItem *createItem(const FXString& text,FXIcon *big,FXIcon* mini,void* ptr);
00237   static FXint compareSection(const FXchar *p,const FXchar* q,FXint s);
00238   static FXint compareSectionCase(const FXchar *p,const FXchar* q,FXint s);
00239 private:
00240   FXIconList(const FXIconList&);
00241   FXIconList &operator=(const FXIconList&);
00242 public:
00243   long onPaint(FXObject*,FXSelector,void*);
00244   long onEnter(FXObject*,FXSelector,void*);
00245   long onLeave(FXObject*,FXSelector,void*);
00246   long onUngrabbed(FXObject*,FXSelector,void*);
00247   long onKeyPress(FXObject*,FXSelector,void*);
00248   long onKeyRelease(FXObject*,FXSelector,void*);
00249   long onLeftBtnPress(FXObject*,FXSelector,void*);
00250   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00251   long onRightBtnPress(FXObject*,FXSelector,void*);
00252   long onRightBtnRelease(FXObject*,FXSelector,void*);
00253   long onMotion(FXObject*,FXSelector,void*);
00254   long onQueryTip(FXObject*,FXSelector,void*);
00255   long onQueryHelp(FXObject*,FXSelector,void*);
00256   long onTipTimer(FXObject*,FXSelector,void*);
00257   long onCmdSelectAll(FXObject*,FXSelector,void*);
00258   long onCmdDeselectAll(FXObject*,FXSelector,void*);
00259   long onCmdSelectInverse(FXObject*,FXSelector,void*);
00260   long onCmdArrangeByRows(FXObject*,FXSelector,void*);
00261   long onUpdArrangeByRows(FXObject*,FXSelector,void*);
00262   long onCmdArrangeByColumns(FXObject*,FXSelector,void*);
00263   long onUpdArrangeByColumns(FXObject*,FXSelector,void*);
00264   long onCmdShowDetails(FXObject*,FXSelector,void*);
00265   long onUpdShowDetails(FXObject*,FXSelector,void*);
00266   long onCmdShowBigIcons(FXObject*,FXSelector,void*);
00267   long onUpdShowBigIcons(FXObject*,FXSelector,void*);
00268   long onCmdShowMiniIcons(FXObject*,FXSelector,void*);
00269   long onUpdShowMiniIcons(FXObject*,FXSelector,void*);
00270   long onHeaderChanged(FXObject*,FXSelector,void*);
00271   long onHeaderResize(FXObject*,FXSelector,void*);
00272   long onFocusIn(FXObject*,FXSelector,void*);
00273   long onFocusOut(FXObject*,FXSelector,void*);
00274   long onClicked(FXObject*,FXSelector,void*);
00275   long onDoubleClicked(FXObject*,FXSelector,void*);
00276   long onTripleClicked(FXObject*,FXSelector,void*);
00277   long onCommand(FXObject*,FXSelector,void*);
00278   long onAutoScroll(FXObject*,FXSelector,void*);
00279   long onLookupTimer(FXObject*,FXSelector,void*);
00280   long onCmdSetValue(FXObject*,FXSelector,void*);
00281   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00282   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00283 public:
00284   static FXint ascending(const FXIconItem* a,const FXIconItem* b);
00285   static FXint descending(const FXIconItem* a,const FXIconItem* b);
00286   static FXint ascendingCase(const FXIconItem* a,const FXIconItem* b);
00287   static FXint descendingCase(const FXIconItem* a,const FXIconItem* b);
00288 public:
00289   enum {
00290     ID_SHOW_DETAILS=FXScrollArea::ID_LAST,
00291     ID_SHOW_MINI_ICONS,
00292     ID_SHOW_BIG_ICONS,
00293     ID_ARRANGE_BY_ROWS,
00294     ID_ARRANGE_BY_COLUMNS,
00295     ID_HEADER_CHANGE,
00296     ID_LOOKUPTIMER,
00297     ID_SELECT_ALL,
00298     ID_DESELECT_ALL,
00299     ID_SELECT_INVERSE,
00300     ID_LAST
00301     };
00302 public:
00303 
00305   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);
00306 
00308   virtual void create();
00309 
00311   virtual void detach();
00312 
00314   virtual void recalc();
00315 
00317   virtual void layout();
00318 
00320   virtual FXint getContentWidth();
00321 
00323   virtual FXint getContentHeight();
00324 
00326   virtual bool canFocus() const;
00327 
00329   virtual void setFocus();
00330 
00332   virtual void killFocus();
00333 
00335   virtual FXint getViewportHeight();
00336 
00338   virtual void resize(FXint w,FXint h);
00339 
00341   virtual void position(FXint x,FXint y,FXint w,FXint h);
00342 
00344   FXint getNumItems() const { return items.no(); }
00345 
00347   FXint getNumRows() const { return nrows; }
00348 
00350   FXint getNumCols() const { return ncols; }
00351 
00353   FXHeader* getHeader() const { return header; }
00354 
00356   void setHeaders(const FXchar** strings,FXint size=1);
00357 
00359   void setHeaders(const FXString& strings,FXint size=1);
00360 
00362   void appendHeader(const FXString& text,FXIcon *icon=NULL,FXint size=1);
00363 
00365   void removeHeader(FXint index);
00366 
00368   void setHeaderText(FXint index,const FXString& text);
00369 
00371   FXString getHeaderText(FXint index) const;
00372 
00374   void setHeaderIcon(FXint index,FXIcon *icon);
00375 
00377   FXIcon* getHeaderIcon(FXint index) const;
00378 
00380   void setHeaderSize(FXint index,FXint size);
00381 
00383   FXint getHeaderSize(FXint index) const;
00384 
00386   FXint getNumHeaders() const;
00387 
00389   FXIconItem *getItem(FXint index) const;
00390 
00392   FXint setItem(FXint index,FXIconItem* item,FXbool notify=FALSE);
00393 
00395   FXint setItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00396 
00398   FXint fillItems(const FXchar** strings,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00399 
00401   FXint fillItems(const FXString& strings,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00402 
00404   FXint insertItem(FXint index,FXIconItem* item,FXbool notify=FALSE);
00405 
00407   FXint insertItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00408 
00410   FXint appendItem(FXIconItem* item,FXbool notify=FALSE);
00411 
00413   FXint appendItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00414 
00416   FXint prependItem(FXIconItem* item,FXbool notify=FALSE);
00417 
00419   FXint prependItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL,FXbool notify=FALSE);
00420 
00422   FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=FALSE);
00423 
00425   FXIconItem* extractItem(FXint index,FXbool notify=FALSE);
00426 
00428   void removeItem(FXint index,FXbool notify=FALSE);
00429 
00431   void clearItems(FXbool notify=FALSE);
00432 
00434   FXint getItemWidth() const { return itemWidth; }
00435 
00437   FXint getItemHeight() const { return itemHeight; }
00438 
00440   virtual FXint getItemAt(FXint x,FXint y) const;
00441 
00452   FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00453 
00461   FXint findItemByData(const void *ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00462 
00464   virtual void makeItemVisible(FXint index);
00465 
00467   void setItemText(FXint index,const FXString& text);
00468 
00470   FXString getItemText(FXint index) const;
00471 
00473   void setItemBigIcon(FXint index,FXIcon* icon,FXbool owned=FALSE);
00474 
00476   FXIcon* getItemBigIcon(FXint index) const;
00477 
00479   void setItemMiniIcon(FXint index,FXIcon* icon,FXbool owned=FALSE);
00480 
00482   FXIcon* getItemMiniIcon(FXint index) const;
00483 
00485   void setItemData(FXint index,void* ptr);
00486 
00488   void* getItemData(FXint index) const;
00489 
00491   FXbool isItemSelected(FXint index) const;
00492 
00494   FXbool isItemCurrent(FXint index) const;
00495 
00497   FXbool isItemVisible(FXint index) const;
00498 
00500   FXbool isItemEnabled(FXint index) const;
00501 
00503   FXint hitItem(FXint index,FXint x,FXint y,FXint ww=1,FXint hh=1) const;
00504 
00506   void updateItem(FXint index) const;
00507 
00509   virtual FXbool enableItem(FXint index);
00510 
00512   virtual FXbool disableItem(FXint index);
00513 
00515   virtual FXbool selectItem(FXint index,FXbool notify=FALSE);
00516 
00518   virtual FXbool deselectItem(FXint index,FXbool notify=FALSE);
00519 
00521   virtual FXbool toggleItem(FXint index,FXbool notify=FALSE);
00522 
00524   virtual FXbool selectInRectangle(FXint x,FXint y,FXint w,FXint h,FXbool notify=FALSE);
00525 
00527   virtual FXbool extendSelection(FXint index,FXbool notify=FALSE);
00528 
00530   virtual FXbool killSelection(FXbool notify=FALSE);
00531 
00533   virtual void setCurrentItem(FXint index,FXbool notify=FALSE);
00534 
00536   FXint getCurrentItem() const { return current; }
00537 
00539   void setAnchorItem(FXint index);
00540 
00542   FXint getAnchorItem() const { return anchor; }
00543 
00545   FXint getCursorItem() const { return cursor; }
00546 
00548   void sortItems();
00549 
00551   FXIconListSortFunc getSortFunc() const { return sortfunc; }
00552 
00554   void setSortFunc(FXIconListSortFunc func){ sortfunc=func; }
00555 
00557   void setFont(FXFont* fnt);
00558 
00560   FXFont* getFont() const { return font; }
00561 
00563   FXColor getTextColor() const { return textColor; }
00564 
00566   void setTextColor(FXColor clr);
00567 
00569   FXColor getSelBackColor() const { return selbackColor; }
00570 
00572   void setSelBackColor(FXColor clr);
00573 
00575   FXColor getSelTextColor() const { return seltextColor; }
00576 
00578   void setSelTextColor(FXColor clr);
00579 
00581   void setItemSpace(FXint s);
00582 
00584   FXint getItemSpace() const { return itemSpace; }
00585 
00587   FXuint getListStyle() const;
00588 
00590   void setListStyle(FXuint style);
00591 
00593   void setHelpText(const FXString& text);
00594 
00596   const FXString& getHelpText() const { return help; }
00597 
00599   virtual void save(FXStream& store) const;
00600 
00602   virtual void load(FXStream& store);
00603 
00605   virtual ~FXIconList();
00606   };
00607 
00608 #ifdef _MSC_VER
00609 #pragma warning(pop)
00610 #endif
00611 
00612 }
00613 
00614 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:22 2009 for TnFOX by doxygen v1.4.7