TDE graphics utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kptextstyle.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. Copyright (c) 2003,2004,2005 Clarence Dang <dang@kde.org>
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  13. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #ifndef __kp_text_style_h__
  24. #define __kp_text_style_h__
  25. #include <tqstring.h>
  26. #include <kpcolor.h>
  27. class TQDataStream;
  28. class TQFont;
  29. class TQFontMetrics;
  30. class kpTextStyle
  31. {
  32. public:
  33. kpTextStyle ();
  34. kpTextStyle (const TQString &fontFamily,
  35. int fontSize,
  36. bool isBold, bool isItalic,
  37. bool isUnderline, bool isStrikeThru,
  38. const kpColor &fcolor,
  39. const kpColor &bcolor,
  40. bool isBackgroundOpaque);
  41. ~kpTextStyle ();
  42. friend TQDataStream &operator<< (TQDataStream &stream, const kpTextStyle &textStyle);
  43. friend TQDataStream &operator>> (TQDataStream &stream, kpTextStyle &textStyle);
  44. bool operator== (const kpTextStyle &rhs) const;
  45. bool operator!= (const kpTextStyle &rhs) const;
  46. TQString fontFamily () const;
  47. void setFontFamily (const TQString &f);
  48. int fontSize () const;
  49. void setFontSize (int s);
  50. bool isBold () const;
  51. void setBold (bool yes = true);
  52. bool isItalic () const;
  53. void setItalic (bool yes = true);
  54. bool isUnderline () const;
  55. void setUnderline (bool yes = true);
  56. bool isStrikeThru () const;
  57. void setStrikeThru (bool yes = true);
  58. kpColor foregroundColor () const;
  59. void setForegroundColor (const kpColor &fcolor);
  60. // Note: This is the _input_ backgroundColor without applying any
  61. // isBackground(Opaque|Transparent)() transformation.
  62. // See effectiveBackgroundColor().
  63. kpColor backgroundColor () const;
  64. void setBackgroundColor (const kpColor &bcolor);
  65. bool isBackgroundOpaque () const;
  66. void setBackgroundOpaque (bool yes = true);
  67. bool isBackgroundTransparent () const;
  68. void setBackgroundTransparent (bool yes = true);
  69. // If isBackgroundOpaque(), returns backgroundColor().
  70. // Else, returns kpColor::transparent.
  71. kpColor effectiveBackgroundColor () const;
  72. TQFont font () const;
  73. TQFontMetrics fontMetrics () const;
  74. private:
  75. TQString m_fontFamily;
  76. int m_fontSize;
  77. bool m_isBold, m_isItalic, m_isUnderline, m_isStrikeThru;
  78. kpColor m_foregroundColor, m_backgroundColor;
  79. bool m_isBackgroundOpaque;
  80. };
  81. #endif // __kp_text_style_h__