28#include <tqstringlist.h>
29#include <tqvaluestack.h>
33#include <KoTextZoomHandler.h>
36#include "kformuladefs.h"
39KFORMULA_NAMESPACE_BEGIN
57 enum Alignment { left, center, right };
78 enum IndexStyle {normal, cramped};
98 bool edit()
const {
return m_edit; }
99 void setEdit(
bool e ) { m_edit = e; }
106 const FontStyle& fontStyle()
const {
return *m_fontStyle; }
117 bool syntaxHighlighting()
const {
return m_syntaxHighlighting; }
118 void setSyntaxHighlighting(
bool highlight ) { m_syntaxHighlighting = highlight; }
120 TQColor getDefaultColor()
const {
return defaultColor; }
121 TQColor getNumberColorPlain()
const {
return numberColor; }
122 TQColor getOperatorColorPlain()
const {
return operatorColor; }
123 TQColor getErrorColorPlain()
const {
return errorColor; }
124 TQColor getEmptyColorPlain()
const {
return emptyColor; }
125 TQColor getHelpColorPlain()
const {
return helpColor; }
126 TQColor getNumberColor()
const;
127 TQColor getOperatorColor()
const;
128 TQColor getErrorColor()
const;
129 TQColor getEmptyColor()
const;
130 TQColor getHelpColor()
const;
132 void setDefaultColor(
const TQColor& );
133 void setNumberColor(
const TQColor& );
134 void setOperatorColor(
const TQColor& );
135 void setErrorColor(
const TQColor& );
136 void setEmptyColor(
const TQColor& );
137 void setHelpColor(
const TQColor& );
139 TQString getFontStyle()
const {
return m_fontStyleName; }
140 void setFontStyle(
const TQString& fontStyle,
bool init =
true );
142 TQFont getMathFont()
const {
return mathFont; }
143 TQFont getBracketFont()
const {
return bracketFont; }
144 TQFont getDefaultFont()
const {
return defaultFont; }
145 TQFont getNameFont()
const {
return nameFont; }
146 TQFont getNumberFont()
const {
return numberFont; }
147 TQFont getOperatorFont()
const {
return operatorFont; }
148 TQFont getSymbolFont()
const {
return symbolFont; }
150 void setMathFont( TQFont f ) { defaultFont = f; }
151 void setBracketFont( TQFont f ) { bracketFont = f; }
152 void setDefaultFont( TQFont f ) { defaultFont = f; }
153 void setNameFont( TQFont f ) { nameFont = f; }
154 void setNumberFont( TQFont f ) { numberFont = f; }
155 void setOperatorFont( TQFont f ) { operatorFont = f; }
160 double getReductionFactor(
TextStyle tstyle )
const;
162 luPt getBaseSize()
const;
163 int baseSize()
const {
return m_baseSize; }
164 void setBaseSize(
int pointSize );
165 void setSizeFactor(
double factor );
167 TextStyle getBaseTextStyle()
const {
return m_baseTextStyle; }
168 bool isScript(
TextStyle tstyle )
const {
return ( tstyle == scriptStyle ) ||
169 ( tstyle == scriptScriptStyle ); }
175 luPixel getThinSpace(
TextStyle tstyle,
double factor )
const;
176 luPixel getMediumSpace(
TextStyle tstyle,
double factor )
const;
177 luPixel getThickSpace(
TextStyle tstyle,
double factor )
const;
178 luPixel getQuadSpace(
TextStyle tstyle,
double factor )
const;
180 luPixel axisHeight(
TextStyle tstyle,
double factor )
const;
192 luPixel getEmptyRectWidth(
double factor )
const;
193 luPixel getEmptyRectHeight(
double factor )
const;
195 Alignment getMatrixAlignment()
const {
return center; }
197 bool getCenterSymbol()
const {
return centerSymbol; }
244 struct TextStyleValues {
246 void setup(
double reduction ) { reductionFactor = reduction; }
248 luPt thinSpace( luPt quad )
const {
return static_cast<luPt
>( reductionFactor*
static_cast<double>( quad )/6. ); }
249 luPt mediumSpace( luPt quad )
const {
return static_cast<luPt
>( reductionFactor*
static_cast<double>( quad )*2./9. ); }
250 luPt thickSpace( luPt quad )
const {
return static_cast<luPt
>( reductionFactor*
static_cast<double>( quad )*5./18. ); }
251 luPt quadSpace( luPt quad )
const {
return quad; }
253 luPixel axisHeight( luPixel height )
const {
return static_cast<luPixel
>( reductionFactor*height ); }
254 double reductionFactor;
257 TextStyleValues textStyleValues[ 4 ];
269 TQColor defaultColor;
271 TQColor operatorColor;
311 luPixel m_axisHeight;
322 bool m_syntaxHighlighting;
335 TQString m_fontStyleName;
339const double scriptsizemultiplier = 0.71;
340const double scriptminsize = 8;
341const double veryverythinmathspace = 0.0555556;
342const double verythinmathspace = 0.111111;
343const double thinmathspace = 0.166667;
344const double mediummathspace = 0.222222;
345const double thickmathspace = 0.277778;
346const double verythickmathspace = 0.333333;
347const double veryverythickmathspace = 0.388889;
349class StyleAttributes {
351 double sizeFactor()
const ;
352 bool customMathVariant()
const ;
353 CharStyle charStyle()
const ;
354 CharFamily charFamily()
const ;
355 TQColor color()
const ;
356 TQColor background()
const ;
357 TQFont font()
const ;
358 bool fontWeight()
const ;
359 bool customFontWeight()
const ;
360 bool fontStyle()
const ;
361 bool customFontStyle()
const ;
362 bool customFont()
const ;
364 int scriptLevel()
const ;
365 double scriptSizeMultiplier()
const ;
366 double scriptMinSize()
const ;
367 double veryVeryThinMathSpace()
const ;
368 double veryThinMathSpace()
const ;
369 double thinMathSpace()
const ;
370 double mediumMathSpace()
const ;
371 double thickMathSpace()
const ;
372 double veryThickMathSpace()
const ;
373 double veryVeryThickMathSpace()
const ;
374 bool displayStyle()
const ;
375 bool customDisplayStyle()
const ;
377 double getSpace( SizeType type,
double length )
const ;
379 void setSizeFactor(
double s ) { m_size.push( s ); }
380 void setCustomMathVariant(
bool cmv ) { m_customMathVariant.push( cmv ); }
381 void setCharStyle( CharStyle cs ) { m_charStyle.push( cs ); }
382 void setCharFamily( CharFamily cf ) { m_charFamily.push( cf ); }
383 void setColor(
const TQColor& c ) { m_color.push( c ); }
384 void setBackground(
const TQColor& bg ) { m_background.push( bg ); }
385 void setFont(
const TQFont& f ) { m_font.push( f ); }
386 void setCustomFont(
bool cf ) { m_customFontFamily.push ( cf ); }
387 void setCustomFontWeight(
bool cfw ) { m_customFontWeight.push( cfw ); }
388 void setFontWeight(
bool fw ) { m_fontWeight.push( fw ); }
389 void setCustomFontStyle(
bool cfs ) { m_customFontStyle.push( cfs ); }
390 void setFontStyle(
bool fs ) { m_fontStyle.push( fs ); }
392 void setScriptLevel(
int s ) { m_scriptLevel.push( s ); }
393 void setScriptSizeMultiplier(
double s ) { m_scriptSizeMultiplier.push( s ); }
394 void setScriptMinSize(
double s ) { m_scriptMinSize.push( s ); }
395 void setVeryVeryThinMathSpace(
double s ) { m_veryVeryThinMathSpace.push( s ); }
396 void setVeryThinMathSpace(
double s ) { m_veryThinMathSpace.push( s ); }
397 void setThinMathSpace(
double s ) { m_thinMathSpace.push( s ); }
398 void setMediumMathSpace(
double s ) { m_mediumMathSpace.push( s ); }
399 void setThickMathSpace(
double s ) { m_thickMathSpace.push( s ); }
400 void setVeryThickMathSpace(
double s ) { m_veryThickMathSpace.push( s ); }
401 void setVeryVeryThickMathSpace(
double s ) { m_veryVeryThickMathSpace.push( s ); }
402 void setDisplayStyle(
bool ds ) { m_displayStyle.push( ds ); }
403 void setCustomDisplayStyle(
bool cds ) { m_customDisplayStyle.push( cds ); }
407 void resetCharStyle();
408 void resetCharFamily();
410 void resetBackground();
411 void resetFontFamily();
412 void resetFontWeight();
413 void resetFontStyle();
415 void resetScriptLevel();
416 void resetScriptSizeMultiplier();
417 void resetScriptMinSize();
418 void resetVeryVeryThinMathSpace();
419 void resetVeryThinMathSpace();
420 void resetThinMathSpace();
421 void resetMediumMathSpace();
422 void resetThickMathSpace();
423 void resetVeryThickMathSpace();
424 void resetVeryVeryThickMathSpace();
425 void resetDisplayStyle();
429 TQValueStack<double> m_size;
432 TQValueStack<bool> m_customMathVariant;
435 TQValueStack<CharStyle> m_charStyle;
438 TQValueStack<CharFamily> m_charFamily;
441 TQValueStack<TQColor> m_color;
444 TQValueStack<TQColor> m_background;
447 TQValueStack<TQFont> m_font;
450 TQValueStack<bool> m_customFontFamily;
453 TQValueStack<bool> m_fontWeight;
456 TQValueStack<bool> m_customFontWeight;
459 TQValueStack<bool> m_fontStyle;
462 TQValueStack<bool> m_customFontStyle;
464 TQValueStack<int> m_scriptLevel;
465 TQValueStack<double> m_scriptSizeMultiplier;
466 TQValueStack<double> m_scriptMinSize;
467 TQValueStack<double> m_veryVeryThinMathSpace;
468 TQValueStack<double> m_veryThinMathSpace;
469 TQValueStack<double> m_thinMathSpace;
470 TQValueStack<double> m_mediumMathSpace;
471 TQValueStack<double> m_thickMathSpace;
472 TQValueStack<double> m_veryThickMathSpace;
473 TQValueStack<double> m_veryVeryThickMathSpace;
474 TQValueStack<bool> m_displayStyle;
475 TQValueStack<bool> m_customDisplayStyle;
478KFORMULA_NAMESPACE_END
Contains all the style information for the formela.
TextStyle convertTextStyleIndex(TextStyle tstyle) const
Font-conversions a la TeX.
luPt getAdjustedSize(TextStyle tstyle, double factor) const
Calculates the font size corresponding to the given TextStyle.
TextStyle
Textstyles like in TeX.
IndexStyle convertIndexStyleLower(IndexStyle) const
Index-style-conversions a la TeX.
luPixel getLineWidth(double factor) const
All simple lines like the one that makes up a fraction.
void init(bool init=true)
ContextStyle()
Build a default context style.
IndexStyle convertIndexStyleUpper(IndexStyle istyle) const
Index-style-conversions a la TeX.
void setZoomAndResolution(int zoom, int dpiX, int dpiY)
Change the zoom factor to z (e.g.
void readConfig(TDEConfig *config, bool init=true)
luPixel getSpace(TextStyle tstyle, SpaceWidth space, double factor) const
TeX like spacings.
const SymbolTable & symbolTable() const
TextStyle convertTextStyleFraction(TextStyle tstyle) const
Font-conversions a la TeX.
Base class for all supported font styles.
This class extends KoZoomHandler to add support for WYSIWYG text layouting.