![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * C o l o r L i s t W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2005,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (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 * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXColorList.h,v 1.13 2009/01/06 13:07:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXCOLORLIST_H 00024 #define FXCOLORLIST_H 00025 00026 #ifndef FXLIST_H 00027 #include "FXList.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// Color item 00034 class FXAPI FXColorItem : public FXListItem { 00035 FXDECLARE(FXColorItem) 00036 protected: 00037 FXColor color; 00038 private: 00039 FXColorItem(const FXColorItem&); 00040 FXColorItem& operator=(const FXColorItem&); 00041 protected: 00042 FXColorItem():color(0){} 00043 virtual void draw(const FXList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00044 virtual FXint hitItem(const FXList* list,FXint x,FXint y) const; 00045 public: 00046 /// Construct new item with given text, color, and user-data 00047 FXColorItem(const FXString& text,FXColor clr,void* ptr=NULL):FXListItem(text,NULL,ptr),color(clr){} 00048 00049 /// Change item's color 00050 void setColor(FXColor clr){ color=clr; } 00051 00052 /// Return item's color 00053 FXColor getColor() const { return color; } 00054 00055 /// Return width of item as drawn in list 00056 virtual FXint getWidth(const FXList* list) const; 00057 00058 /// Return height of item as drawn in list 00059 virtual FXint getHeight(const FXList* list) const; 00060 }; 00061 00062 00063 /** 00064 * A ColorList Widget displays a list of colors. 00065 */ 00066 class FXAPI FXColorList : public FXList { 00067 FXDECLARE(FXColorList) 00068 protected: 00069 FXColorList(){} 00070 virtual FXListItem *createItem(const FXString& text,FXIcon* icon,void* ptr); 00071 private: 00072 FXColorList(const FXColorList&); 00073 FXColorList &operator=(const FXColorList&); 00074 public: 00075 00076 /// Construct a list with initially no items in it 00077 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); 00078 00079 /// Fill list by appending color items from array of strings and array of colors 00080 FXint fillItems(const FXchar** strings,FXColor *colors=NULL,void* ptr=NULL,FXbool notify=false); 00081 00082 /// Insert item at index with given text, color, and user-data pointer 00083 FXint insertItem(FXint index,const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=false); 00084 00085 /// Append new item with given text, color, and user-data pointer 00086 FXint appendItem(const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=false); 00087 00088 /// Prepend new item with given text, color, and user-data pointer 00089 FXint prependItem(const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=false); 00090 00091 /// Change item color 00092 void setItemColor(FXint index,FXColor color); 00093 00094 /// Return item color 00095 FXColor getItemColor(FXint index) const; 00096 }; 00097 00098 } 00099 00100 #endif
![]() |