00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TEXTELEMENT_H
00024 #define TEXTELEMENT_H
00025
00026 #include <QFont>
00027 #include <QString>
00028
00029 #include "BasicElement.h"
00030
00031 class SymbolTable;
00032
00033
00034 namespace KFormula {
00035
00039 class TextElement : public BasicElement {
00040 public:
00042 TextElement( BasicElement* parent = 0 );
00043
00048 const QList<BasicElement*> childElements();
00049
00050 void readMathML( const QDomElement& element );
00051
00052 void writeMathML( KoXmlWriter* writer, bool oasisFormat = false );
00053
00054
00055
00060 virtual TokenType getTokenType() const;
00061
00065 virtual bool isInvisible() const;
00066
00071 virtual QChar getCharacter() const { return character; }
00072
00077 virtual void calcSizes(const ContextStyle& context,
00078 ContextStyle::TextStyle tstyle,
00079 ContextStyle::IndexStyle istyle
00080 StyleAttributes& style );
00081
00087 virtual void draw( QPainter& painter, const LuPixelRect& r,
00088 const ContextStyle& context,
00089 ContextStyle::TextStyle tstyle,
00090 ContextStyle::IndexStyle istyle,
00091 StyleAttributes& style,
00092 const LuPixelPoint& parentOrigin );
00093
00097 virtual void dispatchFontCommand( FontCommand* cmd );
00098
00099 CharStyle getCharStyle() const { return charStyle(); }
00100 void setCharStyle( CharStyle cs );
00101
00102 CharFamily getCharFamily() const { return charFamily(); }
00103 void setCharFamily( CharFamily cf );
00104
00105 char format() const { return m_format; }
00106
00110 bool isSymbol() const { return symbol; }
00111
00112 protected:
00113
00114
00118 virtual QString getTagName() const { return "TEXT"; }
00119
00123 virtual void writeDom(QDomElement element);
00124
00129 virtual bool readAttributesFromDom(QDomElement element);
00130
00136 virtual bool readContentFromDom(QDomNode& node);
00137
00141 QChar getRealCharacter(const ContextStyle& context);
00142
00146 QFont getFont(const ContextStyle& context, const StyleAttributes& style);
00147
00151 void setUpPainter(const ContextStyle& context, QPainter& painter);
00152
00153 const SymbolTable& getSymbolTable() const;
00154
00155 private:
00156
00160 QChar character;
00161
00165 bool symbol;
00166
00172 CharStyle charStyle() const { return static_cast<CharStyle>( m_format & 0x0f ); }
00173 void charStyle( CharStyle cs )
00174 { m_format = ( m_format & 0xf0 ) | static_cast<char>( cs ); }
00175
00181 CharFamily charFamily() const
00182 { return static_cast<CharFamily>( m_format >> 4 ); }
00183 void charFamily( CharFamily cf )
00184 { m_format = ( m_format & 0x0f ) | ( static_cast<char>( cf ) << 4 ); }
00185
00190 char m_format;
00191 };
00192
00193 }
00194
00195 #endif // TEXTELEMENT_H