00001 #ifndef __CColour__ 00002 #define __CColour__ 00003 00004 #include <Basics/CCountedObject.hpp> 00005 using Exponent::Basics::CCountedObject; 00006 00007 // =========================================================================== 00008 00009 namespace Exponent 00010 { 00011 namespace GUI 00012 { 00013 namespace Basics 00014 { 00032 class CColour : public CCountedObject 00033 { 00035 EXPONENT_CLASS_DECLARATION; 00038 // =========================================================================== 00039 00040 public: 00041 00042 // =========================================================================== 00043 00044 const static CColour CCOLOUR_BLACK; 00045 const static CColour CCOLOUR_WHITE; 00046 const static CColour CCOLOUR_RED; 00047 const static CColour CCOLOUR_GREEN; 00048 const static CColour CCOLOUR_BLUE; 00049 const static CColour CCOLOUR_YELLOW; 00050 const static CColour CCOLOUR_ORANGE; 00051 const static CColour CCOLOUR_TURQUOISE; 00052 const static CColour CCOLOUR_PURPLE; 00053 const static CColour CCOLOUR_PINK; 00054 const static CColour CCOLOUR_LIGHT_GREY; 00055 const static CColour CCOLOUR_DARK_GREY; 00057 // =========================================================================== 00058 00065 CColour(const unsigned long red, const unsigned long green, const unsigned long blue); 00066 00070 CColour(); 00071 00076 CColour(const CColour &colour); 00077 00078 #ifdef WIN32 00079 00083 CColour(COLORREF &colour); 00084 #else 00085 00089 CColour(const RGBColor &colour); 00090 #endif 00091 00095 virtual ~CColour(); 00096 00097 // =========================================================================== 00098 00104 CColour &operator = (const CColour &colour); 00105 00111 CColour &operator += (const CColour &colour); 00112 00118 bool operator == (const CColour &colour); 00119 00120 // =========================================================================== 00121 00126 void setRed(const unsigned long red) { m_red = red; } 00127 00132 void setGreen(const unsigned long green) { m_green = green; } 00133 00138 void setBlue(const unsigned long blue) { m_blue = blue; } 00139 00146 virtual void setColour(const unsigned long red, const unsigned long green, const unsigned long blue); 00147 00148 // =========================================================================== 00149 00154 unsigned long getRed() const { return m_red; } 00155 00160 unsigned long getGreen() const { return m_green; } 00161 00166 unsigned long getBlue() const { return m_blue; } 00167 00168 // =========================================================================== 00169 00170 #ifdef WIN32 00171 00175 COLORREF getAsColourRef() const; 00176 00181 void setFromColourRef(const COLORREF &colour); 00182 #else 00183 00187 RGBColor *getAsRGBColour() const; 00188 00193 void setFromRGBColour(const RGBColor &colour); 00194 #endif 00195 00196 // =========================================================================== 00197 00203 virtual void getObjectDescription(char *string, const long size) const; 00204 00205 // =========================================================================== 00206 00207 protected: 00208 00209 // =========================================================================== 00210 00211 #ifndef WIN32 00212 00217 static unsigned short toAppleValue(const long value); 00218 00224 static long fromAppleValue(const unsigned short appleValue); 00225 #endif 00226 00227 // =========================================================================== 00228 00229 unsigned long m_red; 00230 unsigned long m_green; 00231 unsigned long m_blue; 00233 }; 00234 } 00235 } 00236 } 00237 #endif // End of CColour.hpp