Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

color.h

00001 //  Copyright (c) 1996-2001 by Autodesk, Inc.
00002 //
00003 //  By using this code, you are agreeing to the terms and conditions of
00004 //  the License Agreement included in the documentation for this code.
00005 //
00006 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00007 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00008 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00009 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00010 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00011 //
00012 //  Use, duplication, or disclosure by the U.S. Government is subject to
00013 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00014 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00015 //  Data and Computer Software), as applicable.
00016 //
00017 
00018 #if !defined COLOR_HEADER
00019 #define COLOR_HEADER
00020 
00021 #include "whiptk/whipcore.h"
00022 #include "whiptk/attribute.h"
00023 
00024 class WT_File;
00025 class WT_Color_Map;
00026 
00031 
00032 
00035 class WHIPTK_API WT_Color
00036 : public WT_Attribute
00037 {
00038 public:
00040     enum WT_Color_Map_Mode
00041     {   No_Mapping,
00042         Search_666_Color_Cube_Exact,
00043         Search_666_Color_Cube_Nearest,
00044         Search_666_Color_Cube_Exact_Then_Color_Map_Exact,
00045         Search_666_Color_Cube_Exact_Then_Color_Map_Nearest
00046     };
00047 
00049 
00050     WT_Color()
00051     : m_stage(Getting_Color)
00052     { set(255,255,255); }
00053 
00055 
00056     WT_Color(
00057         WT_RGBA32 color, 
00058         WT_Color_Map_Mode m = No_Mapping 
00059         )
00060     : m_stage(Getting_Color)
00061     { set(color,m); }
00062 
00064 
00065     WT_Color(
00066         int red, 
00067         int green, 
00068         int blue, 
00069         WT_Color_Map_Mode m=No_Mapping 
00070         )
00071     : m_stage(Getting_Color)
00072     { set(red,green,blue,m); }
00073 
00075 
00076     WT_Color(
00077         int red, 
00078         int green, 
00079         int blue, 
00080         int alpha, 
00081         WT_Color_Map_Mode m=No_Mapping 
00082         )
00083     : m_stage(Getting_Color)
00084     { set(red,green,blue,alpha,m); }
00085 
00087 
00089     WT_Color(
00090         WT_Color_Index index, 
00091         WT_Color_Map const & color_map 
00092         )
00093     : m_mode(No_Mapping)
00094     , m_stage(Getting_Color)
00095     { set(index,color_map); }
00096 
00098 
00099     inline int index()      const { return m_index; }
00101     inline WT_RGBA32 rgba() const { return m_rgba; }
00102 
00104 
00106     void set(
00107         WT_Color_Index index, 
00108         WT_Color_Map const & color_map 
00109         );
00110 
00112     inline void set(
00113         int red, 
00114         int green, 
00115         int blue, 
00116         int alpha, 
00117         WT_Color_Map_Mode m=No_Mapping 
00118         )
00119     {   set(WT_RGBA32(red,green,blue,alpha),m); }
00120 
00122     inline void set(
00123         int red, 
00124         int green, 
00125         int blue, 
00126         WT_Color_Map_Mode m=No_Mapping 
00127         )
00128     {   set(WT_RGBA32(red,green,blue,0xFF),m); }
00129 
00131     inline void set(
00132         WT_RGBA32 color, 
00133         WT_Color_Map_Mode m = No_Mapping 
00134         )
00135     {   m_mode = m;
00136         m_rgba = color;
00137         m_index = WD_NO_COLOR_INDEX;
00138     }
00140 
00142     WT_ID            object_id() const;
00143     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00144     WT_Result        process(WT_File & file);
00145     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00146     WT_Result        serialize (WT_File & file) const;
00147     WT_Result        sync (WT_File & file) const;
00148     WT_Boolean       operator== (WT_Attribute const & attrib) const;
00150 
00152 
00155     static int map_to_index(
00156         WT_RGBA32 color,  
00157         WT_Color_Map_Mode mode, 
00158         WT_Color_Map const & map 
00159         );
00160 
00162 
00164     static WT_Result default_process(
00165         WT_Color & item, 
00166         WT_File & file 
00167         );
00168 
00169 private:
00170 
00171     WT_RGBA32 m_rgba;
00172     WT_Color_Index m_index;
00173     WT_Color_Map_Mode m_mode;
00174     enum WT_Materialize_Stage
00175     {   Getting_Color,
00176         Getting_Close_Paren
00177     } m_stage;
00178 };
00179 
00181 
00182 #endif // COLOR_HEADER

Generated on Tue May 17 12:07:43 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1