lib

fractionelement.h

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 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef FRACTIONELEMENT_H
00022 #define FRACTIONELEMENT_H
00023 
00024 #include "basicelement.h"
00025 
00026 KFORMULA_NAMESPACE_BEGIN
00027 class SequenceElement;
00028 
00029 
00033 class FractionElement : public BasicElement {
00034     FractionElement& operator=( const FractionElement& ) { return *this; }
00035 public:
00036 
00037     enum { numeratorPos, denominatorPos };
00038 
00039     FractionElement(BasicElement* parent = 0);
00040     ~FractionElement();
00041 
00042     FractionElement( const FractionElement& );
00043 
00044     virtual FractionElement* clone() {
00045         return new FractionElement( *this );
00046     }
00047 
00048     virtual bool accept( ElementVisitor* visitor );
00049 
00054     virtual TokenType getTokenType() const { return INNER; }
00055 
00060     virtual void entered( SequenceElement* child );
00061 
00068     virtual BasicElement* goToPos( FormulaCursor*, bool& handled,
00069                                    const LuPixelPoint& point, const LuPixelPoint& parentOrigin );
00070 
00075     virtual void calcSizes(const ContextStyle& style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00076 
00082     virtual void draw( QPainter& painter, const LuPixelRect& r,
00083                        const ContextStyle& style,
00084                        ContextStyle::TextStyle tstyle,
00085                        ContextStyle::IndexStyle istyle,
00086                        const LuPixelPoint& parentOrigin );
00087 
00091     virtual void dispatchFontCommand( FontCommand* cmd );
00092 
00098     virtual void moveLeft(FormulaCursor* cursor, BasicElement* from);
00099 
00105     virtual void moveRight(FormulaCursor* cursor, BasicElement* from);
00106 
00112     virtual void moveUp(FormulaCursor* cursor, BasicElement* from);
00113 
00119     virtual void moveDown(FormulaCursor* cursor, BasicElement* from);
00120 
00124     virtual void insert(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00125 
00135     virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00136 
00137 
00138     // main child
00139     //
00140     // If an element has children one has to become the main one.
00141 
00142     virtual SequenceElement* getMainChild();
00143 
00144     SequenceElement* getNumerator() { return numerator; }
00145     SequenceElement* getDenominator() { return denominator; }
00146 
00152     virtual bool isSenseless();
00153 
00158     virtual void selectChild(FormulaCursor* cursor, BasicElement* child);
00159 
00164     //virtual void childWillVanish(FormulaCursor* cursor, BasicElement* child) = 0;
00165 
00169     void showLine(bool line) { withLine = line; }
00170 
00175     virtual QString toLatex();
00176 
00177     virtual QString formulaString();
00178 
00179     virtual void writeMathML( QDomDocument& doc, QDomNode parent, bool oasisFormat = false );
00180 
00181 protected:
00182 
00183     //Save/load support
00184 
00188     virtual QString getTagName() const { return "FRACTION"; }
00189 
00193     virtual void writeDom(QDomElement element);
00194 
00199     virtual bool readAttributesFromDom(QDomElement element);
00200 
00206     virtual bool readContentFromDom(QDomNode& node);
00207 
00208 private:
00209 
00210     SequenceElement* numerator;
00211     SequenceElement* denominator;
00212 
00213     bool withLine;
00214 };
00215 
00216 KFORMULA_NAMESPACE_END
00217 
00218 #endif // FRACTIONELEMENT_H
KDE Home | KDE Accessibility Home | Description of Access Keys