home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qfontmetrics.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  4KB  |  122 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qfontmetrics.h   3.0.0   edited Jun 22 12:24 $
  3. **
  4. ** Definition of QFontMetrics class
  5. **
  6. ** Created : 940514
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the kernel module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QFONTMETRICS_H
  39. #define QFONTMETRICS_H
  40.  
  41. #ifndef QT_H
  42. #include "qfont.h"
  43. #include "qrect.h"
  44. #endif // QT_H
  45.  
  46. class QFontStruct;
  47. class QTextCodec;
  48. class QTextParag;
  49.  
  50. class Q_EXPORT QFontMetrics
  51. {
  52. public:
  53.     QFontMetrics( const QFont & );
  54.     QFontMetrics( const QFontMetrics & );
  55.     ~QFontMetrics();
  56.  
  57.     QFontMetrics &operator=( const QFontMetrics & );
  58.  
  59.     int        ascent()    const;
  60.     int        descent()    const;
  61.     int        height()    const;
  62.     int        leading()    const;
  63.     int        lineSpacing()    const;
  64.     int        minLeftBearing() const;
  65.     int        minRightBearing() const;
  66.     int        maxWidth()    const;
  67.  
  68.     bool    inFont(QChar)    const;
  69.  
  70.     int        leftBearing(QChar) const;
  71.     int        rightBearing(QChar) const;
  72.     int        width( const QString &, int len = -1 ) const;
  73.     
  74.     int        width( QChar ) const;
  75. #ifndef QT_NO_COMPAT
  76.     int        width( char c ) const { return width( (QChar) c ); }
  77. #endif
  78.     
  79.     int         charWidth( const QString &str, int pos ) const;
  80.     QRect    boundingRect( const QString &, int len = -1 ) const;
  81.     QRect    boundingRect( QChar ) const;
  82.     QRect    boundingRect( int x, int y, int w, int h, int flags,
  83.                   const QString& str, int len=-1, int tabstops=0,
  84.                   int *tabarray=0, QTextParag **intern=0 ) const;
  85.     QSize    size( int flags,
  86.               const QString& str, int len=-1, int tabstops=0,
  87.               int *tabarray=0, QTextParag **intern=0 ) const;
  88.  
  89.     int        underlinePos()    const;
  90.     int        strikeOutPos()    const;
  91.     int        lineWidth()    const;
  92.  
  93. private:
  94.     QFontMetrics( const QPainter * );
  95.     static void reset( const QPainter * );
  96.  
  97. #if defined(Q_WS_WIN)
  98.     void   *textMetric() const;
  99.     HDC        hdc() const;
  100. #elif defined(Q_WS_QWS)
  101.     QFontStruct *internal();
  102. #endif
  103.  
  104.     friend class QWidget;
  105.     friend class QPainter;
  106. #if defined( Q_WS_MAC )
  107.     friend class QFontPrivate;
  108. #endif
  109.  
  110.     QFontPrivate  *d;
  111.     QPainter      *painter;
  112.     int           flags;
  113.  
  114.     bool    underlineFlag()  const { return (flags & 0x1) != 0; }
  115.     bool    strikeOutFlag()  const { return (flags & 0x2) != 0; }
  116.     void    setUnderlineFlag()       { flags |= 0x1; }
  117.     void    setStrikeOutFlag()       { flags |= 0x2; }
  118. };
  119.  
  120.  
  121. #endif // QFONTMETRICS_H
  122.