GL Studio SCECpp Runtime Library
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
GlsText Class Referenceabstract

#include <gls_text.h>

Inheritance diagram for GlsText:
GlsRenderObject GlsDisplayObject GlsTextBox GlsTextGrid

Classes

struct  CharAttribute
 
struct  InitParameters
 
struct  RowInfo
 
class  UnderlineStrikeThruRenderer
 

Public Types

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

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)
 
virtual void SetCharAttributes (const CharAttribute &charAttribute)=0
 
- 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

 GlsText (const InitParameters &initParameters, const GlsUInt32 maxNumLineSegmentsPerRow, GlsEventDispatcher *const eventDispatcher)
 
GlsFloat32 JustificationOffset (const GlsUInt32 row) const
 
virtual void DrawCharacters (GlsStateManager &gl)=0
 
virtual void CalculateRowData (void)=0
 
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 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 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 serves as a base class for text displays

Invariant
base class invariant holds, _rows > 0u, _cellWidth >= 0.0f, _cellHeight >= 0.0f, _font invariant holds, _haloColor.IsValid(), GlsTextJustificationIsValid( _justification ), ( -1.0f <= _shadowDistance ) && ( _shadowDistance <= 1.0f ), _shadowColor.IsValid(), _str invariant holds, GlsFloatIsValid( _rowOffset ), GlsFloatIsValid( _textWidth ), GlsFloatIsValid( _textHeight ), GLS_NULL != _backgroundPoly, _backgroundPoly invariant holds, GLMatrixAffineFIsValid( _textRotationMatrix ), _underlineStrikeThruRenderers invariant holds, invariant holds for each element in the _underlineStrikeThruRenderers array GLS_NULL != _rowInfo, Each element in the _rowInfo array has valid members

Member Enumeration Documentation

text justification modes

Enumerator
JUSTIFICATION_LEFT 

left justify text

JUSTIFICATION_CENTER 

center justify text

JUSTIFICATION_RIGHT 

right justify text

Constructor & Destructor Documentation

GlsText::GlsText ( const InitParameters initParameters,
const GlsUInt32  maxNumLineSegmentsPerRow,
GlsEventDispatcher *const  eventDispatcher 
)
protected

Constructor - create an instance

Parameters
initParametersinitialization parameters
maxNumLineSegmentsPerRowmaximum nubmer of line segments required per row to render underline / strike thru line segments (>0)
eventDispatcherevent dispatcher for this object else GLS_NULL
Precondition
initParameters.IsValid(), maxNumLineSegmentsPerRow > 0
Postcondition
instance created
virtual GlsText::~GlsText ( )
protectedvirtual

Destructor – shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

virtual void GlsText::CalculateRowData ( void  )
protectedpure virtual

Populate the _rowInfo array based on the current display string

Precondition
none
Postcondition
_rowInfo array is populated based on the current display string

Implemented in GlsTextGrid, and GlsTextBox.

virtual void GlsText::Draw ( GlsStateManager gl,
const GlsFloat64  time 
)
virtual

Draws the text object

Parameters
glGL State manager for OpenGL into which text object is drawn
timethe elaspsed time in seconds since program start
Precondition
time >= 0.0
Postcondition
text object is drawn to OpenGL if visible and not blinked off

Implements GlsDisplayObject.

virtual void GlsText::DrawCharacters ( GlsStateManager gl)
protectedpure virtual

Draw the characters associated with the text object

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

Implemented in GlsTextGrid, and GlsTextBox.

GlsFloat32 GlsText::JustificationOffset ( const GlsUInt32  row) const
protected

Get the justification offset in pixels for the given row

Parameters
rowrow in question
Returns
the justification offset in pixels for the given row
Precondition
row < _rows
Postcondition
none
virtual void GlsText::OffsetTexture ( const GlsVector2D offset)
virtual

Offset the texture on the object

Parameters
offsetx, y offset for texture
Precondition
offset.IsValid()
Postcondition
offset is added to the texture coordinates

Implements GlsRenderObject.

void GlsText::ResetUnderineStrikeThruRenderers ( void  )
protected

Reset all of the line underline / strikethru renderers in the text objecy all of the underline and strikethru line segments to be recomputed the next time the text object is drawn

Precondition
none
Postcondition
all of the underline / strikethru renderers are reset
virtual void GlsText::SetAlphaMode ( const GlsAlphaMode  alphaMode)
virtual

Set the alpha mode

Parameters
alphaModedesired alpha mode
Precondition
GlsAlphaModeIsValid( alphaMode )
Postcondition
object has new alpha mode

Reimplemented from GlsRenderObject.

virtual void GlsText::SetCharAttributes ( const CharAttribute charAttribute)
pure virtual

Set the character attributes for the text ( pure virtual )

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

Implemented in GlsTextBox, and GlsTextGrid.

virtual void GlsText::SetFillColor ( const GlsColor fillColor)
virtual

