font.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 FONT_HEADER
00020 #define FONT_HEADER
00021 
00025 
00026 #include "whiptk/font_options.h"
00027 
00028 #define WD_FONT_STYLE_BOLD        0x01
00029 #define WD_FONT_STYLE_ITALIC      0x02
00030 #define WD_FONT_STYLE_UNDERLINED  0x04
00031 
00032 
00033 class WT_File;
00034 
00035 
00040 
00041 
00047 class WHIPTK_API WT_Font : public WT_Attribute
00048 {
00049         friend class WT_Rendition;
00050         friend class WT_W2D_Class_Factory;
00051         friend class WT_Text;
00052         friend class WT_Opcode;
00053         friend class WT_DWF_Header;
00054 
00055 protected:
00056     WT_Font_Option_Font_Name    m_option_font_name;
00057     WT_Font_Option_Charset      m_option_charset;
00058     WT_Font_Option_Pitch        m_option_pitch;
00059     WT_Font_Option_Family       m_option_family;
00060     WT_Font_Option_Style        m_option_style;
00061     WT_Font_Option_Height       m_option_height;
00062     WT_Font_Option_Rotation     m_option_rotation;
00063     WT_Font_Option_Width_Scale  m_option_width_scale;
00064     WT_Font_Option_Spacing      m_option_spacing;
00065     WT_Font_Option_Oblique      m_option_oblique;
00066     WT_Font_Option_Flags        m_option_flags;
00067 
00068     WT_Integer32            m_name_length;  // Obsolete, but needed to read older files
00069     WT_Boolean              m_rotation_checked; // A hack to get landscape_to_portrait() working.
00070 
00071     enum
00072     {
00073         Getting_Name_Length,
00074         Getting_Fields,
00075         Getting_Name,
00076         Getting_Charset,
00077         Getting_Pitch,
00078         Getting_Family,
00079         Getting_Style,
00080         Getting_Height,
00081         Getting_Rotation,
00082         Getting_Width_Scale,
00083         Getting_Spacing,
00084         Getting_Oblique,
00085         Getting_Flags,
00086         Getting_Next_Optioncode,
00087         Materializing_Option,
00088         Getting_Bold_Italic,
00089         Getting_Pitch_and_Family,
00090         Skipping_Last_Paren,
00091         Completed
00092     }               m_stage;
00093 
00094     WT_Font_Optioncode      m_optioncode;
00095 
00096     WT_Unsigned_Integer16   m_fields_defined;
00097 
00098 public:
00099 
00101     enum Font_Options
00102     {
00103         FONT_NO_FIELDS          = 0x0000,
00104         FONT_NAME_BIT           = 0x0001,
00105         FONT_CHARSET_BIT        = 0x0002,
00106         FONT_PITCH_BIT          = 0x0004,
00107         FONT_FAMILY_BIT         = 0x0008,
00108         FONT_STYLE_BIT          = 0x0010,
00109         FONT_HEIGHT_BIT         = 0x0020,
00110         FONT_ROTATION_BIT       = 0x0040,
00111         FONT_WIDTH_SCALE_BIT    = 0x0080,
00112         FONT_SPACING_BIT        = 0x0100,
00113         FONT_OBLIQUE_BIT        = 0x0200,
00114         FONT_FLAGS_BIT          = 0x0400,
00115         FONT_ALL_FIELDS         = 0xFFFF
00116     };
00117 public:
00119 
00120     WT_Font()
00121         : m_name_length (0) // Obsolete, but needed to read older files
00122         , m_rotation_checked(WD_False)
00123         , m_stage (Getting_Name_Length)
00124         , m_fields_defined(FONT_NO_FIELDS)
00125     { }
00126 
00128     WT_Font (
00129         WT_String             name, 
00130         WT_Boolean            bold, 
00131         WT_Boolean            italic, 
00132         WT_Boolean            underline, 
00133         WT_Byte               charset, 
00134         WT_Byte               pitch, 
00135         WT_Byte               family, 
00136         WT_Integer32          height, 
00137         WT_Unsigned_Integer16 rotation, 
00141         WT_Unsigned_Integer16 width_scale,
00146         WT_Unsigned_Integer16 spacing,
00150         WT_Unsigned_Integer16 oblique,
00151         WT_Integer32          flags = 0 
00152         );
00153 
00155         WT_Font(WT_Font const& font)
00156         : m_name_length (0) // Obsolete, but needed to read older files
00157         , m_rotation_checked(WD_False)
00158         , m_stage (Getting_Name_Length)
00159         , m_fields_defined(FONT_NO_FIELDS)
00160         {
00161                 *this = font;
00162         }
00163 
00164         virtual ~WT_Font()
00165         {}
00167 public:
00172     WT_Font_Option_Charset const & charset() const         { return m_option_charset; }
00173     WT_Font_Option_Family const & family() const           { return m_option_family; }
00174     WT_Font_Option_Flags const & flags() const             { return m_option_flags; }
00175     WT_Font_Option_Font_Name const & font_name() const     { return m_option_font_name; }
00176     WT_Font_Option_Height const & height() const           { return m_option_height; }
00177     WT_Font_Option_Oblique const & oblique() const         { return m_option_oblique; }
00178     WT_Font_Option_Pitch const & pitch() const             { return m_option_pitch; }
00179     WT_Font_Option_Rotation const & rotation() const       { return m_option_rotation; }
00180     WT_Font_Option_Spacing const & spacing() const         { return m_option_spacing; }
00181     WT_Font_Option_Style const & style() const             { return m_option_style; }
00182     WT_Font_Option_Width_Scale const & width_scale() const { return m_option_width_scale;}
00184 
00189     WT_Font_Option_Charset & charset()         { m_fields_defined |= FONT_CHARSET_BIT; return m_option_charset; }
00190     WT_Font_Option_Family & family()           { m_fields_defined |= FONT_FAMILY_BIT; return m_option_family; }
00191     WT_Font_Option_Flags & flags()             { m_fields_defined |= FONT_FLAGS_BIT; return m_option_flags; }
00192     WT_Font_Option_Font_Name & font_name()     { m_fields_defined |= FONT_NAME_BIT; return m_option_font_name; }
00193     WT_Font_Option_Height & height()           { m_fields_defined |= FONT_HEIGHT_BIT; return m_option_height; }
00194     WT_Font_Option_Oblique & oblique()         { m_fields_defined |= FONT_OBLIQUE_BIT; return m_option_oblique; }
00195     WT_Font_Option_Pitch & pitch()             { m_fields_defined |= FONT_PITCH_BIT; return m_option_pitch; }
00196     WT_Font_Option_Rotation & rotation()       { m_fields_defined |= FONT_ROTATION_BIT; return m_option_rotation; }
00197     WT_Font_Option_Spacing & spacing()         { m_fields_defined |= FONT_SPACING_BIT; return m_option_spacing; }
00198     WT_Font_Option_Style & style()             { m_fields_defined |= FONT_STYLE_BIT; return m_option_style; }
00199     WT_Font_Option_Width_Scale & width_scale() { m_fields_defined |= FONT_WIDTH_SCALE_BIT; return m_option_width_scale;}
00201 
00203 
00204     WT_Unsigned_Integer16              fields_defined() const                           {   return m_fields_defined;    }
00206     void                               set_fields_defined(WT_Unsigned_Integer16 fields) {   m_fields_defined = fields;  }
00208     WT_Font const & operator=  (WT_Font const & font);
00210 
00212     WT_ID            object_id() const;
00213     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00214     WT_Result        process(WT_File & file);
00215     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00216     WT_Result        serialize (WT_File & file) const;
00217     WT_Result        sync (WT_File & file) const;
00218     WT_Boolean       operator== (WT_Attribute const & attrib) const;
00219     WT_Boolean       operator!= (WT_Attribute const & attrib) const;
00221 
00223 
00225     static WT_Result default_process(
00226         WT_Font & item, 
00227         WT_File & file 
00228         );
00229 };
00230 
00232 
00233 #endif // FONT_HEADER

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