00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef FBTK_COLOR_HH
00028 #define FBTK_COLOR_HH
00029
00030 #include "NotCopyable.hh"
00031
00032 namespace FbTk {
00033
00035 class Color {
00036 public:
00037 Color();
00038 explicit Color(unsigned long pixel);
00039 Color(const Color &col_copy);
00040 Color(unsigned short red, unsigned short green, unsigned short blue, int screen);
00042 Color(const char *color_string, int screen);
00043 ~Color();
00044
00046 bool setFromString(const char *color_string, int screen);
00048 void setPixel(unsigned long pixel) { m_pixel = pixel; }
00049
00050
00051
00052 inline bool isAllocated() const { return m_allocated; }
00053 inline unsigned short red() const { return m_red; }
00054 inline unsigned short green() const { return m_green; }
00055 inline unsigned short blue() const { return m_blue; }
00056 inline unsigned long pixel() const { return m_pixel; }
00057
00058 private:
00059 void free();
00060 void copy(const Color &col);
00061 void allocate(unsigned short red, unsigned short green,
00062 unsigned short blue, int screen);
00063 inline void setAllocated(bool a) { m_allocated = a; }
00064 void setRGB(unsigned short red, unsigned short green, unsigned short blue);
00065
00066
00067 unsigned short m_red, m_green, m_blue;
00068 unsigned long m_pixel;
00069 bool m_allocated;
00070 int m_screen;
00071 };
00072
00073 }
00074
00075 #endif // FBTK_COLOR_HH