# kate Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kateattribute.cpp

    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., 59 Temple Place - Suite 330,
    00016    Boston, MA 02111-1307, USA.
    00017 */
    00018
    00019 #include "kateattribute.h"
    00020
    00021 KateAttribute::KateAttribute()
    00022   : m_weight(QFont::Normal)
    00023   , m_italic(false)
    00024   , m_underline(false)
    00025   , m_overline(false)
    00026   , m_strikeout(false)
    00027   , m_itemsSet(0)
    00028
    00029 {
    00030 }
    00031
    00032 KateAttribute::~KateAttribute()
    00033 {
    00034 }
    00035
    00036 void KateAttribute::clear()
    00037 {
    00038   m_itemsSet=0;
    00039 }
    00040
    00041 KateAttribute& KateAttribute::operator+=(const KateAttribute& a)
    00042 {
    00043   if (a.itemSet(Weight))
    00044     setWeight(a.weight());
    00045
    00046   if (a.itemSet(Italic))
    00047     setItalic(a.italic());
    00048
    00049   if (a.itemSet(Underline))
    00050     setUnderline(a.underline());
    00051
    00052   if (a.itemSet(Overline))
    00053     setOverline(a.overline());
    00054
    00055   if (a.itemSet(StrikeOut))
    00056     setStrikeOut(a.strikeOut());
    00057
    00058   if (a.itemSet(Outline))
    00059     setOutline(a.outline());
    00060
    00061   if (a.itemSet(TextColor))
    00062     setTextColor(a.textColor());
    00063
    00064   if (a.itemSet(SelectedTextColor))
    00065     setSelectedTextColor(a.selectedTextColor());
    00066
    00067   if (a.itemSet(BGColor))
    00068     setBGColor(a.bgColor());
    00069
    00070   if (a.itemSet(SelectedBGColor))
    00071     setSelectedBGColor(a.selectedBGColor());
    00072
    00073   return *this;
    00074 }
    00075
    00076 QFont KateAttribute::font(const QFont& ref)
    00077 {
    00078   QFont ret = ref;
    00079
    00080   if (itemSet(Weight))
    00081     ret.setWeight(weight());
    00082   if (itemSet(Italic))
    00083     ret.setItalic(italic());
    00084   if (itemSet(Underline))
    00085     ret.setUnderline(underline());
    00086    if (itemSet(Overline))
    00087     ret.setOverline(overline());
    00088   if (itemSet(StrikeOut))
    00089     ret.setStrikeOut(strikeOut());
    00090
    00091   return ret;
    00092 }
    00093
    00094 void KateAttribute::setWeight(int weight)
    00095 {
    00096   if (!(m_itemsSet & Weight) || m_weight != weight)
    00097   {
    00098     m_itemsSet |= Weight;
    00099
    00100     m_weight = weight;
    00101
    00102     changed();
    00103   }
    00104 }
    00105
    00106 void KateAttribute::setBold(bool enable)
    00107 {
    00108   setWeight(enable ? QFont::Bold : QFont::Normal);
    00109 }
    00110
    00111 void KateAttribute::setItalic(bool enable)
    00112 {
    00113   if (!(m_itemsSet & Italic) || m_italic != enable)
    00114   {
    00115     m_itemsSet |= Italic;
    00116
    00117     m_italic = enable;
    00118
    00119     changed();
    00120   }
    00121 }
    00122
    00123 void KateAttribute::setUnderline(bool enable)
    00124 {
    00125   if (!(m_itemsSet & Underline) || m_underline != enable)
    00126   {
    00127     m_itemsSet |= Underline;
    00128
    00129     m_underline = enable;
    00130
    00131     changed();
    00132   }
    00133 }
    00134
    00135 void KateAttribute::setOverline(bool enable)
    00136 {
    00137   if (!(m_itemsSet & Overline) || m_overline != enable)
    00138   {
    00139     m_itemsSet |= Overline;
    00140
    00141     m_overline = enable;
    00142
    00143     changed();
    00144   }
    00145 }
    00146
    00147 void KateAttribute::setStrikeOut(bool enable)
    00148 {
    00149   if (!(m_itemsSet & StrikeOut) || m_strikeout != enable)
    00150   {
    00151     m_itemsSet |= StrikeOut;
    00152
    00153     m_strikeout = enable;
    00154
    00155     changed();
    00156   }
    00157 }
    00158
    00159 void KateAttribute::setOutline(const QColor& color)
    00160 {
    00161   if (!(m_itemsSet & Outline) || m_outline != color)
    00162   {
    00163     m_itemsSet |= Outline;
    00164
    00165     m_outline = color;
    00166
    00167     changed();
    00168   }
    00169 }
    00170
    00171 void KateAttribute::setTextColor(const QColor& color)
    00172 {
    00173   if (!(m_itemsSet & TextColor) || m_textColor != color)
    00174   {
    00175     m_itemsSet |= TextColor;
    00176
    00177     m_textColor = color;
    00178
    00179     changed();
    00180   }
    00181 }
    00182
    00183 void KateAttribute::setSelectedTextColor(const QColor& color)
    00184 {
    00185   if (!(m_itemsSet & SelectedTextColor) || m_selectedTextColor != color)
    00186   {
    00187     m_itemsSet |= SelectedTextColor;
    00188
    00189     m_selectedTextColor = color;
    00190
    00191     changed();
    00192   }
    00193 }
    00194
    00195 void KateAttribute::setBGColor(const QColor& color)
    00196 {
    00197   if (!(m_itemsSet & BGColor) || m_bgColor != color)
    00198   {
    00199     m_itemsSet |= BGColor;
    00200
    00201     m_bgColor = color;
    00202
    00203     changed();
    00204   }
    00205 }
    00206
    00207 void KateAttribute::setSelectedBGColor(const QColor& color)
    00208 {
    00209   if (!(m_itemsSet & SelectedBGColor) || m_selectedBGColor != color)
    00210   {
    00211     m_itemsSet |= SelectedBGColor;
    00212
    00213     m_selectedBGColor = color;
    00214
    00215     changed();
    00216   }
    00217 }
    00218
    00219 bool operator ==(const KateAttribute& h1, const KateAttribute& h2)
    00220 {
    00221   if (h1.m_itemsSet != h2.m_itemsSet)
    00222     return false;
    00223
    00224   if (h1.itemSet(KateAttribute::Weight))
    00225     if (h1.m_weight != h2.m_weight)
    00226       return false;
    00227
    00228   if (h1.itemSet(KateAttribute::Italic))
    00229     if (h1.m_italic != h2.m_italic)
    00230       return false;
    00231
    00232   if (h1.itemSet(KateAttribute::Underline))
    00233     if (h1.m_underline != h2.m_underline)
    00234       return false;
    00235
    00236   if (h1.itemSet(KateAttribute::StrikeOut))
    00237     if (h1.m_strikeout != h2.m_strikeout)
    00238       return false;
    00239
    00240   if (h1.itemSet(KateAttribute::Outline))
    00241     if (h1.m_outline != h2.m_outline)
    00242       return false;
    00243
    00244   if (h1.itemSet(KateAttribute::TextColor))
    00245     if (h1.m_textColor != h2.m_textColor)
    00246       return false;
    00247
    00248   if (h1.itemSet(KateAttribute::SelectedTextColor))
    00249     if (h1.m_selectedTextColor != h2.m_selectedTextColor)
    00250       return false;
    00251
    00252   if (h1.itemSet(KateAttribute::BGColor))
    00253     if (h1.m_bgColor != h2.m_bgColor)
    00254       return false;
    00255
    00256   if (h1.itemSet(KateAttribute::SelectedBGColor))
    00257     if (h1.m_selectedBGColor != h2.m_selectedBGColor)
    00258       return false;
    00259
    00260   return true;
    00261 }
    00262
    00263 bool operator !=(const KateAttribute& h1, const KateAttribute& h2)
    00264 {
    00265   return !(h1 == h2);
    00266 }
    00267
    00268 // kate: space-indent on; indent-width 2; replace-tabs on;

This file is part of the documentation for kate Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:36:29 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003