lib
textelement.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef TEXTELEMENT_H
00022 #define TEXTELEMENT_H
00023
00024 #include <qfont.h>
00025 #include <qstring.h>
00026
00027 #include "basicelement.h"
00028
00029 class SymbolTable;
00030
00031
00032 KFORMULA_NAMESPACE_BEGIN
00033
00037 class TextElement : public BasicElement {
00038 TextElement operator=( const TextElement& ) { return *this; }
00039 public:
00040
00041 TextElement(QChar ch = ' ', bool beSymbol = false, BasicElement* parent = 0);
00042 TextElement( const TextElement& );
00043
00044 virtual TextElement* clone() {
00045 return new TextElement( *this );
00046 }
00047
00048 virtual bool accept( ElementVisitor* visitor );
00049
00054 virtual TokenType getTokenType() const;
00055
00059 virtual bool isInvisible() const;
00060
00065 virtual QChar getCharacter() const { return character; }
00066
00067
00068
00069
00070
00071
00072
00073
00078 virtual void calcSizes(const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00079
00085 virtual void draw( QPainter& painter, const LuPixelRect& r,
00086 const ContextStyle& context,
00087 ContextStyle::TextStyle tstyle,
00088 ContextStyle::IndexStyle istyle,
00089 const LuPixelPoint& parentOrigin );
00090
00094 virtual void dispatchFontCommand( FontCommand* cmd );
00095
00096 CharStyle getCharStyle() const { return charStyle(); }
00097 void setCharStyle( CharStyle cs );
00098
00099 CharFamily getCharFamily() const { return charFamily(); }
00100 void setCharFamily( CharFamily cf );
00101
00102 char format() const { return m_format; }
00103
00108
00109
00113 bool isSymbol() const { return symbol; }
00114
00119 virtual QString toLatex();
00120
00121 virtual QString formulaString();
00122
00123 protected:
00124
00125
00126
00130 virtual QString getTagName() const { return "TEXT"; }
00131
00135 virtual void writeDom(QDomElement element);
00136
00141 virtual bool readAttributesFromDom(QDomElement element);
00142
00148 virtual bool readContentFromDom(QDomNode& node);
00149
00153 QChar getRealCharacter(const ContextStyle& context);
00154
00158 QFont getFont(const ContextStyle& context);
00159
00163 void setUpPainter(const ContextStyle& context, QPainter& painter);
00164
00165 const SymbolTable& getSymbolTable() const;
00166
00167 private:
00168
00172 QChar character;
00173
00177 bool symbol;
00178
00184 CharStyle charStyle() const { return static_cast<CharStyle>( m_format & 0x0f ); }
00185 void charStyle( CharStyle cs )
00186 { m_format = ( m_format & 0xf0 ) | static_cast<char>( cs ); }
00187
00193 CharFamily charFamily() const
00194 { return static_cast<CharFamily>( m_format >> 4 ); }
00195 void charFamily( CharFamily cf )
00196 { m_format = ( m_format & 0x0f ) | ( static_cast<char>( cf ) << 4 ); }
00197
00202 char m_format;
00203 };
00204
00205
00209 class EmptyElement : public BasicElement {
00210 EmptyElement& operator=( const EmptyElement& ) { return *this; }
00211 public:
00212
00213 EmptyElement( BasicElement* parent = 0 );
00214 EmptyElement( const EmptyElement& );
00215
00216 virtual EmptyElement* clone() {
00217 return new EmptyElement( *this );
00218 }
00219
00220 virtual bool accept( ElementVisitor* visitor );
00221
00227 virtual QChar getCharacter() const { return 'A'; }
00228
00233 virtual void calcSizes(const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00234
00240 virtual void draw( QPainter& painter, const LuPixelRect& r,
00241 const ContextStyle& context,
00242 ContextStyle::TextStyle tstyle,
00243 ContextStyle::IndexStyle istyle,
00244 const LuPixelPoint& parentOrigin );
00245
00246
00251 virtual QString toLatex();
00252
00253 protected:
00254
00255
00256
00260 virtual QString getTagName() const { return "EMPTY"; }
00261 };
00262
00263
00264 KFORMULA_NAMESPACE_END
00265
00266 #endif // TEXTELEMENT_H
|