lib

tokenstyleelement.h
1/* This file is part of the KDE project
2 Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef TOKENSTYLEELEMENT_H
21#define TOKENSTYLEELEMENT_H
22
23#include "kformuladefs.h"
24#include "sequenceelement.h"
25
26KFORMULA_NAMESPACE_BEGIN
27
35class TokenStyleElement : public SequenceElement {
36 typedef SequenceElement inherited;
37public:
38
39 TokenStyleElement( BasicElement* parent = 0 );
40
41 virtual void calcSizes( const ContextStyle& context,
43 ContextStyle::IndexStyle istyle,
44 StyleAttributes& style );
45
46 virtual void draw( TQPainter& painter, const LuPixelRect& r,
47 const ContextStyle& context,
49 ContextStyle::IndexStyle istyle,
50 StyleAttributes& style,
51 const LuPixelPoint& parentOrigin );
52
53protected:
54 virtual bool readAttributesFromMathMLDom( const TQDomElement &element );
55 virtual void writeMathMLAttributes( TQDomElement& element ) const ;
56
57 void setAbsoluteSize( double s, bool fontsize = false );
58 void setRelativeSize( double s, bool fontsize = false );
59 void setPixelSize( double s, bool fontsize = false );
60
61 void setCharStyle( CharStyle cs ) {
62 m_charStyle = cs;
63 m_customMathVariant = true;
64 }
65 CharStyle charStyle() const { return m_charStyle; }
66
67 void setCharFamily( CharFamily cf ) {
68 m_charFamily = cf;
69 m_customMathVariant = true;
70 }
71 CharFamily charFamily() const { return m_charFamily; }
72
73 void setMathColor( const TQColor& c ) {
74 m_mathColor = c;
75 m_customMathColor = true;
76 }
77 TQColor mathColor() const { return m_mathColor; }
78
79 void setMathBackground( const TQColor& bg ) {
80 m_mathBackground = bg;
81 m_customMathBackground = true;
82 }
83 TQColor mathBackground() const { return m_mathBackground; }
84
85 void setFontWeight( bool w ) {
86 m_fontWeight = w;
87 m_customFontWeight = true;
88 }
89 bool fontWeight() const { return m_fontWeight; }
90
91 void setFontStyle( bool s ) {
92 m_fontStyle = s;
93 m_customFontStyle = true;
94 }
95 bool fontStyle() const { return m_fontStyle; }
96
97 void setFontFamily( const TQString& s ) {
98 m_fontFamily = s;
99 m_customFontFamily = true;
100 }
101 TQString fontFamily() const { return m_fontFamily; }
102
103 void setColor( const TQColor& c ) {
104 m_color = c;
105 m_customColor = true;
106 }
107 TQColor color() const { return m_color; }
108
109 bool customMathVariant() const { return m_customMathVariant; }
110 bool customMathColor() const { return m_customMathColor; }
111 bool customMathBackground() const { return m_customMathBackground; }
112 bool customFontWeight() const { return m_customFontWeight; }
113 bool customFontStyle() const { return m_customFontStyle; }
114 bool customFontFamily() const { return m_customFontFamily; }
115 bool customColor() const { return m_customColor; }
116
117 virtual void setStyleSize( const ContextStyle& context, StyleAttributes& style );
123 virtual void setStyleVariant( StyleAttributes& style );
124
125 void setStyleColor( StyleAttributes& style );
126 virtual void setStyleBackground( StyleAttributes& style );
127
128 virtual void resetStyle( StyleAttributes& style );
132 TQString getHtmlColor( const TQString& colorStr );
133
134private:
135
136 double sizeFactor( const ContextStyle& context, double factor );
137
138 // MathML 2.0 attributes
139 SizeType m_mathSizeType;
140 double m_mathSize;
141 CharStyle m_charStyle;
142 CharFamily m_charFamily;
143 TQColor m_mathColor;
144 TQColor m_mathBackground;
145
146 // Deprecated MathML 1.01 attributes
147 SizeType m_fontSizeType;
148 double m_fontSize;
149 TQString m_fontFamily;
150 TQColor m_color;
151 bool m_fontWeight;
152 bool m_fontStyle;
153
154 // MathML 2.0 attributes set ?
155 bool m_customMathVariant;
156 bool m_customMathColor;
157 bool m_customMathBackground;
158
159 // Deprecated MathML 1.01 attributes set ?
160 bool m_customFontWeight;
161 bool m_customFontStyle;
162 bool m_customFontFamily;
163 bool m_customColor;
164};
165
166KFORMULA_NAMESPACE_END
167
168#endif // TOKENSTYLEELEMENT_H
Contains all the style information for the formela.
TextStyle
Textstyles like in TeX.
TQString getHtmlColor(const TQString &colorStr)
Return RGB string from HTML Colors.
virtual void calcSizes(const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style)
Calculates our width and height and our children's parentPosition.
virtual bool readAttributesFromMathMLDom(const TQDomElement &element)
Reads our attributes from the MathML element.
virtual void setStyleVariant(StyleAttributes &style)
Set the mathvariant related info in style stacks, including info for deprecated attributes.