Kate
KateRenderer Class Reference
#include <katerenderer.h>
Detailed Description
Handles all of the work of rendering the text (used for the views and printing).Definition at line 51 of file katerenderer.h.
Public Types | |
enum | caretStyles { Line, Block } |
Public Member Functions | |
KTextEditor::Attribute::Ptr | attribute (uint pos) const |
KateRenderer::caretStyles | caretStyle () const |
KateRendererConfig * | config () const |
const QFont & | currentFont () const |
const QFontMetrics & | currentFontMetrics () const |
int | cursorToX (const KateTextLayout &range, const KTextEditor::Cursor &pos) const |
int | cursorToX (const KateTextLayout &range, int col) const |
QList< QTextLayout::FormatRange > | decorationsForLine (const KateTextLine::Ptr &textLine, int line, bool selectionsOnly=false, KateRenderRange *completionHighlight=0L, bool completionSelected=false) const |
void | decreaseFontSizes () |
KateDocument * | doc () const |
uint | documentHeight () |
bool | drawCaret () const |
KateSmartRegion & | dynamicRegion () |
uint | fontHeight () |
bool | getSelectionBounds (int line, int lineLength, int &start, int &end) const |
void | increaseFontSizes () |
bool | isLineRightToLeft (KateLineLayoutPtr lineLayout) const |
bool | isPrinterFriendly () const |
KateRenderer (KateDocument *doc, KateView *view=0) | |
void | layoutLine (KateLineLayoutPtr line, int maxwidth=-1, bool cacheLayout=false) const |
void | paintTextLine (QPainter &paint, KateLineLayoutPtr range, int xStart, int xEnd, const KTextEditor::Cursor *cursor=0L) |
void | paintTextLineBackground (QPainter &paint, KateLineLayoutPtr layout, int currentViewLine, int xStart, int xEnd) |
void | setCaretOverrideColor (const QColor &color) |
void | setCaretStyle (KateRenderer::caretStyles style) |
void | setDrawCaret (bool drawCaret) |
void | setIndentWidth (int indentWidth) |
void | setPrinterFriendly (bool printerFriendly) |
void | setShowIndentLines (bool showLines) |
void | setShowSelections (bool showSelections) |
void | setShowTabs (bool showTabs) |
void | setShowTrailingSpaces (bool showSpaces) |
void | setTabWidth (int tabWidth) |
bool | showIndentLines () const |
bool | showSelections () const |
bool | showTabs () const |
bool | showTrailingSpaces () const |
uint | spaceWidth () const |
KTextEditor::Attribute::Ptr | specificAttribute (int context) const |
uint | textWidth (const KTextEditor::Cursor &cursor) |
uint | textWidth (const KateTextLine::Ptr &textLine, uint startcol, uint maxwidth, bool *needWrap, int *endX=0) |
uint | textWidth (const KateTextLine::Ptr &, int cursorCol) |
void | updateAttributes () |
void | updateConfig () |
KateView * | view () const |
KTextEditor::Cursor | xToCursor (const KateTextLayout &range, int x, bool returnPastLine=false) const |
~KateRenderer () |
Member Enumeration Documentation
Constructor & Destructor Documentation
KateRenderer::KateRenderer | ( | KateDocument * | doc, | |
KateView * | view = 0 | |||
) | [explicit] |
Constructor.
- Parameters:
-
doc document to render view view which is output (0 for example for rendering to print)
Definition at line 44 of file katerenderer.cpp.
KateRenderer::~KateRenderer | ( | ) |
Member Function Documentation
KTextEditor::Attribute::Ptr KateRenderer::attribute | ( | uint | pos | ) | const |
This takes an in index, and returns all the attributes for it.
For example, if you have a ktextline, and want the KTextEditor::Attribute for a given position, do:
attribute(myktextline->attribute(position));
Definition at line 71 of file katerenderer.cpp.
KateRenderer::caretStyles KateRenderer::caretStyle | ( | ) | const [inline] |
The style of the caret (text cursor) to be painted.
- Returns:
- caretStyle
Definition at line 106 of file katerenderer.h.
KateRendererConfig* KateRenderer::config | ( | ) | const [inline] |
const QFont & KateRenderer::currentFont | ( | ) | const |
Definition at line 660 of file katerenderer.cpp.
const QFontMetrics & KateRenderer::currentFontMetrics | ( | ) | const |
Definition at line 665 of file katerenderer.cpp.
int KateRenderer::cursorToX | ( | const KateTextLayout & | range, | |
const KTextEditor::Cursor & | pos | |||
) | const |
Definition at line 878 of file katerenderer.cpp.
int KateRenderer::cursorToX | ( | const KateTextLayout & | range, | |
int | col | |||
) | const |
Returns the x position of cursor col
on the line range
.
Definition at line 873 of file katerenderer.cpp.
QList< QTextLayout::FormatRange > KateRenderer::decorationsForLine | ( | const KateTextLine::Ptr & | textLine, | |
int | line, | |||
bool | selectionsOnly = false , |
|||
KateRenderRange * | completionHighlight = 0L , |
|||
bool | completionSelected = false | |||
) | const |
The ultimate decoration creation function.
- Parameters:
-
range line to return decoration for selectionsOnly return decorations for selections and/or dynamic highlighting.
Definition at line 291 of file katerenderer.cpp.
void KateRenderer::decreaseFontSizes | ( | ) |
Definition at line 140 of file katerenderer.cpp.
KateDocument* KateRenderer::doc | ( | ) | const [inline] |
uint KateRenderer::documentHeight | ( | ) |
Definition at line 675 of file katerenderer.cpp.
bool KateRenderer::drawCaret | ( | ) | const [inline] |
Determine whether the caret (text cursor) will be drawn.
- Returns:
- should it be drawn?
Definition at line 94 of file katerenderer.h.
KateSmartRegion& KateRenderer::dynamicRegion | ( | ) | [inline] |
Definition at line 221 of file katerenderer.h.
uint KateRenderer::fontHeight | ( | ) |
Definition at line 670 of file katerenderer.cpp.
bool KateRenderer::getSelectionBounds | ( | int | line, | |
int | lineLength, | |||
int & | start, | |||
int & | end | |||
) | const |
Definition at line 680 of file katerenderer.cpp.
void KateRenderer::increaseFontSizes | ( | ) |
bool KateRenderer::isLineRightToLeft | ( | KateLineLayoutPtr | lineLayout | ) | const |
A QString::isRightToLeft() on steroids.
This function will guess the best direction of this line/paragraph by measuring which type of characters is mostly available on that line. If the number of LTR characters is the same as RTL characters, this method will return false.
Definition at line 838 of file katerenderer.cpp.
bool KateRenderer::isPrinterFriendly | ( | ) | const |
- Returns:
- whether the renderer is configured to paint in a printer-friendly fashion.
Definition at line 150 of file katerenderer.cpp.
void KateRenderer::layoutLine | ( | KateLineLayoutPtr | line, | |
int | maxwidth = -1 , |
|||
bool | cacheLayout = false | |||
) | const |
void KateRenderer::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.
The text line is painted from the upper limit of (0,0). To move that, apply a transform to your painter.
- Parameters:
-
paint painter to use range layout to use in painting this line xStart starting width in pixels. xEnd ending width in pixels. cursor position of the caret, if placed on the current line.
Definition at line 433 of file katerenderer.cpp.
void KateRenderer::paintTextLineBackground | ( | QPainter & | paint, | |
KateLineLayoutPtr | layout, | |||
int | currentViewLine, | |||
int | xStart, | |||
int | xEnd | |||
) |
Paint the background of a line.
Split off from the main paintTextLine method to make it smaller. As it's being called only once per line it shouldn't noticably affect performance and it helps readability a LOT.
- Parameters:
-
paint painter to use layout layout to use in painting this line currentViewLine if one of the view lines is the current line, set this to the index; otherwise -1. xStart starting width in pixels. xEnd ending width in pixels.
Definition at line 164 of file katerenderer.cpp.
void KateRenderer::setCaretOverrideColor | ( | const QColor & | color | ) |
Set a brush with which to override drawing of the caret.
Set to QColor() to clear.
Definition at line 905 of file katerenderer.cpp.
void KateRenderer::setCaretStyle | ( | KateRenderer::caretStyles | style | ) |
Set the style of caret to be painted.
- Parameters:
-
style style to set
Definition at line 92 of file katerenderer.cpp.
void KateRenderer::setDrawCaret | ( | bool | drawCaret | ) |
Set whether the caret (text cursor) will be drawn.
- Parameters:
-
drawCaret should caret be drawn?
Definition at line 87 of file katerenderer.cpp.
void KateRenderer::setIndentWidth | ( | int | indentWidth | ) |
Sets the width of the tab.
Helps performance.
- Parameters:
-
indentWidth new indent width
Definition at line 122 of file katerenderer.cpp.
void KateRenderer::setPrinterFriendly | ( | bool | printerFriendly | ) |
Configure this renderer to paint in a printer-friendly fashion.
Sets the other options appropriately if true.
Definition at line 155 of file katerenderer.cpp.
void KateRenderer::setShowIndentLines | ( | bool | showLines | ) |
Set whether a guide should be painted to help identifying indent lines.
- Parameters:
-
showLines show the indent lines?
Definition at line 117 of file katerenderer.cpp.
void KateRenderer::setShowSelections | ( | bool | showSelections | ) |
Set whether the view's selections should be shown.
The default is true.
- Parameters:
-
showSelections show the selections?
Definition at line 127 of file katerenderer.cpp.
void KateRenderer::setShowTabs | ( | bool | showTabs | ) |
Set whether a mark should be painted to help identifying tabs.
- Parameters:
-
showTabs show the tabs?
Definition at line 97 of file katerenderer.cpp.
void KateRenderer::setShowTrailingSpaces | ( | bool | showSpaces | ) |
Set whether a mark should be painted for trailing spaces.
Definition at line 102 of file katerenderer.cpp.
void KateRenderer::setTabWidth | ( | int | tabWidth | ) |
Sets the width of the tab.
Helps performance.
- Parameters:
-
tabWidth new tab width
Definition at line 107 of file katerenderer.cpp.
bool KateRenderer::showIndentLines | ( | ) | const |
- Returns:
- whether indent lines should be shown
- Returns:
- indent lines should be shown
Definition at line 112 of file katerenderer.cpp.
bool KateRenderer::showSelections | ( | ) | const [inline] |
bool KateRenderer::showTabs | ( | ) | const [inline] |
- Returns:
- whether tabs should be shown (ie.
a small mark drawn to identify a tab)
- Returns:
- tabs should be shown
Definition at line 124 of file katerenderer.h.
bool KateRenderer::showTrailingSpaces | ( | ) | const [inline] |
uint KateRenderer::spaceWidth | ( | ) | const |
Definition at line 736 of file katerenderer.cpp.
KTextEditor::Attribute::Ptr KateRenderer::specificAttribute | ( | int | context | ) | const |
Definition at line 79 of file katerenderer.cpp.
uint KateRenderer::textWidth | ( | const KTextEditor::Cursor & | cursor | ) |
uint KateRenderer::textWidth | ( | const KateTextLine::Ptr & | textLine, | |
uint | startcol, | |||
uint | maxwidth, | |||
bool * | needWrap, | |||
int * | endX = 0 | |||
) |
uint KateRenderer::textWidth | ( | const KateTextLine::Ptr & | , | |
int | cursorCol | |||
) |
void KateRenderer::updateAttributes | ( | ) |
update the highlighting attributes (for example after an hl change or after hl config changed)
Definition at line 66 of file katerenderer.cpp.
void KateRenderer::updateConfig | ( | ) |
Definition at line 727 of file katerenderer.cpp.
KateView* KateRenderer::view | ( | ) | const [inline] |
KTextEditor::Cursor KateRenderer::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.
If returnPastLine
is true, the column will be extrapolated out with the assumption that the extra characters are spaces.
Definition at line 885 of file katerenderer.cpp.
The documentation for this class was generated from the following files: