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

FXColorList.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         C o l o r   L i s t   W i d g e t                     *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2005,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: FXColorList.h,v 1.4 2006/01/22 17:57:59 fox Exp $                        *
00023 ********************************************************************************/
00024 #ifndef FXCOLORLIST_H
00025 #define FXCOLORLIST_H
00026 
00027 #ifndef FXLIST_H
00028 #include "FXList.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Color item
00035 class FXColorItem : public FXListItem {
00036   FXDECLARE(FXColorItem)
00037 protected:
00038   FXColor  color;
00039 private:
00040   FXColorItem(const FXColorItem&);
00041   FXColorItem& operator=(const FXColorItem&);
00042 protected:
00043   FXColorItem():color(0){}
00044   virtual void draw(const FXList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h);
00045   virtual FXint hitItem(const FXList* list,FXint x,FXint y) const;
00046 public:
00047   /// Construct new item with given text, color, and user-data
00048   FXColorItem(const FXString& text,FXColor clr,void* ptr=NULL):FXListItem(text,NULL,ptr),color(clr){}
00049 
00050   /// Change item's color
00051   void setColor(FXColor clr){ color=clr; }
00052 
00053   /// Return item's color
00054   FXColor getColor() const { return color; }
00055 
00056   /// Return width of item as drawn in list
00057   virtual FXint getWidth(const FXList* list) const;
00058 
00059   /// Return height of item as drawn in list
00060   virtual FXint getHeight(const FXList* list) const;
00061   };
00062 
00063 
00064 /**
00065 * A ColorList Widget displays a list of colors.
00066 */
00067 class FXAPI FXColorList : public FXList {
00068   FXDECLARE(FXColorList)
00069 protected:
00070   FXColorList(){}
00071   virtual FXListItem *createItem(const FXString& text,FXIcon* icon,void* ptr);
00072 private:
00073   FXColorList(const FXColorList&);
00074   FXColorList &operator=(const FXColorList&);
00075 public:
00076 
00077   /// Construct a list with initially no items in it
00078   FXColorList(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=LIST_BROWSESELECT,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00079 
00080   /// Fill list by appending color items from array of strings and array of colors
00081   FXint fillItems(const FXchar** strings,FXColor *colors=NULL,void* ptr=NULL,FXbool notify=FALSE);
00082 
00083   /// Insert item at index with given text, color, and user-data pointer
00084   FXint insertItem(FXint index,const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=FALSE);
00085 
00086   /// Append new item with given text, color, and user-data pointer
00087   FXint appendItem(const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=FALSE);
00088 
00089   /// Prepend new item with given text, color, and user-data pointer
00090   FXint prependItem(const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=FALSE);
00091 
00092   /// Change item color
00093   void setItemColor(FXint index,FXColor color);
00094 
00095   /// Return item color
00096   FXColor getItemColor(FXint index) const;
00097   };
00098 
00099 }
00100 
00101 #endif

Copyright © 1997-2005 Jeroen van der Zijp