lib

tokenstyleelement.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef TOKENSTYLEELEMENT_H
00021 #define TOKENSTYLEELEMENT_H
00022 
00023 #include "kformuladefs.h"
00024 #include "sequenceelement.h"
00025 
00026 KFORMULA_NAMESPACE_BEGIN
00027 
00035 class TokenStyleElement : public SequenceElement {
00036     typedef SequenceElement inherited;
00037 public:
00038 
00039     TokenStyleElement( BasicElement* parent = 0 );
00040 
00041     virtual void calcSizes( const ContextStyle& context,
00042                             ContextStyle::TextStyle tstyle,
00043                             ContextStyle::IndexStyle istyle,
00044                             StyleAttributes& style );
00045 
00046     virtual void draw( QPainter& painter, const LuPixelRect& r,
00047                        const ContextStyle& context,
00048                        ContextStyle::TextStyle tstyle,
00049                        ContextStyle::IndexStyle istyle,
00050                        StyleAttributes& style,
00051                        const LuPixelPoint& parentOrigin );
00052 
00053 protected:
00054     virtual bool readAttributesFromMathMLDom( const QDomElement &element );
00055     virtual void writeMathMLAttributes( QDomElement& element ) const ;
00056 
00057     void setAbsoluteSize( double s, bool fontsize = false );
00058     void setRelativeSize( double s, bool fontsize = false );
00059     void setPixelSize( double s, bool fontsize = false );
00060 
00061     void setCharStyle( CharStyle cs ) { 
00062         m_charStyle = cs;
00063         m_customMathVariant = true; 
00064     }
00065     CharStyle charStyle() const { return m_charStyle; }
00066 
00067     void setCharFamily( CharFamily cf ) { 
00068         m_charFamily = cf; 
00069         m_customMathVariant = true;
00070     }
00071     CharFamily charFamily() const { return m_charFamily; }
00072 
00073     void setMathColor( const QColor& c ) {
00074         m_mathColor = c; 
00075         m_customMathColor = true;
00076     }
00077     QColor mathColor() const { return m_mathColor; }
00078 
00079     void setMathBackground( const QColor& bg ) { 
00080         m_mathBackground = bg; 
00081         m_customMathBackground = true;
00082     }
00083     QColor mathBackground() const { return m_mathBackground; }
00084 
00085     void setFontWeight( bool w ) { 
00086         m_fontWeight = w;
00087         m_customFontWeight = true; 
00088     }
00089     bool fontWeight() const { return m_fontWeight; }
00090 
00091     void setFontStyle( bool s ) { 
00092         m_fontStyle = s;
00093         m_customFontStyle = true;
00094     }
00095     bool fontStyle() const { return m_fontStyle; }
00096 
00097     void setFontFamily( const QString& s ) { 
00098         m_fontFamily = s;
00099         m_customFontFamily = true;
00100     }
00101     QString fontFamily() const { return m_fontFamily; }
00102 
00103     void setColor( const QColor& c ) { 
00104         m_color = c; 
00105         m_customColor = true;
00106     }
00107     QColor color() const { return m_color; }
00108 
00109     bool customMathVariant() const { return m_customMathVariant; }
00110     bool customMathColor() const { return m_customMathColor; }
00111     bool customMathBackground() const { return m_customMathBackground; }
00112     bool customFontWeight() const { return m_customFontWeight; }
00113     bool customFontStyle() const { return m_customFontStyle; }
00114     bool customFontFamily() const { return m_customFontFamily; }
00115     bool customColor() const { return m_customColor; }
00116 
00117     virtual void setStyleSize( const ContextStyle& context, StyleAttributes& style );
00123     virtual void setStyleVariant( StyleAttributes& style );
00124 
00125     void setStyleColor( StyleAttributes& style );
00126     virtual void setStyleBackground( StyleAttributes& style );
00127 
00128     virtual void resetStyle( StyleAttributes& style );
00132     QString getHtmlColor( const QString& colorStr );
00133 
00134 private:
00135 
00136     double sizeFactor( const ContextStyle& context, double factor );
00137 
00138     // MathML 2.0 attributes
00139     SizeType m_mathSizeType;
00140     double m_mathSize;
00141     CharStyle m_charStyle;
00142     CharFamily m_charFamily;
00143     QColor m_mathColor;
00144     QColor m_mathBackground;
00145 
00146     // Deprecated MathML 1.01 attributes
00147     SizeType m_fontSizeType;
00148     double m_fontSize;
00149     QString m_fontFamily;
00150     QColor m_color;
00151     bool m_fontWeight;
00152     bool m_fontStyle;
00153 
00154     // MathML 2.0 attributes set ?
00155     bool m_customMathVariant;
00156     bool m_customMathColor;
00157     bool m_customMathBackground;
00158 
00159     // Deprecated MathML 1.01 attributes set ?
00160     bool m_customFontWeight;
00161     bool m_customFontStyle;
00162     bool m_customFontFamily;
00163     bool m_customColor;
00164 };
00165 
00166 KFORMULA_NAMESPACE_END
00167 
00168 #endif // TOKENSTYLEELEMENT_H
KDE Home | KDE Accessibility Home | Description of Access Keys