lib
symbolelement.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SYMBOLELEMENT_H
00022 #define SYMBOLELEMENT_H
00023
00024 #include "fontstyle.h"
00025 #include "basicelement.h"
00026 #include "kformuladefs.h"
00027
00028 KFORMULA_NAMESPACE_BEGIN
00029
00033 class SymbolElement : public BasicElement {
00034 SymbolElement operator=( const SymbolElement& ) { return *this; }
00035 public:
00036
00037
00038
00039 SymbolElement(SymbolType type = EmptyBracket, BasicElement* parent = 0);
00040 ~SymbolElement();
00041
00042 SymbolElement( const SymbolElement& );
00043
00044 virtual SymbolElement* clone() {
00045 return new SymbolElement( *this );
00046 }
00047
00048 virtual bool accept( ElementVisitor* visitor );
00049
00056 virtual BasicElement* goToPos( FormulaCursor*, bool& handled,
00057 const LuPixelPoint& point, const LuPixelPoint& parentOrigin );
00058
00059
00060
00061
00062
00063
00064
00065
00070 virtual void calcSizes( const ContextStyle& cstyle,
00071 ContextStyle::TextStyle tstyle,
00072 ContextStyle::IndexStyle istyle,
00073 StyleAttributes& style );
00074
00080 virtual void draw( QPainter& painter, const LuPixelRect& r,
00081 const ContextStyle& context,
00082 ContextStyle::TextStyle tstyle,
00083 ContextStyle::IndexStyle istyle,
00084 StyleAttributes& style,
00085 const LuPixelPoint& parentOrigin );
00086
00090 virtual void dispatchFontCommand( FontCommand* cmd );
00091
00092
00093
00094
00095
00096
00097
00098
00099
00105 virtual void moveLeft(FormulaCursor* cursor, BasicElement* from);
00106
00112 virtual void moveRight(FormulaCursor* cursor, BasicElement* from);
00113
00119 virtual void moveUp(FormulaCursor* cursor, BasicElement* from);
00120
00126 virtual void moveDown(FormulaCursor* cursor, BasicElement* from);
00127
00128
00129
00137
00138
00139
00140
00141
00142
00143
00144 virtual SequenceElement* getMainChild() { return content; }
00145
00146
00147
00158 virtual void insert(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00159
00171 virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00172
00177 virtual void normalize(FormulaCursor*, Direction);
00178
00182 virtual BasicElement* getChild(FormulaCursor*, Direction = beforeCursor);
00183
00188 virtual void selectChild(FormulaCursor* cursor, BasicElement* child);
00189
00194
00195
00196 bool hasUpper() const { return upper != 0; }
00197 bool hasLower() const { return lower != 0; }
00198
00199
00200
00201 void setToUpper(FormulaCursor* cursor);
00202 void setToLower(FormulaCursor* cursor);
00203
00204
00205 void moveToUpper(FormulaCursor*, Direction);
00206 void moveToLower(FormulaCursor*, Direction);
00207
00208
00209
00210 ElementIndexPtr getUpperIndex() { return ElementIndexPtr( new UpperIndex( this ) ); }
00211 ElementIndexPtr getLowerIndex() { return ElementIndexPtr( new LowerIndex( this ) ); }
00212
00216 ElementIndexPtr getIndex( int position );
00217
00218
00219
00220
00221
00226 virtual QString toLatex();
00227
00228 virtual QString formulaString();
00229
00230 virtual void writeMathML( QDomDocument& doc, QDomNode& parent, bool oasisFormat = false ) const ;
00231
00232 protected:
00233
00234
00235
00239 virtual QString getTagName() const { return "SYMBOL"; }
00240
00244 virtual void writeDom(QDomElement element);
00245
00250 virtual bool readAttributesFromDom(QDomElement element);
00251
00257 virtual bool readContentFromDom(QDomNode& node);
00258
00259 private:
00260
00264 class SymbolElementIndex : public ElementIndex {
00265 public:
00266 SymbolElementIndex(SymbolElement* p) : parent(p) {}
00267 virtual SymbolElement* getElement() { return parent; }
00268 protected:
00269 SymbolElement* parent;
00270 };
00271
00272
00273
00274 class UpperIndex : public SymbolElementIndex {
00275 public:
00276 UpperIndex(SymbolElement* parent) : SymbolElementIndex(parent) {}
00277 virtual void moveToIndex(FormulaCursor* cursor, Direction direction)
00278 { parent->moveToUpper(cursor, direction); }
00279 virtual void setToIndex(FormulaCursor* cursor)
00280 { parent->setToUpper(cursor); }
00281 virtual bool hasIndex() const
00282 { return parent->hasUpper(); }
00283 };
00284
00285 class LowerIndex : public SymbolElementIndex {
00286 public:
00287 LowerIndex(SymbolElement* parent) : SymbolElementIndex(parent) {}
00288 virtual void moveToIndex(FormulaCursor* cursor, Direction direction)
00289 { parent->moveToLower(cursor, direction); }
00290 virtual void setToIndex(FormulaCursor* cursor)
00291 { parent->setToLower(cursor); }
00292 virtual bool hasIndex() const
00293 { return parent->hasLower(); }
00294 };
00295
00296
00297 void setToContent(FormulaCursor* cursor);
00298
00299 SequenceElement* content;
00300 SequenceElement* upper;
00301 SequenceElement* lower;
00302
00306 Artwork* symbol;
00307
00308 SymbolType symbolType;
00309 };
00310
00311 KFORMULA_NAMESPACE_END
00312
00313 #endif // SYMBOLELEMENT_H
|