• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Kate

katerenderer.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2007 Mirko Stocker <me@misto.ch>
00003    Copyright (C) 2003-2005 Hamish Rodda <rodda@kde.org>
00004    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00005    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
00006    Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License version 2 as published by the Free Software Foundation.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020    Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #ifndef __KATE_RENDERER_H__
00024 #define __KATE_RENDERER_H__
00025 
00026 #include <ktexteditor/attribute.h>
00027 #include "katetextline.h"
00028 #include "katelinelayout.h"
00029 
00030 #include <QtGui/QFont>
00031 #include <QtGui/QFontMetrics>
00032 #include <QtCore/QList>
00033 #include <QtGui/QTextLine>
00034 
00035 class KateDocument;
00036 class KateView;
00037 class KateRendererConfig;
00038 class KateRenderRange;
00039 namespace  KTextEditor { class Range; }
00040 
00041 class KateLineLayout;
00042 typedef KSharedPtr<KateLineLayout> KateLineLayoutPtr;
00043 
00049 class KateRenderer
00050 {
00051 public:
00055     enum caretStyles {
00056       Line,
00057       Block
00058     };
00059 
00065     explicit KateRenderer(KateDocument* doc, KateView *view = 0);
00066 
00070     ~KateRenderer();
00071 
00075     KateDocument* doc() const { return m_doc; }
00076 
00080     KateView* view() const { return m_view; }
00081 
00086     void updateAttributes ();
00087 
00092     inline bool drawCaret() const { return m_drawCaret; }
00093 
00098     void setDrawCaret(bool drawCaret);
00099 
00104     inline KateRenderer::caretStyles caretStyle() const { return m_caretStyle; }
00105 
00110     void setCaretStyle(KateRenderer::caretStyles style);
00111 
00115     void setCaretOverrideColor(const QColor& color);
00116 
00122     inline bool showTabs() const { return m_showTabs; }
00123 
00128     void setShowTabs(bool showTabs);
00129 
00133     inline bool showTrailingSpaces() const { return m_showSpaces; }
00134 
00138     void setShowTrailingSpaces(bool showSpaces);
00139 
00144     void setTabWidth(int tabWidth);
00145 
00150     bool showIndentLines() const;
00151 
00156     void setShowIndentLines(bool showLines);
00157 
00162     void setIndentWidth(int indentWidth);
00163 
00168     inline bool showSelections() const { return m_showSelections; }
00169 
00175     void setShowSelections(bool showSelections);
00176 
00180     void increaseFontSizes();
00181     void decreaseFontSizes();
00182     const QFont& currentFont() const;
00183     const QFontMetrics& currentFontMetrics() const;
00184 
00189     bool isPrinterFriendly() const;
00190 
00196     void setPrinterFriendly(bool printerFriendly);
00197 
00201     void layoutLine(KateLineLayoutPtr line, int maxwidth = -1, bool cacheLayout = false) const;
00202 
00213     bool isLineRightToLeft( KateLineLayoutPtr lineLayout ) const;
00214 
00221     QList<QTextLayout::FormatRange> decorationsForLine(const Kate::TextLine& textLine, int line, bool selectionsOnly = false, KateRenderRange* completionHighlight = 0L, bool completionSelected = false) const;
00222 
00223     // Width calculators
00224     uint spaceWidth() const;
00225 #ifndef KDE_NO_DEPRECATED
00226     KDE_DEPRECATED uint textWidth(const Kate::TextLine &, int cursorCol);
00227     KDE_DEPRECATED uint textWidth(const Kate::TextLine &textLine, uint startcol, uint maxwidth, bool *needWrap, int *endX = 0);
00228     KDE_DEPRECATED uint textWidth(const KTextEditor::Cursor& cursor);
00229 #endif
00230 
00234     int cursorToX(const KateTextLayout& range, int col) const;
00236     int cursorToX(const KateTextLayout& range, const KTextEditor::Cursor& pos) const;
00238     int cursorToX(const KateTextLayout& range, const KTextEditor::Cursor& pos, bool returnPastLine) const;
00239 
00245     KTextEditor::Cursor xToCursor(const KateTextLayout& range, int x, bool returnPastLine = false) const;
00246 
00247     // Font height
00248     uint fontHeight();
00249 
00250     // Line height
00251     int lineHeight();
00252 
00253     // Document height
00254     uint documentHeight();
00255 
00256     // Selection boundaries
00257     bool getSelectionBounds(int line, int lineLength, int &start, int &end) const;
00258 
00271     void paintTextLine(QPainter& paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor* cursor = 0L);
00272 
00287     void paintTextLineBackground(QPainter& paint, KateLineLayoutPtr layout, int currentViewLine, int xStart, int xEnd);
00288 
00296     KTextEditor::Attribute::Ptr attribute(uint pos) const;
00297     KTextEditor::Attribute::Ptr specificAttribute(int context) const;
00298 
00299   private:
00303     void paintTrailingSpace(QPainter &paint, qreal x, qreal y);
00307     void paintTabstop(QPainter &paint, qreal x, qreal y);
00308 
00312     void paintNonBreakSpace(QPainter &paint, qreal x, qreal y);
00313 
00315     void paintIndentMarker(QPainter &paint, uint x, uint y);
00316 
00317     void assignSelectionBrushesFromAttribute(QTextLayout::FormatRange& target, const KTextEditor::Attribute& attribute) const;
00318 
00319     KateDocument *const m_doc;
00320     KateView *const m_view;
00321 
00322     // cache of config values
00323     int m_tabWidth;
00324     int m_indentWidth;
00325 
00326     // some internal flags
00327     KateRenderer::caretStyles m_caretStyle;
00328     bool m_drawCaret;
00329     bool m_showSelections;
00330     bool m_showTabs;
00331     bool m_showSpaces;
00332     bool m_printerFriendly;
00333     QColor m_caretOverrideColor;
00334 
00335     QList<KTextEditor::Attribute::Ptr> m_attributes;
00336 
00340   public:
00341     inline KateRendererConfig *config () const { return m_config; }
00342 
00343     void updateConfig ();
00344 
00345   private:
00346     KateRendererConfig *const m_config;
00347 };
00348 
00349 #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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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