color.cpp

Go to the documentation of this file.
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 #include <iostream>
00022 #include <sstream>
00023 
00024 #include <wt/trace.h>
00025 #include <wt/color.h>
00026 
00027 namespace Wt {
00028 
00029 Color::Map Color::map;
00030 
00031 Color::Map::Map() {
00032     const struct {
00033         const char* name;
00034         int r, g, b;
00035     }
00036     color_info[] = {
00037                        {"black",0,0,0},
00038                        {"darkgrey",8,8,8},
00039                        {"darkgreen",32,64,32},
00040                        {"darkslateblue",32,0,64},
00041                        {"lightblue",128,0,255},
00042                        {"grey",64,64,64},
00043                        {"lightgrey",128,128,128},
00044                        {"red",128,32,32},
00045                        {"blue",32,32,128},
00046                        {"green",32,128,32},
00047                        {"seagreen",16,64,64},
00048                        {"white",254,254,254},
00049                        {"snow",255,250,250},
00050                        {"GhostWhite",248,248,255},
00051                        {"WhiteSmoke",245,245,245},
00052                        {"gainsboro",220,220,220},
00053                        {"FloralWhite",255,250,240},
00054                        {"OldLace",253,245,230},
00055                        {"linen",250,240,230},
00056                        {"AntiqueWhite",250,235,215},
00057                        {"PapayaWhip",255,239,213},
00058                        {"BlanchedAlmond",255,235,205},
00059                        {"bisque",255,228,196},
00060                        {"PeachPuff",255,218,185},
00061                        {"NavajoWhite",255,222,173},
00062                        {"moccasin",255,228,181},
00063                        {"cornsilk",255,248,220},
00064                        {"ivory",255,255,240},
00065                        {"LemonChiffon",255,250,205},
00066                        {"seashell",255,245,238},
00067                        {"honeydew",240,255,240},
00068                        {"MintCream",245,255,250},
00069                        {"azure",240,255,255},
00070                        {"AliceBlue",240,248,255},
00071                        {"lavender",230,230,250},
00072                        {"LavenderBlush",255,240,245},
00073                        {"MistyRose",255,228,225},
00074                        {"DarkSlateGray",47,79,79},
00075                        {"DarkSlateGrey",47,79,79},
00076                        {"DimGray",105,105,105},
00077                        {"DimGrey",105,105,105},
00078                        {"SlateGray",112,128,144},
00079                        {"SlateGrey",112,128,144},
00080                        {"LightSlateGray",119,136,153},
00081                        {"LightSlateGrey",119,136,153},
00082                        {"gray",190,190,190},
00083                        {"LightGrey",211,211,211},
00084                        {"LightGray",211,211,211},
00085                        {"MidnightBlue",25,25,112},
00086                        {"navy",0,0,128},
00087                        {"NavyBlue",0,0,128},
00088                        {"CornflowerBlue",100,149,237},
00089                        {"DarkSlateBlue",72,61,139},
00090                        {"SlateBlue",106,90,205},
00091                        {"MediumSlateBlue",123,104,238},
00092                        {"LightSlateBlue",132,112,255},
00093                        {"MediumBlue",0,0,205},
00094                        {"RoyalBlue",65,105,225},
00095                        {"DodgerBlue",30,144,255},
00096                        {"DeepSkyBlue",0,191,255},
00097                        {"SkyBlue",135,206,235},
00098                        {"LightSkyBlue",135,206,250},
00099                        {"SteelBlue",70,130,180},
00100                        {"LightSteelBlue",176,196,222},
00101                        {"LightBlue",173,216,230},
00102                        {"PowderBlue",176,224,230},
00103                        {"PaleTurquoise",175,238,238},
00104                        {"DarkTurquoise",0,206,209},
00105                        {"MediumTurquoise",72,209,204},
00106                        {"turquoise",64,224,208},
00107                        {"cyan",0,255,255},
00108                        {"LightCyan",224,255,255},
00109                        {"CadetBlue",95,158,160},
00110                        {"MediumAquamarine",102,205,170},
00111                        {"aquamarine",127,255,212},
00112                        {"DarkGreen",0,100,0},
00113                        {"DarkOliveGreen",85,107,47},
00114                        {"DarkSeaGreen",143,188,143},
00115                        {"SeaGreen",46,139,87},
00116                        {"MediumSeaGreen",60,179,113},
00117                        {"LightSeaGreen",32,178,170},
00118                        {"PaleGreen",152,251,152},
00119                        {"SpringGreen",0,255,127},
00120                        {"LawnGreen",124,252,0},
00121                        {"chartreuse",127,255,0},
00122                        {"MediumSpringGreen",0,250,154},
00123                        {"GreenYellow",173,255,47},
00124                        {"LimeGreen",50,205,50},
00125                        {"YellowGreen",154,205,50},
00126                        {"ForestGreen",34,139,34},
00127                        {"OliveDrab",107,142,35},
00128                        {"DarkKhaki",189,183,107},
00129                        {"khaki",240,230,140},
00130                        {"PaleGoldenrod",238,232,170},
00131                        {"LightGoldenrodYellow",250,250,210},
00132                        {"LightYellow",255,255,224},
00133                        {"yellow",255,255,0},
00134                        {"gold",255,215,0},
00135                        {"LightGoldenrod",238,221,130},
00136                        {"goldenrod",218,165,32},
00137                        {"DarkGoldenrod",184,134,11},
00138                        {"RosyBrown",188,143,143},
00139                        {"IndianRed",205,92,92},
00140                        {"SaddleBrown",139,69,19},
00141                        {"sienna",160,82,45},
00142                        {"peru",205,133,63},
00143                        {"burlywood",222,184,135},
00144                        {"beige",245,245,220},
00145                        {"wheat",245,222,179},
00146                        {"SandyBrown",244,164,96},
00147                        {"tan",210,180,140},
00148                        {"chocolate",210,105,30},
00149                        {"firebrick",178,34,34},
00150                        {"brown",165,42,42},
00151                        {"DarkSalmon",233,150,122},
00152                        {"salmon",250,128,114},
00153                        {"LightSalmon",255,160,122},
00154                        {"orange",255,165,0},
00155                        {"DarkOrange",255,140,0},
00156                        {"coral",255,127,80},
00157                        {"LightCoral",240,128,128},
00158                        {"tomato",255,99,71},
00159                        {"OrangeRed",255,69,0},
00160                        {"HotPink",255,105,180},
00161                        {"DeepPink",255,20,147},
00162                        {"pink",255,192,203},
00163                        {"LightPink",255,182,193},
00164                        {"PaleVioletRed",219,112,147},
00165                        {"maroon",176,48,96},
00166                        {"MediumVioletRed",199,21,133},
00167                        {"VioletRed",208,32,144},
00168                        {"magenta",255,0,255},
00169                        {"violet",238,130,238},
00170                        {"plum",221,160,221},
00171                        {"orchid",218,112,214},
00172                        {"MediumOrchid",186,85,211},
00173                        {"DarkOrchid",153,50,204},
00174                        {"DarkViolet",148,0,211},
00175                        {"BlueViolet",138,43,226},
00176                        {"purple",160,32,240},
00177                        {"MediumPurple",147,112,219},
00178                        {"thistle",216,191,216},
00179                        {"snow1",255,250,250},
00180                        {"snow2",238,233,233},
00181                        {"snow3",205,201,201},
00182                        {"snow4",139,137,137},
00183                        {"seashell1",255,245,238},
00184                        {"seashell2",238,229,222},
00185                        {"seashell3",205,197,191},
00186                        {"seashell4",139,134,130},
00187                        {"AntiqueWhite1",255,239,219},
00188                        {"AntiqueWhite2",238,223,204},
00189                        {"AntiqueWhite3",205,192,176},
00190                        {"AntiqueWhite4",139,131,120},
00191                        {"bisque1",255,228,196},
00192                        {"bisque2",238,213,183},
00193                        {"bisque3",205,183,158},
00194                        {"bisque4",139,125,107},
00195                        {"PeachPuff1",255,218,185},
00196                        {"PeachPuff2",238,203,173},
00197                        {"PeachPuff3",205,175,149},
00198                        {"PeachPuff4",139,119,101},
00199                        {"NavajoWhite1",255,222,173},
00200                        {"NavajoWhite2",238,207,161},
00201                        {"NavajoWhite3",205,179,139},
00202                        {"NavajoWhite4",139,121,94},
00203                        {"LemonChiffon1",255,250,205},
00204                        {"LemonChiffon2",238,233,191},
00205                        {"LemonChiffon3",205,201,165},
00206                        {"LemonChiffon4",139,137,112},
00207                        {"cornsilk1",255,248,220},
00208                        {"cornsilk2",238,232,205},
00209                        {"cornsilk3",205,200,177},
00210                        {"cornsilk4",139,136,120},
00211                        {"ivory1",255,255,240},
00212                        {"ivory2",238,238,224},
00213                        {"ivory3",205,205,193},
00214                        {"ivory4",139,139,131},
00215                        {"honeydew1",240,255,240},
00216                        {"honeydew2",224,238,224},
00217                        {"honeydew3",193,205,193},
00218                        {"honeydew4",131,139,131},
00219                        {"LavenderBlush1",255,240,245},
00220                        {"LavenderBlush2",238,224,229},
00221                        {"LavenderBlush3",205,193,197},
00222                        {"LavenderBlush4",139,131,134},
00223                        {"MistyRose1",255,228,225},
00224                        {"MistyRose2",238,213,210},
00225                        {"MistyRose3",205,183,181},
00226                        {"MistyRose4",139,125,123},
00227                        {"azure1",240,255,255},
00228                        {"azure2",224,238,238},
00229                        {"azure3",193,205,205},
00230                        {"azure4",131,139,139},
00231                        {"SlateBlue1",131,111,255},
00232                        {"SlateBlue2",122,103,238},
00233                        {"SlateBlue3",105,89,205},
00234                        {"SlateBlue4",71,60,139},
00235                        {"RoyalBlue1",72,118,255},
00236                        {"RoyalBlue2",67,110,238},
00237                        {"RoyalBlue3",58,95,205},
00238                        {"RoyalBlue4",39,64,139},
00239                        {"blue1",0,0,255},
00240                        {"blue2",0,0,238},
00241                        {"blue3",0,0,205},
00242                        {"blue4",0,0,139},
00243                        {"DodgerBlue1",30,144,255},
00244                        {"DodgerBlue2",28,134,238},
00245                        {"DodgerBlue3",24,116,205},
00246                        {"DodgerBlue4",16,78,139},
00247                        {"SteelBlue1",99,184,255},
00248                        {"SteelBlue2",92,172,238},
00249                        {"SteelBlue3",79,148,205},
00250                        {"SteelBlue4",54,100,139},
00251                        {"DeepSkyBlue1",0,191,255},
00252                        {"DeepSkyBlue2",0,178,238},
00253                        {"DeepSkyBlue3",0,154,205},
00254                        {"DeepSkyBlue4",0,104,139},
00255                        {"SkyBlue1",135,206,255},
00256                        {"SkyBlue2",126,192,238},
00257                        {"SkyBlue3",108,166,205},
00258                        {"SkyBlue4",74,112,139},
00259                        {"LightSkyBlue1",176,226,255},
00260                        {"LightSkyBlue2",164,211,238},
00261                        {"LightSkyBlue3",141,182,205},
00262                        {"LightSkyBlue4",96,123,139},
00263                        {"SlateGray1",198,226,255},
00264                        {"SlateGray2",185,211,238},
00265                        {"SlateGray3",159,182,205},
00266                        {"SlateGray4",108,123,139},
00267                        {"LightSteelBlue1",202,225,255},
00268                        {"LightSteelBlue2",188,210,238},
00269                        {"LightSteelBlue3",162,181,205},
00270                        {"LightSteelBlue4",110,123,139},
00271                        {"LightBlue1",191,239,255},
00272                        {"LightBlue2",178,223,238},
00273                        {"LightBlue3",154,192,205},
00274                        {"LightBlue4",104,131,139},
00275                        {"LightCyan1",224,255,255},
00276                        {"LightCyan2",209,238,238},
00277                        {"LightCyan3",180,205,205},
00278                        {"LightCyan4",122,139,139},
00279                        {"PaleTurquoise1",187,255,255},
00280                        {"PaleTurquoise2",174,238,238},
00281                        {"PaleTurquoise3",150,205,205},
00282                        {"PaleTurquoise4",102,139,139},
00283                        {"CadetBlue1",152,245,255},
00284                        {"CadetBlue2",142,229,238},
00285                        {"CadetBlue3",122,197,205},
00286                        {"CadetBlue4",83,134,139},
00287                        {"turquoise1",0,245,255},
00288                        {"turquoise2",0,229,238},
00289                        {"turquoise3",0,197,205},
00290                        {"turquoise4",0,134,139},
00291                        {"cyan1",0,255,255},
00292                        {"cyan2",0,238,238},
00293                        {"cyan3",0,205,205},
00294                        {"cyan4",0,139,139},
00295                        {"DarkSlateGray1",151,255,255},
00296                        {"DarkSlateGray2",141,238,238},
00297                        {"DarkSlateGray3",121,205,205},
00298                        {"DarkSlateGray4",82,139,139},
00299                        {"aquamarine1",127,255,212},
00300                        {"aquamarine2",118,238,198},
00301                        {"aquamarine3",102,205,170},
00302                        {"aquamarine4",69,139,116},
00303                        {"DarkSeaGreen1",193,255,193},
00304                        {"DarkSeaGreen2",180,238,180},
00305                        {"DarkSeaGreen3",155,205,155},
00306                        {"DarkSeaGreen4",105,139,105},
00307                        {"SeaGreen1",84,255,159},
00308                        {"SeaGreen2",78,238,148},
00309                        {"SeaGreen3",67,205,128},
00310                        {"SeaGreen4",46,139,87},
00311                        {"PaleGreen1",154,255,154},
00312                        {"PaleGreen2",144,238,144},
00313                        {"PaleGreen3",124,205,124},
00314                        {"PaleGreen4",84,139,84},
00315                        {"SpringGreen1",0,255,127},
00316                        {"SpringGreen2",0,238,118},
00317                        {"SpringGreen3",0,205,102},
00318                        {"SpringGreen4",0,139,69},
00319                        {"green1",0,255,0},
00320                        {"green2",0,238,0},
00321                        {"green3",0,205,0},
00322                        {"green4",0,139,0},
00323                        {"chartreuse1",127,255,0},
00324                        {"chartreuse2",118,238,0},
00325                        {"chartreuse3",102,205,0},
00326                        {"chartreuse4",69,139,0},
00327                        {"OliveDrab1",192,255,62},
00328                        {"OliveDrab2",179,238,58},
00329                        {"OliveDrab3",154,205,50},
00330                        {"OliveDrab4",105,139,34},
00331                        {"DarkOliveGreen1",202,255,112},
00332                        {"DarkOliveGreen2",188,238,104},
00333                        {"DarkOliveGreen3",162,205,90},
00334                        {"DarkOliveGreen4",110,139,61},
00335                        {"khaki1",255,246,143},
00336                        {"khaki2",238,230,133},
00337                        {"khaki3",205,198,115},
00338                        {"khaki4",139,134,78},
00339                        {"LightGoldenrod1",255,236,139},
00340                        {"LightGoldenrod2",238,220,130},
00341                        {"LightGoldenrod3",205,190,112},
00342                        {"LightGoldenrod4",139,129,76},
00343                        {"LightYellow1",255,255,224},
00344                        {"LightYellow2",238,238,209},
00345                        {"LightYellow3",205,205,180},
00346                        {"LightYellow4",139,139,122},
00347                        {"yellow1",255,255,0},
00348                        {"yellow2",238,238,0},
00349                        {"yellow3",205,205,0},
00350                        {"yellow4",139,139,0},
00351                        {"gold1",255,215,0},
00352                        {"gold2",238,201,0},
00353                        {"gold3",205,173,0},
00354                        {"gold4",139,117,0},
00355                        {"goldenrod1",255,193,37},
00356                        {"goldenrod2",238,180,34},
00357                        {"goldenrod3",205,155,29},
00358                        {"goldenrod4",139,105,20},
00359                        {"DarkGoldenrod1",255,185,15},
00360                        {"DarkGoldenrod2",238,173,14},
00361                        {"DarkGoldenrod3",205,149,12},
00362                        {"DarkGoldenrod4",139,101,8},
00363                        {"RosyBrown1",255,193,193},
00364                        {"RosyBrown2",238,180,180},
00365                        {"RosyBrown3",205,155,155},
00366                        {"RosyBrown4",139,105,105},
00367                        {"IndianRed1",255,106,106},
00368                        {"IndianRed2",238,99,99},
00369                        {"IndianRed3",205,85,85},
00370                        {"IndianRed4",139,58,58},
00371                        {"sienna1",255,130,71},
00372                        {"sienna2",238,121,66},
00373                        {"sienna3",205,104,57},
00374                        {"sienna4",139,71,38},
00375                        {"burlywood1",255,211,155},
00376                        {"burlywood2",238,197,145},
00377                        {"burlywood3",205,170,125},
00378                        {"burlywood4",139,115,85},
00379                        {"wheat1",255,231,186},
00380                        {"wheat2",238,216,174},
00381                        {"wheat3",205,186,150},
00382                        {"wheat4",139,126,102},
00383                        {"tan1",255,165,79},
00384                        {"tan2",238,154,73},
00385                        {"tan3",205,133,63},
00386                        {"tan4",139,90,43},
00387                        {"chocolate1",255,127,36},
00388                        {"chocolate2",238,118,33},
00389                        {"chocolate3",205,102,29},
00390                        {"chocolate4",139,69,19},
00391                        {"firebrick1",255,48,48},
00392                        {"firebrick2",238,44,44},
00393                        {"firebrick3",205,38,38},
00394                        {"firebrick4",139,26,26},
00395                        {"brown1",255,64,64},
00396                        {"brown2",238,59,59},
00397                        {"brown3",205,51,51},
00398                        {"brown4",139,35,35},
00399                        {"salmon1",255,140,105},
00400                        {"salmon2",238,130,98},
00401                        {"salmon3",205,112,84},
00402                        {"salmon4",139,76,57},
00403                        {"LightSalmon1",255,160,122},
00404                        {"LightSalmon2",238,149,114},
00405                        {"LightSalmon3",205,129,98},
00406                        {"LightSalmon4",139,87,66},
00407                        {"orange1",255,165,0},
00408                        {"orange2",238,154,0},
00409                        {"orange3",205,133,0},
00410                        {"orange4",139,90,0},
00411                        {"DarkOrange1",255,127,0},
00412                        {"DarkOrange2",238,118,0},
00413                        {"DarkOrange3",205,102,0},
00414                        {"DarkOrange4",139,69,0},
00415                        {"coral1",255,114,86},
00416                        {"coral2",238,106,80},
00417                        {"coral3",205,91,69},
00418                        {"coral4",139,62,47},
00419                        {"tomato1",255,99,71},
00420                        {"tomato2",238,92,66},
00421                        {"tomato3",205,79,57},
00422                        {"tomato4",139,54,38},
00423                        {"OrangeRed1",255,69,0},
00424                        {"OrangeRed2",238,64,0},
00425                        {"OrangeRed3",205,55,0},
00426                        {"OrangeRed4",139,37,0},
00427                        {"red1",255,0,0},
00428                        {"red2",238,0,0},
00429                        {"red3",205,0,0},
00430                        {"red4",139,0,0},
00431                        {"DeepPink1",255,20,147},
00432                        {"DeepPink2",238,18,137},
00433                        {"DeepPink3",205,16,118},
00434                        {"DeepPink4",139,10,80},
00435                        {"HotPink1",255,110,180},
00436                        {"HotPink2",238,106,167},
00437                        {"HotPink3",205,96,144},
00438                        {"HotPink4",139,58,98},
00439                        {"pink1",255,181,197},
00440                        {"pink2",238,169,184},
00441                        {"pink3",205,145,158},
00442                        {"pink4",139,99,108},
00443                        {"LightPink1",255,174,185},
00444                        {"LightPink2",238,162,173},
00445                        {"LightPink3",205,140,149},
00446                        {"LightPink4",139,95,101},
00447                        {"PaleVioletRed1",255,130,171},
00448                        {"PaleVioletRed2",238,121,159},
00449                        {"PaleVioletRed3",205,104,137},
00450                        {"PaleVioletRed4",139,71,93},
00451                        {"maroon1",255,52,179},
00452                        {"maroon2",238,48,167},
00453                        {"maroon3",205,41,144},
00454                        {"maroon4",139,28,98},
00455                        {"VioletRed1",255,62,150},
00456                        {"VioletRed2",238,58,140},
00457                        {"VioletRed3",205,50,120},
00458                        {"VioletRed4",139,34,82},
00459                        {"magenta1",255,0,255},
00460                        {"magenta2",238,0,238},
00461                        {"magenta3",205,0,205},
00462                        {"magenta4",139,0,139},
00463                        {"orchid1",255,131,250},
00464                        {"orchid2",238,122,233},
00465                        {"orchid3",205,105,201},
00466                        {"orchid4",139,71,137},
00467                        {"plum1",255,187,255},
00468                        {"plum2",238,174,238},
00469                        {"plum3",205,150,205},
00470                        {"plum4",139,102,139},
00471                        {"MediumOrchid1",224,102,255},
00472                        {"MediumOrchid2",209,95,238},
00473                        {"MediumOrchid3",180,82,205},
00474                        {"MediumOrchid4",122,55,139},
00475                        {"DarkOrchid1",191,62,255},
00476                        {"DarkOrchid2",178,58,238},
00477                        {"DarkOrchid3",154,50,205},
00478                        {"DarkOrchid4",104,34,139},
00479                        {"purple1",155,48,255},
00480                        {"purple2",145,44,238},
00481                        {"purple3",125,38,205},
00482                        {"purple4",85,26,139},
00483                        {"MediumPurple1",171,130,255},
00484                        {"MediumPurple2",159,121,238},
00485                        {"MediumPurple3",137,104,205},
00486                        {"MediumPurple4",93,71,139},
00487                        {"thistle1",255,225,255},
00488                        {"thistle2",238,210,238},
00489                        {"thistle3",205,181,205},
00490                        {"thistle4",139,123,139},
00491                        {"DarkGrey",169,169,169},
00492                        {"DarkGray",169,169,169},
00493                        {"DarkBlue",0,0,139},
00494                        {"DarkCyan",0,139,139},
00495                        {"DarkMagenta",139,0,139},
00496                        {"DarkRed",139,0,0},
00497                        {"LightGreen",144,238,144},
00498                    };
00499     const int ncolors = sizeof(color_info) / sizeof(color_info[0]);
00500 
00501     Map& self = *this;
00502 
00503     self["transparent"] = Color(0, 0, 0, Transparent);
00504 
00505     for(int i = 0; i < ncolors; ++i) {
00506         self[color_info[i].name] = Color(color_info[i].r,
00507                                          color_info[i].g,
00508                                          color_info[i].b,
00509                                          Opaque);
00510     }
00511 
00512     // add the indexed greys in a loop, instead of putting them
00513     // in by hand
00514     for (int i = 0; i <= 100; i++) {
00515         const int index = (int) ( (i * 255) / 100.0 + 0.5);
00516         std::stringstream name;
00517 
00518         name.str("");
00519         name << "grey" << i;
00520         self[name.str()] = Color(index, index, index, Opaque);
00521         name.str("");
00522         name << "gray" << i;
00523         self[name.str()] = Color(index, index, index, Opaque);
00524     }
00525 }
00526 
00527 Color Color::createColorFromRGBString(const std::string& rgb) {
00528     unsigned int r, g, b, a;
00529     const int conversions = sscanf(rgb.c_str(),
00530                                    "%u %u %u %u", &r, &g, &b, &a);
00531 
00532     if (conversions == 4)
00533         return Color(r,g,b,a);
00534 
00535     if (conversions == 3)
00536         return Color(r,g,b);
00537 
00538     Warn("Resource: error parsing Colorvalue: '%s'\n", rgb.c_str());
00539     return Color(0, 0, 255, Opaque);
00540 }
00541 
00542 Color::Color(const std::string& name) {
00543     assert(sizeof(Color) == sizeof(SDLColor));
00544     Map::iterator it = map.find(name);
00545     if (it != map.end())
00546         *this = map[name];
00547     else
00548         *this = createColorFromRGBString(name);
00549 }
00550 
00551 Color::Color(const char* name) {
00552     assert(sizeof(Color) == sizeof(SDLColor));
00553     Map::iterator it = map.find(name);
00554     if (it != map.end())
00555         *this = it->second;
00556     else
00557         *this = createColorFromRGBString(std::string(name));
00558 }
00559 
00560 
00561 std::ostream& operator<<(std::ostream& s, const Color& c) {
00562     s << "(R"<< c.red() <<" G"<< c.green() <<" B"<< c.blue() <<" A"<< c.alpha() <<")";
00563     return s;
00564 }
00565 
00566 } // namespace Wt

Generated Fri Jul 28 19:23:00 2006.
Copyright © 1998-2003 by the respective authors.

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.