Envision
A visual programming IDE for object-oriented languages
List of all members | Public Member Functions | Private Attributes
Visualization::TextCursor Class Reference
Inheritance diagram for Visualization::TextCursor:
Visualization::Cursor

Public Member Functions

 TextCursor (TextRenderer *owner)
 
int caretPosition ()
 
virtual TextCursorclone () const override
 
int cursorAtX (int x) const
 
bool hasSelection ()
 
virtual bool isAtBoundary () const override
 
bool isCursorBeforeSelection ()
 
virtual bool isSame (Cursor *c) override
 Returns true if this cursor is the same as the cursor other. More...
 
TextRendererowner () const override
 
void selectAll ()
 
int selectionBegin ()
 
int selectionEnd ()
 
int selectionFirstIndex ()
 
int selectionLastIndex ()
 
void setCaretPosition (int beforeCharacter)
 
void setSelectedByDrag (int xBegin, int xEnd)
 
void setSelectedCharacters (int first, int last)
 
void setSelection (int selectionBegin, int selectionEnd)
 
void setVisualizationSize (const QSize &size)
 
void setX (int xBegin, int xEnd)
 
virtual void update () override
 Called on every scene update to update the cursor. More...
 
void update (const QFontMetrics &qfm)
 
int xBegin ()
 
int xEnd ()
 
- Public Member Functions inherited from Visualization::Cursor
 Cursor (const Cursor &other)
 
 Cursor (Item *owner, CursorType type, Item *visualization=nullptr)
 
virtual ~Cursor ()
 
virtual bool isLocationEquivalent (bool otherNotLocationEquivalent, CursorType otherType, bool otherIsAtBoundary, Item *otherOwner)
 
virtual bool isLocationEquivalent (Cursor *c)
 Returns true if this cursor is equivalent with respect to its location to the cursor c. More...
 
bool notLocationEquivalent () const
 
Cursoroperator= (const Cursor &other)=delete
 
const QPoint & position ()
 Returns the position of this cursor in corrdinates local to owner() More...
 
const QRect & region ()
 Returns the region of this cursor in corrdinates local to owner() More...
 
QRect sceneRegion ()
 Returns the region of this cursor in scene coordinates. More...
 
void setNotLocationEquivalent (bool notEquivalent)
 
void setPosition (const QPoint &pos)
 
void setRegion (const QRect &region)
 
CursorType type () const
 
Itemvisualization ()
 

Private Attributes

int selectionBegin_
 selectionBegin_ and selectionEnd_ indicate the currently selected characters in a text. More...
 
int selectionEnd_
 
int xBegin_
 xBegin_ and xEnd_ indicate the beginning and end (along the X coordinate) where the selection background must be drawn. More...
 
int xEnd_
 

Additional Inherited Members

- Public Types inherited from Visualization::Cursor
enum  CursorType { VerticalCursor , HorizontalCursor , BoxCursor }
 
- Protected Member Functions inherited from Visualization::Cursor
void setVisualization (Item *visualization)
 

Constructor & Destructor Documentation

◆ TextCursor()

Visualization::TextCursor::TextCursor ( TextRenderer owner)

Member Function Documentation

◆ caretPosition()

int Visualization::TextCursor::caretPosition ( )
inline

◆ clone()

TextCursor * Visualization::TextCursor::clone ( ) const
overridevirtual

Reimplemented from Visualization::Cursor.

◆ cursorAtX()

int Visualization::TextCursor::cursorAtX ( int  x) const

◆ hasSelection()

bool Visualization::TextCursor::hasSelection ( )
inline

◆ isAtBoundary()

bool Visualization::TextCursor::isAtBoundary ( ) const
overridevirtual

Reimplemented from Visualization::Cursor.

◆ isCursorBeforeSelection()

bool Visualization::TextCursor::isCursorBeforeSelection ( )
inline

◆ isSame()

bool Visualization::TextCursor::isSame ( Cursor other)
overridevirtual

Returns true if this cursor is the same as the cursor other.

Two cursors are the same if they have the same owner and if they represent the same location within that owner.

Reimplemented from Visualization::Cursor.

◆ owner()

TextRenderer * Visualization::TextCursor::owner ( ) const
overridevirtual

Reimplemented from Visualization::Cursor.

◆ selectAll()

void Visualization::TextCursor::selectAll ( )

◆ selectionBegin()

int Visualization::TextCursor::selectionBegin ( )
inline

◆ selectionEnd()

int Visualization::TextCursor::selectionEnd ( )
inline

◆ selectionFirstIndex()

int Visualization::TextCursor::selectionFirstIndex ( )
inline

◆ selectionLastIndex()

int Visualization::TextCursor::selectionLastIndex ( )
inline

◆ setCaretPosition()

void Visualization::TextCursor::setCaretPosition ( int  beforeCharacter)
inline

◆ setSelectedByDrag()

void Visualization::TextCursor::setSelectedByDrag ( int  xBegin,
int  xEnd 
)

◆ setSelectedCharacters()

void Visualization::TextCursor::setSelectedCharacters ( int  first,
int  last 
)

◆ setSelection()

void Visualization::TextCursor::setSelection ( int  selectionBegin,
int  selectionEnd 
)
inline

◆ setVisualizationSize()

void Visualization::TextCursor::setVisualizationSize ( const QSize &  size)

◆ setX()

void Visualization::TextCursor::setX ( int  xBegin,
int  xEnd 
)

◆ update() [1/2]

void Visualization::TextCursor::update ( )
overridevirtual

Called on every scene update to update the cursor.

The default implementation checks if this is a BoxCursor and if so it assumes it is a whole item cursor to update its position and size. Otherwise it does nothing.

Reimplement this in derived classes to update the cursor's position and size appropriately.

Reimplemented from Visualization::Cursor.

◆ update() [2/2]

void Visualization::TextCursor::update ( const QFontMetrics &  qfm)

◆ xBegin()

int Visualization::TextCursor::xBegin ( )
inline

◆ xEnd()

int Visualization::TextCursor::xEnd ( )
inline

Member Data Documentation

◆ selectionBegin_

int Visualization::TextCursor::selectionBegin_
private

selectionBegin_ and selectionEnd_ indicate the currently selected characters in a text.

If the text has been selected from right to left then selectionEnd_ < selectionBegin_. If the entire text is selected then selectionBegin_ and selectionEnd_ will have the values 0 and text.length().

◆ selectionEnd_

int Visualization::TextCursor::selectionEnd_
private
See also
selectionBegin_

◆ xBegin_

int Visualization::TextCursor::xBegin_
private

xBegin_ and xEnd_ indicate the beginning and end (along the X coordinate) where the selection background must be drawn.

◆ xEnd_

int Visualization::TextCursor::xEnd_
private
See also
xBegin_