color.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #if !defined COLOR_HEADER
00020 #define COLOR_HEADER
00021 
00025 
00026 #include "whiptk/whipcore.h"
00027 #include "whiptk/attribute.h"
00028 
00029 class WT_File;
00030 class WT_Color_Map;
00031 
00036 
00037 
00040 class WHIPTK_API WT_Color
00041 : public WT_Attribute
00042 {
00043         friend class WT_Background;
00044         friend class WT_Rendition;
00045         friend class WT_PDFBackground;
00046         friend class WT_W2D_Class_Factory;
00047         friend class WT_PDFClassFactory;
00048         friend class WT_Opcode;
00049         friend class WT_File;
00050         friend class WT_Color_Map;
00051         friend class WT_Class_Factory;
00052 public:
00054     enum WT_Color_Map_Mode
00055     {   No_Mapping,
00056         Search_666_Color_Cube_Exact,
00057         Search_666_Color_Cube_Nearest,
00058         Search_666_Color_Cube_Exact_Then_Color_Map_Exact,
00059         Search_666_Color_Cube_Exact_Then_Color_Map_Nearest
00060     };
00061 public:
00063 
00064     WT_Color()
00065     : m_stage(Getting_Color)
00066     { set(255,255,255); }
00067 
00069 
00070     WT_Color(
00071         WT_RGBA32 color, 
00072         WT_Color_Map_Mode m = No_Mapping 
00073         )
00074     : m_stage(Getting_Color)
00075     { set(color,m); }
00076 
00078 
00079     WT_Color(
00080         int red, 
00081         int green, 
00082         int blue, 
00083         WT_Color_Map_Mode m=No_Mapping 
00084         )
00085     : m_stage(Getting_Color)
00086     { set(red,green,blue,m); }
00087 
00089 
00090     WT_Color(
00091         int red, 
00092         int green, 
00093         int blue, 
00094         int alpha, 
00095         WT_Color_Map_Mode m=No_Mapping 
00096         )
00097     : m_stage(Getting_Color)
00098     { set(red,green,blue,alpha,m); }
00099 
00101 
00103     WT_Color(
00104         WT_Color_Index index, 
00105         WT_Color_Map const & color_map 
00106         )
00107     : m_mode(No_Mapping)
00108     , m_stage(Getting_Color)
00109     { set(index,color_map); }
00110 
00112 
00114     WT_Color(
00115         WT_Color const& copy 
00116         )
00117     { set (copy); }
00118 
00119         virtual ~WT_Color()
00120         {}
00121 public:
00123 
00124     inline const int index()      const { return m_index; }
00126     inline const WT_RGBA32& rgba() const { return m_rgba; }
00128     inline const WT_Color_Map_Mode& mode() const { return m_mode; }
00129 
00131     inline WT_Color const& operator=( WT_RGBA32 const &oColor )
00132     {   m_mode = No_Mapping;
00133         m_rgba = oColor;
00134         m_index = WD_NO_COLOR_INDEX;
00135         return *this; 
00136     }
00137 
00139 
00141     void set(
00142         WT_Color_Index index, 
00143         WT_Color_Map const & color_map 
00144         );
00145 
00147     inline void set(
00148         int red, 
00149         int green, 
00150         int blue, 
00151         int alpha, 
00152         WT_Color_Map_Mode m=No_Mapping 
00153         )
00154     {   set(WT_RGBA32(red,green,blue,alpha),m); }
00155 
00157     inline void set(
00158         int red, 
00159         int green, 
00160         int blue, 
00161         WT_Color_Map_Mode m=No_Mapping 
00162         )
00163     {   set(WT_RGBA32(red,green,blue,0xFF),m); }
00164 
00166     inline void set(
00167         WT_RGBA32 color, 
00168         WT_Color_Map_Mode m = No_Mapping 
00169         )
00170     {   m_mode = m;
00171         m_rgba = color;
00172         m_index = WD_NO_COLOR_INDEX;
00173     }
00174     
00176     inline void set(
00177         WT_Color const &copy
00178         )
00179     {
00180         m_rgba = copy.m_rgba;
00181         m_index = copy.m_index;
00182         m_mode = copy.m_mode;
00183         m_stage = copy.m_stage;
00184     }
00186 
00188     WT_ID            object_id() const;
00189     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00190     WT_Result        process(WT_File & file);
00191     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00192     WT_Result        serialize (WT_File & file) const;
00193     WT_Result        sync (WT_File & file) const;
00194     WT_Boolean       operator== (WT_Attribute const & attrib) const;
00196 
00198 
00201     static int map_to_index(
00202         WT_RGBA32 color,  
00203         WT_Color_Map_Mode mode, 
00204         WT_Color_Map const & map 
00205         );
00206 
00208 
00210     static WT_Result default_process(
00211         WT_Color & item, 
00212         WT_File & file 
00213         );
00214 
00215 private:
00216     WT_RGBA32 m_rgba;
00217     WT_Color_Index m_index;
00218     WT_Color_Map_Mode m_mode;
00219     enum WT_Materialize_Stage
00220     {   Getting_Color,
00221         Getting_Close_Paren
00222     } m_stage;
00223 };
00224 
00226 
00227 #endif // COLOR_HEADER

Generated on Tue Jan 6 22:41:12 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5