F:/KPlato/koffice/libs/kformula/TextElement.h

Aller à la documentation de ce fichier.
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 Martin Pfeiffer <hubipete@gmx.net>
00005    Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #ifndef TEXTELEMENT_H
00024 #define TEXTELEMENT_H
00025 
00026 #include <QFont>
00027 #include <QString>
00028 
00029 #include "BasicElement.h"
00030 
00031 class SymbolTable;
00032 
00033 
00034 namespace KFormula {
00035 
00039 class TextElement : public BasicElement {
00040 public:
00042     TextElement( BasicElement* parent = 0 );
00043 
00048     const QList<BasicElement*> childElements();
00049 
00050     void readMathML( const QDomElement& element );
00051     
00052     void writeMathML( KoXmlWriter* writer, bool oasisFormat = false );
00053 
00054     
00055 
00060     virtual TokenType getTokenType() const;
00061 
00065     virtual bool isInvisible() const;
00066 
00071     virtual QChar getCharacter() const { return character; }
00072 
00077     virtual void calcSizes(const ContextStyle& context, 
00078                            ContextStyle::TextStyle tstyle, 
00079                            ContextStyle::IndexStyle istyle
00080                            StyleAttributes& style );
00081 
00087     virtual void draw( QPainter& painter, const LuPixelRect& r,
00088                        const ContextStyle& context,
00089                        ContextStyle::TextStyle tstyle,
00090                        ContextStyle::IndexStyle istyle,
00091                        StyleAttributes& style,
00092                        const LuPixelPoint& parentOrigin );
00093 
00097     virtual void dispatchFontCommand( FontCommand* cmd );
00098 
00099     CharStyle getCharStyle() const { return charStyle(); }
00100     void setCharStyle( CharStyle cs );
00101 
00102     CharFamily getCharFamily() const { return charFamily(); }
00103     void setCharFamily( CharFamily cf );
00104 
00105     char format() const { return m_format; }
00106 
00110     bool isSymbol() const { return symbol; }
00111 
00112 protected:
00113     //Save/load support
00114 
00118     virtual QString getTagName() const { return "TEXT"; }
00119 
00123     virtual void writeDom(QDomElement element);
00124 
00129     virtual bool readAttributesFromDom(QDomElement element);
00130 
00136     virtual bool readContentFromDom(QDomNode& node);
00137 
00141     QChar getRealCharacter(const ContextStyle& context);
00142 
00146     QFont getFont(const ContextStyle& context, const StyleAttributes& style);
00147 
00151     void setUpPainter(const ContextStyle& context, QPainter& painter);
00152 
00153     const SymbolTable& getSymbolTable() const;
00154 
00155 private:
00156 
00160     QChar character;
00161 
00165     bool symbol;
00166 
00172     CharStyle charStyle() const { return static_cast<CharStyle>( m_format & 0x0f ); }
00173     void charStyle( CharStyle cs )
00174         { m_format = ( m_format & 0xf0 ) | static_cast<char>( cs ); }
00175 
00181     CharFamily charFamily() const
00182         { return static_cast<CharFamily>( m_format >> 4 ); }
00183     void charFamily( CharFamily cf )
00184         { m_format = ( m_format & 0x0f ) | ( static_cast<char>( cf ) << 4 ); }
00185 
00190     char m_format;
00191 };
00192 
00193 } // namespace KFormula
00194 
00195 #endif // TEXTELEMENT_H

Généré le Wed Nov 22 23:41:01 2006 pour KPlato par  doxygen 1.5.1-p1