lib

formulaelement.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 FORMULAELEMENT_H
00022 #define FORMULAELEMENT_H
00023 
00024 // Formula include
00025 #include "sequenceelement.h"
00026 
00027 KFORMULA_NAMESPACE_BEGIN
00028 
00029 class BasicElement;
00030 class ContextStyle;
00031 class FormulaDocument;
00032 class SymbolTable;
00033 
00034 
00040 class FormulaElement : public SequenceElement {
00041     typedef SequenceElement inherited;
00042 public:
00043 
00048     FormulaElement(FormulaDocument* container);
00049 
00050     virtual FormulaElement* clone() { return 0; }
00051 
00055     BasicElement* goToPos( FormulaCursor*, const LuPixelPoint& point );
00056 
00060     virtual bool readOnly( const BasicElement* /*child*/ ) const { return false; }
00061 
00065     virtual bool readOnly( const FormulaCursor* ) const { return false; }
00066 
00070     virtual FormulaElement* formula() { return this; }
00071 
00075     virtual const FormulaElement* formula() const { return this; }
00076 
00081     void elementRemoval(BasicElement* child);
00082 
00087     virtual void changed();
00088 
00094     void cursorHasMoved( FormulaCursor* );
00095 
00096     void moveOutLeft( FormulaCursor* );
00097     void moveOutRight( FormulaCursor* );
00098     void moveOutBelow( FormulaCursor* );
00099     void moveOutAbove( FormulaCursor* );
00100 
00104     void tell( const QString& msg );
00105 
00110     void removeFormula( FormulaCursor* );
00111 
00112     void insertFormula( FormulaCursor* );
00113 
00118     virtual void calcSizes( const ContextStyle& context,
00119                             ContextStyle::TextStyle tstyle,
00120                             ContextStyle::IndexStyle istyle,
00121                             StyleAttributes& style );
00122 
00128     virtual void draw( QPainter& painter, const LuPixelRect& r,
00129                        const ContextStyle& context,
00130                        ContextStyle::TextStyle tstyle,
00131                        ContextStyle::IndexStyle istyle,
00132                        StyleAttributes& style,
00133                        const LuPixelPoint& parentOrigin );
00134 
00138     void calcSizes( ContextStyle& context );
00139 
00143     void draw( QPainter& painter, const LuPixelRect& r, ContextStyle& context );
00144 
00153     virtual KCommand* buildCommand( Container*, Request* );
00154 
00158     const SymbolTable& getSymbolTable() const;
00159 
00164     virtual QString toLatex();
00165 
00166     int getBaseSize() const { return baseSize; }
00167     void setBaseSize( int size );
00168 
00169     bool hasOwnBaseSize() const { return ownBaseSize; }
00170 
00171     virtual KCommand* input( Container* container, QKeyEvent* event );
00172 
00173     virtual void writeMathML( QDomDocument& doc, QDomNode& parent, bool oasisFormat = false ) const ;
00174 
00178     virtual void writeDom(QDomElement element);
00179 
00183     QDomElement emptyFormulaElement( QDomDocument& doc );
00184 
00185 protected:
00186 
00187     //Save/load support
00188 
00192     virtual QString getTagName() const { return "FORMULA"; }
00193 
00198     virtual bool readAttributesFromDom(QDomElement element);
00199 
00205     virtual bool readContentFromDom(QDomNode& node);
00206 
00207 
00208 private:
00209 
00214     void convertNames( QDomNode node );
00215 
00219     FormulaDocument* document;
00220 
00224     int baseSize;
00225 
00229     bool ownBaseSize;
00230 };
00231 
00232 KFORMULA_NAMESPACE_END
00233 
00234 #endif // FORMULAELEMENT_H
KDE Home | KDE Accessibility Home | Description of Access Keys