lib

spaceelement.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    Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef SPACEELEMENT_H
00023 #define SPACEELEMENT_H
00024 
00025 #include <qfont.h>
00026 #include <qstring.h>
00027 
00028 #include "basicelement.h"
00029 
00030 class SymbolTable;
00031 
00032 
00033 KFORMULA_NAMESPACE_BEGIN
00034 
00038 class SpaceElement : public BasicElement {
00039     enum LineBreakType {
00040         NoBreakType,
00041         AutoBreak,
00042         NewLineBreak,
00043         IndentingNewLineBreak,
00044         NoBreak,
00045         GoodBreak,
00046         BadBreak
00047     };
00048     SpaceElement operator=( const SpaceElement& ) { return *this; }
00049 public:
00050 
00051     SpaceElement( SpaceWidth space = THIN, bool tab=false, BasicElement* parent = 0 );
00052     SpaceElement( const SpaceElement& );
00053 
00054     virtual SpaceElement* clone() {
00055         return new SpaceElement( *this );
00056     }
00057 
00058     virtual bool accept( ElementVisitor* visitor );
00059 
00064     //virtual TokenType getTokenType() const;
00065 
00070     virtual QChar getCharacter() const { return ' '; }
00071 
00072     // drawing
00073     //
00074     // Drawing depends on a conspace which knows the required properties like
00075     // fonts, spaces and such.
00076     // It is essential to calculate elements size with the same conspace
00077     // before you draw.
00078 
00083     virtual void calcSizes( const ContextStyle& cstyle,
00084                             ContextStyle::TextStyle tstyle,
00085                             ContextStyle::IndexStyle istyle,
00086                             StyleAttributes& style );
00087 
00093     virtual void draw( QPainter& painter, const LuPixelRect& r,
00094                        const ContextStyle& context,
00095                        ContextStyle::TextStyle tstyle,
00096                        ContextStyle::IndexStyle istyle,
00097                        StyleAttributes& style,
00098                        const LuPixelPoint& parentOrigin );
00099 
00104     //virtual void childWillVanish(FormulaCursor*, BasicElement*) {}
00105 
00110     virtual QString toLatex();
00111 
00112 protected:
00113 
00114     //Save/load support
00115 
00119     virtual QString getTagName() const { return "SPACE"; }
00120 
00124     virtual void writeDom(QDomElement element);
00125 
00130     virtual bool readAttributesFromDom(QDomElement element);
00131 
00137     virtual bool readContentFromDom(QDomNode& node);
00138 
00143     virtual bool readAttributesFromMathMLDom(const QDomElement& element);
00144 
00145 private:
00146 
00147     virtual QString getElementName() const { return "mspace"; }
00148     virtual void writeMathMLAttributes( QDomElement& element ) const ;
00149 
00153     bool m_tab;
00154 
00155     // MathML Attributes, Section 3.2.7.2
00156     SizeType m_widthType;
00157     double m_width;
00158     SizeType m_heightType;
00159     double m_height;
00160     SizeType m_depthType;
00161     double m_depth;
00162     LineBreakType m_lineBreak;
00163 };
00164 
00165 KFORMULA_NAMESPACE_END
00166 
00167 #endif // SPACEELEMENT_H
KDE Home | KDE Accessibility Home | Description of Access Keys