edbee - Qt Editor Library
Public Slots | Public Member Functions | Protected Slots | List of all members
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. More...
 
void invalidateCaches ()
 call this method to invalidate all caches! More...
 

Public Member Functions

 TextRenderer (TextEditorController *controller)
 The default textrenderer constructor. More...
 
virtual ~TextRenderer ()
 the destructor More...
 
virtual void init ()
 The init method is called if all objects required for editing have been created! More...
 
virtual void reset ()
 This method resets all caching information. More...
 
int lineHeight ()
 This method returns the (maximum) line-height in pixels. More...
 
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. More...
 
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. More...
 
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. More...
 
int totalHeight ()
 This method returns the total height. More...
 
int emWidth ()
 This method returns width of the M cahracter. More...
 
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. More...
 
int viewHeightInLines ()
 This method returns the number of lines. More...
 
int firstVisibleLine ()
 This method returns the first visible line. More...
 
int columnIndexForXpos (int line, int x)
 This method returns the (closet) valid column for the given x-position. More...
 
int xPosForColumn (int line, int column)
 This method returns the x position for the given column. More...
 
int xPosForOffset (int offset)
 This method returns the x-coordinate for the given offset. More...
 
int yPosForLine (int line)
 This method returns the y position for the given line. More...
 
int yPosForOffset (int offset)
 This method returns the offset position for the given line. More...
 
QTextLayout * textLayoutForLine (int line)
 This method returns the textlayout for the given line. More...
 
void renderBegin (const QRect &rect)
 This method starts rendering. More...
 
void renderEnd (const QRect &rect)
 This method starts rendering. More...
 
TextDocumenttextDocument ()
 This method returns the document. More...
 
TextSelectiontextSelection ()
 This method returns the textselection. More...
 
TextEditorConfigconfig ()
 Returns the editor configuration. More...
 
TextEditorControllercontroller ()
 returns a reference to the given controller More...
 
TextEditorWidgettextWidget ()
 This method returns the widget. More...
 
void setViewport (const QRect &viewport)
 Sets the current viewport of the renderer. More...
 
void resetCaretTime ()
 sets the caret time on 0 More...
 
bool shouldRenderCaret ()
 this method returnst true if the caret is visible More...
 
bool isCaretVisible ()
 Returns true if the caret is visible. More...
 
void setCaretVisible (bool visible)
 sets the carets to visible or invisible More...
 
QRect viewport ()
 
int viewportX ()
 
int viewportY ()
 
int viewportWidth ()
 
int viewportHeight ()
 
TextThemeStylerthemeStyler ()
 
QString themeName () const
 returns the current theme name More...
 
TextThemetheme ()
 Returns the active theme. More...
 
void setThemeByName (const QString &name)
 Selects the active theme name. More...
 
void setTheme (TextTheme *theme)
 sets the theme More...
 
const QRect * clipRect ()
 This method is valid only while rendering! More...
 
int startOffset ()
 This method is valid only while rendering! More...
 
int endOffset ()
 This method is valid only while rendering! More...
 
int startLine ()
 This method is valid only while rendering! More...
 
int endLine ()
 This method is valid only while rendering! More...
 

Protected Slots

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

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.

◆ 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.

◆ 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.

◆ 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 returnst 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)
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()

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

This method returns the textlayout for the given 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.

◆ 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: