00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __BASETEXT_H__
00020 #define __BASETEXT_H__
00021
00022 #include <string>
00023
00024 #include <vrs/text/vrs_textprerequisites.h>
00025 #include <vrs/text/fontdefinition.h>
00026 #include <vrs/text/abstracttext.h>
00027
00029 namespace VRS
00030 {
00031 namespace TEXT
00032 {
00033 typedef std::vector< std::pair< float, float > > GlyphPositions;
00034
00041 class VRS_CORE_API BaseText : public AbstractText
00042 {
00043 public:
00044 #ifdef VRS_HAS_WSTRING // Has Unicode support
00045 BaseText( SO<FontDefinition> fd, const std::wstring& text);
00046 #endif
00047 BaseText( SO<FontDefinition> fd, const std::string& text);
00048
00049
00050 BaseText( SO<FontDefinition> fd, BaseText* bt );
00051
00052 virtual ~BaseText();
00053
00054
00055
00056 #ifdef VRS_HAS_WSTRING // Has Unicode support
00057
00058 virtual const std::wstring& getText() const;
00060 virtual void setText(const std::wstring& str);
00062 virtual const std::wstring& getCachedText() const;
00063 #else // Has no Unicode support
00064
00065 virtual const std::string& getText() const;
00067 virtual const std::string& getCachedText() const;
00068 #endif
00070 virtual void setText(const std::string& str);
00071
00072
00073
00074
00075
00077 virtual SO<FontDefinition> getFontDefinition( ) const;
00079 virtual void setFontDefinition( SO<FontDefinition> );
00080
00081
00082
00086 virtual AbstractText::HorizontalAlignment getHorizontalAlignment() const;
00090 virtual void setHorizontalAlignment(AbstractText::HorizontalAlignment tva);
00094 virtual AbstractText::VerticalAlignment getVerticalAlignment() const;
00098 virtual void setVerticalAlignment(AbstractText::VerticalAlignment tva);
00102 virtual AbstractText::HorizontalDirection getHorizontalDirection() const;
00106 virtual void setHorizontalDirection(AbstractText::HorizontalDirection thd);
00110 virtual AbstractText::VerticalDirection getVerticalDirection() const;
00114 virtual void setVerticalDirection(AbstractText::VerticalDirection thd);
00118 virtual AbstractText::Direction getDirection() const;
00122 virtual void setDirection(AbstractText::Direction td);
00123
00135 virtual void setAlignmentBounds( float rightBorder, float bottomBorder );
00139 virtual void setRightAlignmentBound(float rightBorder);
00143 virtual void setBottomAlignmentBound(float bottomBorder);
00147 virtual float getRightAlignmentBound() const;
00151 virtual float getBottomAlignmentBound() const;
00152
00153
00154
00155
00159 virtual float getLineSpacing() const;
00163 virtual void setLineSpacing(float LineSpacing);
00164
00165
00166
00167
00169 virtual void setColor( const Color& color, bool use = true );
00171 virtual Color getColor() const;
00173 virtual bool useColor() const;
00174
00175
00176
00178 virtual Matrix getMatrix() const;
00180 virtual void setMatrix( const Matrix& m );
00186 virtual void setMatrix( AbstractText::TextPlane tp,
00187 const Vector& offset=Vector(0,0,0), const Vector& scale=Vector(1,1,1) )
00188 {
00189 setMatrix( AbstractText::buildMatrix(tp,offset,scale) );
00190 };
00191
00192
00194 virtual Bounds boundingBox() const;
00196 virtual Bounds getLocalBounds() const;
00197
00199 const GlyphPositions getCachedGlyphPositions() const;
00200
00202 bool isDirty() const;
00203
00205 virtual void rebuildAllCaches();
00207 virtual void rebuildTextCache();
00209 virtual void rebuildGlyphCache();
00210
00211 VRS_TYPEINFO(BaseText, Shape);
00212 VRS_SERIALIZABLE(BaseText);
00213 protected:
00215 BaseText( );
00224 virtual void computeLineLengthAndWidth( std::vector<float> *lineWidths,
00225 float *totalWidth, float* totalHeight ) const;
00226
00228 SO<FontDefinition> m_FontDefinition;
00229
00230 #ifdef VRS_HAS_WSTRING // Has Unicode support
00231
00232 std::wstring m_Text;
00233 std::wstring m_CachedText;
00234 #else // Has no Unicode support
00235
00236 std::string m_Text;
00237 std::string m_CachedText;
00238 #endif
00240 float m_LineSpacing;
00242 float m_RightBorder;
00244 float m_BottomBorder;
00245
00247 Color m_Color;
00249 bool m_UseColor;
00250
00252 AbstractText::HorizontalAlignment m_HorizontalAlignment;
00254 AbstractText::VerticalAlignment m_VerticalAlignment;
00256 AbstractText::HorizontalDirection m_HorizontalDirection;
00258 AbstractText::VerticalDirection m_VerticalDirection;
00260 AbstractText::Direction m_Direction;
00261
00263 Matrix m_Matrix;
00264
00266 Bounds m_CachedBounds;
00268 GlyphPositions m_CachedGlyphPositions;
00269
00271 bool m_IsDirty;
00272 private:
00274 void initializeDefaults();
00275
00276 };
00277 }
00278 }
00279
00280 #endif