edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
edbee::TextRenderer Class Reference

A class for rendering the text. More...

#include <textrenderer.h>

+ Inheritance diagram for edbee::TextRenderer:
+ Collaboration diagram for edbee::TextRenderer:

Public Slots

void invalidateTextLayoutCaches (int fromLine=0)
 Invalidates the QTextLayout caches.
 
void invalidateCaches ()
 call this method to invalidate all caches!
 

Signals

void themeChanged (TextTheme *theme)
 

Public Member Functions

 TextRenderer (TextEditorController *controller)
 The default textrenderer constructor.
 
virtual ~TextRenderer ()
 the destructor
 
virtual void init ()
 The init method is called if all objects required for editing have been created!
 
virtual void reset ()
 This method resets all caching information.
 
int lineHeight ()
 This method returns the (maximum) line-height in pixels.
 
int rawLineIndexForYpos (int y)
 This method converts the give y position to a line index Warning this returns a RAW line index, which means it can be an invalid line.
 
int lineIndexForYpos (int y)
 This method returns a valid line index for the given y-pos If the y-position isn't on a line it returns a value < 0.
 
int totalWidth ()
 Returns the total width of the editor. This method is NOT the real with This method takes the maximum line length and multiplies it with the widest character.
 
int totalHeight ()
 This method returns the total height.
 
int emWidth ()
 This method returns width of the M cahracter.
 
int nrWidth ()
 The M-width isn't good enough for calculating the width of numbers. Often the M is to wide. That why we have a nr width which takes the 8 for the width.
 
int viewHeightInLines ()
 This method returns the number of lines.
 
int firstVisibleLine ()
 This method returns the first visible line.
 
int columnIndexForXpos (int line, int x)
 This method returns the (closet) valid column for the given x-position.
 
int xPosForColumn (int line, int column)
 This method returns the x position for the given column.
 
int xPosForOffset (int offset)
 This method returns the x-coordinate for the given offset.
 
int yPosForLine (int line)
 This method returns the y position for the given line.
 
int yPosForOffset (int offset)
 This method returns the offset position for the given line.
 
int lineCount ()
 
QString getLine (int index)
 
TextLayouttextLayoutForLine (int line)
 This method returns the textlayout for the given line.
 
TextLayouttextLayoutForLineForPlaceholder (int line)
 
TextLayouttextLayoutForLineNormal (int line)
 
void renderBegin (const QRect &rect)
 This method starts rendering.
 
void renderEnd (const QRect &rect)
 This method starts rendering.
 
TextDocumenttextDocument ()
 This method returns the document.
 
TextDocumentplaceholderTextDocument ()
 
TextSelectiontextSelection ()
 This method returns the textselection.
 
TextEditorConfigconfig ()
 Returns the editor configuration.
 
TextEditorControllercontroller ()
 returns a reference to the given controller
 
TextEditorWidgettextWidget ()
 This method returns the widget.
 
void setViewport (const QRect &viewport)
 Sets the current viewport of the renderer.
 
void resetCaretTime ()
 sets the caret time on 0
 
bool shouldRenderCaret ()
 this method returns true if the caret is visible
 
bool isCaretVisible ()
 Returns true if the caret is visible.
 
void setCaretVisible (bool visible)
 sets the carets to visible or invisible
 
QRect viewport ()
 
int viewportX ()
 
int viewportY ()
 
int viewportWidth ()
 
int viewportHeight ()
 
TextThemeStylerthemeStyler ()
 
QString themeName () const
 returns the current theme name
 
TextThemetheme ()
 Returns the active theme.
 
void setThemeByName (const QString &name)
 Selects the active theme name.
 
void setTheme (TextTheme *theme)
 sets the theme
 
const QRect * clipRect ()
 This method is valid only while rendering!
 
int startOffset ()
 This method is valid only while rendering!
 
int endOffset ()
 This method is valid only while rendering!
 
int startLine ()
 This method is valid only while rendering!
 
int endLine ()
 This method is valid only while rendering!
 

Protected Slots

