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

ColorPalette.h

00001 #ifndef COLORPALETTE_H
00002 #define COLORPALETTE_H
00003 
00004 #pragma warning(disable : 4786)
00005 #include <map>
00006 
00007 
00009 class VColorPalette
00010 {
00011 protected:
00012         // maps a COLORREF to the number of times it has been used
00013         map<unsigned long, int> m_mColors;
00014 
00015 public:
00016 
00017         void AddColorReference(COLORREF color)
00018         {
00019                 // (will add to the map if color doesn't exist)
00020                 m_mColors[color]++;
00021         }
00022 
00023         void DeleteColorReference(COLORREF color)
00024         {
00025                 m_mColors[color] = m_mColors[color] - 1;
00026                 if (m_mColors[color] <= 0)
00027                 {
00028                         m_mColors.erase( m_mColors.find(color) );
00029                 }
00030         }
00031 
00032         COLORREF GetColor(int pos)
00033         {
00034                 map<COLORREF, int>::iterator it;
00035                 for (it=m_mColors.begin(); it != m_mColors.end() && pos > 0; pos--)
00036                 {
00037                         it++;
00038                 }
00039 
00040                 if ( it != m_mColors.end() )
00041                         return it->first;
00042                 else
00043                         return RGB(0, 0, 0);
00044         }
00045 
00046         int ColorCount()
00047         {
00048                 return (int) m_mColors.size();
00049         }
00050 
00051 };
00052 
00053 #endif

Generated at Wed Aug 29 19:58:55 2001 for Pocket Animator by doxygen1.2.5 written by Dimitri van Heesch, © 1997-2001