font_options.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_OPTIONS_HEADER
00020 #define FONT_OPTIONS_HEADER
00021 
00025 
00026 #include "whiptk/whipcore.h"
00027 #include "whiptk/attribute.h"
00028 #include "whiptk/opcode.h"
00029 
00030 static const int DEFAULT_CHAR_SPACING   =       1024;
00031 static const int DEFAULT_WIDTH_SCALE    =       1024;
00032 
00042 // ====================================================================================
00044 class WHIPTK_API WT_Font_Option_Font_Name : public WT_Option
00045 {
00046         friend class WT_Font;
00047         friend class WT_W2D_Class_Factory;
00048 
00049 private:
00050     WT_String     m_font_name;
00051 
00052 public:
00053 
00055 
00056     WT_Font_Option_Font_Name()
00057         : m_font_name ("Arial") // Shouldn't use hard coded constants like this.
00058     { }
00059 
00061     WT_Font_Option_Font_Name(WT_String const &name)
00062         : m_font_name (name)
00063     { }
00064         virtual ~WT_Font_Option_Font_Name()
00065         {}
00067 public:
00069 
00070     virtual WT_String const &   name() const                                            {   return m_font_name;   }
00072     virtual void                set(WT_String const & name)                             {   m_font_name = name;   }
00074     virtual WT_Boolean          operator==(WT_Font_Option_Font_Name const & nm) const   {   return (m_font_name == nm.m_font_name); }
00076     virtual WT_Boolean          operator!=(WT_Font_Option_Font_Name const & nm) const   {   return (m_font_name != nm.m_font_name); }
00078     virtual operator WT_String const & () const                     {   return m_font_name;     }
00080 
00082     virtual WT_ID            object_id() const;
00083     virtual WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00084     virtual WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00086 
00087 };
00088 
00089 // ====================================================================================
00091 
00098 class WHIPTK_API WT_Font_Option_Charset : public WT_Option
00099 {
00100         friend class WT_Font;
00101         friend class WT_W2D_Class_Factory;
00102 
00103 private:
00104     WT_Byte     m_charset;
00105 
00106 public:
00107 
00109     enum Font_Charset_Code
00110     {
00111          CHARSET_ANSI           = 0x00  // 0
00112         ,CHARSET_DEFAULT        = 0x01  // 1
00113         ,CHARSET_SYMBOL         = 0x02  // 2
00114         ,CHARSET_MAC            = 0x4D  // 77
00115         ,CHARSET_UNICODE        = 0x57  // 87
00116         ,CHARSET_SHIFTJIS       = 0X80  // 128
00117         ,CHARSET_HANGEUL        = 0X81  // 129
00118         ,CHARSET_JOHAB          = 0X82  // 130
00119         ,CHARSET_GB2312         = 0X86  // 134
00120         ,CHARSET_CHINESEBIG5    = 0X88  // 136
00121         ,CHARSET_GREEK          = 0XA1  // 161
00122         ,CHARSET_TURKISH        = 0XA2  // 162
00123         ,CHARSET_VIETNAMESE     = 0XA3  // 163
00124         ,CHARSET_HEBREW         = 0XB1  // 177
00125         ,CHARSET_ARABIC         = 0XB2  // 178
00126         ,CHARSET_BALTIC         = 0XBA  // 186
00127         ,CHARSET_RUSSIAN        = 0XCC  // 204
00128         ,CHARSET_THAI           = 0XDE  // 222
00129         ,CHARSET_EASTEUROPE     = 0XEE  // 238
00130         ,CHARSET_OEM            = 0XFF  // 255
00131     };
00132 public:
00134 
00135     WT_Font_Option_Charset()
00136         : m_charset (CHARSET_DEFAULT)
00137     { }
00138 
00140     WT_Font_Option_Charset(WT_Byte charset)
00141         : m_charset (charset)
00142     { }
00143         virtual ~WT_Font_Option_Charset()
00144         {}
00146 public:
00148 
00149     WT_Byte     charset() const                                     {   return m_charset;   }
00151     void        set(WT_Byte cs)                                     {   m_charset = cs;     }
00153     WT_Boolean  operator==(WT_Font_Option_Charset const & cs) const {   return (m_charset == cs.m_charset); }
00155     WT_Boolean  operator!=(WT_Font_Option_Charset const & cs) const {   return (m_charset != cs.m_charset); }
00157 
00159     WT_ID            object_id() const;
00160     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00161     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00163 };
00164 
00165 // ====================================================================================
00167 
00171 class WHIPTK_API WT_Font_Option_Pitch : public WT_Option
00172 {
00173         friend class WT_Font;
00174         friend class WT_W2D_Class_Factory;
00175 
00176 private:
00177     WT_Byte            m_pitch;
00178 
00179 public:
00180 
00182     enum Font_Pitch_Flags
00183     {
00184      PITCH_DEFAULT     = 0x00 
00185     ,PITCH_FIXED       = 0x01 
00186     ,PITCH_VARIABLE    = 0x02 
00187     ,PITCH_BITS        = ( PITCH_DEFAULT | PITCH_FIXED | PITCH_VARIABLE )
00188     };
00189 public:
00191 
00192     WT_Font_Option_Pitch()
00193         : m_pitch (PITCH_VARIABLE)
00194     { }
00195 
00197     WT_Font_Option_Pitch(
00198         WT_Byte pitch 
00199         )
00200         : m_pitch (pitch)
00201     { }
00202         virtual ~WT_Font_Option_Pitch()
00203         {}
00205 public:
00207 
00208     WT_Byte     pitch() const                                       {   return m_pitch;                     }
00210     void        set(WT_Byte pitch)                                  {   m_pitch = pitch;                    }
00212     WT_Boolean  operator==(WT_Font_Option_Pitch const & pt) const   {   return (m_pitch == pt.m_pitch);     }
00214     WT_Boolean  operator!=(WT_Font_Option_Pitch const & pt) const   {   return (m_pitch != pt.m_pitch);     }
00216 
00218     WT_ID            object_id() const;
00219     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00220     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00222 };
00223 
00224 
00225 // ====================================================================================
00227 class WHIPTK_API WT_Font_Option_Family : public WT_Option
00228 {
00229         friend class WT_Font;
00230         friend class WT_W2D_Class_Factory;
00231 
00232 private:
00233     WT_Byte            m_family;
00234 
00235 public:
00236 
00238     enum Font_Family_Flags
00239     {
00240          FAMILY_UNKNOWN    = 0x00
00241         ,FAMILY_ROMAN      = 0x10
00242         ,FAMILY_SWISS      = 0x20
00243         ,FAMILY_MODERN     = 0x30
00244         ,FAMILY_SCRIPT     = 0x40
00245         ,FAMILY_DECORATIVE = 0x50
00246         ,FAMILY_BITS       = (FAMILY_UNKNOWN | FAMILY_ROMAN | FAMILY_SWISS | FAMILY_MODERN | FAMILY_SCRIPT | FAMILY_DECORATIVE)
00247     };
00248 public:
00250 
00251     WT_Font_Option_Family()
00252         : m_family (FAMILY_ROMAN)
00253     { }
00254 
00256     WT_Font_Option_Family(
00257         WT_Byte family 
00258         )
00259         : m_family(family)
00260     { }
00261         virtual ~WT_Font_Option_Family()
00262         {}
00264 public:
00266 
00267     WT_Byte     family() const                                      {   return m_family;                    }
00269     void        set(
00270         WT_Byte family 
00271         )                                 {   m_family = family;                  }
00273     WT_Boolean  operator==(WT_Font_Option_Family const & fm) const  {   return (m_family == fm.m_family);   }
00275     WT_Boolean  operator!=(WT_Font_Option_Family const & fm) const  {   return (m_family != fm.m_family);   }
00277 
00279     WT_ID            object_id() const;
00280     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00281     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00283 };
00284 
00285 
00286 // ====================================================================================
00288 class WHIPTK_API WT_Font_Option_Style : public WT_Option
00289 {
00290         friend class WT_Font;
00291         friend class WT_W2D_Class_Factory;
00292 
00293 private:
00294     WT_Boolean          m_bold;
00295     WT_Boolean          m_italic;
00296     WT_Boolean          m_underlined;
00297 
00298     enum
00299     {
00300         Starting = 1000,
00301         Getting_Next_Optioncode = 1001,
00302         Skipping_Optioncode = 1002
00303     };
00304 
00305     WT_Opcode       m_optioncode;
00306 
00307 public:
00308 
00310 
00311     WT_Font_Option_Style(
00312         WT_Boolean bold = WD_False,
00313         WT_Boolean italic = WD_False,
00314         WT_Boolean underlined = WD_False
00315         )
00316         : m_bold(bold)
00317         , m_italic(italic)
00318         , m_underlined(underlined)
00319     {
00320         m_stage = Starting;
00321     }
00322         virtual ~WT_Font_Option_Style()
00323         {}
00325 public:
00327 
00328     WT_Boolean      bold() const                                         {   return m_bold;       }
00330     WT_Boolean      italic() const                                       {   return m_italic;     }
00332     WT_Boolean      underlined() const                                   {   return m_underlined; }
00334     void            set_bold(WT_Boolean bold)                            {   m_bold = bold;       }
00336     void            set_italic(WT_Boolean italic)                        {   m_italic = italic;   }
00338     void            set_underlined(WT_Boolean underlined)                {   m_underlined = underlined;  }
00340     WT_Boolean      operator==(WT_Font_Option_Style  const & in) const
00341     {
00342         return (m_bold       == in.m_bold
00343              && m_italic     == in.m_italic
00344              && m_underlined == in.m_underlined);
00345     }
00347     WT_Boolean      operator!=(WT_Font_Option_Style  const & in) const
00348     {
00349         return (m_bold      != in.m_bold
00350              || m_italic    != in.m_italic
00351              || m_underlined != in.m_underlined);
00352     }
00354 
00356     WT_ID            object_id() const;
00357     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00358     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00360 };
00361 
00362 
00363 // ====================================================================================
00365 class WHIPTK_API WT_Font_Option_Height : public WT_Option
00366 {
00367         friend class WT_Font;
00368         friend class WT_W2D_Class_Factory;
00369 
00370 private:
00371     WT_Integer32        m_height;
00372 
00373 public:
00375 
00376     WT_Font_Option_Height()
00377         : m_height (1000) // Pull a rabbit out of a hat! Shouldn't hard code data like this.
00378     { }
00380     WT_Font_Option_Height(WT_Integer32 height)
00381         : m_height(height)
00382     { }
00383         virtual ~WT_Font_Option_Height()
00384         {}
00386 public:
00388 
00389     WT_Integer32    height() const                                      {   return m_height;     }
00391     void            set(WT_Integer32 height)                            {   m_height = height;   }
00393     WT_Boolean      operator==(WT_Font_Option_Height const & in) const  {   return (m_height == in.m_height);   }
00395     WT_Boolean      operator!=(WT_Font_Option_Height const & in) const  {   return (m_height != in.m_height);   }
00397     operator WT_Integer32() const                       {   return m_height;     }
00399 
00401     WT_ID            object_id() const;
00402     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00403     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00405 };
00406 
00407 
00408 // ====================================================================================
00410 class WHIPTK_API WT_Font_Option_Rotation : public WT_Option
00411 {
00412         friend class WT_Font;
00413         friend class WT_W2D_Class_Factory;
00414 
00415 private:
00416     WT_Unsigned_Integer16        m_rotation;
00417 
00418 public:
00420 
00421     WT_Font_Option_Rotation()
00422         : m_rotation (0)
00423     { }
00425     WT_Font_Option_Rotation(
00426         WT_Unsigned_Integer16 rotation 
00427         )
00428         : m_rotation(rotation)
00429     { }
00430         virtual ~WT_Font_Option_Rotation()
00431         {}
00433 public:
00435 
00436     WT_Unsigned_Integer16   rotation() const                                        {   return m_rotation;     }
00438     void                    set(WT_Unsigned_Integer16 rotation)                     {   m_rotation = rotation; }
00440     WT_Boolean              operator==(WT_Font_Option_Rotation const & in) const    {   return (m_rotation == in.m_rotation);   }
00442     WT_Boolean              operator!=(WT_Font_Option_Rotation const & in) const    {   return (m_rotation != in.m_rotation);   }
00444     operator WT_Unsigned_Integer16() const                  {   return m_rotation;     }
00446 
00448     WT_ID            object_id() const;
00449     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00450     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00452 
00453 };
00454 
00455 
00456 // ====================================================================================
00458 
00463 class WHIPTK_API WT_Font_Option_Width_Scale : public WT_Option
00464 {
00465         friend class WT_Font;
00466         friend class WT_W2D_Class_Factory;
00467 
00468 private:
00469     WT_Unsigned_Integer16        m_width_scale;
00470 
00471 public:
00473 
00474     WT_Font_Option_Width_Scale()
00475         : m_width_scale (DEFAULT_WIDTH_SCALE)
00476     { }
00478     WT_Font_Option_Width_Scale( WT_Unsigned_Integer16 width_scale)
00479         : m_width_scale(width_scale)
00480     { }
00481         virtual ~WT_Font_Option_Width_Scale()
00482         {}
00484 public:
00486 
00487     WT_Unsigned_Integer16   width_scale() const                     {   return m_width_scale;        }
00489     void                    set(WT_Unsigned_Integer16 width_scale)  {   m_width_scale = width_scale; }
00491     WT_Boolean              operator==(WT_Font_Option_Width_Scale const & in) const  {   return (m_width_scale == in.m_width_scale);   }
00493     WT_Boolean              operator!=(WT_Font_Option_Width_Scale const & in) const  {   return (m_width_scale != in.m_width_scale);   }
00495     operator WT_Unsigned_Integer16() const                   {   return m_width_scale;     }
00497 
00499     WT_ID            object_id() const;
00500     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00501     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00503 
00504 };
00505 
00506 
00507 // ====================================================================================
00509 
00515 class WHIPTK_API WT_Font_Option_Spacing : public WT_Option
00516 {
00517         friend class WT_Font;
00518         friend class WT_W2D_Class_Factory;
00519 
00520 private:
00521     WT_Unsigned_Integer16        m_spacing;
00522 
00523 public:
00525 
00526     WT_Font_Option_Spacing()
00527                 : m_spacing (DEFAULT_CHAR_SPACING)
00528     { }
00530     WT_Font_Option_Spacing(WT_Unsigned_Integer16 spacing)
00531         : m_spacing(spacing)
00532     { }
00533         virtual ~WT_Font_Option_Spacing()
00534         {}
00536 public:
00538 
00539     WT_Unsigned_Integer16   spacing() const                                      {   return m_spacing;        }
00541     void                    set(WT_Unsigned_Integer16 spacing)                   {   m_spacing = spacing;     }
00543     WT_Boolean              operator==(WT_Font_Option_Spacing const & in) const  {   return (m_spacing == in.m_spacing);   }
00545     WT_Boolean              operator!=(WT_Font_Option_Spacing const & in) const  {   return (m_spacing != in.m_spacing);   }
00547     operator WT_Unsigned_Integer16() const               {   return m_spacing;     }
00549 
00551     WT_ID            object_id() const;
00552     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00553     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00555 
00556 };
00557 
00558 // ====================================================================================
00560 class WHIPTK_API WT_Font_Option_Oblique : public WT_Option
00561 {
00562         friend class WT_Font;
00563         friend class WT_W2D_Class_Factory;
00564 
00565 private:
00566     WT_Unsigned_Integer16        m_oblique;
00567 
00568 public:
00570 
00571     WT_Font_Option_Oblique()
00572         : m_oblique (0)
00573     { }
00575     WT_Font_Option_Oblique(
00576         WT_Unsigned_Integer16 oblique 
00577         )
00578         : m_oblique(oblique)
00579     { }
00580         virtual ~WT_Font_Option_Oblique()
00581         {}
00583 public:
00585 
00586     WT_Unsigned_Integer16   oblique() const                                      {   return m_oblique;        }
00588     void                    set(WT_Unsigned_Integer16 oblique)                   {   m_oblique = oblique;     }
00590     WT_Boolean              operator==(WT_Font_Option_Oblique const & in) const  {   return (m_oblique == in.m_oblique);   }
00592     WT_Boolean              operator!=(WT_Font_Option_Oblique const & in) const  {   return (m_oblique != in.m_oblique);   }
00594     operator WT_Unsigned_Integer16() const               {   return m_oblique;     }
00595 
00597 
00599     WT_ID            object_id() const;
00600     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00601     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00603 
00604 };
00605 
00606 
00607 // ====================================================================================
00609 class WHIPTK_API WT_Font_Option_Flags : public WT_Option
00610 {
00611         friend class WT_Font;
00612         friend class WT_W2D_Class_Factory;
00613 
00614 private:
00615     WT_Integer32        m_flags;
00616 
00617 public:
00619 
00620     WT_Font_Option_Flags()
00621         : m_flags (0)
00622     { }
00624     WT_Font_Option_Flags(WT_Integer32 flags)
00625         : m_flags(flags)
00626     { }
00627         virtual ~WT_Font_Option_Flags()
00628         {}
00630 public:
00632 
00633     WT_Integer32    flags() const                                       {   return m_flags;     }
00635     void            set(WT_Integer32 flags)                             {   m_flags = flags;    }
00637     WT_Boolean      operator==(WT_Font_Option_Flags const & in) const   {   return (m_flags == in.m_flags);   }
00639     WT_Boolean      operator!=(WT_Font_Option_Flags const & in) const   {   return (m_flags != in.m_flags);   }
00641     operator WT_Integer32() const                       {   return m_flags;     }
00643 
00645     WT_ID            object_id() const;
00646     WT_Result        serialize  (WT_Object const & parent, WT_File & file) const;
00647     WT_Result        materialize(WT_Object       & parent, WT_Optioncode const & optioncode, WT_File & file);
00649 
00650 };
00651 
00652 
00653 // ====================================================================================
00654 
00656 class WHIPTK_API WT_Font_Optioncode : public WT_Optioncode
00657 {
00658 public:
00659 
00661     enum
00662     {
00663         Unknown_Option  = 0,
00664         Font_Name_Option,
00665         Charset_Option,
00666         Pitch_Option,
00667         Family_Option,
00668         Style_Option,
00669         Height_Option,
00670         Rotation_Option,
00671         Width_Scale_Option,
00672         Spacing_Option,
00673         Oblique_Option,
00674         Flags_Option
00675     };
00676 
00678     virtual int option_id_from_optioncode();
00679 };
00680 
00682 
00683 #endif // FONT_OPTIONS_HEADER

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