lib

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., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, 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 <KoTextZoomHandler.h>
00033 
00034 //Formula include
00035 #include "kformuladefs.h"
00036 
00037 
00038 KFORMULA_NAMESPACE_BEGIN
00039 
00040 class FontStyle;
00041 class SymbolTable;
00042 
00043 
00052 class ContextStyle : public KoTextZoomHandler
00053 {
00054 public:
00055 
00056     enum Alignment { left, center, right };
00057 
00070     enum TextStyle {
00071         displayStyle = 0,
00072         textStyle = 1,
00073         scriptStyle = 2,
00074         scriptScriptStyle = 3
00075     };
00076 
00077     enum IndexStyle {normal, cramped};
00078 
00082     ContextStyle();
00083     ~ContextStyle();
00084 
00088     void init( bool init = true );
00089 
00095     void readConfig( KConfig* config, bool init = true );
00096 
00097     bool edit() const { return m_edit; }
00098     void setEdit( bool e ) { m_edit = e; }
00099 
00103     const SymbolTable& symbolTable() const;
00104 
00105     const FontStyle& fontStyle() const { return *m_fontStyle; }
00106 
00107 
00108     void setZoomAndResolution( int zoom, int dpiX, int dpiY );
00109 
00114     bool setZoomAndResolution( int zoom, double zoomX, double zoomY, bool updateViews, bool forPrint );
00115 
00116     bool syntaxHighlighting() const { return m_syntaxHighlighting; }
00117     void setSyntaxHighlighting( bool highlight ) { m_syntaxHighlighting = highlight; }
00118 
00119     QColor getDefaultColor()  const { return defaultColor; }
00120     QColor getNumberColorPlain()   const { return numberColor; }
00121     QColor getOperatorColorPlain() const { return operatorColor; }
00122     QColor getErrorColorPlain()    const { return errorColor; }
00123     QColor getEmptyColorPlain()    const { return emptyColor; }
00124     QColor getHelpColorPlain()     const { return helpColor; }
00125     QColor getNumberColor()   const;
00126     QColor getOperatorColor() const;
00127     QColor getErrorColor()    const;
00128     QColor getEmptyColor()    const;
00129     QColor getHelpColor()     const;
00130 
00131     void setDefaultColor( const QColor& );
00132     void setNumberColor( const QColor& );
00133     void setOperatorColor( const QColor& );
00134     void setErrorColor( const QColor& );
00135     void setEmptyColor( const QColor& );
00136     void setHelpColor( const QColor& );
00137 
00138     QString getFontStyle() const { return m_fontStyleName; }
00139     void setFontStyle( const QString& fontStyle, bool init = true );
00140 
00141     QFont getDefaultFont()    const { return defaultFont; }
00142     QFont getNameFont()       const { return nameFont; }
00143     QFont getNumberFont()     const { return numberFont; }
00144     QFont getOperatorFont()   const { return operatorFont; }
00145     QFont getSymbolFont()     const { return symbolFont; }
00146 
00147     void setDefaultFont( QFont f )  { defaultFont = f; }
00148     void setNameFont( QFont f )     { nameFont = f; }
00149     void setNumberFont( QFont f )   { numberFont = f; }
00150     void setOperatorFont( QFont f ) { operatorFont = f; }
00151 
00152     //const QStringList& requestedFonts() const;
00153     //void setRequestedFonts( const QStringList& list );
00154 
00155     double getReductionFactor( TextStyle tstyle ) const;
00156 
00157     luPt getBaseSize() const;
00158     int baseSize() const { return m_baseSize; }
00159     void setBaseSize( int pointSize );
00160     void setSizeFactor( double factor );
00161 
00162     TextStyle getBaseTextStyle() const { return m_baseTextStyle; }
00163     bool isScript( TextStyle tstyle ) const { return ( tstyle == scriptStyle ) ||
00164                                                      ( tstyle == scriptScriptStyle ); }
00165 
00169     luPixel getSpace( TextStyle tstyle, SpaceWidth space ) const;
00170     luPixel getThinSpace( TextStyle tstyle ) const;
00171     luPixel getMediumSpace( TextStyle tstyle ) const;
00172     luPixel getThickSpace( TextStyle tstyle ) const;
00173     luPixel getQuadSpace( TextStyle tstyle ) const;
00174 
00175     luPixel axisHeight( TextStyle tstyle ) const;
00176 
00180     luPt getAdjustedSize( TextStyle tstyle ) const;
00181 
00185     luPixel getLineWidth() const;
00186 
00187     luPixel getEmptyRectWidth() const;
00188     luPixel getEmptyRectHeight() const;
00189 
00190     Alignment getMatrixAlignment() const { return center; }
00191 
00192     bool getCenterSymbol() const { return centerSymbol; }
00193 
00200     TextStyle convertTextStyleFraction( TextStyle tstyle ) const;
00201 
00208     TextStyle convertTextStyleIndex( TextStyle tstyle ) const;
00209 
00219     IndexStyle convertIndexStyleUpper( IndexStyle istyle ) const {
00220     return istyle; }
00221 
00222 
00232     IndexStyle convertIndexStyleLower( IndexStyle /*istyle*/ ) const {
00233     return cramped; }
00234 
00235 private:
00236 
00237     void setup();
00238 
00239     struct TextStyleValues {
00240 
00241         void setup( double reduction ) { reductionFactor = reduction; }
00242 
00243         luPt thinSpace( luPt quad ) const   { return static_cast<luPt>( reductionFactor*static_cast<double>( quad )/6. ); }
00244         luPt mediumSpace( luPt quad ) const { return static_cast<luPt>( reductionFactor*static_cast<double>( quad )*2./9. ); }
00245         luPt thickSpace( luPt quad ) const  { return static_cast<luPt>( reductionFactor*static_cast<double>( quad )*5./18. ); }
00246         luPt quadSpace( luPt quad ) const   { return quad; }
00247 
00248         luPixel axisHeight( luPixel height ) const { return static_cast<luPixel>( reductionFactor*height ); }
00249         double reductionFactor;
00250     };
00251 
00252     TextStyleValues textStyleValues[ 4 ];
00253 
00254     QFont defaultFont;
00255     QFont nameFont;
00256     QFont numberFont;
00257     QFont operatorFont;
00258     QFont symbolFont;
00259 
00260     //QStringList m_requestedFonts;
00261 
00262     QColor defaultColor;
00263     QColor numberColor;
00264     QColor operatorColor;
00265     QColor errorColor;
00266     QColor emptyColor;
00267     QColor helpColor;
00268 
00273     bool linearMovement;
00274 
00278     int m_baseSize;
00279 
00284     double m_sizeFactor;
00285 
00289     TextStyle m_baseTextStyle;
00290 
00294     pt lineWidth;
00295 
00299     luPt quad;
00300 
00304     luPixel m_axisHeight;
00305 
00310     bool centerSymbol;
00311 
00315     bool m_syntaxHighlighting;
00316 
00320     bool m_edit;
00321 
00325     //SymbolTable table;
00326 
00327     FontStyle* m_fontStyle;
00328     QString m_fontStyleName;
00329 };
00330 
00331 KFORMULA_NAMESPACE_END
00332 
00333 #endif // CONTEXTSTYLE_H
KDE Home | KDE Accessibility Home | Description of Access Keys