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

A virtual textlayout. More...

#include <textlayout.h>

+ Collaboration diagram for edbee::TextLayout:

Public Member Functions

 TextLayout (TextDocument *document)
 
virtual ~TextLayout ()
 
void setCacheEnabled (bool enable)
 
QTextLayout * qTextLayout () const
 
QRectF boundingRect () const
 
void buildLayout ()
 
int toVirtualCursorPosition (int cursor) const
 Converts the document cursorPosition to a virtual cursorposition.
 
int fromVirtualCursorPosition (int cursor) const
 Converts the virtual cursorPosition to a docuemnt cursorposition.
 
void draw (QPainter *p, const QPointF &pos, const QVector< QTextLayout::FormatRange > &selections=QVector< QTextLayout::FormatRange >(), const QRectF &clip=QRectF()) const
 
void drawCursor (QPainter *painter, const QPointF &position, int cursorPosition, int width) const
 
void setFormats (const QVector< QTextLayout::FormatRange > &formats)
 
void setText (const QString &string)
 
void useSingleCharRanges ()
 
TextRangeSetsingleCharRanges () const
 
void addSingleCharRange (int index, int length)
 
qreal cursorToX (int cursorPos, QTextLine::Edge edge=QTextLine::Leading) const
 These calculations manipulate the cursor position. ..
 
int xToCursor (qreal x, QTextLine::CursorPosition cpos=QTextLine::CursorBetweenCharacters) const
 

Protected Attributes

QTextLayout * qtextLayout_
 
TextDocumenttextDocumentRef_
 
TextRangeSetsingleCharRanges_
 A list textRanges_ used by TextLayout. Every range in this list is treatet as a single character for cusor-movement etc.
 
QTextLine qtextLine_
 

Detailed Description

A virtual textlayout.

This class wraps the QTextLayout used for rendering. Modifying all cursor/positioning related methods, supporting single-cursor items, while rendering multiple QTextLayout characters

Note: this is very Edbee specific. Every TextLayout has got a single line!

Constructor & Destructor Documentation

◆ TextLayout()

edbee::TextLayout::TextLayout ( TextDocument * document)

◆ ~TextLayout()

edbee::TextLayout::~TextLayout ( )
virtual

Member Function Documentation

◆ addSingleCharRange()

void edbee::TextLayout::addSingleCharRange ( int index,
int length )

◆ boundingRect()

QRectF edbee::TextLayout::boundingRect ( ) const

◆ buildLayout()

void edbee::TextLayout::buildLayout ( )

◆ cursorToX()

qreal edbee::TextLayout::cursorToX ( int cursorPos,
QTextLine::Edge edge = QTextLine::Leading ) const

These calculations manipulate the cursor position. ..

Todo
: store the orginal number of replace characters)

◆ draw()

void edbee::TextLayout::draw ( QPainter * p,
const QPointF & pos,
const QVector< QTextLayout::FormatRange > & selections = QVector<QTextLayout::FormatRange>(),
const QRectF & clip = QRectF() ) const

◆ drawCursor()

void edbee::TextLayout::drawCursor ( QPainter * painter,
const QPointF & position,
int cursorPosition,
int width ) const

◆ fromVirtualCursorPosition()

int edbee::TextLayout::fromVirtualCursorPosition ( int cursor) const

Converts the virtual cursorPosition to a docuemnt cursorposition.

◆ qTextLayout()

QTextLayout * edbee::TextLayout::qTextLayout ( ) const

◆ setCacheEnabled()

void edbee::TextLayout::setCacheEnabled ( bool enable)

◆ setFormats()

void edbee::TextLayout::setFormats ( const QVector< QTextLayout::FormatRange > & formats)

◆ setText()

void edbee::TextLayout::setText ( const QString & string)

◆ singleCharRanges()

TextRangeSet * edbee::TextLayout::singleCharRanges ( ) const

◆ toVirtualCursorPosition()

int edbee::TextLayout::toVirtualCursorPosition ( int cursor) const

Converts the document cursorPosition to a virtual cursorposition.

◆ useSingleCharRanges()

void edbee::TextLayout::useSingleCharRanges ( )

◆ xToCursor()

int edbee::TextLayout::xToCursor ( qreal x,
QTextLine::CursorPosition cpos = QTextLine::CursorBetweenCharacters ) const

Member Data Documentation

◆ qtextLayout_

QTextLayout* edbee::TextLayout::qtextLayout_
protected

◆ qtextLine_

QTextLine edbee::TextLayout::qtextLine_
protected

◆ singleCharRanges_

TextRangeSet* edbee::TextLayout::singleCharRanges_
protected

A list textRanges_ used by TextLayout. Every range in this list is treatet as a single character for cusor-movement etc.

◆ textDocumentRef_

TextDocument* edbee::TextLayout::textDocumentRef_
protected

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