• Skip to content
  • Skip to link menu
KDE 4.2 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     using SmartRange::rebuildChildStructure;
00109     
00110     inline bool hasDynamic() { return m_dynamic.count(); }
00111     const QList<KateDynamicAnimation*>& dynamicAnimations() const;
00112     void addDynamic(KateDynamicAnimation* anim);
00113     void removeDynamic(KateDynamicAnimation* anim);
00114 
00121 
00123 
00125 
00127 
00131     bool feedbackEnabled() const { return notifiers().count() || watchers().count(); }
00132     // request is internal!! Only KateSmartGroup gets to set it to false.
00133     /*void setFeedbackLevel(int feedbackLevel, bool request = true);*/
00134 
00136     void translated(const KateEditInfo& edit);
00137     void feedbackMostSpecific(KateSmartRange* mostSpecific);
00139     void shifted();
00141     void feedbackMouseCaretChange(KTextEditor::View* view, bool mouse, bool entered);
00142 
00143     void registerPointer(KateSmartRangePtr* ptr);
00144     void deregisterPointer(KateSmartRangePtr* ptr);
00145 
00146     inline KateSmartRange& operator=(const KTextEditor::Range& r) { setRange(r); return *this; }
00147 
00148   protected:
00149     friend class KateSmartCursor; //Has to call rangeChanged directly
00150     virtual KTextEditor::SmartRangeNotifier* createNotifier();
00151     virtual void checkFeedback();
00152 
00153   private:
00154     void init();
00155 
00156     KateDynamicAnimation* m_dynamicDoc;
00157     QList<KateDynamicAnimation*> m_dynamic;
00158     QList<KateSmartRangePtr*> m_pointers;
00159 
00160     bool  m_mouseOver   :1,
00161           m_caretOver   :1,
00162           m_isInternal  :1;
00163 };
00164 
00168 class KateSmartRangePtr
00169 {
00170   public:
00171     explicit KateSmartRangePtr(KateSmartRange* range)
00172       : m_range(range)
00173     {
00174       if (m_range)
00175         m_range->registerPointer(this);
00176     }
00177 
00178     ~KateSmartRangePtr()
00179     {
00180       if (m_range)
00181         m_range->deregisterPointer(this);
00182     }
00183 
00184     void deleted()
00185     {
00186       m_range = 0L;
00187     }
00188 
00189     inline KateSmartRangePtr& operator= ( const KateSmartRangePtr& p )
00190     {
00191       if (m_range)
00192         m_range->deregisterPointer(this);
00193 
00194       m_range = p.m_range;
00195 
00196       if (m_range)
00197         m_range->registerPointer(this);
00198 
00199       return *this;
00200     }
00201 
00202     inline KateSmartRangePtr& operator= ( KateSmartRange* p )
00203     {
00204       if (m_range)
00205         m_range->deregisterPointer(this);
00206 
00207       m_range = p;
00208 
00209       if (m_range)
00210         m_range->registerPointer(this);
00211 
00212       return *this;
00213     }
00214 
00215     inline bool operator== ( const KateSmartRangePtr& p ) const { return m_range == p.m_range; }
00216     inline bool operator!= ( const KateSmartRangePtr& p ) const { return m_range != p.m_range; }
00217     inline bool operator== ( const KateSmartRange* p ) const { return m_range == p; }
00218     inline bool operator!= ( const KateSmartRange* p ) const { return m_range != p; }
00219     inline KateSmartRange* operator->() const { return m_range; }
00220     inline operator KateSmartRange*() const { return m_range; }
00221 
00222   private:
00223     KateSmartRange* m_range;
00224 };
00225 
00226 //Q_DECLARE_OPERATORS_FOR_FLAGS(KateSmartRange::FeedbackLevels);
00227 
00228 #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
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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