00001 /********************************************************************************* 00002 * 00003 * Razor! Engine - A modular C++ presentation engine 00004 * 00005 * $Id: Color.h,v 1.2 2003/03/17 21:19:49 teacy Exp $ 00006 * 00007 * Copyright (c) 2003 Tilo Christ. All Rights Reserved. 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a 00010 * copy of this software and associated documentation files (the "Software"), 00011 * to deal in the Software without restriction, including without limitation 00012 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00013 * and/or sell copies of the Software, and to permit persons to whom the Software 00014 * is furnished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included in all 00017 * copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 00020 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 00021 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 00022 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00023 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 * 00025 **********************************************************************************/ 00026 00027 00028 00029 00030 #ifndef COLOR_H 00031 #define COLOR_H 00032 00033 #include "RazorSections.h" 00034 #include <PalmOS.h> 00035 00036 00037 /** 00038 * Representation of a color. 00039 * <br> 00040 * Color operations are very sensitive to the current display settings. 00041 * You should only construct colors while the display is properly setup, and 00042 * is initialized with the palette that you wish to use. 00043 * <br> 00044 * Do not use color objects after you have changed display settings. 00045 */ 00046 class Color 00047 { 00048 public: 00049 /** 00050 * Construct a color with the specified RGB values. 00051 * 00052 * @param r the red value from 0-255 00053 * @param g the green value from 0-255 00054 * @param b the blue value from 0-255 00055 */ 00056 Color(UInt8 r, UInt8 g, UInt8 b); 00057 00058 /** 00059 * Set an existing color object to the color with the specified RGB values. 00060 * Use this to reuse color objects, which might reduce memory fragmentation. 00061 * 00062 * @param r the red value from 0-255 00063 * @param g the green value from 0-255 00064 * @param b the blue value from 0-255 00065 */ 00066 void init(UInt8 r, UInt8 g, UInt8 b); 00067 00068 00069 /** 00070 * Get the index of the color in the display's current palette. 00071 */ 00072 IndexedColorType getIndexedColor() const; 00073 RGBColorType getRGBColor() const; 00074 00075 static const Color BLACK; 00076 static const Color WHITE; 00077 00078 private: 00079 mutable RGBColorType rgbColor; 00080 mutable Boolean isIndexed; 00081 }; 00082 00083 00084 #endif