void textDocumentChanged (edbee::TextDocument *oldDocument, edbee::TextDocument *newDocument)
 The text-document has been changed.
 
void textChanged (edbee::TextBufferChange change, QString oldText=QString())
 The text is replaced.
 
void lastScopedOffsetChanged (int previousOffset, int newOffset)
 The scoped to offset has been changed.
 

Detailed Description

A class for rendering the text.

Todo
: Currently this class is also used for positioning text. This probably should be moved in a class of its own

Constructor & Destructor Documentation

◆ TextRenderer()

edbee::TextRenderer::TextRenderer ( TextEditorController * controller)

The default textrenderer constructor.

◆ ~TextRenderer()

edbee::TextRenderer::~TextRenderer ( )
virtual

the destructor

Member Function Documentation

◆ clipRect()

const QRect * edbee::TextRenderer::clipRect ( )
inline

This method is valid only while rendering!

◆ columnIndexForXpos()

int edbee::TextRenderer::columnIndexForXpos ( int line,
int x )

This method returns the (closet) valid column for the given x-position.

◆ config()

TextEditorConfig * edbee::TextRenderer::config ( )

Returns the editor configuration.

◆ controller()

TextEditorController * edbee::TextRenderer::controller ( )

returns a reference to the given controller

◆ emWidth()

int edbee::TextRenderer::emWidth ( )

This method returns width of the M cahracter.

◆ endLine()

int edbee::TextRenderer::endLine ( )
inline

This method is valid only while rendering!

◆ endOffset()

int edbee::TextRenderer::endOffset ( )
inline

This method is valid only while rendering!

◆ firstVisibleLine()

int edbee::TextRenderer::firstVisibleLine ( )

This method returns the first visible line.

◆ getLine()

QString edbee::TextRenderer::getLine ( int index)

◆ init()

void edbee::TextRenderer::init ( )
virtual

The init method is called if all objects required for editing have been created!

◆ invalidateCaches

void edbee::TextRenderer::invalidateCaches ( )
slot

call this method to invalidate all caches!

◆ invalidateTextLayoutCaches

void edbee::TextRenderer::invalidateTextLayoutCaches ( int fromLine = 0)
slot

Invalidates the QTextLayout caches.

◆ isCaretVisible()

bool edbee::TextRenderer::isCaretVisible ( )

Returns true if the caret is visible.

◆ lastScopedOffsetChanged

void edbee::TextRenderer::lastScopedOffsetChanged ( int previousOffset,
int newOffset )
protectedslot

The scoped to offset has been changed.

◆ lineCount()

int edbee::TextRenderer::lineCount ( )

◆ lineHeight()

int edbee::TextRenderer::lineHeight ( )

This method returns the (maximum) line-height in pixels.

Todo
: cache the height :-)

◆ lineIndexForYpos()

int edbee::TextRenderer::lineIndexForYpos ( int y)

This method returns a valid line index for the given y-pos If the y-position isn't on a line it returns a value < 0.

◆ nrWidth()

int edbee::TextRenderer::nrWidth ( )

The M-width isn't good enough for calculating the width of numbers. Often the M is to wide. That why we have a nr width which takes the 8 for the width.

◆ placeholderTextDocument()

TextDocument * edbee::TextRenderer::placeholderTextDocument ( )

◆ rawLineIndexForYpos()

int edbee::TextRenderer::rawLineIndexForYpos ( int y)

This method converts the give y position to a line index Warning this returns a RAW line index, which means it can be an invalid line.

Parameters
ythe y position

◆ renderBegin()

void edbee::TextRenderer::renderBegin ( const QRect & rect)

This method starts rendering.

Todo
: move this lexing stuff to the controller

◆ renderEnd()

void edbee::TextRenderer::renderEnd ( const QRect & rect)

This method starts rendering.

◆ reset()

void edbee::TextRenderer::reset ( )
virtual

This method resets all caching information.

◆ resetCaretTime()

void edbee::TextRenderer::resetCaretTime ( )

sets the caret time on 0

◆ setCaretVisible()

