kateattribute.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2003 Hamish Rodda <rodda@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef __KATE_ATTRIBUTE_H__ 00020 #define __KATE_ATTRIBUTE_H__ 00021 00022 #include "katefont.h" 00023 00024 #include <tqcolor.h> 00025 00032 class KateAttribute 00033 { 00034 public: 00035 enum items { 00036 Weight = 0x1, 00037 Bold = 0x2, 00038 Italic = 0x4, 00039 Underline = 0x8, 00040 StrikeOut = 0x10, 00041 Outline = 0x20, 00042 TextColor = 0x40, 00043 SelectedTextColor = 0x80, 00044 BGColor = 0x100, 00045 SelectedBGColor = 0x200, 00046 Overline = 0x400 00047 }; 00048 00049 KateAttribute(); 00050 virtual ~KateAttribute(); 00051 00052 TQFont font(const TQFont& ref); 00053 00054 inline int width(KateFontStruct& fs, const TQString& text, int col, int tabWidth) const 00055 { return fs.width(text, col, bold(), italic(), tabWidth); }; 00056 00057 // Non-preferred function when you have a string and you want one char's width!! 00058 inline int width(KateFontStruct& fs, const TQChar& c, int tabWidth) const 00059 { return fs.width(c, bold(), italic(), tabWidth); }; 00060 00061 inline bool itemSet(int item) const 00062 { return item & m_itemsSet; }; 00063 00064 inline bool isSomethingSet() const 00065 { return m_itemsSet; }; 00066 00067 inline int itemsSet() const 00068 { return m_itemsSet; }; 00069 00070 inline void clearAttribute(int item) 00071 { m_itemsSet &= (~item); } 00072 00073 inline int weight() const 00074 { return m_weight; }; 00075 00076 void setWeight(int weight); 00077 00078 inline bool bold() const 00079 { return weight() >= TQFont::Bold; }; 00080 00081 void setBold(bool enable = true); 00082 00083 inline bool italic() const 00084 { return m_italic; }; 00085 00086 void setItalic(bool enable = true); 00087 00088 inline bool overline() const 00089 { return m_overline; }; 00090 00091 void setOverline(bool enable = true); 00092 00093 inline bool underline() const 00094 { return m_underline; }; 00095 00096 void setUnderline(bool enable = true); 00097 00098 inline bool strikeOut() const 00099 { return m_strikeout; }; 00100 00101 void setStrikeOut(bool enable = true); 00102 00103 inline const TQColor& outline() const 00104 { return m_outline; }; 00105 00106 void setOutline(const TQColor& color); 00107 00108 inline const TQColor& textColor() const 00109 { return m_textColor; }; 00110 00111 void setTextColor(const TQColor& color); 00112 00113 inline const TQColor& selectedTextColor() const 00114 { return m_selectedTextColor; }; 00115 00116 void setSelectedTextColor(const TQColor& color); 00117 00118 inline const TQColor& bgColor() const 00119 { return m_bgColor; }; 00120 00121 void setBGColor(const TQColor& color); 00122 00123 inline const TQColor& selectedBGColor() const 00124 { return m_selectedBGColor; }; 00125 00126 void setSelectedBGColor(const TQColor& color); 00127 00128 KateAttribute& operator+=(const KateAttribute& a); 00129 00130 friend bool operator ==(const KateAttribute& h1, const KateAttribute& h2); 00131 friend bool operator !=(const KateAttribute& h1, const KateAttribute& h2); 00132 00133 virtual void changed() { m_changed = true; }; 00134 bool isChanged() { bool ret = m_changed; m_changed = false; return ret; }; 00135 00136 void clear(); 00137 00138 private: 00139 int m_weight; 00140 bool m_italic, m_underline, m_overline,m_strikeout, m_changed; 00141 TQColor m_outline, m_textColor, m_selectedTextColor, m_bgColor, m_selectedBGColor; 00142 int m_itemsSet; 00143 }; 00144 00145 #endif 00146 00147 // kate: space-indent on; indent-width 2; replace-tabs on;