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

Kate

  • sources
  • kde-4.12
  • 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 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
QColor
KateRenderer::cursorToX
int cursorToX(const KateTextLayout &range, int col, bool returnPastLine=false) const
Returns the x position of cursor col on the line range.
Definition: katerenderer.cpp:1048
KateRenderer::setShowSelections
void setShowSelections(bool showSelections)
Set whether the view's selections should be shown.
Definition: katerenderer.cpp:135
KSharedPtr< KateLineLayout >
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::updateConfig
void updateConfig()
Definition: katerenderer.cpp:877
KateRenderer::Block
Definition: katerenderer.h:71
KateRenderer::paintTextLineBackground
void paintTextLineBackground(QPainter &paint, KateLineLayoutPtr layout, int currentViewLine, int xStart, int xEnd)
Paint the background of a line.
Definition: katerenderer.cpp:172
KateRenderer::currentFont
const QFont & currentFont() const
Definition: katerenderer.cpp:805
KateLineLayoutPtr
KSharedPtr< KateLineLayout > KateLineLayoutPtr
Definition: katerenderer.h:42
KateRenderer::spaceWidth
qreal spaceWidth() const
Definition: katerenderer.cpp:907
KTextEditor::Attribute
KateRenderer::fontHeight
uint fontHeight() const
Definition: katerenderer.cpp:815
KateRenderer::setCaretOverrideColor
void setCaretOverrideColor(const QColor &color)
Set a brush with which to override drawing of the caret.
Definition: katerenderer.cpp:1083
KateRenderer::KateRenderer
KateRenderer(KateDocument *doc, Kate::TextFolding &folding, KateView *view=0)
Constructor.
Definition: katerenderer.cpp:49
KateRenderer::currentFontMetrics
const QFontMetricsF & currentFontMetrics() const
Definition: katerenderer.cpp:810
KateRenderer::documentHeight
uint documentHeight() const
Definition: katerenderer.cpp:820
KateRenderer::attribute
KTextEditor::Attribute::Ptr attribute(uint pos) const
This takes an in index, and returns all the attributes for it.
Definition: katerenderer.cpp:79
KateRenderer::increaseFontSizes
void increaseFontSizes()
Change to a different font (soon to be font set?)
Definition: katerenderer.cpp:140
KateRenderer::layoutLine
void layoutLine(KateLineLayoutPtr line, int maxwidth=-1, bool cacheLayout=false) const
Text width & height calculation functions...
Definition: katerenderer.cpp:912
KTextEditor::Cursor
KateLineLayout
Definition: katelinelayout.h:34
KateRenderer::xToCursor
KTextEditor::Cursor xToCursor(const KateTextLayout &range, int x, bool returnPastLine=false) const
Returns the real cursor which is occupied by the specified x value, or that closest to it...
Definition: katerenderer.cpp:1071
KateRenderer::setShowTrailingSpaces
void setShowTrailingSpaces(bool showSpaces)
Set whether a mark should be painted for trailing spaces.
Definition: katerenderer.cpp:110
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:50
KateRenderer::setShowTabs
void setShowTabs(bool showTabs)
Set whether a mark should be painted to help identifying tabs.
Definition: katerenderer.cpp:105
KateRenderer::setPrinterFriendly
void setPrinterFriendly(bool printerFriendly)
Configure this renderer to paint in a printer-friendly fashion.
Definition: katerenderer.cpp:163
KateRenderer::Underline
Definition: katerenderer.h:72
KateRenderer::config
KateRendererConfig * config() const
Configuration.
Definition: katerenderer.h:362
attribute.h
KateRenderer::decreaseFontSizes
void decreaseFontSizes()
Definition: katerenderer.cpp:148
KateRenderer::Half
Definition: katerenderer.h:73
KateRenderer::showIndentLines
bool showIndentLines() const
Definition: katerenderer.cpp:120
KateRenderer::getSelectionBounds
bool getSelectionBounds(int line, int lineLength, int &start, int &end) const
Definition: katerenderer.cpp:830
KateRenderer::view
KateView * view() const
Returns the view to which this renderer is bound.
Definition: katerenderer.h:103
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
KateRenderer::Line
Definition: katerenderer.h:70
KateView
Definition: kateview.h:78
KateRenderer::setIndentWidth
void setIndentWidth(int indentWidth)
Sets the width of the tab.
Definition: katerenderer.cpp:130
KateRenderer::~KateRenderer
~KateRenderer()
Destructor.
Definition: katerenderer.cpp:69
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::updateAttributes
void updateAttributes()
update the highlighting attributes (for example after an hl change or after hl config changed) ...
Definition: katerenderer.cpp:74
KateRenderer::setTabWidth
void setTabWidth(int tabWidth)
Sets the width of the tab.
Definition: katerenderer.cpp:115
KateRenderer::specificAttribute
KTextEditor::Attribute::Ptr specificAttribute(int context) const
Definition: katerenderer.cpp:87
KateRenderer::caretStyles
caretStyles
Style of Caret.
Definition: katerenderer.h:69
QFont
KateRendererConfig
Definition: kateconfig.h:591
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::isPrinterFriendly
bool isPrinterFriendly() const
Definition: katerenderer.cpp:158
KateRenderer::setCaretStyle
void setCaretStyle(KateRenderer::caretStyles style)
Set the style of caret to be painted.
Definition: katerenderer.cpp:100
Kate::TextLine
QSharedPointer< TextLineData > TextLine
The normal world only accesses the text lines with shared pointers.
Definition: katetextline.h:443
KateRenderer::paintTextLine
void paintTextLine(QPainter &paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor *cursor=0L)
This is the ultimate function to perform painting of a text line.
Definition: katerenderer.cpp:506
KateRenderer::doc
KateDocument * doc() const
Returns the document to which this renderer is bound.
Definition: katerenderer.h:92
KateRenderer::lineHeight
int lineHeight() const
Definition: katerenderer.cpp:825
KateRenderer::decorationsForLine
QList< QTextLayout::FormatRange > decorationsForLine(const Kate::TextLine &textLine, int line, bool selectionsOnly=false, KateRenderRange *completionHighlight=0L, bool completionSelected=false) const
The ultimate decoration creation function.
Definition: katerenderer.cpp:340
KateRenderer::setShowIndentLines
void setShowIndentLines(bool showLines)
Set whether a guide should be painted to help identifying indent lines.
Definition: katerenderer.cpp:125
KateRenderer::setDrawCaret
void setDrawCaret(bool drawCaret)
Set whether the caret (text cursor) will be drawn.
Definition: katerenderer.cpp:95
KateRenderRange
Definition: katerenderrange.h:35
KateRenderer::isLineRightToLeft
bool isLineRightToLeft(KateLineLayoutPtr lineLayout) const
This is a smaller QString::isRightToLeft().
Definition: katerenderer.cpp:1010
QList< QTextLayout::FormatRange >
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:52 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
  • Applications
  •   Libraries
  •     libkonq
  • 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