kate Library API Documentation

katefont.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2002 Christian Couder <christian@kdevelop.org> 00003 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 00004 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> 00005 Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License version 2 as published by the Free Software Foundation. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 00022 #ifndef __kate_font_h__ 00023 #define __kate_font_h__ 00024 00025 #include <qfont.h> 00026 #include <qfontmetrics.h> 00027 00028 // 00029 // KateFontMetrics implementation 00030 // 00031 00032 class KateFontMetrics : public QFontMetrics 00033 { 00034 public: 00035 KateFontMetrics(const QFont& f); 00036 ~KateFontMetrics(); 00037 00038 int width(QChar c); 00039 00040 int width(QString s) { return QFontMetrics::width(s); } 00041 00042 private: 00043 short *createRow (short *wa, uchar row); 00044 00045 private: 00046 short *warray[256]; 00047 }; 00048 00049 // 00050 // KateFontStruct definition 00051 // 00052 00053 class KateFontStruct 00054 { 00055 public: 00056 KateFontStruct(); 00057 ~KateFontStruct(); 00058 00059 void setFont(const QFont & font); 00060 00061 private: 00062 void updateFontData (); 00063 00064 public: 00065 inline int width (const QString& text, int col, bool bold, bool italic, int tabWidth) 00066 { 00067 if (text[col] == QChar('\t')) 00068 return tabWidth * myFontMetrics.width(' '); 00069 00070 return (bold) ? 00071 ( (italic) ? 00072 myFontMetricsBI.charWidth(text, col) : 00073 myFontMetricsBold.charWidth(text, col) ) : 00074 ( (italic) ? 00075 myFontMetricsItalic.charWidth(text, col) : 00076 myFontMetrics.charWidth(text, col) ); 00077 } 00078 00079 inline int width (const QChar& c, bool bold, bool italic, int tabWidth) 00080 { 00081 if (c == QChar('\t')) 00082 return tabWidth * myFontMetrics.width(' '); 00083 00084 return (bold) ? 00085 ( (italic) ? 00086 myFontMetricsBI.width(c) : 00087 myFontMetricsBold.width(c) ) : 00088 ( (italic) ? 00089 myFontMetricsItalic.width(c) : 00090 myFontMetrics.width(c) ); 00091 } 00092 00093 inline const QFont& font(bool bold, bool italic) const 00094 { 00095 return (bold) ? 00096 ( (italic) ? myFontBI : myFontBold ) : 00097 ( (italic) ? myFontItalic : myFont ); 00098 } 00099 00100 inline bool fixedPitch() const { return m_fixedPitch; } 00101 00102 public: 00103 QFont myFont, myFontBold, myFontItalic, myFontBI; 00104 00105 KateFontMetrics myFontMetrics, myFontMetricsBold, myFontMetricsItalic, myFontMetricsBI; 00106 00107 int fontHeight; 00108 int fontAscent; 00109 00110 private: 00111 bool m_fixedPitch; 00112 }; 00113 00114 #endif
KDE Logo
This file is part of the documentation for kate Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Apr 12 23:40:00 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003