00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef BRACKETELEMENT_H
00022 #define BRACKETELEMENT_H
00023
00024 #include <qpoint.h>
00025 #include <qsize.h>
00026
00027 #include "basicelement.h"
00028
00029 KFORMULA_NAMESPACE_BEGIN
00030
00031 class Artwork;
00032 class SequenceElement;
00033
00034
00039 class SingleContentElement : public BasicElement {
00040 SingleContentElement& operator=( const SingleContentElement& ) { return *this; }
00041 public:
00042
00043 SingleContentElement(BasicElement* parent = 0);
00044 ~SingleContentElement();
00045
00046 SingleContentElement( const SingleContentElement& );
00047
00053 virtual QChar getCharacter() const;
00054
00061 virtual BasicElement* goToPos( FormulaCursor*, bool& handled,
00062 const LuPixelPoint& point, const LuPixelPoint& parentOrigin );
00063
00067 virtual void dispatchFontCommand( FontCommand* cmd );
00068
00074 virtual void moveLeft(FormulaCursor* cursor, BasicElement* from);
00075
00081 virtual void moveRight(FormulaCursor* cursor, BasicElement* from);
00082
00088 virtual void moveUp(FormulaCursor* cursor, BasicElement* from);
00089
00095 virtual void moveDown(FormulaCursor* cursor, BasicElement* from);
00096
00103 virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00104
00109 virtual void normalize(FormulaCursor*, Direction);
00110
00111
00112
00113
00114
00115 virtual SequenceElement* getMainChild();
00116
00121 virtual void selectChild(FormulaCursor* cursor, BasicElement* child);
00122
00123 protected:
00124
00128 virtual void writeDom(QDomElement element);
00129
00130 virtual void writeMathMLContent( QDomDocument& doc,
00131 QDomElement& element,
00132 bool oasisFormat ) const;
00138 virtual bool readContentFromDom(QDomNode& node);
00139
00145 virtual int readContentFromMathMLDom(QDomNode& node);
00146
00147 SequenceElement* getContent() { return content; }
00148
00149 private:
00150
00154 SequenceElement* content;
00155 };
00156
00157
00161 class BracketElement : public SingleContentElement {
00162 typedef SingleContentElement inherited;
00163 BracketElement& operator=( const BracketElement& ) { return *this; }
00164 public:
00165
00166 enum { contentPos };
00167
00168 BracketElement(SymbolType left = EmptyBracket, SymbolType right = EmptyBracket,
00169 BasicElement* parent = 0);
00170 ~BracketElement();
00171
00172 BracketElement( const BracketElement& );
00173
00174 virtual BracketElement* clone() {
00175 return new BracketElement( *this );
00176 }
00177
00178 virtual bool accept( ElementVisitor* visitor );
00179
00184 virtual TokenType getTokenType() const { return BRACKET; }
00185
00190 virtual void entered( SequenceElement* child );
00191
00198 virtual BasicElement* goToPos( FormulaCursor*, bool& handled,
00199 const LuPixelPoint& point, const LuPixelPoint& parentOrigin );
00200
00205 virtual void calcSizes( const ContextStyle& context,
00206 ContextStyle::TextStyle tstyle,
00207 ContextStyle::IndexStyle istyle,
00208 StyleAttributes& style );
00209
00215 virtual void draw( QPainter& painter, const LuPixelRect& r,
00216 const ContextStyle& context,
00217 ContextStyle::TextStyle tstyle,
00218 ContextStyle::IndexStyle istyle,
00219 StyleAttributes& style,
00220 const LuPixelPoint& parentOrigin );
00221
00222 protected:
00223
00224
00225
00229 virtual QString getTagName() const { return "BRACKET"; }
00230
00235 virtual bool readAttributesFromDom(QDomElement element);
00236
00237 virtual void writeDom(QDomElement element);
00238
00239 virtual QString getElementName() const { return "mfenced"; }
00240 virtual void writeMathMLAttributes( QDomElement& element ) const;
00245 virtual bool readAttributesFromMathMLDom(const QDomElement& element);
00246
00253 virtual int readContentFromMathMLDom(QDomNode& node);
00254
00259 virtual QString toLatex();
00260
00261 virtual QString formulaString();
00262
00263 private:
00264
00268 QString latexString(char);
00269
00275 bool operatorType( QDomNode& node, bool open );
00276
00281 int searchOperator( const QDomNode& node );
00282
00286 Artwork* left;
00287 Artwork* right;
00288
00289 SymbolType leftType;
00290 SymbolType rightType;
00291
00292 QString m_separators;
00293 bool m_operator;
00294 bool m_customLeft;
00295 bool m_customRight;
00296 };
00297
00298
00302 class OverlineElement : public SingleContentElement {
00303 OverlineElement& operator=( const OverlineElement& ) { return *this; }
00304 public:
00305
00306 OverlineElement(BasicElement* parent = 0);
00307 ~OverlineElement();
00308
00309 OverlineElement( const OverlineElement& );
00310
00311 virtual OverlineElement* clone() {
00312 return new OverlineElement( *this );
00313 }
00314
00315 virtual bool accept( ElementVisitor* visitor );
00316
00321 virtual void entered( SequenceElement* child );
00322
00327 virtual void calcSizes( const ContextStyle& context,
00328 ContextStyle::TextStyle tstyle,
00329 ContextStyle::IndexStyle istyle,
00330 StyleAttributes& style );
00331
00337 virtual void draw( QPainter& painter, const LuPixelRect& r,
00338 const ContextStyle& context,
00339 ContextStyle::TextStyle tstyle,
00340 ContextStyle::IndexStyle istyle,
00341 StyleAttributes& style,
00342 const LuPixelPoint& parentOrigin );
00343
00348 virtual QString toLatex();
00349
00350 virtual QString formulaString();
00351
00352 virtual void writeMathML( QDomDocument& doc, QDomNode& parent, bool oasisFormat = false ) const;
00353
00354 protected:
00355
00356
00357
00361 virtual QString getTagName() const { return "OVERLINE"; }
00362
00363 private:
00364 };
00365
00366
00370 class UnderlineElement : public SingleContentElement {
00371 UnderlineElement& operator=( const UnderlineElement& ) { return *this; }
00372 public:
00373 UnderlineElement(BasicElement* parent = 0);
00374 ~UnderlineElement();
00375
00376 UnderlineElement( const UnderlineElement& );
00377
00378 virtual UnderlineElement* clone() {
00379 return new UnderlineElement( *this );
00380 }
00381
00382 virtual bool accept( ElementVisitor* visitor );
00383
00388 virtual void entered( SequenceElement* child );
00389
00394 virtual void calcSizes( const ContextStyle& context,
00395 ContextStyle::TextStyle tstyle,
00396 ContextStyle::IndexStyle istyle,
00397 StyleAttributes& style );
00398
00404 virtual void draw( QPainter& painter, const LuPixelRect& r,
00405 const ContextStyle& context,
00406 ContextStyle::TextStyle tstyle,
00407 ContextStyle::IndexStyle istyle,
00408 StyleAttributes& style,
00409 const LuPixelPoint& parentOrigin );
00410
00415 virtual QString toLatex();
00416
00417 virtual QString formulaString();
00418
00419 virtual void writeMathML( QDomDocument& doc, QDomNode& parent, bool oasisFormat = false ) const;
00420
00421 protected:
00422
00423
00424
00428 virtual QString getTagName() const { return "UNDERLINE"; }
00429
00430 private:
00431 };
00432
00433
00434 KFORMULA_NAMESPACE_END
00435
00436 #endif // BRACKETELEMENT_H