font.h Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# font.h

    00001 /*
    00002  * This file is part of the html renderer for KDE.
    00003  *
    00004  * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
    00005  *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    00006  *           (C) 2000 Dirk Mueller (mueller@kde.org)
    00007  *
    00008  * This library is free software; you can redistribute it and/or
    00009  * modify it under the terms of the GNU Library General Public
    00010  * License as published by the Free Software Foundation; either
    00011  * version 2 of the License, or (at your option) any later version.
    00012  *
    00013  * This library is distributed in the hope that it will be useful,
    00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00016  * Library General Public License for more details.
    00017  *
    00018  * You should have received a copy of the GNU Library General Public License
    00019  * along with this library; see the file COPYING.LIB.  If not, write to
    00020  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00021  * Boston, MA 02111-1307, USA.
    00022  *
    00023  * $Id: font.h,v 1.8.4.1 2003/05/18 12:34:40 mueller Exp $
    00024  */
    00025
    00026 #ifndef KHTMLFONT_H
    00027 #define KHTMLFONT_H
    00028
    00029 #include <qfont.h>
    00030 #include <qfontmetrics.h>
    00031 #include <qpainter.h>
    00032
    00033 class QPaintDeviceMetrics;
    00034
    00035
    00036 namespace khtml
    00037 {
    00038 class RenderStyle;
    00039 class CSSStyleSelector;
    00040
    00041 class FontDef
    00042 {
    00043 public:
    00044     FontDef()
    00045         : size( 0 ), italic( false ), smallCaps( false ), weight( 50 ), hasNbsp( true ) {}
    00046     bool operator == ( const FontDef &other ) const {
    00047         return ( family == other.family &&
    00048                  size == other.size &&
    00049                  italic == other.italic &&
    00050                  smallCaps == other.smallCaps &&
    00051                  weight == other.weight );
    00052     }
    00053
    00054     QString family;
    00055     short int size;
    00056     bool italic                 : 1;
    00057     bool smallCaps              : 1;
    00058     unsigned int weight                 : 8;
    00059     mutable bool hasNbsp : 1;
    00060 };
    00061
    00062
    00063 class Font
    00064 {
    00065     friend class RenderStyle;
    00066     friend class CSSStyleSelector;
    00067
    00068 public:
    00069     Font() : fontDef(), f(), fm( f ), scFont( 0 ), letterSpacing( 0 ), wordSpacing( 0 ) {}
    00070     Font( const FontDef &fd )
    00071         :  fontDef( fd ), f(), fm( f ), scFont( 0 ), letterSpacing( 0 ), wordSpacing( 0 )
    00072         {}
    00073
    00074     bool operator == ( const Font &other ) const {
    00075         return (fontDef == other.fontDef &&
    00076                 letterSpacing == other.letterSpacing &&
    00077                 wordSpacing == other.wordSpacing );
    00078     }
    00079
    00080     void update( QPaintDeviceMetrics *devMetrics ) const;
    00081
    00082     void drawText( QPainter *p, int x, int y, QChar *str, int slen, int pos, int len, int width,
    00083                    QPainter::TextDirection d, int from=-1, int to=-1, QColor bg=QColor() ) const;
    00084
    00085     int width( QChar *str, int slen, int pos, int len ) const;
    00086     int width( QChar *str, int slen, int pos ) const;
    00087
    00088 private:
    00089     FontDef fontDef;
    00090     mutable QFont f;
    00091     mutable QFontMetrics fm;
    00092     QFont *scFont;
    00093     short letterSpacing;
    00094     short wordSpacing;
    00095 };
    00096
    00097 }
    00098
    00099
    00100 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:33:49 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001