GL Studio Safety Critical Embedded C++ Runtime Library
GlsTextBox Class Reference

#include <gls_text_box.h>

+ Inheritance diagram for GlsTextBox:

Classes

struct  InitParameters
 

Public Types

enum  VerticalAlignment { VERTICAL_ALIGNMENT_TOP, VERTICAL_ALIGNMENT_CENTER, VERTICAL_ALIGNMENT_BOTTOM }
 
- Public Types inherited from GlsText
enum  Justification { JUSTIFICATION_LEFT, JUSTIFICATION_CENTER, JUSTIFICATION_RIGHT }
 
- Public Types inherited from GlsDisplayObject
enum  ObjectType { OBJECT_TYPE_COMPOSITE, OBJECT_TYPE_RENDERABLE }
 
enum  PickMode { PICK_MODE_NEVER, PICK_MODE_FIRST, PICK_MODE_ALWAYS }
 

Public Member Functions

 GlsTextBox (const InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
 
virtual void SetCharAttributes (const GlsText::CharAttribute &charAttribute)
 
- Public Member Functions inherited from GlsText
virtual void Draw (GlsStateManager &gl, const GlsFloat64 time)
 
virtual void SetAlphaMode (const GlsAlphaMode alphaMode)
 
virtual void SetFillColor (const GlsColor &fillColor)
 
virtual void SetLineColor (const GlsColor &lineColor)
 
virtual void SetLineWidth (const GlsFloat32 lineWidth)
 
virtual void SetPolygonMode (const GlsPolygonMode polygonMode)
 
virtual void SetTextureIndex (const GlsUInt32 textureIndex)
 
virtual void OffsetTexture (const GlsVector2D &offset)
 
void SetString (const GlsChar *const str)
 
void SetHaloColor (const GlsColor &haloColor)
 
void SetShadowColor (const GlsColor &shadowColor)
 
- Public Member Functions inherited from GlsDisplayObject
virtual void Calculate (const GlsFloat64 time)
 
virtual GlsDisplayObjectPickTest (const GlsVector2D &windowCoord, GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
GlsDisplayObjectHandleEvent (GlsEvent &event)
 
ObjectType GetObjectType (void) const
 
void SetBlinking (const GlsBool blinking)
 
void SetBlinkRate (const GlsFloat32 blinkRate)
 
void SetDynamicRotation (const GlsVector3D &dynamicRotation)
 
void SetDynamicScale (const GlsVector3D &dynamicScale)
 
void SetDynamicTranslation (const GlsVector3D &dynamicTranslation)
 
void SetVisibility (const GlsBool visible)
 
void SetParent (GlsDisplayObject *const parent)
 
void SetPickMode (const PickMode pickMode)
 
GlsBool NeedCalculate (void) const
 
void InvalidatePickCache (void)
 

Protected Member Functions

virtual void DrawCharacters (GlsStateManager &gl)
 
virtual void CalculateRowData (void)
 
void GetNextRowInfo (const GlsUInt32 strIndex, GlsUInt32 &rowLength, GlsFloat32 &rowPixelWidth, GlsUInt32 &nextRowStartIndex) const
 
GlsFloat32 GetCharWidth (const GlsChar c) const
 
virtual ~GlsTextBox ()
 
- Protected Member Functions inherited from GlsText
 GlsText (const InitParameters &initParameters, const GlsUInt32 maxNumLineSegmentsPerRow, GlsEventDispatcher *const eventDispatcher)
 
GlsFloat32 JustificationOffset (const GlsUInt32 row) const
 
void ResetUnderineStrikeThruRenderers (void)
 
virtual ~GlsText ()
 
- Protected Member Functions inherited from GlsRenderObject
 GlsRenderObject (const InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
 
GLint GlsTextureFilterModeToGL (const GlsTextureFilterMode mode) const
 
void SetupDepthTest (GlsStateManager &gl) const
 
void SetupAlpha (GlsStateManager &gl) const
 
GlsBool SetupTexture (GlsStateManager &gl, const GlsUInt32 textureIndex) const
 
void SetupTextureFilterSettings (GlsStateManager &gl) const
 
void SetupBackfaceCulling (GlsStateManager &gl) const
 
void SetupShading (GlsStateManager &gl) const
 
void SetupLineStyle (GlsStateManager &gl) const
 
void SetupAntiAlias (GlsStateManager &gl) const
 
virtual ~GlsRenderObject ()
 
- Protected Member Functions inherited from GlsDisplayObject
 GlsDisplayObject (const InitParameters &initParameters, const ObjectType objectType, GlsEventDispatcher *const eventDispatcher)
 
virtual ~GlsDisplayObject ()
 
GlsBool CalcDrawMatrix (const GlsMatrixAffineD *const additionalTransform, const GlsBool includeLocation)
 
virtual void CalcWindowPickRegion (GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
GlsBool IsBlinkedOff (const GlsFloat64 time) const
 

Protected Attributes

const VerticalAlignment _verticalAlignment
 
GlsText::CharAttribute _charAttribute
 
const GlsFloat32 _cellWidthRatio
 
GlsFloat32 _startingCellY
 
- Protected Attributes inherited from GlsText
const GlsUInt32 _rows
 
const GlsUInt32 _border
 
const GlsFloat32 _cellWidth
 
const GlsFloat32 _cellHeight
 
const GlsFontBase_font
 
const GlsBool _halo
 
GlsColor _haloColor
 
const Justification _justification
 
const GlsBool _shadow
 
const GlsFloat32 _shadowDistance
 
GlsColor _shadowColor
 
GlsString _str
 
const GlsBool _uppercase
 
const GlsBool _wrapText
 
const GlsFloat32 _rowOffset
 
const GlsFloat32 _textWidth
 
const GlsFloat32 _textHeight
 
GlsPolygon_backgroundPoly
 
GlsMatrixAffineD::GLMatrixAffineF _textRotationMatrix
 
GlsBool _textRotationMatrixIsIdentity
 
RowInfo *const _rowInfo
 
GlsPointerArray _underlineStrikeThruRenderers
 
- Protected Attributes inherited from GlsRenderObject
const GlsBool _antiAlias
 
const GlsTexturePalette_texturePalette
 
const GlsBool _textureRepeat
 
const GlsTextureMapMode _textureMapMode
 
const GlsTextureFilterMode _textureMagFilterMode
 
const GlsTextureFilterMode _textureMinFilterMode
 
const GlsBool _cullBackFace
 
const GlsDepthBufferMode _depthBufferMode
 
const GlsPolygonEndMode _polygonEndMode
 
const GlsShadingMode _shadingMode
 
GlsAlphaMode _alphaMode
 
GlsColor _lineColor
 
GlsUInt32 _textureIndex
 
GlsPolygonMode _polygonMode
 
GlsColor _fillColor
 
GlsFloat32 _lineWidth
 
- Protected Attributes inherited from GlsDisplayObject
const GlsMatrixAffineD _dcsMatrix
 
const GlsMatrixAffineD _dcsMatrixInverse
 
const GlsBool _dcsMatrixIsIdentity
 
const GlsVector3D _location
 
const GlsBool _needCalculate
 
const ObjectType _objectType
 
const PickRegion _pickRegion
 
GlsEventDispatcher *const _eventDispatcher
 
const GlsVector3D _rotationPoint
 
GlsBool _blinking
 
GlsFloat32 _blinkRate
 
GlsMatrixAffineD::GLMatrixAffineF _drawMatrix
 
GlsVector3D _dynamicRotation
 
GlsVector3D _dynamicScale
 
GlsBool _dynamicScaleIsUnity
 
GlsVector3D _dynamicTranslation
 
GlsBool _needCalcDrawMatrix
 
GlsBool _visible
 
PickMode _pickMode
 
GlsBool _windowPickRegionValid
 
GlsVector2D _windowPickLowerLeft
 
GlsVector2D _windowPickUpperRight
 
GlsVector2D _windowPickUpperLeft
 
GlsVector2D _windowPickLowerRight
 
GlsMatrixAffineD::GLMatrixAffineF _pickMatrix
 
GlsDisplayObject_parent
 

Static Protected Attributes

static const GlsFloat32 TAB_SPACING
 
- Static Protected Attributes inherited from GlsText
static const GlsUInt32 NUM_VERTS_BACKGROUND_POLY = 4u
 
static const GlsChar NEW_LINE_CHAR
 
static const GlsChar SPACE_CHAR
 
- Static Protected Attributes inherited from GlsRenderObject
static const GLclampf ALPHA_MODE_2_LEVEL_REF
 

Detailed Description

This class implements a box of proportionally spaced text

Invariant
base class invariant holds, GlsTextBoxVerticalAlignmentIsValid( _verticalAlignment ), _charAttribute.IsValid(), GlsFloatIsValid( _cellWidthRatio ), GlsFloatIsValid( _startingCellY )

Member Enumeration Documentation

enumeration describing possible vertical alignment modes

Enumerator
VERTICAL_ALIGNMENT_TOP 

align to top of box

VERTICAL_ALIGNMENT_CENTER 

align to center of box

VERTICAL_ALIGNMENT_BOTTOM 

align to bottom of box

Constructor & Destructor Documentation

GlsTextBox::GlsTextBox ( const InitParameters initParameters,
GlsEventDispatcher *const  eventDispatcher 
)

Constructor - create an instance

Parameters
initParametersinitialization parameters
eventDispatcherevent dispatcher for this object else GLS_NULL
Precondition
initParameters.IsValid()
Postcondition
instance created
virtual GlsTextBox::~GlsTextBox ( )
protectedvirtual

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

virtual void GlsTextBox::CalculateRowData ( void  )
protectedvirtual

Populate the _rowInfo array and _startingCellY based on the current display string

Precondition
none
Postcondition
_rowInfo array and _startingCellY are populated based on the current display string

Implements GlsText.

virtual void GlsTextBox::DrawCharacters ( GlsStateManager gl)
protectedvirtual

Draw the characters associated with the text box

Parameters
glGL state manager to draw into
Precondition
all necessary GL matrix adjustments have been applied, the font texture has been bound to GL with GlsFontBase::BindFontTexture() and its texture filter settings have been setup
Postcondition
text characters are drawn to GL

Implements GlsText.

GlsFloat32 GlsTextBox::GetCharWidth ( const GlsChar  c) const
protected

Get the width for the given character taking into account cell sizing, character spacing, uppercasing and tab characters width being expanded

Parameters
ccharacter in question
Returns
width for given character
Precondition
none
Postcondition
none
void GlsTextBox::GetNextRowInfo ( const GlsUInt32  strIndex,
GlsUInt32 rowLength,
GlsFloat32 rowPixelWidth,
GlsUInt32 nextRowStartIndex 
) const
protected

Get the row info for the row starting at the given string index

Parameters
strIndexstarting index into string
rowLength[out] gets number of characters in row
rowPixelWidth[out] gets pixel width of row
nextRowStartIndex[out] gets starting string index for next row else GLSUINT32_MAX if there is no string data for the next row
Precondition
strIndex < _str.GetLength()
Postcondition
rowLength has the number of characters in the row, rowPixelWidth has the pixel width of the row, nextRowStartIndex has the starting string index for the next row else GLSUINT32_MAX if there is no string data for the next row
virtual void GlsTextBox::SetCharAttributes ( const GlsText::CharAttribute charAttribute)
virtual

Set the character attributes for all of the text

Parameters
charAttributenew character attributes for the text
Precondition
charAttribue.IsValid()
Postcondition
text has new character attribute

Implements GlsText.

Member Data Documentation

const GlsFloat32 GlsTextBox::_cellWidthRatio
protected

ratio of cell width to width of widest character in the font

GlsText::CharAttribute GlsTextBox::_charAttribute
protected

character attribute for all characters

GlsFloat32 GlsTextBox::_startingCellY
protected

starting Y coordinate of first cell in text box ( populated by CalculateRowData() )

const VerticalAlignment GlsTextBox::_verticalAlignment
protected

vertical alignment mode for text

const GlsFloat32 GlsTextBox::TAB_SPACING
staticprotected

number of tab char widths to count for one tab char