F:/KPlato/koffice/libs/kformula/fontstyle.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Ulrich Kuettler <ulrich.kuettler@gmx.de>
00003    Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
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 FONTSTYLE_H
00022 #define FONTSTYLE_H
00023 
00024 #include <QString>
00025 #include <QFont>
00026 
00027 #include "contextstyle.h"
00028 #include "kformuladefs.h"
00029 #include "symboltable.h"
00030 
00031 
00032 KFORMULA_NAMESPACE_BEGIN
00033 
00034 class Artwork;
00035 class SymbolTable;
00036 
00037 
00041 class FontStyle {
00042 public:
00043 
00044     ~FontStyle() {}
00045 
00050     bool init( ContextStyle* context, bool install = true );
00051 
00053     const SymbolTable* symbolTable() const { return &m_symbolTable; }
00054     SymbolTable* symbolTable() { return &m_symbolTable; }
00055 
00056     Artwork* createArtwork(SymbolType type = EmptyBracket) const;
00057 
00058     static QStringList missingFonts( bool install = true );
00059 
00060     static bool m_installed;
00061 
00062     static void testFont( QStringList& missing, const QString& fontName );
00063 
00064 private:
00065 
00066     static QStringList missingFontsInternal();
00067     static void installFonts();
00068 
00069     SymbolTable m_symbolTable;
00070 };
00071 
00072 const QChar spaceChar = 0x0020;
00073 const QChar leftParenthesisChar = 0x0028;
00074 const QChar rightParenthesisChar = 0x0029;
00075 const QChar leftSquareBracketChar = 0x005B;
00076 const QChar rightSquareBracketChar = 0x005D;
00077 const QChar leftCurlyBracketChar = 0x007B;
00078 const QChar verticalLineChar = 0x007C;
00079 const QChar rightCurlyBracketChar = 0x007D;
00080 const QChar leftAngleBracketChar = 0x2329;
00081 const QChar rightAngleBracketChar = 0x232A;
00082 const QChar slashChar = 0x002F;
00083 const QChar backSlashChar = 0x005C;
00084 const QChar integralChar = 0x222B;
00085 const QChar summationChar = 0x2211;
00086 const QChar productChar = 0x220F;
00087 const QChar applyFunctionChar = 0x2061;
00088 const QChar invisibleTimes = 0x2062;
00089 const QChar invisibleComma = 0x2063;
00090 
00091 extern const QChar leftRoundBracket[];
00092 extern const QChar leftSquareBracket[];
00093 extern const QChar leftCurlyBracket[];
00094 
00095 extern const QChar leftLineBracket[];
00096 extern const QChar rightLineBracket[];
00097 
00098 extern const QChar rightRoundBracket[];
00099 extern const QChar rightSquareBracket[];
00100 extern const QChar rightCurlyBracket[];
00101 
00102 /*
00103  * A piece of art that may be used by any element.
00104  */
00105 class Artwork {
00106 public:
00107 
00108     Artwork(SymbolType type = EmptyBracket);
00109     virtual ~Artwork() {}
00110 
00111     virtual void calcSizes( const ContextStyle& style,
00112                             ContextStyle::TextStyle tstyle,
00113                             double factor,
00114                             luPt parentSize );
00115     virtual void calcSizes( const ContextStyle& style,
00116                             ContextStyle::TextStyle tstyle,
00117                             double factor );
00118 
00119     virtual void draw( QPainter& painter, const LuPixelRect& r,
00120                        const ContextStyle& context,
00121                        ContextStyle::TextStyle tstyle,
00122                                            StyleAttributes& style,
00123                        luPt parentSize, const LuPixelPoint& origin );
00124     virtual void draw( QPainter& painter, const LuPixelRect& r,
00125                        const ContextStyle& context,
00126                        ContextStyle::TextStyle tstyle,
00127                                            StyleAttributes& style,
00128                        const LuPixelPoint& parentOrigin );
00129 
00130     luPixel getWidth() const { return size.width(); }
00131     luPixel getHeight() const { return size.height(); }
00132 
00133     void setWidth( luPixel width ) { size.setWidth(width); }
00134     void setHeight( luPixel height ) { size.setHeight(height); }
00135 
00136     luPixel getBaseline() const { return baseline; }
00137     void setBaseline( luPixel line ) { baseline = line; }
00138 
00139     luPixel getX() const { return point.x(); }
00140     luPixel getY() const { return point.y(); }
00141 
00142     void setX( luPixel x ) { point.setX( x ); }
00143     void setY( luPixel y ) { point.setY( y ); }
00144 
00145     SymbolType getType() const { return type; }
00146     void setType(SymbolType t) { type = t; }
00147 
00148     virtual bool isNormalChar() const { return getBaseline() != -1 && ( cmChar == -1 ); }
00149 
00150     virtual double slant() const { return 0; }
00151 
00152 protected:
00153 
00154     void calcCharSize( const ContextStyle& style, luPt height, QChar ch );
00155     void drawCharacter( QPainter& painter, const ContextStyle& style,
00156                         luPixel x, luPixel y, luPt height, QChar ch );
00157 
00158     void calcCharSize( const ContextStyle& style, QFont f, QChar c );
00159     void drawCharacter( QPainter& painter, const ContextStyle& style,
00160                         QFont f,
00161                         luPixel x, luPixel y, luPt height, uchar c );
00162 
00163     void calcRoundBracket( const ContextStyle& style, const QChar chars[], luPt height, luPt charHeight );
00164     void calcCurlyBracket( const ContextStyle& style, const QChar chars[], luPt height, luPt charHeight );
00165 
00166     void drawBigRoundBracket( QPainter& p, const ContextStyle& style, const QChar chars[], luPixel x, luPixel y, luPt charHeight );
00167     void drawBigCurlyBracket( QPainter& p, const ContextStyle& style, const QChar chars[], luPixel x, luPixel y, luPt charHeight );
00168 
00169 private:
00170 
00171     LuPixelSize size;
00172     LuPixelPoint point;
00173 
00177     luPixel baseline;
00178 
00179     SymbolType type;
00180 
00181     bool calcCMDelimiterSize( const ContextStyle& context, uchar c,
00182                               luPt fontSize, luPt parentSize );
00183     void calcLargest( const ContextStyle& context, uchar c, luPt fontSize );
00184     void drawCMDelimiter( QPainter& painter, const ContextStyle& style,
00185                           luPixel x, luPixel y, luPt height );
00186 
00187     short cmChar;
00188 };
00189 
00190 
00191 KFORMULA_NAMESPACE_END
00192 
00193 #endif

Généré le Wed Nov 22 23:41:00 2006 pour KPlato par  doxygen 1.5.1-p1