void edbee::TextRenderer::setCaretVisible ( bool visible)

sets the carets to visible or invisible

◆ setTheme()

void edbee::TextRenderer::setTheme ( TextTheme * theme)

sets the theme

Parameters
themethe them to set

◆ setThemeByName()

void edbee::TextRenderer::setThemeByName ( const QString & name)

Selects the active theme name.

◆ setViewport()

void edbee::TextRenderer::setViewport ( const QRect & viewport)

Sets the current viewport of the renderer.

◆ shouldRenderCaret()

bool edbee::TextRenderer::shouldRenderCaret ( )

this method returns true if the caret is visible

◆ startLine()

int edbee::TextRenderer::startLine ( )
inline

This method is valid only while rendering!

◆ startOffset()

int edbee::TextRenderer::startOffset ( )
inline

This method is valid only while rendering!

◆ textChanged

void edbee::TextRenderer::textChanged ( edbee::TextBufferChange change,
QString oldText = QString() )
protectedslot

The text is replaced.

◆ textDocument()

TextDocument * edbee::TextRenderer::textDocument ( )

This method returns the document.

◆ textDocumentChanged

void edbee::TextRenderer::textDocumentChanged ( edbee::TextDocument * oldDocument,
edbee::TextDocument * newDocument )
protectedslot

The text-document has been changed.

◆ textLayoutForLine()

TextLayout * edbee::TextRenderer::textLayoutForLine ( int line)

This method returns the textlayout for the given line.

Todo
: Invalide TextLayout cache when required!!!

◆ textLayoutForLineForPlaceholder()

TextLayout * edbee::TextRenderer::textLayoutForLineForPlaceholder ( int line)
Todo
: Invalide TextLayout cache when required!!!
Todo
: Make an option to show spaces and tabs

◆ textLayoutForLineNormal()

TextLayout * edbee::TextRenderer::textLayoutForLineNormal ( int line)
Todo
: Invalide TextLayout cache when required!!!
Todo
: Make an option to show spaces and tabs

◆ textSelection()

TextSelection * edbee::TextRenderer::textSelection ( )

This method returns the textselection.

◆ textWidget()

TextEditorWidget * edbee::TextRenderer::textWidget ( )

This method returns the widget.

◆ theme()

TextTheme * edbee::TextRenderer::theme ( )

Returns the active theme.

◆ themeChanged

void edbee::TextRenderer::themeChanged ( TextTheme * theme)
signal

◆ themeName()

QString edbee::TextRenderer::themeName ( ) const

returns the current theme name

◆ themeStyler()

TextThemeStyler * edbee::TextRenderer::themeStyler ( )
inline

◆ totalHeight()

int edbee::TextRenderer::totalHeight ( )

This method returns the total height.

◆ totalWidth()

int edbee::TextRenderer::totalWidth ( )

Returns the total width of the editor. This method is NOT the real with This method takes the maximum line length and multiplies it with the widest character.

◆ viewHeightInLines()

int edbee::TextRenderer::viewHeightInLines ( )

This method returns the number of lines.

◆ viewport()

QRect edbee::TextRenderer::viewport ( )
inline

◆ viewportHeight()

int edbee::TextRenderer::viewportHeight ( )
inline

◆ viewportWidth()

int edbee::TextRenderer::viewportWidth ( )
inline

◆ viewportX()

int edbee::TextRenderer::viewportX ( )
inline

◆ viewportY()

int edbee::TextRenderer::viewportY ( )
inline

◆ xPosForColumn()

int edbee::TextRenderer::xPosForColumn ( int line,
int column )

This method returns the x position for the given column.

◆ xPosForOffset()

int edbee::TextRenderer::xPosForOffset ( int offset)

This method returns the x-coordinate for the given offset.

◆ yPosForLine()

int edbee::TextRenderer::yPosForLine ( int line)

This method returns the y position for the given line.

◆ yPosForOffset()

int edbee::TextRenderer::yPosForOffset ( int offset)

This method returns the offset position for the given line.


The documentation for this class was generated from the following files: