• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

katesmartrange.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2003,2004,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 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 KATESMARTRANGE_H
00020 #define KATESMARTRANGE_H
00021 
00022 #include "katesmartcursor.h"
00023 #include <ktexteditor/smartrange.h>
00024 #include <ktexteditor/rangefeedback.h>
00025 #include "kateedit.h"
00026 
00027 class KateSmartRange;
00028 class KateDynamicAnimation;
00029 
00033 class KateSmartRangeNotifier : public KTextEditor::SmartRangeNotifier
00034 {
00035   Q_OBJECT
00036   friend class KateSmartRange;
00037 
00038   public:
00039     explicit KateSmartRangeNotifier(KateSmartRange* owner);
00040 
00045     bool needsPositionChanges() const;
00046 
00047   protected:
00048     virtual void connectNotify(const char* signal);
00049     virtual void disconnectNotify(const char* signal);
00050 
00051   private:
00052     KateSmartRange* m_owner;
00053 };
00054 
00055 class KateSmartRangePtr;
00056 
00063 class KateSmartRange : public KTextEditor::SmartRange
00064 {
00065   friend class KateSmartRangeNotifier;
00066 
00067   public:
00071     KateSmartRange(const KTextEditor::Range& range, KateDocument* doc, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = DoNotExpand);
00073     explicit KateSmartRange(KateDocument* doc, KTextEditor::SmartRange* parent = 0L);
00074 
00075     KateSmartRange(KateSmartCursor* start, KateSmartCursor* end, KTextEditor::SmartRange* parent = 0L, KTextEditor::SmartRange::InsertBehaviors insertBehavior = DoNotExpand);
00076     virtual ~KateSmartRange();
00077 
00079     KateDocument* kateDocument() const;
00081     inline KateSmartCursor& kStart() { return *static_cast<KateSmartCursor*>(m_start); }
00083     inline KateSmartCursor& kEnd() { return *static_cast<KateSmartCursor*>(m_end); }
00084 
00085     bool isInternal() const { return m_isInternal; }
00086     void setInternal();
00087 
00090     inline bool isMouseOver() { return m_mouseOver; }
00093     inline void setMouseOver(bool mouseOver) { m_mouseOver = mouseOver; }
00094 
00095     inline bool isCaretOver() { return m_caretOver; }
00096     inline void setCaretOver(bool caretOver) { m_caretOver = caretOver; }
00097 
00098     void unbindAndDelete();
00099 
00100     enum AttachActions {
00101       NoActions   = 0x0,
00102       TagLines    = 0x1,
00103       Redraw      = 0x2
00104     };
00105 
00106     virtual void setParentRange(SmartRange* r);
00107 
00108     inline bool hasDynamic() { return m_dynamic.count(); }
00109     const QList<KateDynamicAnimation*>& dynamicAnimations() const;
00110     void addDynamic(KateDynamicAnimation* anim);
00111     void removeDynamic(KateDynamicAnimation* anim);
00112 
00119 
00121 
00123 
00125 
00129     bool feedbackEnabled() const { return notifiers().count() || watchers().count(); }
00130     // request is internal!! Only KateSmartGroup gets to set it to false.
00131     /*void setFeedbackLevel(int feedbackLevel, bool request = true);*/
00132 
00134     void translated(const KateEditInfo& edit);
00135     void feedbackMostSpecific(KateSmartRange* mostSpecific);
00137     void shifted();
00139     void feedbackMouseCaretChange(KTextEditor::View* view, bool mouse, bool entered);
00140 
00141     void registerPointer(KateSmartRangePtr* ptr);
00142     void deregisterPointer(KateSmartRangePtr* ptr);
00143 
00144     inline KateSmartRange& operator=(const KTextEditor::Range& r) { setRange(r); return *this; }
00145 
00146   protected:
00147     virtual KTextEditor::SmartRangeNotifier* createNotifier();
00148     virtual void checkFeedback();
00149 
00150   private:
00151     void init();
00152 
00153     KateDynamicAnimation* m_dynamicDoc;
00154     QList<KateDynamicAnimation*> m_dynamic;
00155     QList<KateSmartRangePtr*> m_pointers;
00156 
00157     bool  m_mouseOver   :1,
00158           m_caretOver   :1,
00159           m_isInternal  :1;
00160 };
00161 
00165 class KateSmartRangePtr
00166 {
00167   public:
00168     explicit KateSmartRangePtr(KateSmartRange* range)
00169       : m_range(range)
00170     {
00171       if (m_range)
00172         m_range->registerPointer(this);
00173     }
00174 
00175     ~KateSmartRangePtr()
00176     {
00177       if (m_range)
00178         m_range->deregisterPointer(this);
00179     }
00180 
00181     void deleted()
00182     {
00183       m_range = 0L;
00184     }
00185 
00186     inline KateSmartRangePtr& operator= ( const KateSmartRangePtr& p )
00187     {
00188       if (m_range)
00189         m_range->deregisterPointer(this);
00190 
00191       m_range = p.m_range;
00192 
00193       if (m_range)
00194         m_range->registerPointer(this);
00195 
00196       return *this;
00197     }
00198 
00199     inline KateSmartRangePtr& operator= ( KateSmartRange* p )
00200     {
00201       if (m_range)
00202         m_range->deregisterPointer(this);
00203 
00204       m_range = p;
00205 
00206       if (m_range)
00207         m_range->registerPointer(this);
00208 
00209       return *this;
00210     }
00211 
00212     inline bool operator== ( const KateSmartRangePtr& p ) const { return m_range == p.m_range; }
00213     inline bool operator!= ( const KateSmartRangePtr& p ) const { return m_range != p.m_range; }
00214     inline bool operator== ( const KateSmartRange* p ) const { return m_range == p; }
00215     inline bool operator!= ( const KateSmartRange* p ) const { return m_range != p; }
00216     inline KateSmartRange* operator->() const { return m_range; }
00217     inline operator KateSmartRange*() const { return m_range; }
00218 
00219   private:
00220     KateSmartRange* m_range;
00221 };
00222 
00223 //Q_DECLARE_OPERATORS_FOR_FLAGS(KateSmartRange::FeedbackLevels);
00224 
00225 #endif

Kate

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal