XamlText.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 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 XAML_TEXT_HEADER
00020 #define XAML_TEXT_HEADER
00021 
00025 
00026 #include "XAML/XamlCore.h"
00027 
00028 #include "whiptk/text.h"
00029 #include "XAML/XamlXML.h"
00030 
00031 
00036 class XAMLTK_API WT_XAML_Text 
00037     : public WT_Text
00038     , public XamlDrawableAttributes::OriginX::Provider
00039     , public XamlDrawableAttributes::OriginY::Provider
00040     , public XamlDrawableAttributes::RenderTransform::Provider
00041     , public XamlDrawableAttributes::Indices::Provider
00042     , public XamlDrawableAttributes::UnicodeString::Provider
00043     , public XamlDrawableAttributes::GlyphsAttributeProvider
00044 {
00045         friend class WT_XAML_Class_Factory;
00046 
00047 public:
00048     enum teGhostPosition
00049     {
00050         Undefined,
00051         None,
00052         Left,
00053         Top,
00054         Right,
00055         Bottom
00056     };
00057 
00058 protected:
00060     WT_XAML_Text()
00061                 : WT_Text()
00062         , _fOriginX(0.0)
00063         , _fOriginY(0.0)
00064         , _fWidth(0.0)
00065         , _fHeight(0.0)
00066         , _fBase(0.0)
00067         , _fAscent(0.0)
00068         , _bIsRelativized(false)
00069         , _pSerializeFile(NULL)
00070         , _bHaveFontMetrics(false)
00071         , _eGhostPosition(None)
00072         {}
00073 
00075     WT_XAML_Text (WT_XAML_Text const & text)
00076                 : WT_Text(static_cast<WT_Text const &>(text))
00077         , _fOriginX(0.0)
00078         , _fOriginY(0.0)
00079         , _fWidth(0.0)
00080         , _fHeight(0.0)
00081         , _fBase(0.0)
00082         , _fAscent(0.0)
00083         , _bIsRelativized(false)
00084         , _pSerializeFile(NULL)
00085         , _bHaveFontMetrics(false)
00086         , _eGhostPosition(None)
00087         {}   
00088 
00089 
00091     WT_XAML_Text(
00092         WT_Logical_Point const &        position, 
00093         WT_String const &               string, 
00094         WT_Logical_Point const *        bbox, 
00095         WT_Unsigned_Integer16           overscore_count, 
00096         WT_Unsigned_Integer16 const *   overscore_pos, 
00097         WT_Unsigned_Integer16           underscore_count, 
00098         WT_Unsigned_Integer16 const *   underscore_pos 
00099         )
00100                 : WT_Text(position,string,bbox,overscore_count,overscore_pos,underscore_count,underscore_pos)
00101         , _fOriginX(0.0)
00102         , _fOriginY(0.0)
00103         , _fWidth(0.0)
00104         , _fHeight(0.0)
00105         , _fBase(0.0)
00106         , _fAscent(0.0)
00107         , _bIsRelativized(false)
00108         , _pSerializeFile(NULL)
00109         , _bHaveFontMetrics(false)
00110         , _eGhostPosition(None)
00111         {}
00112 
00114     WT_XAML_Text(
00115         WT_Logical_Point const &        position, 
00116         WT_String const &               string 
00117         )
00118                 : WT_Text(position,string)
00119         , _fOriginX(0.0)
00120         , _fOriginY(0.0)
00121         , _fWidth(0.0)
00122         , _fHeight(0.0)
00123         , _fBase(0.0)
00124         , _fAscent(0.0)
00125         , _bIsRelativized(false)
00126         , _pSerializeFile(NULL)
00127         , _bHaveFontMetrics(false)
00128         , _eGhostPosition(None)
00129         {}
00130 
00132     virtual ~WT_XAML_Text()
00133         {}
00134 
00135 public:
00137     WT_XAML_Text & operator= (WT_Text const & other)
00138         {
00139         _fOriginX = 0.0;
00140         _fOriginY = 0.0;
00141         _fWidth = 0.0;
00142         _fHeight = 0.0;
00143         _fBase = 0.0;
00144         _fAscent = 0.0;
00145         _bIsRelativized = false;
00146         _pSerializeFile = NULL;
00147         _bHaveFontMetrics = false;
00148         _eGhostPosition = None;
00149                 WT_Text::operator= (other);
00150                 return *this;
00151     }
00152     
00154     WT_XAML_Text & operator= (WT_XAML_Text const & other)
00155         {
00156         _fOriginX = other._fOriginX;
00157         _fOriginY = other._fOriginY;
00158         _fWidth = other._fWidth;
00159         _fHeight = other._fHeight;
00160         _fBase = other._fBase;
00161         _fAscent = other._fAscent;
00162         _bIsRelativized = other._bIsRelativized;
00163         _pSerializeFile = other._pSerializeFile;
00164         _bHaveFontMetrics = other._bHaveFontMetrics;
00165         _eGhostPosition = other._eGhostPosition;
00166                 WT_Text::operator= (other);
00167                 return *this;
00168         }
00169 
00171     virtual WT_Result  serialize(WT_File & /*file*/) const;
00173         WT_Result                parseAttributeList(XamlXML::tAttributeMap& rMap, WT_XAML_File& rFile);
00175 
00176     const teGhostPosition& ghostPosition() const { return _eGhostPosition; }
00177           teGhostPosition& ghostPosition()       { return _eGhostPosition; }
00178 
00179 protected:
00180     virtual WT_Result provideOriginX( XamlDrawableAttributes::OriginX *& rpOriginX );
00181     virtual WT_Result provideOriginY( XamlDrawableAttributes::OriginY *& rpOriginY );
00182     virtual WT_Result provideIndices( XamlDrawableAttributes::Indices *& rpIndices  );
00183     virtual WT_Result provideUnicodeString( XamlDrawableAttributes::UnicodeString *& rpUnicodeString );
00184     virtual WT_Result provideRenderTransform( XamlDrawableAttributes::RenderTransform *& rpRenderTransform );
00185     virtual WT_Result provideGlyphsAttributes( XamlDrawableAttributes::GlyphsAttributeConsumer* p, WT_XAML_File& r) const;
00186     virtual WT_Result relativizePosition(void);
00187 
00188 
00189 private:
00190     WT_Result _getFontMetrics( const WT_XAML_File &rFile ) const;
00191     bool _needCanvasWrapper( WT_XAML_File &rFile ) const;
00192 
00193 private:
00194     float _fOriginX, _fOriginY;
00195     double _fWidth, _fHeight, _fBase, _fAscent;
00196     bool _bIsRelativized;
00197     WT_XAML_File *_pSerializeFile;
00198     bool _bHaveFontMetrics;
00199     teGhostPosition _eGhostPosition;
00200 };
00202 
00203 #endif //XAML_TEXT_HEADER

Generated on Tue Jan 6 22:40:06 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5