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 #if !defined(AFX_COLOR_H__1682DCA5_6086_49F9_8026_B40B6B373A56__INCLUDED_)
00028 #define AFX_COLOR_H__1682DCA5_6086_49F9_8026_B40B6B373A56__INCLUDED_
00029 
00030 #if _MSC_VER > 1000
00031 #pragma once
00032 #endif // _MSC_VER > 1000
00033 
00034 #ifdef WIN32
00035         #include <windows.h>
00036 #endif
00037 
00038 #include <math.h>
00039 #include "Object.h"
00040 #include "XMLNode.h"
00041 #include "JString.h"
00042 
00043 namespace cmlabs {
00044 
00045 class Color : public Object  
00046 {
00047 public:
00048         Color();
00049         Color(int red, int green, int blue);
00050         Color(JString name);
00051         Color(const Color &color);
00052         Color(XMLNode* node);
00053         virtual ~Color();
00054 
00055         Object* clone() const;
00056         bool fromXML(XMLNode* node);
00057         JString toXML(JString name);
00058         JString toXML();
00059 
00060         Color mixOn(Color& color, double weight);
00061         Color getReverseColor();
00062         int getGrayValue();
00063 
00064         int r, g, b;
00065         int size;
00066 
00067         double distance(Color &otherColor);
00068         bool setNoColor();
00069         bool isValid();
00070         bool isNoColor();
00071 
00072         static ObjectCollection* createColorsMaxDifference(int count, bool mix = false);
00073 
00074 #ifdef WIN32
00075         Color& operator =(COLORREF ref);
00076         operator COLORREF();
00077         operator HPEN();
00078         operator HBRUSH();
00079 #endif // WIN32
00080 
00081 private:
00082         void init(int red, int green, int blue);
00083         void init(JString colorName);
00084 #ifdef WIN32
00085         HPEN pen;
00086         HBRUSH brush;
00087 #else
00088         void* pen;
00089         void* brush;
00090 #endif // WIN32
00091 };
00092 
00093 } 
00094 
00095 #endif // !defined(AFX_COLOR_H__1682DCA5_6086_49F9_8026_B40B6B373A56__INCLUDED_)