lib Library API Documentation

textelement.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 TEXTELEMENT_H
00022 #define TEXTELEMENT_H
00023 
00024 #include <qfont.h>
00025 #include <qstring.h>
00026 
00027 #include "basicelement.h"
00028 
00029 class SymbolTable;
00030 
00031 
00032 KFORMULA_NAMESPACE_BEGIN
00033 
00037 class TextElement : public BasicElement {
00038     TextElement operator=( const TextElement& ) { return *this; }
00039 public:
00040 
00041     TextElement(QChar ch = ' ', bool beSymbol = false, BasicElement* parent = 0);
00042     TextElement( const TextElement& );
00043 
00044     virtual TextElement* clone() {
00045         return new TextElement( *this );
00046     }
00047 
00048     virtual bool accept( ElementVisitor* visitor );
00049 
00054     virtual TokenType getTokenType() const;
00055 
00059     virtual bool isInvisible() const;
00060 
00065     virtual QChar getCharacter() const { return character; }
00066 
00067     // drawing
00068     //
00069     // Drawing depends on a context which knows the required properties like
00070     // fonts, spaces and such.
00071     // It is essential to calculate elements size with the same context
00072     // before you draw.
00073 
00078     virtual void calcSizes(const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00079 
00085     virtual void draw( QPainter& painter, const LuPixelRect& r,
00086                        const ContextStyle& context,
00087                        ContextStyle::TextStyle tstyle,
00088                        ContextStyle::IndexStyle istyle,
00089                        const LuPixelPoint& parentOrigin );
00090 
00094     virtual void dispatchFontCommand( FontCommand* cmd );
00095 
00096     CharStyle getCharStyle() const { return charStyle(); }
00097     void setCharStyle( CharStyle cs );
00098 
00099     CharFamily getCharFamily() const { return charFamily(); }
00100     void setCharFamily( CharFamily cf );
00101 
00102     char format() const { return m_format; }
00103 
00108     //virtual void childWillVanish(FormulaCursor*, BasicElement*) {}
00109 
00113     bool isSymbol() const { return symbol; }
00114 
00119     virtual QString toLatex();
00120 
00121     virtual QString formulaString();
00122 
00123 protected:
00124 
00125     //Save/load support
00126 
00130     virtual QString getTagName() const { return "TEXT"; }
00131 
00135     virtual void writeDom(QDomElement element);
00136 
00141     virtual bool readAttributesFromDom(QDomElement element);
00142 
00148     virtual bool readContentFromDom(QDomNode& node);
00149 
00153     QChar getRealCharacter(const ContextStyle& context);
00154 
00158     QFont getFont(const ContextStyle& context);
00159 
00163     void setUpPainter(const ContextStyle& context, QPainter& painter);
00164 
00165     const SymbolTable& getSymbolTable() const;
00166 
00167 private:
00168 
00172     QChar character;
00173 
00177     bool symbol;
00178 
00184     CharStyle charStyle() const { return static_cast<CharStyle>( m_format & 0x0f ); }
00185     void charStyle( CharStyle cs )
00186         { m_format = ( m_format & 0xf0 ) | static_cast<char>( cs ); }
00187 
00193     CharFamily charFamily() const
00194         { return static_cast<CharFamily>( m_format >> 4 ); }
00195     void charFamily( CharFamily cf )
00196         { m_format = ( m_format & 0x0f ) | ( static_cast<char>( cf ) << 4 ); }
00197 
00202     char m_format;
00203 };
00204 
00205 
00209 class EmptyElement : public BasicElement {
00210     EmptyElement& operator=( const EmptyElement& ) { return *this; }
00211 public:
00212 
00213     EmptyElement( BasicElement* parent = 0 );
00214     EmptyElement( const EmptyElement& );
00215 
00216     virtual EmptyElement* clone() {
00217         return new EmptyElement( *this );
00218     }
00219 
00220     virtual bool accept( ElementVisitor* visitor );
00221 
00227     virtual QChar getCharacter() const { return 'A'; }
00228 
00233     virtual void calcSizes(const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00234 
00240     virtual void draw( QPainter& painter, const LuPixelRect& r,
00241                        const ContextStyle& context,
00242                        ContextStyle::TextStyle tstyle,
00243                        ContextStyle::IndexStyle istyle,
00244                        const LuPixelPoint& parentOrigin );
00245 
00246 
00251     virtual QString toLatex();
00252 
00253 protected:
00254 
00255     //Save/load support
00256 
00260     virtual QString getTagName() const { return "EMPTY"; }
00261 };
00262 
00263 
00264 KFORMULA_NAMESPACE_END
00265 
00266 #endif // TEXTELEMENT_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 13:19:28 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2003