lib Library API Documentation

bracketelement.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 BRACKETELEMENT_H 00022 #define BRACKETELEMENT_H 00023 00024 #include <qpoint.h> 00025 #include <qsize.h> 00026 00027 #include "basicelement.h" 00028 00029 KFORMULA_NAMESPACE_BEGIN 00030 00031 class Artwork; 00032 class SequenceElement; 00033 00034 00039 class SingleContentElement : public BasicElement { 00040 SingleContentElement& operator=( const SingleContentElement& ) { return *this; } 00041 public: 00042 00043 SingleContentElement(BasicElement* parent = 0); 00044 ~SingleContentElement(); 00045 00046 SingleContentElement( const SingleContentElement& ); 00047 00053 virtual QChar getCharacter() const; 00054 00061 virtual BasicElement* goToPos( FormulaCursor*, bool& handled, 00062 const LuPixelPoint& point, const LuPixelPoint& parentOrigin ); 00063 00067 virtual void dispatchFontCommand( FontCommand* cmd ); 00068 00074 virtual void moveLeft(FormulaCursor* cursor, BasicElement* from); 00075 00081 virtual void moveRight(FormulaCursor* cursor, BasicElement* from); 00082 00088 virtual void moveUp(FormulaCursor* cursor, BasicElement* from); 00089 00095 virtual void moveDown(FormulaCursor* cursor, BasicElement* from); 00096 00103 virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction); 00104 00109 virtual void normalize(FormulaCursor*, Direction); 00110 00111 // main child 00112 // 00113 // If an element has children one has to become the main one. 00114 00115 virtual SequenceElement* getMainChild(); 00116 00121 virtual void selectChild(FormulaCursor* cursor, BasicElement* child); 00122 00123 virtual void writeMathML( QDomDocument doc, QDomNode parent ); 00124 00125 protected: 00126 00130 virtual void writeDom(QDomElement element); 00131 00137 virtual bool readContentFromDom(QDomNode& node); 00138 00139 SequenceElement* getContent() { return content; } 00140 00141 private: 00142 00146 SequenceElement* content; 00147 }; 00148 00149 00153 class BracketElement : public SingleContentElement { 00154 BracketElement& operator=( const BracketElement& ) { return *this; } 00155 public: 00156 00157 enum { contentPos }; 00158 00159 BracketElement(SymbolType left = EmptyBracket, SymbolType right = EmptyBracket, 00160 BasicElement* parent = 0); 00161 ~BracketElement(); 00162 00163 BracketElement( const BracketElement& ); 00164 00165 virtual BracketElement* clone() { 00166 return new BracketElement( *this ); 00167 } 00168 00169 virtual bool accept( ElementVisitor* visitor ); 00170 00175 virtual TokenType getTokenType() const { return BRACKET; } 00176 00181 virtual void entered( SequenceElement* child ); 00182 00189 virtual BasicElement* goToPos( FormulaCursor*, bool& handled, 00190 const LuPixelPoint& point, const LuPixelPoint& parentOrigin ); 00191 00196 virtual void calcSizes(const ContextStyle& style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle); 00197 00203 virtual void draw( QPainter& painter, const LuPixelRect& r, 00204 const ContextStyle& style, 00205 ContextStyle::TextStyle tstyle, 00206 ContextStyle::IndexStyle istyle, 00207 const LuPixelPoint& parentOrigin ); 00208 00209 virtual void writeMathML( QDomDocument doc, QDomNode parent ); 00210 00211 protected: 00212 00213 //Save/load support 00214 00218 virtual QString getTagName() const { return "BRACKET"; } 00219 00224 virtual bool readAttributesFromDom(QDomElement element); 00225 00226 virtual void writeDom(QDomElement element); 00227 00232 virtual QString toLatex(); 00233 00234 virtual QString formulaString(); 00235 00236 private: 00237 00241 QString latexString(char); 00242 00246 Artwork* left; 00247 Artwork* right; 00248 00249 SymbolType leftType; 00250 SymbolType rightType; 00251 }; 00252 00253 00257 class OverlineElement : public SingleContentElement { 00258 OverlineElement& operator=( const OverlineElement& ) { return *this; } 00259 public: 00260 00261 OverlineElement(BasicElement* parent = 0); 00262 ~OverlineElement(); 00263 00264 OverlineElement( const OverlineElement& ); 00265 00266 virtual OverlineElement* clone() { 00267 return new OverlineElement( *this ); 00268 } 00269 00270 virtual bool accept( ElementVisitor* visitor ); 00271 00276 virtual void entered( SequenceElement* child ); 00277 00282 virtual void calcSizes(const ContextStyle& style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle); 00283 00289 virtual void draw( QPainter& painter, const LuPixelRect& r, 00290 const ContextStyle& style, 00291 ContextStyle::TextStyle tstyle, 00292 ContextStyle::IndexStyle istyle, 00293 const LuPixelPoint& parentOrigin ); 00294 00299 virtual QString toLatex(); 00300 00301 virtual QString formulaString(); 00302 00303 virtual void writeMathML( QDomDocument doc, QDomNode parent ); 00304 00305 protected: 00306 00307 //Save/load support 00308 00312 virtual QString getTagName() const { return "OVERLINE"; } 00313 00314 private: 00315 }; 00316 00317 00321 class UnderlineElement : public SingleContentElement { 00322 UnderlineElement& operator=( const UnderlineElement& ) { return *this; } 00323 public: 00324 UnderlineElement(BasicElement* parent = 0); 00325 ~UnderlineElement(); 00326 00327 UnderlineElement( const UnderlineElement& ); 00328 00329 virtual UnderlineElement* clone() { 00330 return new UnderlineElement( *this ); 00331 } 00332 00333 virtual bool accept( ElementVisitor* visitor ); 00334 00339 virtual void entered( SequenceElement* child ); 00340 00345 virtual void calcSizes(const ContextStyle& style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle); 00346 00352 virtual void draw( QPainter& painter, const LuPixelRect& r, 00353 const ContextStyle& style, 00354 ContextStyle::TextStyle tstyle, 00355 ContextStyle::IndexStyle istyle, 00356 const LuPixelPoint& parentOrigin ); 00357 00362 virtual QString toLatex(); 00363 00364 virtual QString formulaString(); 00365 00366 virtual void writeMathML( QDomDocument doc, QDomNode parent ); 00367 00368 protected: 00369 00370 //Save/load support 00371 00375 virtual QString getTagName() const { return "UNDERLINE"; } 00376 00377 private: 00378 }; 00379 00380 00381 KFORMULA_NAMESPACE_END 00382 00383 #endif // BRACKETELEMENT_H
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 06:54:13 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003