Set the fill color

Parameters
fillColordesired fill color
Precondition
fillColor.IsValid()
Postcondition
object has new fill color

Reimplemented from GlsRenderObject.

void GlsText::SetHaloColor ( const GlsColor haloColor)

Set the halo color

Parameters
haloColornew halo color
Precondition
haloColor.IsValid()
Postcondition
object has new halo olor
virtual void GlsText::SetLineColor ( const GlsColor lineColor)
virtual

Set the line color

Parameters
lineColordesired line color
Precondition
lineColor.IsValid()
Postcondition
object has new line color

Reimplemented from GlsRenderObject.

virtual void GlsText::SetLineWidth ( const GlsFloat32  lineWidth)
virtual

Set the line width

Parameters
lineWidthnew line width, GlsRenderObject::LINE_WIDTH_MIN <= lineWidth <= GlsRenderObject::LINE_WIDTH_MAX
Precondition
GlsLineWidthIsValid( lineWidth )
Postcondition
object has new line width

Reimplemented from GlsRenderObject.

virtual void GlsText::SetPolygonMode ( const GlsPolygonMode  polygonMode)
virtual

Set the polygon mode

Parameters
polygonModenew polygon mode
Precondition
GlsPolygonModeIsValid( polygonMode )
Postcondition
object has new polygon mode

Reimplemented from GlsRenderObject.

void GlsText::SetShadowColor ( const GlsColor shadowColor)

Set the shadow color

Parameters
shadowColornew shadow color
Precondition
shadowColor.IsValid()
Postcondition
object has new shadow color
void GlsText::SetString ( const GlsChar *const  str)

Set the display string. Will truncate to size of string buffer if str will not fit in buffer.

Parameters
strdesired display string
Precondition
str != GLS_NULL
Postcondition
display string updated
virtual void GlsText::SetTextureIndex ( const GlsUInt32  textureIndex)
virtual

Set the desired texture index

Parameters
textureIndexdesired texture index into palette else GlsTexturePalette::NO_TEXTURE
Precondition
textureIndex is less than the size of the texture palette, else GlsTexturePalette::NO_TEXTURE, object's texture palette must have a valid texture (not an empty palette entry) at textureIndex if textureIndex != GlsTexturePalette::NO_TEXTURE
Postcondition
object has new texture index or is untextured if textureIndex == GlsTexturePalette::NO_TEXTURE

Reimplemented from GlsRenderObject.

Member Data Documentation

GlsPolygon* GlsText::_backgroundPoly
protected

background polygon

const GlsUInt32 GlsText::_border
protected

size of border in logical units

const GlsFloat32 GlsText::_cellHeight
protected

height of character cell in logical units ( >= 0.0f )

const GlsFloat32 GlsText::_cellWidth
protected

width of character cell in logical units ( >= 0.0f )

const GlsFontBase& GlsText::_font
protected

font for text display

const GlsBool GlsText::_halo
protected

GLS_TRUE if halo is enabled else GLS_FALSE

GlsColor GlsText::_haloColor
protected

halo color

const Justification GlsText::_justification
protected

text justification mode

RowInfo* const GlsText::_rowInfo
protected

array ( _rows number of elements ) of RowInfo

const GlsFloat32 GlsText::_rowOffset
protected

row offset when drawing chars

const GlsUInt32 GlsText::_rows
protected

number of rows of text( > 0 )

const GlsBool GlsText::_shadow
protected

GLS_TRUE if shadow effect is on else GLS_FALSE

GlsColor GlsText::_shadowColor
protected

color of the shadow effect behind the characters

const GlsFloat32 GlsText::_shadowDistance
protected

amount of cell width for offset of shadow effect, ( -1.0f <= shadowDistance <= 1.0f )

GlsString GlsText::_str
protected

string value to display

const GlsFloat32 GlsText::_textHeight
protected

text object height when drawing

GlsMatrixAffineD::GLMatrixAffineF GlsText::_textRotationMatrix
protected

additional rotation matrix for text cells

GlsBool GlsText::_textRotationMatrixIsIdentity
protected

GLS_TRUE if _textRotationMatrix is identity else GLS_FALSE

const GlsFloat32 GlsText::_textWidth
protected

text object width when drawing

GlsPointerArray GlsText::_underlineStrikeThruRenderers
protected

array ( _rows number of elements ) where element i is the underline strike thru renderer for row i

const GlsBool GlsText::_uppercase
protected

GLS_TRUE if all characters will display as uppercase else GLS_FALSE

const GlsBool GlsText::_wrapText
protected

GLS_TRUE if text wrapping is enabled else GLS_FALSE

const GlsChar GlsText::NEW_LINE_CHAR
staticprotected

new line character constant

const GlsUInt32 GlsText::NUM_VERTS_BACKGROUND_POLY = 4u
staticprotected

required number of verts in background poly

const GlsChar GlsText::SPACE_CHAR
staticprotected

space character constant