wg_color.h

00001 // wg_color.h
00002 //
00003 // CRGBColor class interface
00004 //
00005 //
00006 // Copyright (c) 2002-2004 Rob Wiskow
00007 // rob-dev@boxedchaos.com
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022 //
00023 
00024 
00025 #ifndef _WG_COLOR_H_
00026 #define _WG_COLOR_H_
00027 
00028 #include "SDL.h"
00029 #include <cmath>
00030 #include <string>
00031 
00032 
00033 namespace wGui
00034 {
00035 
00037 
00038 class CRGBColor
00039 {
00040 public:
00041      unsigned char red;  
00042      unsigned char green;  
00043      unsigned char blue;  
00044      unsigned char alpha;  
00045 
00051      CRGBColor(const unsigned char r, const unsigned char g, const unsigned char b, const unsigned char a = 0xFF) :
00052           red(r), green(g), blue(b), alpha(a) { }
00053 
00057      CRGBColor(const Uint32* pColorValue, const SDL_PixelFormat* pFormat);
00058 
00064      CRGBColor(std::wstring sColor);
00065 
00068      unsigned long int SDLColor(SDL_PixelFormat* pFormat) const
00069           { return SDL_MapRGBA(pFormat, red, green, blue, alpha); }
00070 
00073      bool operator==(const CRGBColor& c) const
00074      {
00075           return (red == c.red && green == c.green && blue == c.blue);
00076      }
00077 
00080      bool operator!=(const CRGBColor& c) const
00081      {
00082           return (red != c.red || green != c.green || blue != c.blue);
00083      }
00084 
00086      CRGBColor& operator=(const CRGBColor& c);
00087 
00089      CRGBColor operator+(const CRGBColor& c) const;
00090 
00092      CRGBColor operator|(const CRGBColor& c) const;
00093 
00095      CRGBColor operator&(const CRGBColor& c) const;
00096 
00098      CRGBColor operator^(const CRGBColor& c) const;
00099 
00102      CRGBColor MixNormal(const CRGBColor& c) const;
00103 
00104 };
00105 
00106 
00107 // Predefined colors
00108 extern CRGBColor DEFAULT_BACKGROUND_COLOR;  
00109 extern CRGBColor DEFAULT_FOREGROUND_COLOR;  
00110 extern CRGBColor DEFAULT_LINE_COLOR;  
00111 extern CRGBColor DEFAULT_DISABLED_LINE_COLOR;  
00112 extern CRGBColor COLOR_TRANSPARENT;
00113 extern CRGBColor COLOR_WHITE;
00114 extern CRGBColor COLOR_LIGHTGRAY;
00115 extern CRGBColor COLOR_GRAY;
00116 extern CRGBColor COLOR_DARKGRAY;
00117 extern CRGBColor COLOR_BLACK;
00118 extern CRGBColor COLOR_BLUE;
00119 extern CRGBColor COLOR_RED;
00120 extern CRGBColor COLOR_GREEN;
00121 extern CRGBColor COLOR_YELLOW;
00122 extern CRGBColor COLOR_CYAN;
00123 extern CRGBColor COLOR_MAGENTA;
00124 
00125 }
00126 
00127 
00128 #include "unit_tests/wg_color_unittests.h"
00129 
00130 #endif // _WG_COLOR_H_
00131 

Generated on Wed May 16 23:11:25 2007 for wGui by  doxygen 1.5.1