kateattribute.h
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #ifndef KATEATTRIBUTE_H
00020 #define KATEATTRIBUTE_H
00021 
00022 #include "katefont.h"
00023 
00024 #include <qcolor.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   };
00047 
00048   KateAttribute();
00049   virtual ~KateAttribute();
00050 
00051   QFont font(const QFont& ref);
00052 
00053   inline int width(FontStruct& fs, const QString& text, int col, int tabWidth) const
00054   { return fs.width(text, col, bold(), italic(), tabWidth); };
00055 
00056   
00057   inline int width(FontStruct& fs, const QChar& c, int tabWidth) const
00058   { return fs.width(c, bold(), italic(), tabWidth); };
00059 
00060   inline bool itemSet(int item) const
00061   { return item & m_itemsSet; };
00062 
00063   inline bool isSomethingSet() const
00064   { return m_itemsSet; };
00065 
00066   inline int itemsSet() const
00067   { return m_itemsSet; };
00068 
00069   inline void clearAttribute(int item)
00070   { m_itemsSet &= (~item); }
00071 
00072   inline int weight() const
00073   { return m_weight; };
00074 
00075   void setWeight(int weight);
00076 
00077   inline bool bold() const
00078   { return weight() >= QFont::Bold; };
00079   
00080   void setBold(bool enable = true);
00081 
00082   inline bool italic() const
00083   { return m_italic; };
00084   
00085   void setItalic(bool enable = true);
00086 
00087   inline bool underline() const
00088   { return m_underline; };
00089   
00090   void setUnderline(bool enable = true);
00091 
00092   inline bool strikeOut() const
00093   { return m_strikeout; };
00094 
00095   void setStrikeOut(bool enable = true);
00096 
00097   inline const QColor& outline() const
00098   { return m_outline; };
00099   
00100   void setOutline(const QColor& color);
00101 
00102   inline const QColor& textColor() const
00103   { return m_textColor; };
00104   
00105   void setTextColor(const QColor& color);
00106 
00107   inline const QColor& selectedTextColor() const
00108   { return m_selectedTextColor; };
00109 
00110   void setSelectedTextColor(const QColor& color);
00111 
00112   inline const QColor& bgColor() const
00113   { return m_bgColor; };
00114   
00115   void setBGColor(const QColor& color);
00116 
00117   inline const QColor& selectedBGColor() const
00118   { return m_selectedBGColor; };
00119   
00120   void setSelectedBGColor(const QColor& color);
00121 
00122   KateAttribute& operator+=(const KateAttribute& a);
00123 
00124   friend bool operator ==(const KateAttribute& h1, const KateAttribute& h2);
00125   friend bool operator !=(const KateAttribute& h1, const KateAttribute& h2);
00126 
00127   virtual void changed() { m_changed = true; };
00128   bool isChanged() { bool ret = m_changed; m_changed = false; return ret; };
00129 
00130   void clear();
00131 
00132 private:
00133   int m_weight;
00134   bool m_italic, m_underline, m_strikeout, m_changed;
00135   QColor m_outline, m_textColor, m_selectedTextColor, m_bgColor, m_selectedBGColor;
00136   int m_itemsSet;
00137 };
00138 
00139 #endif
 
This file is part of the documentation for kate Library Version 3.2.0.