lib Library API Documentation

rootelement.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., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef ROOTELEMENT_H 00022 #define ROOTELEMENT_H 00023 00024 #include <qpoint.h> 00025 00026 #include "basicelement.h" 00027 00028 KFORMULA_NAMESPACE_BEGIN 00029 class SequenceElement; 00030 00031 00035 class RootElement : public BasicElement { 00036 RootElement& operator=( const RootElement& ) { return *this; } 00037 public: 00038 00039 //enum { contentPos, indexPos }; 00040 00041 RootElement(BasicElement* parent = 0); 00042 ~RootElement(); 00043 00044 RootElement( const RootElement& ); 00045 00046 virtual RootElement* clone() { 00047 return new RootElement( *this ); 00048 } 00049 00050 virtual bool accept( ElementVisitor* visitor ); 00051 00056 virtual void entered( SequenceElement* child ); 00057 00064 virtual BasicElement* goToPos( FormulaCursor*, bool& handled, 00065 const LuPixelPoint& point, const LuPixelPoint& parentOrigin ); 00066 00071 virtual void calcSizes(const ContextStyle& style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle); 00072 00078 virtual void draw( QPainter& painter, const LuPixelRect& r, 00079 const ContextStyle& style, 00080 ContextStyle::TextStyle tstyle, 00081 ContextStyle::IndexStyle istyle, 00082 const LuPixelPoint& parentOrigin ); 00083 00087 virtual void dispatchFontCommand( FontCommand* cmd ); 00088 00094 virtual void moveLeft(FormulaCursor* cursor, BasicElement* from); 00095 00101 virtual void moveRight(FormulaCursor* cursor, BasicElement* from); 00102 00108 virtual void moveUp(FormulaCursor* cursor, BasicElement* from); 00109 00115 virtual void moveDown(FormulaCursor* cursor, BasicElement* from); 00116 00120 virtual void insert(FormulaCursor*, QPtrList<BasicElement>&, Direction); 00121 00128 virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction); 00129 00134 virtual void normalize(FormulaCursor*, Direction); 00135 00136 // main child 00137 // 00138 // If an element has children one has to become the main one. 00139 00140 virtual SequenceElement* getMainChild(); 00141 SequenceElement* getRadiant() { return index; } 00142 //virtual void setMainChild(SequenceElement*); 00143 00148 virtual void selectChild(FormulaCursor* cursor, BasicElement* child); 00149 00154 //virtual void childWillVanish(FormulaCursor* cursor, BasicElement* child) = 0; 00155 00156 // Moves the cursor inside the index. The index has to exist. 00157 void moveToIndex(FormulaCursor*, Direction); 00158 00159 // Sets the cursor to point to the place where the index normaly 00160 // is. These functions are only used if there is no such index and 00161 // we want to insert them. 00162 void setToIndex(FormulaCursor*); 00163 00164 bool hasIndex() const { return index != 0; } 00165 00166 ElementIndexPtr getIndex() { return ElementIndexPtr( new RootElementIndex( this ) ); } 00167 00168 // Save&load 00169 //virtual QDomElement getElementDom(QDomDocument *doc); 00170 //virtual bool buildFromDom(QDomElement *elem); 00171 00176 virtual QString toLatex(); 00177 00178 virtual QString formulaString(); 00179 00180 virtual void writeMathML( QDomDocument doc, QDomNode parent ); 00181 00182 protected: 00183 00184 //Save/load support 00185 00189 virtual QString getTagName() const { return "ROOT"; } 00190 00194 virtual void writeDom(QDomElement element); 00195 00200 virtual bool readAttributesFromDom(QDomElement element); 00201 00207 virtual bool readContentFromDom(QDomNode& node); 00208 00209 private: 00210 00211 class RootElementIndex : public ElementIndex { 00212 public: 00213 RootElementIndex(RootElement* p) : parent(p) {} 00214 virtual void moveToIndex(FormulaCursor* cursor, Direction direction) 00215 { parent->moveToIndex(cursor, direction); } 00216 virtual void setToIndex(FormulaCursor* cursor) 00217 { parent->setToIndex(cursor); } 00218 virtual bool hasIndex() const 00219 { return parent->hasIndex(); } 00220 virtual RootElement* getElement() { return parent; } 00221 protected: 00222 RootElement* parent; 00223 }; 00224 00225 00229 SequenceElement* content; 00230 00234 SequenceElement* index; 00235 00239 LuPixelPoint rootOffset; 00240 }; 00241 00242 00243 KFORMULA_NAMESPACE_END 00244 00245 #endif // ROOTELEMENT_H
KDE Logo
This file is part of the documentation for lib Library Version 1.3.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Sep 28 04:04:03 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003