kformula/flake
BasicElement.hGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef BASICELEMENT_H
00025 #define BASICELEMENT_H
00026
00027 #include "kformula_export.h"
00028 #include "ElementFactory.h"
00029
00030 #include <QHash>
00031 #include <QList>
00032 #include <QString>
00033 #include <QRectF>
00034 #include <QLineF>
00035 class QPainter;
00036 class QVariant;
00037 class KoXmlWriter;
00038 #include "KoXmlReaderForward.h"
00039 class AttributeManager;
00040 class FormulaCursor;
00041 class QPainterPath;
00042 class TableEntryElement;
00043 #define DEBUGID 40000
00044
00068 class KOFORMULA_EXPORT BasicElement {
00069 public:
00070
00071
00072
00073
00074 BasicElement( BasicElement* parent = 0 );
00075
00077 virtual ~BasicElement();
00078
00084 BasicElement* childElementAt( const QPointF& p );
00085
00090 virtual const QList<BasicElement*> childElements() const;
00091
00097 virtual bool replaceChild( BasicElement* oldelement, BasicElement* newelement );
00098
00104 virtual void paint( QPainter& painter, AttributeManager* am );
00105
00111 virtual void paintEditingHints( QPainter& painter, AttributeManager* am );
00112
00113
00128 virtual void layout( const AttributeManager* am );
00129
00133 virtual void stretch();
00134
00140 virtual bool acceptCursor( const FormulaCursor& cursor );
00141
00148 virtual QLineF cursorLine(int position) const;
00149
00150 virtual QPainterPath selectionRegion(const int pos1, const int pos2) const;
00151
00152 virtual QList<BasicElement*> elementsBetween(int pos1, int pos2) const;
00153
00160 virtual bool moveCursor(FormulaCursor& newcursor, FormulaCursor& oldcursor);
00161
00163 virtual ElementType elementType() const;
00164
00166 void setWidth( double width );
00167
00169 double width() const;
00170
00172 void setHeight( double height );
00173
00175 double height() const;
00176
00178 const QRectF& boundingRect() const;
00179
00181 const QRectF absoluteBoundingRect() const;
00182
00193 virtual bool setCursorTo(FormulaCursor& cursor, QPointF point);
00194
00196 const QRectF& childrenBoundingRect() const;
00197
00199 void setChildrenBoundingRect(const QRectF &rect);
00200
00202 void setBaseLine( double baseLine );
00203
00205 double baseLine() const;
00206
00208 void setOrigin( QPointF origin );
00209
00211 QPointF origin() const;
00212
00214 void setParentElement( BasicElement* parent );
00215
00217 BasicElement* parentElement() const;
00218
00220 virtual int endPosition() const;
00221
00226 virtual int positionOfChild(BasicElement* child) const;
00227
00229 virtual BasicElement* elementBefore(int position) const;
00230
00232 virtual BasicElement* elementAfter(int position) const;
00233
00235 void setScaleFactor( double scaleFactor );
00236
00238 double scaleFactor() const;
00239
00241 void setScaleLevel( int scaleLevel );
00242
00244 int scaleLevel() const;
00245
00251 void setAttribute( const QString& name, const QVariant& value );
00252
00254 QString attribute( const QString& attribute ) const;
00255
00257 virtual QString inheritsAttribute( const QString& attribute ) const;
00258
00260 virtual QString attributesDefaultValue( const QString& attribute ) const;
00261
00263 bool displayStyle() const;
00264
00266 void setDisplayStyle(bool displayStyle);
00267
00269 bool readMathML( const KoXmlElement& element );
00270
00272 void writeMathML( KoXmlWriter* writer ) const;
00273
00275 bool hasDescendant(BasicElement* other) const;
00276
00278 BasicElement* emptyDescendant();
00279
00281 virtual bool isEmpty() const;
00282
00284 virtual bool isInferredRow() const;
00285
00287 BasicElement* formulaElement();
00288
00294 virtual void writeElementTree(int indent=0, bool wrong=false) const;
00295
00297 virtual const QString writeElementContent() const;
00298
00300 TableEntryElement* parentTableEntry();
00301
00302 protected:
00304 virtual bool readMathMLAttributes( const KoXmlElement& element );
00305
00307 virtual bool readMathMLContent( const KoXmlElement& element );
00308
00310 virtual void writeMathMLAttributes( KoXmlWriter* writer ) const;
00311
00313 virtual void writeMathMLContent( KoXmlWriter* writer ) const;
00314
00315 static void cleanElementTree(BasicElement* element);
00316
00317 private:
00319 BasicElement* m_parentElement;
00320
00322 QHash<QString,QString> m_attributes;
00323
00325 QRectF m_boundingRect;
00326
00331 QRectF m_childrenBoundingRect;
00332
00334 double m_baseLine;
00335
00337 double m_scaleFactor;
00338
00340 double m_scaleLevel;
00341
00343 bool m_displayStyle;
00344 };
00345
00346 #endif // BASICELEMENT_H
|