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 // FontStruct definition
00051 //
00052 
00053 class FontStruct
00054 {
00055   public:
00056     FontStruct();
00057     ~FontStruct();
00058 
00059     int width(const QString& text, int col, bool bold, bool italic, int tabWidth);
00060     int width(const QChar& c, bool bold, bool italic, int tabWidth);
00061 
00062     inline const QFont& font(bool bold, bool italic) const
00063     {
00064       return (bold) ?
00065         ( (italic) ? myFontBI : myFontBold ) :
00066         ( (italic) ? myFontItalic : myFont );
00067     }
00068 
00069     void setFont(const QFont & font);
00070 
00071   private:
00072      void updateFontData ();
00073 
00074   public:
00075     QFont myFont, myFontBold, myFontItalic, myFontBI;
00076 
00077     KateFontMetrics myFontMetrics, myFontMetricsBold, myFontMetricsItalic, myFontMetricsBI;
00078 
00079     int fontHeight;
00080     int fontAscent;
00081 };
00082 
00083 #endif
KDE Logo
This file is part of the documentation for kate Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 3 19:25:02 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003