Kate
katelinelayout.h
Go to the documentation of this file.00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2002-2005 Hamish Rodda <rodda@kde.org> 00003 Copyright (C) 2003 Anakim Border <aborder@sources.sourceforge.net> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 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 _KATE_LINELAYOUT_H_ 00021 #define _KATE_LINELAYOUT_H_ 00022 00023 #include "katecursor.h" 00024 #include "katetextline.h" 00025 00026 class QTextLayout; 00027 class KateDocument; 00028 class KateTextLayout; 00029 00030 class KateLineLayout : public KShared 00031 { 00032 public: 00033 KateLineLayout(KateDocument* doc = 0L); 00034 ~KateLineLayout(); 00035 00036 KateDocument* doc() const; 00037 void debugOutput() const; 00038 00039 void clear(); 00040 bool isValid() const; 00041 bool isOutsideDocument() const; 00042 00043 bool isRightToLeft() const; 00044 00045 bool includesCursor(const KTextEditor::Cursor& realCursor) const; 00046 00047 friend bool operator> (const KateLineLayout& r, const KTextEditor::Cursor& c); 00048 friend bool operator>= (const KateLineLayout& r, const KTextEditor::Cursor& c); 00049 friend bool operator< (const KateLineLayout& r, const KTextEditor::Cursor& c); 00050 friend bool operator<= (const KateLineLayout& r, const KTextEditor::Cursor& c); 00051 00052 const KateTextLine::Ptr& textLine(bool forceReload = false) const; 00053 int length() const; 00054 00055 int line() const; 00059 void setLine(int line, int virtualLine = -1); 00060 KTextEditor::Cursor start() const; 00061 00062 int virtualLine() const; 00063 void setVirtualLine(int virtualLine); 00064 00065 bool isDirty(int viewLine) const; 00066 bool setDirty(int viewLine, bool dirty = true); 00067 00068 int width() const; 00069 int widthOfLastLine() const; 00070 00071 int viewLineCount() const; 00072 KateTextLayout viewLine(int viewLine) const; 00073 int viewLineForColumn(int column) const; 00074 00075 bool startsInvisibleBlock() const; 00076 00077 // This variable is used as follows: 00078 // non-dynamic-wrapping mode: unused 00079 // dynamic wrapping mode: 00080 // first viewLine of a line: the X position of the first non-whitespace char 00081 // subsequent viewLines: the X offset from the left of the display. 00082 // 00083 // this is used to provide a dynamic-wrapping-retains-indent feature. 00084 int shiftX() const; 00085 void setShiftX(int shiftX); 00086 00087 QTextLayout* layout() const; 00088 void setLayout(QTextLayout* layout); 00089 void invalidateLayout(); 00090 00091 bool isLayoutDirty() const; 00092 void setLayoutDirty(bool dirty = true); 00093 00094 bool usePlainTextLine () const; 00095 void setUsePlainTextLine (bool plain = true); 00096 00097 private: 00098 // Disable copy 00099 KateLineLayout(const KateLineLayout& copy); 00100 00101 QTextLayout* takeLayout() const; 00102 00103 KateDocument* m_doc; 00104 mutable KateTextLine::Ptr m_textLine; 00105 int m_line; 00106 int m_virtualLine; 00107 int m_shiftX; 00108 00109 QTextLayout* m_layout; 00110 QList<bool> m_dirtyList; 00111 00112 bool m_layoutDirty; 00113 bool m_usePlainTextLine; 00114 }; 00115 00116 typedef KSharedPtr<KateLineLayout> KateLineLayoutPtr; 00117 00118 #endif