lib
tokenstyleelement.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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
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
00155 bool m_customMathVariant;
00156 bool m_customMathColor;
00157 bool m_customMathBackground;
00158
00159
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
|