F:/KPlato/koffice/libs/kformula/RootElement.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
00003                       Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
00004    Copyright (C) 2006 Martin Pfeiffer <hubipete@gmx.net>
00005    Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #ifndef ROOTELEMENT_H
00024 #define ROOTELEMENT_H
00025 
00026 #include <QPoint>
00027 
00028 #include "BasicElement.h"
00029 
00030 namespace KFormula {
00031 
00035 class RootElement : public BasicElement {
00036 public:
00038     RootElement( BasicElement* parent = 0 );
00039 
00040     ~RootElement();
00041 
00042     void insertInExponent( int index, BasicElement* element );
00043 
00044     void insertInRadicand( int index, BasicElement* element );
00045      
00050     const QList<BasicElement*> childElements();
00051 
00056     virtual void calcSizes( const ContextStyle& style, 
00057                             ContextStyle::TextStyle tstyle, 
00058                             ContextStyle::IndexStyle istyle,
00059                             StyleAttributes& style );
00060 
00066     virtual void draw( QPainter& painter, const LuPixelRect& r,
00067                        const ContextStyle& style,
00068                        ContextStyle::TextStyle tstyle,
00069                        ContextStyle::IndexStyle istyle,
00070                        StyleAttributes& style,
00071                        const LuPixelPoint& parentOrigin );
00072 
00078     virtual void moveLeft(FormulaCursor* cursor, BasicElement* from);
00079 
00085     virtual void moveRight(FormulaCursor* cursor, BasicElement* from);
00086 
00092     virtual void moveUp(FormulaCursor* cursor, BasicElement* from);
00093 
00099     virtual void moveDown(FormulaCursor* cursor, BasicElement* from);
00100 
00104     virtual void insert(FormulaCursor*, QList<BasicElement*>&, Direction);
00105 
00112     virtual void remove(FormulaCursor*, QList<BasicElement*>&, Direction);
00113 
00114     // main child
00115     //
00116     // If an element has children one has to become the main one.
00117 
00118     virtual SequenceElement* getMainChild();
00119 
00124     virtual void selectChild(FormulaCursor* cursor, BasicElement* child);
00125 
00126     // Moves the cursor inside the index. The index has to exist.
00127     void moveToIndex(FormulaCursor*, Direction);
00128 
00129     // Sets the cursor to point to the place where the index normaly
00130     // is. These functions are only used if there is no such index and
00131     // we want to insert them.
00132     void setToIndex(FormulaCursor*);
00133 
00134     bool hasIndex() const { return m_exponent != 0; }
00135 
00136 protected:
00137     //Save/load support
00138 
00142     virtual QString getTagName() const { return "ROOT"; }
00143 
00147     virtual void writeDom(QDomElement element);
00148 
00153     virtual bool readAttributesFromDom(QDomElement element);
00154 
00160     virtual bool readContentFromDom(QDomNode& node);
00161 
00166     virtual void readMathMLAttributes( const QDomElement& element );
00167 
00172     virtual int readMathMLContent( QDomNode& node );
00173 
00174 private:
00175     virtual QString getElementName() const { return hasIndex() ? "mroot" : "msqrt"; }
00176     virtual void writeMathMLContent( QDomDocument& doc, 
00177                                      QDomElement& element,
00178                                      bool oasisFormat ) const ;
00179 
00181     BasicElement* m_radicand;
00182 
00184     BasicElement* m_exponent;
00185 
00187     LuPixelPoint rootOffset;
00188 
00194         bool square;
00195 };
00196 
00197 } // namespace KFormula
00198 
00199 #endif // ROOTELEMENT_H

Généré le Wed Nov 22 23:41:01 2006 pour KPlato par  doxygen 1.5.1-p1