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

FXColorList.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * C o l o r L i s t W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2005,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (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 GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXColorList.h,v 1.4.2.1 2006/07/27 02:18:50 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXCOLORLIST_H
25 #define FXCOLORLIST_H
26 
27 #ifndef FXLIST_H
28 #include "FXList.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Color item
35 class FXAPI FXColorItem : public FXListItem {
37 protected:
38  FXColor color;
39 private:
40  FXColorItem(const FXColorItem&);
41  FXColorItem& operator=(const FXColorItem&);
42 protected:
43  FXColorItem():color(0){}
44  virtual void draw(const FXList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h);
45  virtual FXint hitItem(const FXList* list,FXint x,FXint y) const;
46 public:
47  /// Construct new item with given text, color, and user-data
48  FXColorItem(const FXString& text,FXColor clr,void* ptr=NULL):FXListItem(text,NULL,ptr),color(clr){}
49 
50  /// Change item's color
51  void setColor(FXColor clr){ color=clr; }
52 
53  /// Return item's color
54  FXColor getColor() const { return color; }
55 
56  /// Return width of item as drawn in list
57  virtual FXint getWidth(const FXList* list) const;
58 
59  /// Return height of item as drawn in list
60  virtual FXint getHeight(const FXList* list) const;
61  };
62 
63 
64 /**
65 * A ColorList Widget displays a list of colors.
66 */
67 class FXAPI FXColorList : public FXList {
69 protected:
70  FXColorList(){}
71  virtual FXListItem *createItem(const FXString& text,FXIcon* icon,void* ptr);
72 private:
73  FXColorList(const FXColorList&);
74  FXColorList &operator=(const FXColorList&);
75 public:
76 
77  /// Construct a list with initially no items in it
78  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);
79 
80  /// Fill list by appending color items from array of strings and array of colors
81  FXint fillItems(const FXchar** strings,FXColor *colors=NULL,void* ptr=NULL,FXbool notify=FALSE);
82 
83  /// Insert item at index with given text, color, and user-data pointer
84  FXint insertItem(FXint index,const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=FALSE);
85 
86  /// Append new item with given text, color, and user-data pointer
87  FXint appendItem(const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=FALSE);
88 
89  /// Prepend new item with given text, color, and user-data pointer
90  FXint prependItem(const FXString& text,FXColor color=0,void* ptr=NULL,FXbool notify=FALSE);
91 
92  /// Change item color
93  void setItemColor(FXint index,FXColor color);
94 
95  /// Return item color
96  FXColor getItemColor(FXint index) const;
97  };
98 
99 }
100 
101 #endif
Color item.
Definition: FXColorList.h:35
char FXchar
Definition: fxdefs.h:387
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXSelector
Association key.
Definition: FXObject.h:53
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
Abstract Device Context.
Definition: FXDC.h:191
Browse selection mode enforces one single item to be selected at all times.
Definition: FXList.h:41
A List Widget displays a list of items, each with a text and optional icon.
Definition: FXList.h:167
int FXint
Definition: fxdefs.h:397
A ColorList Widget displays a list of colors.
Definition: FXColorList.h:58
#define FALSE
Definition: fxdefs.h:35
List item.
Definition: FXList.h:59
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp