• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • part
kateattribute.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "kateattribute.h"
20 
21 KateAttribute::KateAttribute()
22  : m_weight(TQFont::Normal)
23  , m_italic(false)
24  , m_underline(false)
25  , m_overline(false)
26  , m_strikeout(false)
27  , m_itemsSet(0)
28 
29 {
30 }
31 
32 KateAttribute::~KateAttribute()
33 {
34 }
35 
36 void KateAttribute::clear()
37 {
38  m_itemsSet=0;
39 }
40 
41 KateAttribute& KateAttribute::operator+=(const KateAttribute& a)
42 {
43  if (a.itemSet(Weight))
44  setWeight(a.weight());
45 
46  if (a.itemSet(Italic))
47  setItalic(a.italic());
48 
49  if (a.itemSet(Underline))
50  setUnderline(a.underline());
51 
52  if (a.itemSet(Overline))
53  setOverline(a.overline());
54 
55  if (a.itemSet(StrikeOut))
56  setStrikeOut(a.strikeOut());
57 
58  if (a.itemSet(Outline))
59  setOutline(a.outline());
60 
61  if (a.itemSet(TextColor))
62  setTextColor(a.textColor());
63 
64  if (a.itemSet(SelectedTextColor))
65  setSelectedTextColor(a.selectedTextColor());
66 
67  if (a.itemSet(BGColor))
68  setBGColor(a.bgColor());
69 
70  if (a.itemSet(SelectedBGColor))
71  setSelectedBGColor(a.selectedBGColor());
72 
73  return *this;
74 }
75 
76 TQFont KateAttribute::font(const TQFont& ref)
77 {
78  TQFont ret = ref;
79 
80  if (itemSet(Weight))
81  ret.setWeight(weight());
82  if (itemSet(Italic))
83  ret.setItalic(italic());
84  if (itemSet(Underline))
85  ret.setUnderline(underline());
86  if (itemSet(Overline))
87  ret.setOverline(overline());
88  if (itemSet(StrikeOut))
89  ret.setStrikeOut(strikeOut());
90 
91  return ret;
92 }
93 
94 void KateAttribute::setWeight(int weight)
95 {
96  if (!(m_itemsSet & Weight) || m_weight != weight)
97  {
98  m_itemsSet |= Weight;
99 
100  m_weight = weight;
101 
102  changed();
103  }
104 }
105 
106 void KateAttribute::setBold(bool enable)
107 {
108  setWeight(enable ? TQFont::Bold : TQFont::Normal);
109 }
110 
111 void KateAttribute::setItalic(bool enable)
112 {
113  if (!(m_itemsSet & Italic) || m_italic != enable)
114  {
115  m_itemsSet |= Italic;
116 
117  m_italic = enable;
118 
119  changed();
120  }
121 }
122 
123 void KateAttribute::setUnderline(bool enable)
124 {
125  if (!(m_itemsSet & Underline) || m_underline != enable)
126  {
127  m_itemsSet |= Underline;
128 
129  m_underline = enable;
130 
131  changed();
132  }
133 }
134 
135 void KateAttribute::setOverline(bool enable)
136 {
137  if (!(m_itemsSet & Overline) || m_overline != enable)
138  {
139  m_itemsSet |= Overline;
140 
141  m_overline = enable;
142 
143  changed();
144  }
145 }
146 
147 void KateAttribute::setStrikeOut(bool enable)
148 {
149  if (!(m_itemsSet & StrikeOut) || m_strikeout != enable)
150  {
151  m_itemsSet |= StrikeOut;
152 
153  m_strikeout = enable;
154 
155  changed();
156  }
157 }
158 
159 void KateAttribute::setOutline(const TQColor& color)
160 {
161  if (!(m_itemsSet & Outline) || m_outline != color)
162  {
163  m_itemsSet |= Outline;
164 
165  m_outline = color;
166 
167  changed();
168  }
169 }
170 
171 void KateAttribute::setTextColor(const TQColor& color)
172 {
173  if (!(m_itemsSet & TextColor) || m_textColor != color)
174  {
175  m_itemsSet |= TextColor;
176 
177  m_textColor = color;
178 
179  changed();
180  }
181 }
182 
183 void KateAttribute::setSelectedTextColor(const TQColor& color)
184 {
185  if (!(m_itemsSet & SelectedTextColor) || m_selectedTextColor != color)
186  {
187  m_itemsSet |= SelectedTextColor;
188 
189  m_selectedTextColor = color;
190 
191  changed();
192  }
193 }
194 
195 void KateAttribute::setBGColor(const TQColor& color)
196 {
197  if (!(m_itemsSet & BGColor) || m_bgColor != color)
198  {
199  m_itemsSet |= BGColor;
200 
201  m_bgColor = color;
202 
203  changed();
204  }
205 }
206 
207 void KateAttribute::setSelectedBGColor(const TQColor& color)
208 {
209  if (!(m_itemsSet & SelectedBGColor) || m_selectedBGColor != color)
210  {
211  m_itemsSet |= SelectedBGColor;
212 
213  m_selectedBGColor = color;
214 
215  changed();
216  }
217 }
218 
219 bool operator ==(const KateAttribute& h1, const KateAttribute& h2)
220 {
221  if (h1.m_itemsSet != h2.m_itemsSet)
222  return false;
223 
224  if (h1.itemSet(KateAttribute::Weight))
225  if (h1.m_weight != h2.m_weight)
226  return false;
227 
228  if (h1.itemSet(KateAttribute::Italic))
229  if (h1.m_italic != h2.m_italic)
230  return false;
231 
232  if (h1.itemSet(KateAttribute::Underline))
233  if (h1.m_underline != h2.m_underline)
234  return false;
235 
236  if (h1.itemSet(KateAttribute::StrikeOut))
237  if (h1.m_strikeout != h2.m_strikeout)
238  return false;
239 
240  if (h1.itemSet(KateAttribute::Outline))
241  if (h1.m_outline != h2.m_outline)
242  return false;
243 
244  if (h1.itemSet(KateAttribute::TextColor))
245  if (h1.m_textColor != h2.m_textColor)
246  return false;
247 
248  if (h1.itemSet(KateAttribute::SelectedTextColor))
249  if (h1.m_selectedTextColor != h2.m_selectedTextColor)
250  return false;
251 
252  if (h1.itemSet(KateAttribute::BGColor))
253  if (h1.m_bgColor != h2.m_bgColor)
254  return false;
255 
256  if (h1.itemSet(KateAttribute::SelectedBGColor))
257  if (h1.m_selectedBGColor != h2.m_selectedBGColor)
258  return false;
259 
260  return true;
261 }
262 
263 bool operator !=(const KateAttribute& h1, const KateAttribute& h2)
264 {
265  return !(h1 == h2);
266 }
KateAttribute
The Attribute class incorporates all text decorations supported by Kate.
Definition: kateattribute.h:33

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kate

Skip menu "kate"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kate by doxygen 1.9.1
This website is maintained by Timothy Pearson.