• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • 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 "katecursor.h"
00027 #include <ktexteditor/attribute.h>
00028 #include "katetextline.h"
00029 #include "katelinelayout.h"
00030 #include "katesmartregion.h"
00031 
00032 #include <QtGui/QFont>
00033 #include <QtGui/QFontMetrics>
00034 #include <QtCore/QList>
00035 #include <QtGui/QTextLine>
00036 
00037 class KateDocument;
00038 class KateView;
00039 class KateRendererConfig;
00040 class KateRenderRange;
00041 namespace  KTextEditor { class Range; }
00042 
00043 class KateLineLayout;
00044 typedef KSharedPtr<KateLineLayout> KateLineLayoutPtr;
00045 
00051 class KateRenderer
00052 {
00053 public:
00057     enum caretStyles {
00058       Line,
00059       Block
00060     };
00061 
00067     explicit KateRenderer(KateDocument* doc, KateView *view = 0);
00068 
00072     ~KateRenderer();
00073 
00077     KateDocument* doc() const { return m_doc; }
00078 
00082     KateView* view() const { return m_view; }
00083 
00088     void updateAttributes ();
00089 
00094     inline bool drawCaret() const { return m_drawCaret; }
00095 
00100     void setDrawCaret(bool drawCaret);
00101 
00106     inline KateRenderer::caretStyles caretStyle() const { return m_caretStyle; }
00107 
00112     void setCaretStyle(KateRenderer::caretStyles style);
00113 
00117     void setCaretOverrideColor(const QColor& color);
00118 
00124     inline bool showTabs() const { return m_showTabs; }
00125 
00130     void setShowTabs(bool showTabs);
00131 
00135     inline bool showTrailingSpaces() const { return m_showSpaces; }
00136 
00140     void setShowTrailingSpaces(bool showSpaces);
00141 
00146     void setTabWidth(int tabWidth);
00147 
00152     bool showIndentLines() const;
00153 
00158     void setShowIndentLines(bool showLines);
00159 
00164     void setIndentWidth(int indentWidth);
00165 
00170     inline bool showSelections() const { return m_showSelections; }
00171 
00177     void setShowSelections(bool showSelections);
00178 
00182     void increaseFontSizes();
00183     void decreaseFontSizes();
00184     const QFont& currentFont() const;
00185     const QFontMetrics& currentFontMetrics() const;
00186 
00191     bool isPrinterFriendly() const;
00192 
00198     void setPrinterFriendly(bool printerFriendly);
00199 
00203     void layoutLine(KateLineLayoutPtr line, int maxwidth = -1, bool cacheLayout = false) const;
00204 
00211     bool isLineRightToLeft( KateLineLayoutPtr lineLayout ) const;
00212 
00219     QList<QTextLayout::FormatRange> decorationsForLine(const KateTextLine::Ptr& textLine, int line, bool selectionsOnly = false, KateRenderRange* completionHighlight = 0L, bool completionSelected = false) const;
00220 
00221     KateSmartRegion& dynamicRegion() { return m_dynamicRegion; }
00222 
00223     // Width calculators
00224     uint spaceWidth() const;
00225     KDE_DEPRECATED uint textWidth(const KateTextLine::Ptr &, int cursorCol);
00226     KDE_DEPRECATED uint textWidth(const KateTextLine::Ptr &textLine, uint startcol, uint maxwidth, bool *needWrap, int *endX = 0);
00227     KDE_DEPRECATED uint textWidth(const KTextEditor::Cursor& cursor);
00228 
00232     int cursorToX(const KateTextLayout& range, int col) const;
00234     int cursorToX(const KateTextLayout& range, const KTextEditor::Cursor& pos) const;
00235 
00241     KTextEditor::Cursor xToCursor(const KateTextLayout& range, int x, bool returnPastLine = false) const;
00242 
00243     // Font height
00244     uint fontHeight();
00245 
00246     // Document height
00247     uint documentHeight();
00248 
00249     // Selection boundaries
00250     bool getSelectionBounds(int line, int lineLength, int &start, int &end) const;
00251 
00264     void paintTextLine(QPainter& paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor* cursor = 0L);
00265 
00280     void paintTextLineBackground(QPainter& paint, KateLineLayoutPtr layout, int currentViewLine, int xStart, int xEnd);
00281 
00289     KTextEditor::Attribute::Ptr attribute(uint pos) const;
00290     KTextEditor::Attribute::Ptr specificAttribute(int context) const;
00291 
00292   private:
00296     void paintTrailingSpace(QPainter &paint, qreal x, qreal y);
00300     void paintTabstop(QPainter &paint, qreal x, qreal y);
00301 
00303     void paintIndentMarker(QPainter &paint, uint x, uint y);
00304     
00305     void assignSelectionBrushesFromAttribute(QTextLayout::FormatRange& target, const KTextEditor::Attribute& attribute) const;
00306 
00307     KateDocument* m_doc;
00308     KateView *m_view;
00309 
00310     // cache of config values
00311     int m_tabWidth;
00312     int m_indentWidth;
00313 
00314     // some internal flags
00315     KateRenderer::caretStyles m_caretStyle;
00316     bool m_drawCaret;
00317     bool m_showSelections;
00318     bool m_showTabs;
00319     bool m_showSpaces;
00320     bool m_printerFriendly;
00321     QColor m_caretOverrideColor;
00322 
00323     QList<KTextEditor::Attribute::Ptr> m_attributes;
00324 
00328   public:
00329     inline KateRendererConfig *config () const { return m_config; }
00330 
00331     void updateConfig ();
00332 
00333   private:
00334     KateRendererConfig *m_config;
00335 
00336     KateSmartRegion m_dynamicRegion;
00337 };
00338 
00339 #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