Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CGUIText Class Reference

An CGUIText object is a parsed string, divided into text-rendering components. More...

#include <CGUIText.h>

Collaboration diagram for CGUIText:

Classes

struct  SSpriteCall
 A sprite call to the CRenderer. More...
 
struct  STextCall
 A text call to the CRenderer. More...
 

Public Member Functions

 NONCOPYABLE (CGUIText)
 
 MOVABLE (CGUIText)
 
 CGUIText ()=default
 Generates empty text. More...
 
 CGUIText (const CGUI &pGUI, const CGUIString &string, const CStrW &fontW, const float width, const float bufferZone, const EAlign align, const IGUIObject *pObject)
 Generate a CGUIText object from the inputted string. More...
 
void Draw (CGUI &pGUI, CCanvas2D &canvas, const CGUIColor &DefaultColor, const CVector2D &pos, CRect clipping) const
 Draw this CGUIText object. More...
 
const CSize2DGetSize () const
 
const std::list< SSpriteCall > & GetSpriteCalls () const
 
const std::vector< STextCall > & GetTextCalls () const
 
bool ProcessLine (const CGUI &pGUI, const CGUIString &string, const CStrIntern &font, const IGUIObject *pObject, const SGenerateTextImages &images, const EAlign align, const float prelimLineHeight, const float width, const float bufferZone, bool &firstLine, float &y, int &i, int &from)
 
void SetupSpriteCalls (const CGUI &pGUI, const std::array< std::vector< CStr >, 2 > &feedbackImages, const float y, const float width, const float bufferZone, const int i, const int posLastImage, SGenerateTextImages &images)
 
float GetLineOffset (const EAlign align, const float widthRangeFrom, const float widthRangeTo, const CSize2D &lineSize) const
 
void ComputeLineRange (const SGenerateTextImages &images, const float y, const float width, const float prelimLineHeight, float &widthRangeFrom, float &widthRangeTo) const
 
void ComputeLineSize (const CGUI &pGUI, const CGUIString &string, const CStrIntern &font, const bool firstLine, const float width, const float widthRangeFrom, const float widthRangeTo, const int i, const int tempFrom, CSize2D &lineSize) const
 
bool AssembleCalls (const CGUI &pGUI, const CGUIString &string, const CStrIntern &font, const IGUIObject *pObject, const bool firstLine, const float width, const float widthRangeTo, const float dx, const float y, const int tempFrom, const int i, int &from)
 

Public Attributes

std::vector< STextCallm_TextCalls
 List of TextCalls, for instance "Hello", "there!". More...
 
std::list< SSpriteCallm_SpriteCalls
 List of sprites, or "icons" that should be rendered along with the text. More...
 
CSize2D m_Size
 Width and height of the whole output, used when setting up scrollbars and such. More...
 

Detailed Description

An CGUIText object is a parsed string, divided into text-rendering components.

Each component, being a call to the Renderer. For instance, if you by tags change the color, then the GUI will have to make individual calls saying it want that color on the text.

For instance: "Hello [b]there[/b] bunny!"

That without word-wrapping would mean 3 components. i.e. 3 calls to CRenderer. One drawing "Hello", one drawing "there" in bold, and one drawing "bunny!".

Constructor & Destructor Documentation

◆ CGUIText() [1/2]

CGUIText::CGUIText ( )
default

Generates empty text.

◆ CGUIText() [2/2]

CGUIText::CGUIText ( const CGUI pGUI,
const CGUIString string,
const CStrW &  fontW,
const float  width,
const float  bufferZone,
const EAlign  align,
const IGUIObject pObject 
)

Generate a CGUIText object from the inputted string.

The function will break down the string and its tags to calculate exactly which rendering queries will be sent to the Renderer. Also, horizontal alignment is taken into acount in this method but NOT vertical alignment.

Parameters
stringText to generate CGUIText object from.
fontDefault font, notice both Default color and default font can be changed by tags.
widthWidth, 0 if no word-wrapping.
bufferZoneSpace between text and edge, and space between text and images.
alignHorizontal alignment (left / center / right).
pObjectOptional parameter for error output. Used only if error parsing fails, and we need to be able to output which object the error occurred in to aid the user.

Member Function Documentation

◆ AssembleCalls()

bool CGUIText::AssembleCalls ( const CGUI pGUI,
const CGUIString string,
const CStrIntern font,
const IGUIObject pObject,
const bool  firstLine,
const float  width,
const float  widthRangeTo,
const float  dx,
const float  y,
const int  tempFrom,
const int  i,
int &  from 
)

◆ ComputeLineRange()

void CGUIText::ComputeLineRange ( const SGenerateTextImages images,
const float  y,
const float  width,
const float  prelimLineHeight,
float &  widthRangeFrom,
float &  widthRangeTo 
) const

◆ ComputeLineSize()

void CGUIText::ComputeLineSize ( const CGUI pGUI,
const CGUIString string,
const CStrIntern font,
const bool  firstLine,
const float  width,
const float  widthRangeFrom,
const float  widthRangeTo,
const int  i,
const int  tempFrom,
CSize2D lineSize 
) const

◆ Draw()

void CGUIText::Draw ( CGUI pGUI,
CCanvas2D canvas,
const CGUIColor DefaultColor,
const CVector2D pos,
CRect  clipping 
) const

Draw this CGUIText object.

◆ GetLineOffset()

float CGUIText::GetLineOffset ( const EAlign  align,
const float  widthRangeFrom,
const float  widthRangeTo,
const CSize2D lineSize 
) const

◆ GetSize()

const CSize2D & CGUIText::GetSize ( ) const
inline

◆ GetSpriteCalls()

const std::list< SSpriteCall > & CGUIText::GetSpriteCalls ( ) const
inline

◆ GetTextCalls()

const std::vector< STextCall > & CGUIText::GetTextCalls ( ) const
inline

◆ MOVABLE()

CGUIText::MOVABLE ( CGUIText  )

◆ NONCOPYABLE()

CGUIText::NONCOPYABLE ( CGUIText  )

◆ ProcessLine()

bool CGUIText::ProcessLine ( const CGUI pGUI,
const CGUIString string,
const CStrIntern font,
const IGUIObject pObject,
const SGenerateTextImages images,
const EAlign  align,
const float  prelimLineHeight,
const float  width,
const float  bufferZone,
bool &  firstLine,
float &  y,
int &  i,
int &  from 
)

◆ SetupSpriteCalls()

void CGUIText::SetupSpriteCalls ( const CGUI pGUI,
const std::array< std::vector< CStr >, 2 > &  feedbackImages,
const float  y,
const float  width,
const float  bufferZone,
const int  i,
const int  posLastImage,
SGenerateTextImages images 
)

Member Data Documentation

◆ m_Size

CSize2D CGUIText::m_Size

Width and height of the whole output, used when setting up scrollbars and such.

◆ m_SpriteCalls

std::list<SSpriteCall> CGUIText::m_SpriteCalls

List of sprites, or "icons" that should be rendered along with the text.

◆ m_TextCalls

std::vector<STextCall> CGUIText::m_TextCalls

List of TextCalls, for instance "Hello", "there!".


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