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

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • render
katerenderer.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2007 Mirko Stocker <me@misto.ch>
3  Copyright (C) 2003-2005 Hamish Rodda <rodda@kde.org>
4  Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
5  Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
6  Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License version 2 as published by the Free Software Foundation.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #ifndef __KATE_RENDERER_H__
24 #define __KATE_RENDERER_H__
25 
26 #include <ktexteditor/attribute.h>
27 #include "katetextline.h"
28 #include "katelinelayout.h"
29 
30 #include <QtGui/QFont>
31 #include <QtGui/QFontMetricsF>
32 #include <QtCore/QList>
33 #include <QtGui/QTextLine>
34 
35 class KateDocument;
36 class KateView;
37 class KateRendererConfig;
38 class KateRenderRange;
39 namespace KTextEditor { class Range; }
40 namespace Kate { class TextFolding; }
41 
42 class KateLineLayout;
43 typedef KSharedPtr<KateLineLayout> KateLineLayoutPtr;
44 
50 class KATEPART_TESTS_EXPORT KateRenderer
51 {
52 public:
69  enum caretStyles {
70  Line,
71  Block,
72  Underline,
73  Half
74  };
75 
82  explicit KateRenderer(KateDocument* doc, Kate::TextFolding &folding, KateView *view = 0);
83 
87  ~KateRenderer();
88 
92  KateDocument* doc() const { return m_doc; }
93 
98  Kate::TextFolding &folding() const { return m_folding; }
99 
103  KateView* view() const { return m_view; }
104 
109  void updateAttributes ();
110 
115  inline bool drawCaret() const { return m_drawCaret; }
116 
121  void setDrawCaret(bool drawCaret);
122 
127  inline KateRenderer::caretStyles caretStyle() const { return m_caretStyle; }
128 
133  void setCaretStyle(KateRenderer::caretStyles style);
134 
138  void setCaretOverrideColor(const QColor& color);
139 
145  inline bool showTabs() const { return m_showTabs; }
146 
151  void setShowTabs(bool showTabs);
152 
156  inline bool showTrailingSpaces() const { return m_showSpaces; }
157 
161  void setShowTrailingSpaces(bool showSpaces);
162 
167  void setTabWidth(int tabWidth);
168 
173  bool showIndentLines() const;
174 
179  void setShowIndentLines(bool showLines);
180 
185  void setIndentWidth(int indentWidth);
186 
191  inline bool showSelections() const { return m_showSelections; }
192 
198  void setShowSelections(bool showSelections);
199 
203  void increaseFontSizes();
204  void decreaseFontSizes();
205  const QFont& currentFont() const;
206  const QFontMetricsF& currentFontMetrics() const;
207 
212  bool isPrinterFriendly() const;
213 
219  void setPrinterFriendly(bool printerFriendly);
220 
224  void layoutLine(KateLineLayoutPtr line, int maxwidth = -1, bool cacheLayout = false) const;
225 
236  bool isLineRightToLeft( KateLineLayoutPtr lineLayout ) const;
237 
244  QList<QTextLayout::FormatRange> decorationsForLine(const Kate::TextLine& textLine, int line, bool selectionsOnly = false, KateRenderRange* completionHighlight = 0L, bool completionSelected = false) const;
245 
246  // Width calculators
247  qreal spaceWidth() const;
248 
252  int cursorToX(const KateTextLayout& range, int col, bool returnPastLine = false) const;
254  int cursorToX(const KateTextLayout& range, const KTextEditor::Cursor& pos, bool returnPastLine = false) const;
255 
261  KTextEditor::Cursor xToCursor(const KateTextLayout& range, int x, bool returnPastLine = false) const;
262 
263  // Font height
264  uint fontHeight() const;
265 
266  // Line height
267  int lineHeight() const;
268 
269  // Document height
270  uint documentHeight() const;
271 
272  // Selection boundaries
273  bool getSelectionBounds(int line, int lineLength, int &start, int &end) const;
274 
287  void paintTextLine(QPainter& paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor* cursor = 0L);
288 
303  void paintTextLineBackground(QPainter& paint, KateLineLayoutPtr layout, int currentViewLine, int xStart, int xEnd);
304 
312  KTextEditor::Attribute::Ptr attribute(uint pos) const;
313  KTextEditor::Attribute::Ptr specificAttribute(int context) const;
314 
315  private:
319  void paintTrailingSpace(QPainter &paint, qreal x, qreal y);
323  void paintTabstop(QPainter &paint, qreal x, qreal y);
324 
328  void paintNonBreakSpace(QPainter &paint, qreal x, qreal y);
329 
331  void paintIndentMarker(QPainter &paint, uint x, uint y);
332 
333  void assignSelectionBrushesFromAttribute(QTextLayout::FormatRange& target, const KTextEditor::Attribute& attribute) const;
334 
335  // update font height
336  void updateFontHeight ();
337 
338  KateDocument *const m_doc;
339  Kate::TextFolding &m_folding;
340  KateView *const m_view;
341 
342  // cache of config values
343  int m_tabWidth;
344  int m_indentWidth;
345  int m_fontHeight;
346 
347  // some internal flags
348  KateRenderer::caretStyles m_caretStyle;
349  bool m_drawCaret;
350  bool m_showSelections;
351  bool m_showTabs;
352  bool m_showSpaces;
353  bool m_printerFriendly;
354  QColor m_caretOverrideColor;
355 
356  QList<KTextEditor::Attribute::Ptr> m_attributes;
357 
361  public:
362  inline KateRendererConfig *config () const { return m_config; }
363 
364  void updateConfig ();
365 
366  private:
367  KateRendererConfig *const m_config;
368 };
369 
370 #endif
KateRenderer::drawCaret
bool drawCaret() const
Determine whether the caret (text cursor) will be drawn.
Definition: katerenderer.h:115
KateRenderer::showTrailingSpaces
bool showTrailingSpaces() const
Definition: katerenderer.h:156
katetextline.h
KateRenderer::Block
Definition: katerenderer.h:71
KateLineLayoutPtr
KSharedPtr< KateLineLayout > KateLineLayoutPtr
Definition: katerenderer.h:42
QFont
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
KateLineLayout
Definition: katelinelayout.h:34
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:50
KateRenderer::Underline
Definition: katerenderer.h:72
KateRenderer::config
KateRendererConfig * config() const
Configuration.
Definition: katerenderer.h:362
QSharedPointer
KateRenderer::view
KateView * view() const
Returns the view to which this renderer is bound.
Definition: katerenderer.h:103
QPainter
KateRenderer::showSelections
bool showSelections() const
Show the view's selection?
Definition: katerenderer.h:191
KateRenderer::showTabs
bool showTabs() const
Definition: katerenderer.h:145
Kate::TextFolding
Class representing the folding information for a TextBuffer.
Definition: katetextfolding.h:42
QList< QTextLayout::FormatRange >
KateRenderer::Line
Definition: katerenderer.h:70
QColor
KateView
Definition: kateview.h:77
KateRenderer::folding
Kate::TextFolding & folding() const
Returns the folding info to which this renderer is bound.
Definition: katerenderer.h:98
KateDocument
Definition: katedocument.h:74
KateRenderer::caretStyles
caretStyles
Style of Caret.
Definition: katerenderer.h:69
KateRendererConfig
Definition: kateconfig.h:618
KateTextLayout
This class represents one visible line of text; with dynamic wrapping, many KateTextLayouts can be ne...
Definition: katetextlayout.h:38
katelinelayout.h
KateRenderer::caretStyle
KateRenderer::caretStyles caretStyle() const
The style of the caret (text cursor) to be painted.
Definition: katerenderer.h:127
KateRenderer::doc
KateDocument * doc() const
Returns the document to which this renderer is bound.
Definition: katerenderer.h:92
QTextLayout::FormatRange
KateLineLayoutPtr
KSharedPtr< KateLineLayout > KateLineLayoutPtr
Definition: katelinelayout.h:120
KateRenderRange
Definition: katerenderrange.h:35
QFontMetricsF
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

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

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal