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

  1. /****************************************************************************
  2. ** $Id:  qt/qfont.h   3.0.0   edited Jul 31 16:40 $
  3. **
  4. ** Definition of QFont 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 QFONT_H
  39. #define QFONT_H
  40.  
  41. #ifndef QT_H
  42. #include "qwindowdefs.h"
  43. #include "qstring.h"
  44. #endif // QT_H
  45.  
  46.  
  47. class QFontPrivate;                                     /* don't touch */
  48. class QStringList;
  49.  
  50. class Q_EXPORT QFont
  51. {
  52. public:
  53.     enum StyleHint {
  54.     Helvetica,  SansSerif = Helvetica,
  55.     Times,      Serif = Times,
  56.     Courier,    TypeWriter = Courier,
  57.     OldEnglish, Decorative = OldEnglish,
  58.     System,
  59.     AnyStyle
  60.     };
  61.  
  62.     enum StyleStrategy {
  63.     PreferDefault = 0x0001,
  64.     PreferBitmap  = 0x0002,
  65.     PreferDevice  = 0x0004,
  66.     PreferOutline = 0x0008,
  67.     ForceOutline  = 0x0010,
  68.     PreferMatch   = 0x0020,
  69.     PreferQuality = 0x0040,
  70.     PreferAntialias = 0x0080,
  71.     NoAntialias = 0x0100
  72.     };
  73.  
  74.     enum Weight {
  75.     Light    = 25,
  76.     Normal   = 50,
  77.     DemiBold = 63,
  78.     Bold     = 75,
  79.     Black     = 87
  80.     };
  81.  
  82.     // default font
  83.     QFont();
  84.     // specific font
  85.     QFont( const QString &family, int pointSize = 12, int weight = Normal,
  86.        bool italic = FALSE );
  87.     // copy constructor
  88.     QFont( const QFont & );
  89.  
  90.     ~QFont();
  91.  
  92.     QString family() const;
  93.     void setFamily( const QString &);
  94.  
  95.     int pointSize() const;
  96.     float pointSizeFloat() const;
  97.     void setPointSize( int );
  98.     void setPointSizeFloat( float );
  99.  
  100.     int pixelSize() const;
  101.     void setPixelSize( int );
  102.     void setPixelSizeFloat( float );
  103.  
  104.     int weight() const;
  105.     void setWeight( int );
  106.  
  107.     bool bold() const;
  108.     void setBold( bool );
  109.  
  110.     bool italic() const;
  111.     void setItalic( bool );
  112.  
  113.     bool underline() const;
  114.     void setUnderline( bool );
  115.  
  116.     bool strikeOut() const;
  117.     void setStrikeOut( bool );
  118.  
  119.     bool fixedPitch() const;
  120.     void setFixedPitch( bool );
  121.  
  122.     StyleHint styleHint() const;
  123.     StyleStrategy styleStrategy() const;
  124.     void setStyleHint( StyleHint, StyleStrategy = PreferDefault );
  125.     void setStyleStrategy( StyleStrategy s );
  126.  
  127.     // is raw mode still needed?
  128.     bool rawMode() const;
  129.     void setRawMode( bool );
  130.  
  131.     // dupicated from QFontInfo
  132.     bool exactMatch() const;
  133.  
  134.     QFont &operator=( const QFont & );
  135.     bool operator==( const QFont & ) const;
  136.     bool operator!=( const QFont & ) const;
  137.     bool isCopyOf( const QFont & ) const;
  138.  
  139.  
  140. #ifdef Q_WS_WIN
  141.     HFONT handle() const;
  142. #else // !Q_WS_WIN
  143.     Qt::HANDLE handle() const;
  144. #endif // Q_WS_WIN
  145.  
  146.  
  147.     // needed for X11
  148.     void setRawName( const QString & );
  149.     QString rawName() const;
  150.  
  151.     QString key() const;
  152.  
  153. #ifndef QT_NO_STRINGLIST
  154.     QString toString() const;
  155.     bool fromString(const QString &);
  156.  
  157.     static QString substitute(const QString &);
  158.     static QStringList substitutes(const QString &);
  159.     static QStringList substitutions();
  160.     static void insertSubstitution(const QString&, const QString &);
  161.     static void insertSubstitutions(const QString&, const QStringList &);
  162.     static void removeSubstitution(const QString &);
  163. #endif //QT_NO_STRINGLIST
  164.     static void initialize();
  165.     static void cleanup();
  166.     static void cacheStatistics();
  167.  
  168.  
  169. #if defined(Q_WS_QWS)
  170.     void qwsRenderToDisk(bool all=TRUE);
  171. #endif
  172.  
  173.  
  174.     enum Script {
  175.     // European Alphabetic Scripts
  176.     Latin,
  177.     Greek,
  178.     Cyrillic,
  179.     Armenian,
  180.     Georgian,
  181.     Runic,
  182.     Ogham,
  183.     SpacingModifiers,
  184.     CombiningMarks,
  185.  
  186.     // Middle Eastern Scripts
  187.     Hebrew,
  188.     Arabic,
  189.     Syriac,
  190.     Thaana,
  191.  
  192.     // South and Southeast Asian Scripts
  193.     Devanagari,
  194.     Bengali,
  195.     Gurmukhi,
  196.     Gujarati,
  197.     Oriya,
  198.     Tamil,
  199.     Telugu,
  200.     Kannada,
  201.     Malayalam,
  202.     Sinhala,
  203.     Thai,
  204.     Lao,
  205.     Tibetan,
  206.     Myanmar,
  207.     Khmer,
  208.  
  209.     // East Asian Scripts
  210.     Han,
  211.     Hiragana,
  212.     Katakana,
  213.     Hangul,
  214.     Bopomofo,
  215.     Yi,
  216.  
  217.     // Additional Scripts
  218.     Ethiopic,
  219.     Cherokee,
  220.     CanadianAboriginal,
  221.     Mongolian,
  222.  
  223.     // Symbols
  224.     CurrencySymbols,
  225.     LetterlikeSymbols,
  226.     NumberForms,
  227.     MathematicalOperators,
  228.     TechnicalSymbols,
  229.     GeometricSymbols,
  230.     MiscellaneousSymbols,
  231.     EnclosedAndSquare,
  232.     Braille,
  233.  
  234.     Unicode,
  235.  
  236.     // End
  237.     NScripts,
  238.     UnknownScript = NScripts,
  239.  
  240.     NoScript,
  241.  
  242.     // ----------------------------------------
  243.     // Dear User, you can see values > Unicode,
  244.     // but they are internal - do not touch.
  245.  
  246.            // only used on X11 to get some char displayed for all of the Han area.
  247.     HanX11,
  248.  
  249.     LatinBasic = Latin,             // from ISO-8859-1
  250.     LatinExtendedA_2 = HanX11 + 1,  // from ISO-8859-2
  251.     LatinExtendedA_3,               // from ISO-8859-3
  252.     LatinExtendedA_4,               // from ISO-8859-4
  253.     LatinExtendedA_14,              // from ISO-8859-14
  254.     LatinExtendedA_15,              // from ISO-8859-15
  255.  
  256.     LastPrivateScript
  257.     };
  258.  
  259.     QString defaultFamily() const;
  260.     QString lastResortFamily() const;
  261.     QString lastResortFont() const;
  262.  
  263. #ifndef QT_NO_COMPAT
  264.  
  265.     static QFont defaultFont();
  266.     static void setDefaultFont( const QFont & );
  267.  
  268. #endif // QT_NO_COMPAT
  269.  
  270.  
  271. protected:
  272.     // why protected?
  273.     bool dirty() const;
  274.     int deciPointSize() const;
  275.  
  276.  
  277. private:
  278.     QFont( QFontPrivate *, bool deep = TRUE );
  279.     QFont( QFontPrivate *, QPaintDevice *pd );
  280.  
  281.     void detach();
  282.  
  283.  
  284. #if defined(Q_WS_MAC)
  285.     void macSetFont(QPaintDevice *);
  286. #endif
  287.  
  288.  
  289. #if defined(Q_WS_WIN)
  290.     void *textMetric() const;
  291. #endif
  292.  
  293.     friend class QFontMetrics;
  294.     friend class QFontInfo;
  295.     friend class QPainter;
  296.     friend class QPSPrinterFont;
  297.  
  298. #ifndef QT_NO_DATASTREAM
  299.     friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QFont & );
  300.     friend Q_EXPORT QDataStream &operator>>( QDataStream &, QFont & );
  301. #endif
  302.  
  303.     QFontPrivate *d;
  304. };
  305.  
  306.  
  307. inline bool QFont::bold() const
  308. { return weight() > Normal; }
  309.  
  310.  
  311. inline void QFont::setBold( bool enable )
  312. { setWeight( enable ? Bold : Normal ); }
  313.  
  314.  
  315.  
  316.  
  317. /*****************************************************************************
  318.   QFont stream functions
  319.  *****************************************************************************/
  320.  
  321. #ifndef QT_NO_DATASTREAM
  322. Q_EXPORT QDataStream &operator<<( QDataStream &, const QFont & );
  323. Q_EXPORT QDataStream &operator>>( QDataStream &, QFont & );
  324. #endif
  325.  
  326.  
  327. #endif // QFONT_H
  328.