00001 /* 00002 libwt - Vassilis Virvilis Toolkit - a widget library 00003 Copyright (C) 2006 Vassilis Virvilis <vasvir2@fastmail.fm> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the 00017 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, SA. 00019 */ 00020 00021 #ifndef WT_COLOR_H 00022 #define WT_COLOR_H 00023 00024 #include <map> 00025 00026 #include <wt/sdlcolor.h> 00027 00028 namespace Wt { 00029 /// Wrapper class for describing colors 00030 /// using 8-bits per red, green, blue, and alpha channels 00031 class Color : public SDLColor { 00032 public: 00033 Color() : SDLColor() { 00034 assert(sizeof(Color) == sizeof(SDLColor)); 00035 } 00036 00037 /// Construct from a triple/quadruple. (R, G, B, A) 00038 Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = Opaque) 00039 : SDLColor(red, green, blue, alpha) { 00040 assert(sizeof(Color) == sizeof(SDLColor)); 00041 } 00042 00043 /// constructor from SDLColor for implicit conversions 00044 Color(const SDLColor& color) : SDLColor(color) { 00045 assert(sizeof(Color) == sizeof(SDLColor)); 00046 } 00047 00048 /// Construct a named color (as find()) 00049 Color(const std::string& name); 00050 00051 /// same thing, so compiler will autocreate temporaries from "foo" 00052 Color(const char* name); 00053 00054 00055 class Map : public std::map<std::string, Color> { 00056 public: 00057 Map(); 00058 }; 00059 00060 static Map map; 00061 00062 protected: 00063 static Color createColorFromRGBString(const std::string& rgb); 00064 }; 00065 00066 /// Operator for output streams 00067 std::ostream& operator<<(std::ostream& s, const Color& c); 00068 00069 } 00070 00071 #endif // WT_COLOR_H
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.