lib Library API Documentation

contextstyle.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 CONTEXTSTYLE_H 00022 #define CONTEXTSTYLE_H 00023 00024 //Qt Include 00025 #include <qcolor.h> 00026 #include <qfont.h> 00027 #include <qstring.h> 00028 #include <qstringlist.h> 00029 00030 //KDE Include 00031 #include <kconfig.h> 00032 //#include <kozoomhandler.h> 00033 #include "kozoomhandler.h" 00034 00035 //Formula include 00036 #include "kformuladefs.h" 00037 00038 00039 KFORMULA_NAMESPACE_BEGIN 00040 00041 class FontStyle; 00042 class SymbolTable; 00043 00044 00053 class ContextStyle : public KoZoomHandler 00054 { 00055 public: 00056 00057 enum Alignment { left, center, right }; 00058 00071 enum TextStyle { 00072 displayStyle = 0, 00073 textStyle = 1, 00074 scriptStyle = 2, 00075 scriptScriptStyle = 3 00076 }; 00077 00078 enum IndexStyle {normal, cramped}; 00079 00083 ContextStyle(); 00084 ~ContextStyle(); 00085 00086 void init(); 00087 void readConfig( KConfig* config ); 00088 00089 bool edit() const { return m_edit; } 00090 void setEdit( bool e ) { m_edit = e; } 00091 00095 const SymbolTable& symbolTable() const; 00096 00097 const FontStyle& fontStyle() const { return *m_fontStyle; } 00098 00099 00100 void setZoomAndResolution( int zoom, int dpiX, int dpiY ); 00101 00106 bool setZoomAndResolution( int zoom, double zoomX, double zoomY, bool updateViews, bool forPrint ); 00107 00108 bool syntaxHighlighting() const { return m_syntaxHighlighting; } 00109 void setSyntaxHighlighting( bool highlight ) { m_syntaxHighlighting = highlight; } 00110 00111 QColor getDefaultColor() const { return defaultColor; } 00112 QColor getNumberColorPlain() const { return numberColor; } 00113 QColor getOperatorColorPlain() const { return operatorColor; } 00114 QColor getErrorColorPlain() const { return errorColor; } 00115 QColor getEmptyColorPlain() const { return emptyColor; } 00116 QColor getHelpColorPlain() const { return helpColor; } 00117 QColor getNumberColor() const; 00118 QColor getOperatorColor() const; 00119 QColor getErrorColor() const; 00120 QColor getEmptyColor() const; 00121 QColor getHelpColor() const; 00122 00123 void setDefaultColor( const QColor& ); 00124 void setNumberColor( const QColor& ); 00125 void setOperatorColor( const QColor& ); 00126 void setErrorColor( const QColor& ); 00127 void setEmptyColor( const QColor& ); 00128 void setHelpColor( const QColor& ); 00129 00130 QString getFontStyle() const { return m_fontStyleName; } 00131 void setFontStyle( const QString& fontStyle ); 00132 00133 QFont getDefaultFont() const { return defaultFont; } 00134 QFont getNameFont() const { return nameFont; } 00135 QFont getNumberFont() const { return numberFont; } 00136 QFont getOperatorFont() const { return operatorFont; } 00137 QFont getSymbolFont() const { return symbolFont; } 00138 00139 void setDefaultFont( QFont f ) { defaultFont = f; } 00140 void setNameFont( QFont f ) { nameFont = f; } 00141 void setNumberFont( QFont f ) { numberFont = f; } 00142 void setOperatorFont( QFont f ) { operatorFont = f; } 00143 00144 //const QStringList& requestedFonts() const; 00145 //void setRequestedFonts( const QStringList& list ); 00146 00147 double getReductionFactor( TextStyle tstyle ) const; 00148 00149 luPt getBaseSize() const; 00150 int baseSize() const { return m_baseSize; } 00151 void setBaseSize( int pointSize ); 00152 void setSizeFactor( double factor ); 00153 00154 TextStyle getBaseTextStyle() const { return m_baseTextStyle; } 00155 bool isScript( TextStyle tstyle ) const { return ( tstyle == scriptStyle ) || 00156 ( tstyle == scriptScriptStyle ); } 00157 00161 luPixel getSpace( TextStyle tstyle, SpaceWidth space ) const; 00162 luPixel getThinSpace( TextStyle tstyle ) const; 00163 luPixel getMediumSpace( TextStyle tstyle ) const; 00164 luPixel getThickSpace( TextStyle tstyle ) const; 00165 luPixel getQuadSpace( TextStyle tstyle ) const; 00166 00167 luPixel axisHeight( TextStyle tstyle ) const; 00168 00172 luPt getAdjustedSize( TextStyle tstyle ) const; 00173 00177 luPixel getLineWidth() const; 00178 00179 luPixel getEmptyRectWidth() const; 00180 luPixel getEmptyRectHeight() const; 00181 00182 Alignment getMatrixAlignment() const { return center; } 00183 00184 bool getCenterSymbol() const { return centerSymbol; } 00185 00192 TextStyle convertTextStyleFraction( TextStyle tstyle ) const; 00193 00200 TextStyle convertTextStyleIndex( TextStyle tstyle ) const; 00201 00211 IndexStyle convertIndexStyleUpper( IndexStyle istyle ) const { 00212 return istyle; } 00213 00214 00224 IndexStyle convertIndexStyleLower( IndexStyle /*istyle*/ ) const { 00225 return cramped; } 00226 00227 private: 00228 00229 void setup(); 00230 00231 struct TextStyleValues { 00232 00233 void setup( double reduction ) { reductionFactor = reduction; } 00234 00235 luPt thinSpace( luPt quad ) const { return static_cast<luPt>( reductionFactor*static_cast<double>( quad )/6. ); } 00236 luPt mediumSpace( luPt quad ) const { return static_cast<luPt>( reductionFactor*static_cast<double>( quad )*2./9. ); } 00237 luPt thickSpace( luPt quad ) const { return static_cast<luPt>( reductionFactor*static_cast<double>( quad )*5./18. ); } 00238 luPt quadSpace( luPt quad ) const { return quad; } 00239 00240 luPixel axisHeight( luPixel height ) const { return static_cast<luPixel>( reductionFactor*height ); } 00241 double reductionFactor; 00242 }; 00243 00244 TextStyleValues textStyleValues[ 4 ]; 00245 00246 QFont defaultFont; 00247 QFont nameFont; 00248 QFont numberFont; 00249 QFont operatorFont; 00250 QFont symbolFont; 00251 00252 //QStringList m_requestedFonts; 00253 00254 QColor defaultColor; 00255 QColor numberColor; 00256 QColor operatorColor; 00257 QColor errorColor; 00258 QColor emptyColor; 00259 QColor helpColor; 00260 00265 bool linearMovement; 00266 00270 int m_baseSize; 00271 00276 double m_sizeFactor; 00277 00281 TextStyle m_baseTextStyle; 00282 00286 pt lineWidth; 00287 00291 luPt quad; 00292 00296 luPixel m_axisHeight; 00297 00302 bool centerSymbol; 00303 00307 bool m_syntaxHighlighting; 00308 00312 bool m_edit; 00313 00317 //SymbolTable table; 00318 00319 FontStyle* m_fontStyle; 00320 QString m_fontStyleName; 00321 }; 00322 00323 KFORMULA_NAMESPACE_END 00324 00325 #endif // CONTEXTSTYLE_H
KDE Logo
This file is part of the documentation for lib Library Version 1.3.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Sep 28 04:03:58 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003