KTextEditor
attribute.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 * Copyright (C) 2003-2005 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 as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KDELIBS_KTEXTEDITOR_ATTRIBUTE_H 00021 #define KDELIBS_KTEXTEDITOR_ATTRIBUTE_H 00022 00023 #include <QtGui/QTextFormat> 00024 00025 #include <ksharedptr.h> 00026 #include <ktexteditor/ktexteditor_export.h> 00027 00028 class KAction; 00029 00030 namespace KTextEditor 00031 { 00032 00033 class SmartRange; 00034 00060 class KTEXTEDITOR_EXPORT Attribute : public QTextCharFormat, public KShared 00061 { 00062 friend class SmartRange; 00063 00064 public: 00065 typedef KSharedPtr<Attribute> Ptr; 00066 00070 Attribute(); 00071 00075 Attribute(const Attribute& a); 00076 00080 virtual ~Attribute(); 00081 00089 void changed() const; 00090 00091 //BEGIN custom properties 00095 enum CustomProperties { 00097 Outline = QTextFormat::UserProperty, 00099 SelectedForeground, 00101 SelectedBackground, 00103 BackgroundFillWhitespace, 00105 AttributeDynamicEffect = 0x10A00, 00107 AttributeInternalProperty = 0x10E00, 00109 AttributeUserProperty = 0x110000 00110 }; 00111 00126 bool fontBold() const; 00127 00135 void setFontBold(bool bold = true); 00136 00142 QBrush outline() const; 00143 00151 void setOutline(const QBrush& brush); 00152 00158 QBrush selectedForeground() const; 00159 00167 void setSelectedForeground(const QBrush& foreground); 00168 00174 QBrush selectedBackground() const; 00175 00183 void setSelectedBackground(const QBrush& brush); 00184 00190 bool backgroundFillWhitespace() const; 00191 00199 void setBackgroundFillWhitespace(bool fillWhitespace); 00200 00201 // Fix deficiencies in QText{Char}Format 00205 void clear(); 00206 00212 bool hasAnyProperty() const; 00213 //END 00214 00215 //BEGIN Action association 00234 void associateAction(KAction* action); 00235 00242 void dissociateAction(KAction* action); 00243 00247 const QList<KAction*>& associatedActions() const; 00248 00252 void clearAssociatedActions(); 00254 //END 00255 00256 //BEGIN Dynamic highlighting 00262 enum ActivationType { 00264 ActivateMouseIn = 0, 00266 ActivateCaretIn 00267 }; 00268 00273 enum Effect { 00274 EffectNone = 0x0 , 00275 EffectFadeIn = 0x1 , 00276 EffectFadeOut = 0x2 , 00277 EffectPulse = 0x4 , 00278 EffectCycleGradient = 0x8 00279 }; 00280 Q_DECLARE_FLAGS(Effects, Effect) 00296 Attribute::Ptr dynamicAttribute(ActivationType type) const; 00297 00306 void setDynamicAttribute(ActivationType type, Attribute::Ptr attribute); 00307 00308 Effects effects() const; 00309 void setEffects(Effects effects); 00311 //END 00312 00320 Attribute& operator+=(const Attribute& a); 00321 00327 Attribute& operator=(const Attribute& a); 00328 00329 protected: 00343 private: 00344 class AttributePrivate* const d; 00345 }; 00346 00347 Q_DECLARE_OPERATORS_FOR_FLAGS(Attribute::Effects) 00348 00349 } 00350 00351 #endif 00352 00353 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference