File indexing completed on 2024-06-23 04:19:02

0001 
0002 /*
0003    Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
0004    All rights reserved.
0005 
0006    Redistribution and use in source and binary forms, with or without
0007    modification, are permitted provided that the following conditions
0008    are met:
0009 
0010    1. Redistributions of source code must retain the above copyright
0011       notice, this list of conditions and the following disclaimer.
0012    2. Redistributions in binary form must reproduce the above copyright
0013       notice, this list of conditions and the following disclaimer in the
0014       documentation and/or other materials provided with the distribution.
0015 
0016    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0017    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0018    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0019    IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0020    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0021    NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0022    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0023    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0024    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0025    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0026 */
0027 
0028 
0029 #ifndef KP_TEXT_STYLE_H
0030 #define KP_TEXT_STYLE_H
0031 
0032 
0033 #include <QString>
0034 
0035 #include "imagelib/kpColor.h"
0036 
0037 
0038 class QDataStream;
0039 class QFont;
0040 class QFontMetrics;
0041 
0042 
0043 class kpTextStyle
0044 {
0045 public:
0046     kpTextStyle ();
0047     kpTextStyle (const QString &fontFamily,
0048                  int fontSize,
0049                  bool isBold, bool isItalic,
0050                  bool isUnderline, bool isStrikeThru,
0051                  const kpColor &fcolor,
0052                  const kpColor &bcolor,
0053                  bool isBackgroundOpaque);
0054     ~kpTextStyle ();
0055 
0056 
0057     friend QDataStream &operator<< (QDataStream &stream, const kpTextStyle &textStyle);
0058     friend QDataStream &operator>> (QDataStream &stream, kpTextStyle &textStyle);
0059     bool operator== (const kpTextStyle &rhs) const;
0060     bool operator!= (const kpTextStyle &rhs) const;
0061 
0062 
0063     QString fontFamily () const;
0064     void setFontFamily (const QString &f);
0065 
0066     int fontSize () const;
0067     void setFontSize (int s);
0068 
0069     bool isBold () const;
0070     void setBold (bool yes = true);
0071 
0072     bool isItalic () const;
0073     void setItalic (bool yes = true);
0074 
0075     bool isUnderline () const;
0076     void setUnderline (bool yes = true);
0077 
0078     bool isStrikeThru () const;
0079     void setStrikeThru (bool yes = true);
0080 
0081     kpColor foregroundColor () const;
0082     void setForegroundColor (const kpColor &fcolor);
0083 
0084     // Note: This is the _input_ backgroundColor
0085     kpColor backgroundColor () const;
0086     void setBackgroundColor (const kpColor &bcolor);
0087 
0088     bool isBackgroundOpaque () const;
0089     void setBackgroundOpaque (bool yes = true);
0090 
0091     bool isBackgroundTransparent () const;
0092     void setBackgroundTransparent (bool yes = true);
0093 
0094 
0095     QFont font () const;
0096     QFontMetrics fontMetrics () const;
0097 
0098 private:
0099     QString m_fontFamily;
0100     int m_fontSize;
0101     bool m_isBold, m_isItalic, m_isUnderline, m_isStrikeThru;
0102     kpColor m_foregroundColor, m_backgroundColor;
0103     bool m_isBackgroundOpaque;
0104 };
0105 
0106 
0107 #endif  // KP_TEXT_STYLE_H