GL Studio Safety Critical Embedded C++ Runtime Library
gls_text_grid.h
Go to the documentation of this file.
1 #ifndef _GLS_TEXT_GRID_H
2 #define _GLS_TEXT_GRID_H
3 
4 /*! \file gls_text_grid.h
5 
6 \brief This header defines the GlsTextGrid class
7  in the GL Studio DO-178B Runtime Library.
8 
9 \par Copyright Information
10 Copyright (C) 1999-2012 The DiSTI Corporation<br>
11 Orlando, FL USA<br>
12 All rights reserved.<br>
13 
14  This file is copyrighted software and contains proprietary trade secrets of
15 DiSTI, and embodies substantial creative efforts as well as confidential
16 information, ideas, and expressions.
17 
18  Permission to use, and copy this software and its documentation for any
19 purpose is hereby granted per the Distribution Agreement and/or the Licensing
20 Agreement signed with DiSTI. This permission is granted provided that:
21  1. The above copyright notice appears in all copies.
22  2. That both the copyright notice and this permission notice appear in
23  the supporting documentation.
24  3. That the names DiSTI and GL Studio not be used in advertising or
25  publicity pertaining to distribution of the software without specific,
26  written prior permission of DiSTI.
27 
28  Permission to modify the software is granted, but not the right to
29 distribute the source code whether modified, or non-modified. Modifying the
30 software might invalidate the DO-178B certification package.
31 
32  Permission to distribute binaries produced by compiling source code, or
33 modified source code is granted, provided you:
34  1. Provide your name and address as the primary contact for the support
35  of your modified version.
36  2. Retain our contact information in regard to use of the base software.
37 
38  DiSTI does not provide warranty for this software or guarantee that it
39 satisfies any specification or requirement unless otherwise stated in a
40 specific contractual arrangement between the customer and DiSTI.
41 
42 */
43 
44 #include "gls_include.h"
45 #include "gls_text.h"
47 #include "gls_class_invariant.h"
48 
49 // forward ref
50 class GlsPolygon;
51 
52 /** This class implements an mxn display grid of characters.
53  * \invariant base class invariant holds,
54  * _columns > 0, _rows > 0,
55  * _charAttributes invariant holds,
56  * each _rowInfo element has a length field <= columns
57  */
58 class GlsTextGrid : public GlsText
59 {
60 public:
62 
63  /** initialization parameters for a GlsTextGrid */
65  {
66  const GlsText::InitParameters textInitParameters; /**< base class initialization parameters */
67 
68  const GlsUInt32 columns; /**< number of columns in grid ( > 0 ) */
69 
70  #if defined( GLS_DEBUG )
71  /** Determine if the initialization parameters are valid ( GLS_DEBUG only )
72  * \return GLS_TRUE if valid else GLS_FALSE
73  * \pre none
74  * \post none
75  */
76  GlsBool IsValid( void ) const;
77  #endif // GLS_DEBUG
78  };
79 
80  /** Constructor - create an instance
81  * \param initParameters initialization parameters
82  * \param eventDispatcher event dispatcher for this object else GLS_NULL
83  * \pre initParameters.IsValid()
84  * \post instance created
85  */
86  GlsTextGrid( const InitParameters &initParameters, GlsEventDispatcher* const eventDispatcher );
87 
88  /** Set the character attributes for all of the text
89  * \param charAttribute new character attributes for the text
90  * \pre charAttribue.IsValid()
91  * \post text has new character attribute
92  */
93  virtual void SetCharAttributes( const GlsText::CharAttribute &charAttribute );
94 
95  /** Set the character attributes for a character at a given column and row
96  * \param column column in question ( < _columns )
97  * \param row row in question ( < _rows )
98  * \param charAttribute new attributes for character at given column, row
99  * \pre column < _columns, row < _rows, charAttribute.IsValid()
100  * \post character at column, row has new character attributes
101  */
102  void SetCharAttribute( const GlsUInt32 column, const GlsUInt32 row, const GlsText::CharAttribute &charAttribute );
103 
104 protected:
105  /** Helper class encapsulates a grid of GlsText::CharAttribute 's
106  * \invariant _columns > 0, _rows > 0,
107  * GLS_NULL != _charAttributes,
108  * each element in the _charAttributes array is valid
109  */
111  {
112  public:
114 
115  /** Constructor - create an instance
116  * \param columns number of columns in grid ( > 0 )
117  * \param rows number of rows in grid ( > 0 )
118  * \param initialAttributes initial value of each attribute in the grid
119  * \pre columns > 0, rows > 0, initialAttributes.IsValid()
120  * \post instance created
121  */
122  CharAttributeGrid( const GlsUInt32 columns, const GlsUInt32 rows,
123  const GlsText::CharAttribute &initialAttributes );
124 
125  /** Destructor - shall never be called
126  * \pre none
127  * \post none
128  */
129  virtual ~CharAttributeGrid();
130 
131  /** get a const ref to the attribute at the given column and row
132  * \param column column in question ( column < _columns )
133  * \param row row in question ( row < _rows )
134  * \return ref to character attribute at given column and row
135  * \pre column < _columns, row < _rows
136  * \post none
137  */
138  const GlsText::CharAttribute& GetCharAttribute( const GlsUInt32 column, const GlsUInt32 row ) const;
139 
140  /** set the attribute at the given column and row
141  * \param column column in question ( column < _columns )
142  * \param row row in question ( row < _rows )
143  * \param charAttribute new value for attribue
144  * \pre column < _columns, row < _rows
145  * \post attribute at column, row is set to new value
146  */
147  void SetCharAttribute( const GlsUInt32 column, const GlsUInt32 row,
148  const GlsText::CharAttribute &charAttribute );
149 
150  protected:
151  const GlsUInt32 _columns; /**< number of columns in grid ( > 0 ) */
152  const GlsUInt32 _rows; /**< number of rows in grid ( > 0 ) */
153  GlsText::CharAttribute* const _charAttributes; /**< grid array of attributes (_columns*_rows) in row major */
154 
155  private:
156  // Disable implicit generated Members
157  CharAttributeGrid& operator=( const CharAttributeGrid &rhs );
158  CharAttributeGrid( const CharAttributeGrid &src );
159  };
160 
161  const GlsUInt32 _columns; /**< number of columns in grid ( > 0 ) */
162  CharAttributeGrid _charAttributes; /**< grid (_columns*_rows) of character attributes */
163  GlsBool _perCharAttributes; /**< GLS_TRUE if grid utilizes character attributes on
164  * a per character basis else GLS_FALSE if all text uses
165  * the first character attribute in _charAttributes */
166 
167 
168  /** Draw the characters associated with the text grid
169  * \param gl GL state manager to draw into
170  * \pre all necessary GL matrix adjustments have been applied,
171  * the font texture has been bound to GL with GlsFontBase::BindFontTexture()
172  * and its texture filter settings have been setup
173  * \post text characters are drawn to GL
174  */
175  virtual void DrawCharacters( GlsStateManager &gl );
176 
177  /** Populate the _rowInfo array based on the current display string
178  * \pre none
179  * \post _rowInfo array is populated based on the current display string
180  */
181  virtual void CalculateRowData( void );
182 
183  /** Destructor - shall never be called
184  * \pre none
185  * \post none
186  */
187  virtual ~GlsTextGrid();
188 
189 private:
190  typedef GlsText _BaseClass; /**< base class alias */
191 
192  // Disable implicit generated Members
193  GlsTextGrid& operator=( const GlsTextGrid &rhs );
194  GlsTextGrid( const GlsTextGrid &src );
195 };
196 
197 #endif // _GLS_TEXT_GRID_H
Definition: gls_text_grid.h:64
const GlsText::InitParameters textInitParameters
Definition: gls_text_grid.h:66
bool GlsBool
Definition: gls_types.h:96
void SetCharAttribute(const GlsUInt32 column, const GlsUInt32 row, const GlsText::CharAttribute &charAttribute)
#define GLS_CLASS_INVARIANT_DECLARATION(ClassName)
Definition: gls_class_invariant.h:80
Definition: gls_state_manager.h:63
GlsText::CharAttribute *const _charAttributes
Definition: gls_text_grid.h:153
This header defines GlsTextureVertexArray which encapsulates an array of GlsTextureVertex 's in the G...
const GlsUInt32 _columns
Definition: gls_text_grid.h:161
GlsBool _perCharAttributes
Definition: gls_text_grid.h:163
const GlsUInt32 _columns
Definition: gls_text_grid.h:151
unsigned int GlsUInt32
Definition: gls_types.h:73
This header defines the GlsText base class in the GL Studio DO-178B Runtime Library.
virtual void CalculateRowData(void)
Definition: gls_event.h:304
This header defines any preprocessor defines needed to configure the GL Studio DO-178B Runtime Librar...
GlsTextGrid(const InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
const GlsUInt32 columns
Definition: gls_text_grid.h:68
virtual void SetCharAttributes(const GlsText::CharAttribute &charAttribute)
const GlsText::CharAttribute & GetCharAttribute(const GlsUInt32 column, const GlsUInt32 row) const
Definition: gls_text_grid.h:110
virtual void DrawCharacters(GlsStateManager &gl)
Definition: gls_display_object.h:64
This header defines a GLS_DEBUG only macro for facilitating evaluating class invariants in the GL Stu...
Definition: gls_text_grid.h:58
CharAttributeGrid(const GlsUInt32 columns, const GlsUInt32 rows, const GlsText::CharAttribute &initialAttributes)
CharAttributeGrid _charAttributes
Definition: gls_text_grid.h:162
void SetCharAttribute(const GlsUInt32 column, const GlsUInt32 row, const GlsText::CharAttribute &charAttribute)
Definition: gls_polygon.h:55
Definition: gls_text.h:90
const GlsUInt32 _rows
Definition: gls_text_grid.h:152
Definition: gls_text.h:114
Definition: gls_text.h:72
virtual ~GlsTextGrid()