katerenderer.h
/* This file is part of the KDE libraries
Copyright (C) 2003 Hamish Rodda <rodda@kde.org>
Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __KATE_RENDERER_H__
#define __KATE_RENDERER_H__
#include "katecursor.h"
#include "kateattribute.h"
#include "katetextline.h"
#include <qfont.h>
#include <qfontmetrics.h>
class KateDocument;
class KateView;
class KateLineRange;
class KateRendererConfig;
class KateRenderer
{
public:
enum caretStyles {
Insert,
Replace
};
KateRenderer(KateDocument* doc, KateView *view = 0);
~KateRenderer();
void updateAttributes ();
inline bool drawCaret() const { return m_drawCaret; }
void setDrawCaret(bool drawCaret);
inline KateRenderer::caretStyles caretStyle() const { return m_caretStyle; }
void setCaretStyle(KateRenderer::caretStyles style);
inline bool showTabs() const { return m_showTabs; }
void setShowTabs(bool showTabs);
void setTabWidth(int tabWidth);
bool showIndentLines() const;
void setShowIndentLines(bool showLines);
void setIndentWidth(int indentWidth);
inline bool showSelections() const { return m_showSelections; }
void setShowSelections(bool showSelections);
void increaseFontSizes();
void decreaseFontSizes();
const QFont* currentFont();
const QFontMetrics* currentFontMetrics();
bool isPrinterFriendly() const;
void setPrinterFriendly(bool printerFriendly);
// Width calculators
uint spaceWidth();
uint textWidth(const KateTextLine::Ptr &, int cursorCol);
uint textWidth(const KateTextLine::Ptr &textLine, uint startcol, uint maxwidth, bool *needWrap, int *endX = 0);
uint textWidth(const KateTextCursor &cursor);
// Cursor constrainer
uint textWidth(KateTextCursor &cursor, int xPos, uint startCol = 0);
// Column calculators
uint textPos(uint line, int xPos, uint startCol = 0, bool nearest=true);
uint textPos(const KateTextLine::Ptr &, int xPos, uint startCol = 0, bool nearest=true);
// Font height
uint fontHeight();
// Document height
uint documentHeight();
// Selection boundaries
bool getSelectionBounds(uint line, uint lineLength, uint &start, uint &end);
void paintTextLine(QPainter& paint, const KateLineRange* range, int xStart, int xEnd, const KateTextCursor* cursor = 0L, const KateBracketRange* bracketmark = 0L);
bool paintTextLineBackground(QPainter& paint, int line, bool isCurrentLine, int xStart, int xEnd);
KateAttribute* attribute(uint pos);
private:
void paintWhitespaceMarker(QPainter &paint, uint x, uint y);
void paintIndentMarker(QPainter &paint, uint x, uint y);
KateDocument* m_doc;
KateView *m_view;
// cache of config values
int m_tabWidth;
int m_indentWidth;
uint m_schema;
// some internal flags
KateRenderer::caretStyles m_caretStyle;
bool m_drawCaret;
bool m_showSelections;
bool m_showTabs;
bool m_printerFriendly;
QMemArray<KateAttribute> *m_attributes;
public:
inline KateRendererConfig *config () { return m_config; };
void updateConfig ();
private:
KateRendererConfig *m_config;
};
#endif
KateTextCursor
Simple cursor class with no document pointer.
Definition: katecursor.h:33
KateRenderer::setShowSelections
void setShowSelections(bool showSelections)
Set whether the view's selections should be shown.
Definition: katerenderer.cpp:116
KateAttribute
The Attribute class incorporates all text decorations supported by Kate.
Definition: kateattribute.h:32
KSharedPtr
KateRenderer::drawCaret
bool drawCaret() const
Determine whether the caret (text cursor) will be drawn.
Definition: katerenderer.h:75
KateRenderer::textPos
uint textPos(uint line, int xPos, uint startCol=0, bool nearest=true)
Definition: katerenderer.cpp:932
KateRenderer::attribute
KateAttribute * attribute(uint pos)
This takes an in index, and returns all the attributes for it.
Definition: katerenderer.cpp:69
KateRenderer::increaseFontSizes
void increaseFontSizes()
Change to a different font (soon to be font set?)
Definition: katerenderer.cpp:121
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:42
KateRenderer::setShowTabs
void setShowTabs(bool showTabs)
Set whether a mark should be painted to help identifying tabs.
Definition: katerenderer.cpp:87
KateRenderer::spaceWidth
uint spaceWidth()
Text width & height calculation functions...
Definition: katerenderer.cpp:1027
KateRenderer::setPrinterFriendly
void setPrinterFriendly(bool printerFriendly)
Configure this renderer to paint in a printer-friendly fashion.
Definition: katerenderer.cpp:144
KateRenderer::showIndentLines
bool showIndentLines() const
Definition: katerenderer.cpp:97
KateRenderer::config
KateRendererConfig * config()
Configuration.
Definition: katerenderer.h:264
KateRenderer::showSelections
bool showSelections() const
Show the view's selection?
Definition: katerenderer.h:136
KateRenderer::showTabs
bool showTabs() const
Definition: katerenderer.h:100
KateRenderer::paintTextLineBackground
bool paintTextLineBackground(QPainter &paint, int line, bool isCurrentLine, int xStart, int xEnd)
Paint the background of a line.
Definition: katerenderer.cpp:152
KateRenderer::setIndentWidth
void setIndentWidth(int indentWidth)
Sets the width of the tab.
Definition: katerenderer.cpp:107
KateRenderer::~KateRenderer
~KateRenderer()
Destructor.
Definition: katerenderer.cpp:57
KateRenderer::updateAttributes
void updateAttributes()
update the highlighting attributes (for example after an hl change or after hl config changed) ...
Definition: katerenderer.cpp:63
KateRenderer::setTabWidth
void setTabWidth(int tabWidth)
Sets the width of the tab.
Definition: katerenderer.cpp:92
KateRenderer::caretStyles
caretStyles
Style of Caret (Insert or Replace mode)
Definition: katerenderer.h:48
KateRenderer::caretStyle
KateRenderer::caretStyles caretStyle() const
The style of the caret (text cursor) to be painted.
Definition: katerenderer.h:87
KateRenderer::isPrinterFriendly
bool isPrinterFriendly() const
Definition: katerenderer.cpp:139
KateRenderer::setCaretStyle
void setCaretStyle(KateRenderer::caretStyles style)
Set the style of caret to be painted.
Definition: katerenderer.cpp:82
KateRenderer::setShowIndentLines
void setShowIndentLines(bool showLines)
Set whether a guide should be painted to help identifying indent lines.
Definition: katerenderer.cpp:102
KateRenderer::setDrawCaret
void setDrawCaret(bool drawCaret)
Set whether the caret (text cursor) will be drawn.
Definition: katerenderer.cpp:77
KateRenderer::KateRenderer
KateRenderer(KateDocument *doc, KateView *view=0)
Constructor.
Definition: katerenderer.cpp:37
KateRenderer::paintTextLine
void paintTextLine(QPainter &paint, const KateLineRange *range, int xStart, int xEnd, const KateTextCursor *cursor=0L, const KateBracketRange *bracketmark=0L)
This is the ultimate function to perform painting of a text line.
Definition: katerenderer.cpp:253

KDE Home | KDE Accessibility Home | Description of Access Keys