| GL Studio C++ Runtime API

gls_text_box.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsTextBox class.
3
4 \par Copyright Information
5
6 Copyright (c) 2017 by The DiSTI Corporation.<br>
7 11301 Corporate Blvd; Suite 100<br>
8 Orlando, Florida 32817<br>
9 USA<br>
10 <br>
11 All rights reserved.<br>
12
13 This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38
39*/
40#ifndef _GLS_TEXT_BOX_H
41#define _GLS_TEXT_BOX_H
42
43/// Provides support for creating DLLs.
44#if( defined( GLSGEN_EXPORT_GLSTEXTBOX ) || defined( GLSGEN_IMPORT_GLSTEXTBOX ) || defined( GLSGEN_GLSTEXTBOX_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
45 && defined( _MSC_VER )
46# if defined( GLSGEN_EXPORT_GLSTEXTBOX ) || defined( GLSGEN_GLSTEXTBOX_EXPORT_GENERATED )
47# define GLSGEN_GLSTEXTBOX_EXPORT __declspec( dllexport )
48# else
49# define GLSGEN_GLSTEXTBOX_EXPORT __declspec( dllimport )
50# endif
51#else
52# define GLSGEN_GLSTEXTBOX_EXPORT
53#endif
54///////////////////////////////////////////////////////////////////////////////
55
56#include "gls_gl.h"
57#include <string>
58
59#include "gls_cpp_lang_support.h"
60#include "gls_text.h"
61#include "unhide_globals.h"
62
63#ifdef GLES
64# include "gls_quad_storage.h"
65# include "gls_state_manager.h"
66#endif
67
68/// Automatically link the runtime library plugin (on Windows).
69#define LIB_BASE_NAME "gls_text_box"
70#include "gls_auto_lib.h"
71#undef LIB_BASE_NAME
72
73#undef GetCharWidth
74
75//===========================================================================
76// BEGIN NAMESPACE
77//===========================================================================
78 namespace disti
79{
80#ifdef GLES
81// Forward Declaration
82 class GlsGloFileAttribute;
83#endif
84
85//===========================================================================
86/**
87* The GlsTextBox
88*/
89 class GlsTextBox : public GlsText
90{
91 protected:
92 class UnderlineStrikeThruHelper;
93
94 /// Helper function that performs the underlying text draw.
95 /// \note Not normally called by users.
96 void DrawText();
97
98#ifdef GLES
99 GlsQuadListVC_3D _backgrounds; ///< Quads used to render the backgrounds. This is rendered behind the other quads associated with this text box.
100 GlsQuadListVCT_2D _shadows; ///< Quads used to render the shadows behind the text.
101 GlsQuadListVC_3D _shadowLines; ///< Quads used to render the shadows for lines such as underlines and strikethroughs.
102 GlsQuadListVCT_2D _characters; ///< Quads used to render the characters in the foreground.
103 GlsQuadListVC_3D _lines; ///< Quads used to render lines such as underlines and strikethroughs.
104
105 /// Constructs primitives and renders each character. This function considers the text box's position, justification, character size,
106 /// and decorations (such as strikethroughs and shadows).
107 void PopulateQuadStorage();
108#endif
109
110 public:
111 /// The ResizeMode_t enumeration. Describes the resize behavior of this text object.
112 enum ResizeMode_t
113 {
114 RESIZE_MODE_FIXED,
115 RESIZE_MODE_AUTO_WIDTH,
116 RESIZE_MODE_AUTO_HEIGHT
117 };
118
119 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
120 typedef GlsText _BaseClass; ///< Deprecated typedef for the base class.
121 typedef GlsText BaseClass; ///< Typedef for the base class.
122
123 friend class GlsTextBoxEditor;
124
125 /** Class Constructor. */
126 GLSGEN_GLSTEXTBOX_EXPORT GlsTextBox();
127
128 /// Copy constructor
129 /// \param that The object to copy from.
130 /// \param generateNames Whether or not to generate an instance name for this object.
131 GLSGEN_GLSTEXTBOX_EXPORT GlsTextBox( const GlsTextBox& that, const bool generateNames );
132
133 /** Class Constructor. */
134 virtual GLSGEN_GLSTEXTBOX_EXPORT ~GlsTextBox();
135
136 // Need to declare using all base class methods that we overload
137 using BaseClass::Baseline;
138 using BaseClass::BgColor;
139 using BaseClass::CellHeight;
140 using BaseClass::CellWidth;
141 using BaseClass::Char;
142 using BaseClass::CharAttr;
143 using BaseClass::CharScaling;
144 using BaseClass::CharSpacing;
145 using BaseClass::Erase;
146 using BaseClass::FauxBold;
147 using BaseClass::Inverse;
148 using BaseClass::StrikeThru;
149 using BaseClass::String;
150 using BaseClass::TextColor;
151 using BaseClass::Underline;
152
153 virtual GLSGEN_GLSTEXTBOX_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
154
155 /* Peform any necessary non-draw calculations like resizing
156 * the grid.
157 * \param time The time since the start of program execution
158 */
159 virtual GLSGEN_GLSTEXTBOX_EXPORT void Calculate( double time ) DISTI_METHOD_OVERRIDE;
160
161 virtual GLSGEN_GLSTEXTBOX_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
162 virtual GLSGEN_GLSTEXTBOX_EXPORT void CopyGeometry( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
163 virtual GLSGEN_GLSTEXTBOX_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
164 virtual GLSGEN_GLSTEXTBOX_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
165
166#ifndef GLES
167 virtual GLSGEN_GLSTEXTBOX_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
168 virtual GLSGEN_GLSTEXTBOX_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
169#endif
170
171#ifdef GLES
172 virtual GLSGEN_GLSTEXTBOX_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) DISTI_METHOD_OVERRIDE;
173#endif
174
175 virtual GLSGEN_GLSTEXTBOX_EXPORT void SetVertices( unsigned int nPoints, Vertex* vertices ) DISTI_METHOD_OVERRIDE;
176
177 /// Sets the initial state of this object.
178 virtual GLSGEN_GLSTEXTBOX_EXPORT void Initialize();
179
180 /// Rebuilds this text box layout. This may be an expensive call, so it should only be called when a property changes.
181 GLSGEN_GLSTEXTBOX_EXPORT void Rebuild();
182
183 /* Unhides base class implementation. */
184 using BaseClass::Scale;
185
186 /**
187 We need to know the Max number of lines/rows possible to display, we
188 may run out of characters to print/display before we hit the max
189 number of lines though.
190 \return A value between Zero and INT_MAX, representing the max lines/rows to draw
191 \pre The TextBox object has been initialized
192 \post The value of max lines returned to the caller
193 */
194 virtual GLSGEN_GLSTEXTBOX_EXPORT unsigned int MaxLinesToDraw();
195
196 virtual GLSGEN_GLSTEXTBOX_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
197
198 /// Different text justifications.
199 enum Align_t
200 {
201 ALIGN_CENTER,
202 ALIGN_TOP,
203 ALIGN_BOTTOM
204 };
205
206 /** Set the vertical justification for this text object
207 * \param justification The justification mode (TOP, BOTTOM, CENTER)
208 */
209 GLSGEN_GLSTEXTBOX_EXPORT void VerticalAlignment( Align_t justification );
210
211 /** Get the vertical justification for this text object
212 * \return vertical justification
213 */
214 virtual Align_t VerticalAlignment() const
215 {
216 return _verticalAlignment;
217 }
218
219 //-----------------------------------------------------------------------
220 //-----------------------------------------------------------------------
221 // Routines for compatbility with TextDisplay.gls
222 //-----------------------------------------------------------------------
223 //-----------------------------------------------------------------------
224
225 /** Clears all of the characters and resets the attributes of all
226 * characters (TextDisplay compatability method)
227 * \deprecated use Erase instead
228 */
229 GLSGEN_GLSTEXTBOX_EXPORT void Clear()
230 {
231 Erase();
232 }
233
234 /** Clears all of the characters. Does NOT reset the attributes
235 * of the characters (TextDisplay compatability method)
236 * \deprecated
237 */
238 GLSGEN_GLSTEXTBOX_EXPORT void ClearChars()
239 {
240 _text.erase();
241 SetRebuild();
242 }
243
244 /** SetColor() meaning has changed, now use TextColor */
245
246 /** Print a string into this text object starting at index 0 and proceeding Left
247 * to right Wraps at newline characters. Does not change the color or any
248 * other modes. Replaces the entire string.
249 * (TextDisplay compatability method)
250 * \param s The string to print
251 * \deprecated use String instead
252 */
253 GLSGEN_GLSTEXTBOX_EXPORT void SetString( const char* s )
254 {
255 String( s );
256 }
257
258 /** Print a string into this text object
259 * to right. Wraps at newline characters. Does not change the color or any
260 * other modes. Replaces the entire string.
261 * \param format printf style varargs formatting string.
262 */
263 GLSGEN_GLSTEXTBOX_EXPORT void VaString( const char* format, ... );
264
265 /// \cond INTERNAL
266 // Undocumented.
267 // This method is used to calculate the lines of the text box and is likely to change in future releases.
268 GLSGEN_GLSTEXTBOX_EXPORT void NextLineInfo( const unsigned int currentStringIndex,
269 unsigned int* lineEndIndex,
270 unsigned int* nextLineStringIndex,
271 float* startXpixels,
272 float* lineLengthPixels );
273
274 // Undocumented.
275 // This method is used to calculate the lines of the text box and may change in future releases.
276 GLSGEN_GLSTEXTBOX_EXPORT unsigned int GetLineCount();
277 // \endcond
278
279 /** Sets tab space multiplier, 1.0 == same as specified in font */
280 GLSGEN_GLSTEXTBOX_EXPORT void TabSpacing( float );
281
282 /** Returns the current tab space multiplier
283 * \return the current tab space multiplier
284 */
285 GLSGEN_GLSTEXTBOX_EXPORT float TabSpacing();
286
287 /** Determine if the text direction is set to left->right or right->left
288 * \return true if if the text direction is set to left->right else false for right->left
289 */
290 GLSGEN_GLSTEXTBOX_EXPORT bool LeftToRight();
291
292 /** Set the text direction
293 * \param leftToRight true for left->right else false for right->left
294 */
295 GLSGEN_GLSTEXTBOX_EXPORT void LeftToRight( bool leftToRight );
296
297 /// Set the resize behavior for this object.
298 /// \param value The new resize behavior.
299 virtual GLSGEN_GLSTEXTBOX_EXPORT void ResizeMode( ResizeMode_t value );
300
301 /// \return The current resize behavior for this object.
302 virtual GLSGEN_GLSTEXTBOX_EXPORT ResizeMode_t ResizeMode();
303
304 /// Set the maximum resize width for this object in logical units.
305 /// \param value The new maximum width.
306 virtual GLSGEN_GLSTEXTBOX_EXPORT void MaxWidth( float value );
307
308 /// \return The current maximum resize width for this object in logical units.
309 virtual GLSGEN_GLSTEXTBOX_EXPORT float MaxWidth();
310
311 /// Set the maximum resize height for this object in logical units.
312 /// \param value The new maximum height.
313 virtual GLSGEN_GLSTEXTBOX_EXPORT void MaxHeight( float value );
314
315 /// \return The current maximum resize height for this object in logical units.
316 virtual GLSGEN_GLSTEXTBOX_EXPORT float MaxHeight();
317
318 protected:
319#ifdef GLES
320 /** Set a single attribute from the GLO file.
321 * \param data The attribute to set and its associated data.
322 */
323 virtual GLSGEN_GLSTEXTBOX_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
324#endif
325
326 /// Allocate a text buffer of the appropriate size for this grid and output snprintf style format into the buffer.
327 /// \param format snprintf style format spec
328 /// \param args Arguments for sprintf style formatting.
329 /// \return A formatted textbuffer ( must be deleted by caller ).
330 GLSGEN_GLSTEXTBOX_EXPORT char* FormatVarArgList( const char* format, va_list args );
331
332 /// true -> grid will draw characters using "per character attributes" else
333 /// false -> all characters will be drawn using the first character's attribute
334 /// NOTE: This defaults to false and automatically enables to true if the user calls
335 /// a method that requires per character attributes
336 bool _perCharAttribs;
337
338 /// Enable per character attribute drawing for this grid.
339 GLSGEN_GLSTEXTBOX_EXPORT void EnablePerCharAttribs()
340 {
341 if( !_perCharAttribs )
342 {
343 _perCharAttribs = true;
344 SetRebuild();
345 }
346 }
347
348 Align_t _verticalAlignment; ///< Justification setting (TOP, CENTER, BOTTOM).
349
350 float _tabSpacing; ///< Space multiplier for tabs.
351
352 /// Helper function to calculate cell sizes based on the
353 /// scale of the object if control cell size is enabled.
354 /// \note Not normally called by users.
355 GLSGEN_GLSTEXTBOX_EXPORT void RecalcCellSize();
356
357 /// Helper function to readjust vertices back to the local origin being aligned with vertex 0.
358 /// \note Not normally called by users.
359 GLSGEN_GLSTEXTBOX_EXPORT void RecalcVertices();
360
361 /** Populate the _rowInfo array based on the current display string
362 * \pre none
363 * \post _rowInfo array is populated based on the current display string
364 */
365 GLSGEN_GLSTEXTBOX_EXPORT virtual void CalculateRowData();
366
367 /// Get the row info for the row starting at the given string index
368 /// \param strIndex starting index into string
369 /// \param rowLength [out] gets number of characters in row
370 /// \param rowPixelWidth [out] gets pixel width of row
371 /// \param nextRowStartIndex [out] gets starting string index for next row
372 /// else GLSUINT32_MAX if there is no string data for the next row
373 /// \pre strIndex < _str.GetLength()
374 /// \post rowLength has the number of characters in the row,
375 /// rowPixelWidth has the pixel width of the row,
376 /// nextRowStartIndex has the starting string index for the next row
377 /// else GLSUINT32_MAX if there is no string data for the next row
378 GLSGEN_GLSTEXTBOX_EXPORT void GetNextRowInfo( const unsigned int strIndex,
379 unsigned int& rowLength,
380 float& rowPixelWidth,
381 unsigned int& nextRowStartIndex ) const;
382
383 /// Helper function that returns the maximum line length (text box width) in logical units.
384 /// \return Infinity if no limit, otherwise the limit in logical units.
385 float GetMaxLineLengthForResizeMode() const;
386
387 /// Helper function that adjusts the vertices to contain the text based on the resize behavior.
388 void SetVerticesToTextBounds();
389
390 public:
391 /** Get the width for the given character taking into account cell sizing, character spacing, uppercasing
392 * and tab characters width being expanded
393 * \param c character in question
394 * \return width for given character
395 * \pre none
396 * \post none
397 */
398 GLSGEN_GLSTEXTBOX_EXPORT float GetCharWidth( const unsigned short c ) const;
399
400 protected:
401 /** info for one row of text in the display */
402 struct RowInfo
403 {
404 unsigned int startingIndex; /**< starting text index into the display for row
405 * else GLSUINT32_MAX if row has no characters */
406 unsigned int length; /**< the number of characters in row */
407 float pixelWidth; /**< the width of row in pixels */
408 };
409
410 unsigned int _lineCount; ///< Number of rows of characters in the text grid (number of lines).
411 bool _lineCountChanged; ///< If true, the line count has changed, and row information needs to be rebuilt.
412
413 RowInfo* _rowInfo; /**< array ( _rows number of elements ) of RowInfo */
414
415 float _cellWidthRatio; ///< Holds cell width / max char width ratio used for horizontal advance.
416
417 float _maxLineLengthPixels; ///< Calculated maximimum line width in "pixels" (logical units).
418 float _maxTextHeightPixels; ///< Calculated maximimum height in "pixels" (logical units).
419 unsigned int _maxLinesToDraw; ///< Calculated maximum number of lines that can fit.
420
421 bool _leftToRight; ///< true to render characters from left to right else, false for right to left.
422
423 ResizeMode_t _resizeMode; ///< The current automatic resize behavior.
424 float _resizeMaxWidth; ///< The calculated maximum width in logical units based on the current resize behavior.
425 float _resizeMaxHeight; ///< The calculated maximim height in logical units based on the current resize behavior.
426
427 UTF16String _unicodeText; /**< unicode version of _text from base class, updated by CalculateRowData */
428
429 /// \details A helper class for processing underline and strike-thru when drawing text grid.
430 class UnderlineStrikeThruHelper
431 {
432 public:
433 /**
434 * \param cellWidth maximum width of a character cell in the text box
435 * \param cellHeight height of a character cell in the text box
436 * \param cellYScale unused
437 * \param shadow true if text box has shadow enabled
438 * \param shadowOffset offset for shadow
439 * \param shadowColor color of shadow in text box
440 * \param underlineOffset offset of underline
441 * \param underlineSize size of underline
442 * \param halo true if text box has halo enabled
443 * \param haloOffset offset for halo
444 * \param haloColor color of halo in text box
445 * \param leftToRight true if text flows left to right else false for right to left
446 */
447 UnderlineStrikeThruHelper( float cellWidth, float cellHeight, float cellYScale, bool shadow, const Vector& shadowOffset, const GlsColor& shadowColor,
448 float underlineOffset, float underlineSize, bool halo, float haloOffset, GlsColor haloColor, bool leftToRight );
449
450 /**
451 * Setup to process a new row in the text box.
452 */
453 void NewRow();
454
455 /**
456 * Pre Process the given character attributes
457 * \param charAttr attributes in question
458 * \param c the character code to process.
459 * \param cellX x coord of character cell
460 * \param charY y coord of character
461 */
462 void PreProcessCharacter( const CharAttr_t& charAttr, const Char_t& c, float cellX, float charY );
463
464 /**
465 * Post Process the given character attributes
466 * \param charAttr attributes in question
467 * \param c the character code to process.
468 * \param cellX x coord of character cell
469 * \param charY y coord of character cell
470 * \param cellWidth the width of the current character
471 * \param endOfLine true if character was the end of the current line
472 */
473 void PostProcessCharacter( const CharAttr_t& charAttr, const Char_t& c, float cellX, float charY, float cellWidth, bool endOfLine );
474
475#ifdef GLES
476 /**
477 * Render the line segments for the underline / strikethru
478 * \param quadStorage The quad storage list to render
479 */
480 void RenderLineSegments( GlsQuadListVC_3D& quadStorage );
481#else
482 /**
483 * Render the line segments for the underline / strikethru
484 */
485 void RenderLineSegments();
486#endif
487 /// Sets the underlying shadow visibility flag to false.
488 void IgnoreShadow();
489
490 /// Sets the underlying shadow visibility flag to true.
491 void AllowShadow();
492
493 protected:
494 // cell constants
495 const float _cellWidth; ///< Height of each character cell in the grid in logical units.
496 const float _cellHeight; ///< Width of each character cell in the grid in logical units.
497
498 // shadow constants
499 const bool _shadow; ///< Whether or not the shadow effect is on.
500 const Vector _shadowOffset; ///< Offset of the shadow effect from the characters. Z component is ignored.
501 const GlsColor _shadowColor; ///< Color of the shadow effect behind the characters.
502 bool _allowShadow; ///< Whether or not shadows are being drawn in general.
503
504 // underline constants
505 const float _underlineOffset; ///< Vertical offset of the underline in logical units.
506 const float _underlineSize; ///< Thickness of the underline in logical units.
507
508 // halo constants
509 const bool _halo; ///< Whether or not the halo effect is on.
510 const float _haloOffset; ///< Offset multiplier for the halo effect.
511 const GlsColor _haloColor; ///< Color of the halo effect behind the characters.
512
513 // left to right
514 const bool _leftToRight; ///< If true, characters are rendered left to right, otherwise right to left.
515
516 // state vars for underline processing
517 float _underlineX1; ///< Current underline state left X coordinate.
518 float _underlineX2; ///< Current underline state right X coordinate.
519 float _underlineY; ///< Current underline state Y coordinate.
520 float _underlineScale; ///< Current underline drawing scale.
521 GlsColor _underlineColor; ///< Current underline drawing color.
522 bool _underlineOn; ///< If true, underline drawing is enabled.
523
524 // state vars for strike-thru processing
525 float _strikeX1; ///< Current strike through state left X coordinate.
526 float _strikeX2; ///< Current strike through state right X coordinate.
527 float _strikeY; ///< Current strike through state Y coordinate.
528 float _strikeScale; ///< Current strike through drawing scale.
529 GlsColor _strikeColor; ///< Current strike through drawing color.
530 bool _strikeOn; ///< If true, strike through drawing is enabled.
531
532 // state vars for line processing
533 bool _whiteSpaceYes; ///< If true, the currently processed character is whitespace.
534
535 // line segments to draw
536 typedef std::list<LineSegment_t> LineSegmentCont_t; ///< Typedef for a list of line segments.
537 LineSegmentCont_t _lineSegments; ///< The list of line segments to draw.
538 };
539
540 private:
541 GlsTextBox& operator=( const GlsTextBox& ) DISTI_SPECIAL_MEM_FUN_DELETE;
542 GlsTextBox( const GlsTextBox& ) DISTI_SPECIAL_MEM_FUN_DELETE;
543
544 void OnCellDimensionChanged() DISTI_METHOD_OVERRIDE
545 {
546 _needToRebuild = true;
547 }
548};
549
550/// Stream in operator
551/// \param instr The stream to read from.
552/// \param j The returned value read from the stream.
553/// \return The stream in its current state.
554 inline std::istream& operator>>( std::istream& instr, disti::GlsTextBox::Align_t& j )
555{
556 std::string str;
557 instr >> str;
558
559 if( str == "ALIGN_TOP" )
560 {
561 j = disti::GlsTextBox::ALIGN_TOP;
562 }
563 else if( str == "ALIGN_CENTER" )
564 {
565 j = disti::GlsTextBox::ALIGN_CENTER;
566 }
567 else if( str == "ALIGN_BOTTOM" )
568 {
569 j = disti::GlsTextBox::ALIGN_BOTTOM;
570 }
571 return instr;
572}
573
574/// Stream out operator
575/// \param outstr The stream to write to.
576/// \param j The value to write to the stream.
577/// \return The stream in its current state.
578 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsTextBox::Align_t j )
579{
580 switch( j )
581 {
582 case disti::GlsTextBox::ALIGN_TOP:
583 outstr << "ALIGN_TOP";
584 break;
585 case disti::GlsTextBox::ALIGN_CENTER:
586 outstr << "ALIGN_CENTER";
587 break;
588 case disti::GlsTextBox::ALIGN_BOTTOM:
589 outstr << "ALIGN_BOTTOM";
590 break;
591 }
592 return outstr;
593}
594
595/// Stream in operator
596/// \param instr The stream to read from.
597/// \param direction The returned value read from the stream.
598/// \return The stream in its current state.
599 inline std::istream& operator>>( std::istream& instr, disti::GlsTextBox::ResizeMode_t& direction )
600{
601 std::string str;
602 instr >> str;
603
604 if( str == "RESIZE_MODE_FIXED" )
605 {
606 direction = disti::GlsTextBox::RESIZE_MODE_FIXED;
607 }
608 else if( str == "RESIZE_MODE_AUTO_WIDTH" )
609 {
610 direction = disti::GlsTextBox::RESIZE_MODE_AUTO_WIDTH;
611 }
612 else if( str == "RESIZE_MODE_AUTO_HEIGHT" )
613 {
614 direction = disti::GlsTextBox::RESIZE_MODE_AUTO_HEIGHT;
615 }
616 return instr;
617}
618
619/// Stream out operator
620/// \param outstr The stream to write to.
621/// \param direction The value to write to the stream.
622/// \return The stream in its current state.
623 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsTextBox::ResizeMode_t direction )
624{
625 switch( direction )
626 {
627 case disti::GlsTextBox::RESIZE_MODE_FIXED:
628 outstr << "RESIZE_MODE_FIXED";
629 break;
630 case disti::GlsTextBox::RESIZE_MODE_AUTO_WIDTH:
631 outstr << "RESIZE_MODE_AUTO_WIDTH";
632 break;
633 case disti::GlsTextBox::RESIZE_MODE_AUTO_HEIGHT:
634 outstr << "RESIZE_MODE_AUTO_HEIGHT";
635 break;
636 }
637 return outstr;
638}
639
640} // namespace disti
641
642#endif
disti::Culler
Definition: cull.h:50
disti::DisplayObject
Definition: display.h:96
disti::DisplayObject::Scale
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar=0)
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsColor
Definition: gls_color.h:54
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::GlsQuadListVCT_2D
Definition: gls_quad_storage.h:160
disti::GlsQuadListVC_3D
Definition: gls_quad_storage.h:64
disti::GlsTextBox::UnderlineStrikeThruHelper
Definition: gls_text_box.h:431
disti::GlsTextBox::UnderlineStrikeThruHelper::AllowShadow
void AllowShadow()
Sets the underlying shadow visibility flag to true.
disti::GlsTextBox::UnderlineStrikeThruHelper::_underlineY
float _underlineY
Current underline state Y coordinate.
Definition: gls_text_box.h:519
disti::GlsTextBox::UnderlineStrikeThruHelper::_whiteSpaceYes
bool _whiteSpaceYes
If true, the currently processed character is whitespace.
Definition: gls_text_box.h:533
disti::GlsTextBox::UnderlineStrikeThruHelper::_allowShadow
bool _allowShadow
Whether or not shadows are being drawn in general.
Definition: gls_text_box.h:502
disti::GlsTextBox::UnderlineStrikeThruHelper::_cellHeight
const float _cellHeight
Width of each character cell in the grid in logical units.
Definition: gls_text_box.h:496
disti::GlsTextBox::UnderlineStrikeThruHelper::_leftToRight
const bool _leftToRight
If true, characters are rendered left to right, otherwise right to left.
Definition: gls_text_box.h:514
disti::GlsTextBox::UnderlineStrikeThruHelper::_strikeOn
bool _strikeOn
If true, strike through drawing is enabled.
Definition: gls_text_box.h:530
disti::GlsTextBox::UnderlineStrikeThruHelper::NewRow
void NewRow()
disti::GlsTextBox::UnderlineStrikeThruHelper::_underlineOn
bool _underlineOn
If true, underline drawing is enabled.
Definition: gls_text_box.h:522
disti::GlsTextBox::UnderlineStrikeThruHelper::_underlineX1
float _underlineX1
Current underline state left X coordinate.
Definition: gls_text_box.h:517
disti::GlsTextBox::UnderlineStrikeThruHelper::_lineSegments
LineSegmentCont_t _lineSegments
The list of line segments to draw.
Definition: gls_text_box.h:537
disti::GlsTextBox::UnderlineStrikeThruHelper::_underlineScale
float _underlineScale
Current underline drawing scale.
Definition: gls_text_box.h:520
disti::GlsTextBox::UnderlineStrikeThruHelper::_shadowColor
const GlsColor _shadowColor
Color of the shadow effect behind the characters.
Definition: gls_text_box.h:501
disti::GlsTextBox::UnderlineStrikeThruHelper::_haloColor
const GlsColor _haloColor
Color of the halo effect behind the characters.
Definition: gls_text_box.h:511
disti::GlsTextBox::UnderlineStrikeThruHelper::_underlineOffset
const float _underlineOffset
Vertical offset of the underline in logical units.
Definition: gls_text_box.h:505
disti::GlsTextBox::UnderlineStrikeThruHelper::_strikeX2
float _strikeX2
Current strike through state right X coordinate.
Definition: gls_text_box.h:526
disti::GlsTextBox::UnderlineStrikeThruHelper::UnderlineStrikeThruHelper
UnderlineStrikeThruHelper(float cellWidth, float cellHeight, float cellYScale, bool shadow, const Vector &shadowOffset, const GlsColor &shadowColor, float underlineOffset, float underlineSize, bool halo, float haloOffset, GlsColor haloColor, bool leftToRight)
disti::GlsTextBox::UnderlineStrikeThruHelper::_strikeY
float _strikeY
Current strike through state Y coordinate.
Definition: gls_text_box.h:527
disti::GlsTextBox::UnderlineStrikeThruHelper::LineSegmentCont_t
std::list< LineSegment_t > LineSegmentCont_t
Typedef for a list of line segments.
Definition: gls_text_box.h:536
disti::GlsTextBox::UnderlineStrikeThruHelper::_shadow
const bool _shadow
Whether or not the shadow effect is on.
Definition: gls_text_box.h:499
disti::GlsTextBox::UnderlineStrikeThruHelper::_halo
const bool _halo
Whether or not the halo effect is on.
Definition: gls_text_box.h:509
disti::GlsTextBox::UnderlineStrikeThruHelper::PostProcessCharacter
void PostProcessCharacter(const CharAttr_t &charAttr, const Char_t &c, float cellX, float charY, float cellWidth, bool endOfLine)
disti::GlsTextBox::UnderlineStrikeThruHelper::_underlineX2
float _underlineX2
Current underline state right X coordinate.
Definition: gls_text_box.h:518
disti::GlsTextBox::UnderlineStrikeThruHelper::_haloOffset
const float _haloOffset
Offset multiplier for the halo effect.
Definition: gls_text_box.h:510
disti::GlsTextBox::UnderlineStrikeThruHelper::_underlineColor
GlsColor _underlineColor
Current underline drawing color.
Definition: gls_text_box.h:521
disti::GlsTextBox::UnderlineStrikeThruHelper::_underlineSize
const float _underlineSize
Thickness of the underline in logical units.
Definition: gls_text_box.h:506
disti::GlsTextBox::UnderlineStrikeThruHelper::PreProcessCharacter
void PreProcessCharacter(const CharAttr_t &charAttr, const Char_t &c, float cellX, float charY)
disti::GlsTextBox::UnderlineStrikeThruHelper::_cellWidth
const float _cellWidth
Height of each character cell in the grid in logical units.
Definition: gls_text_box.h:495
disti::GlsTextBox::UnderlineStrikeThruHelper::IgnoreShadow
void IgnoreShadow()
Sets the underlying shadow visibility flag to false.
disti::GlsTextBox::UnderlineStrikeThruHelper::RenderLineSegments
void RenderLineSegments(GlsQuadListVC_3D &quadStorage)
disti::GlsTextBox::UnderlineStrikeThruHelper::_strikeScale
float _strikeScale
Current strike through drawing scale.
Definition: gls_text_box.h:528
disti::GlsTextBox::UnderlineStrikeThruHelper::_strikeColor
GlsColor _strikeColor
Current strike through drawing color.
Definition: gls_text_box.h:529
disti::GlsTextBox::UnderlineStrikeThruHelper::_strikeX1
float _strikeX1
Current strike through state left X coordinate.
Definition: gls_text_box.h:525
disti::GlsTextBox::UnderlineStrikeThruHelper::_shadowOffset
const Vector _shadowOffset
Offset of the shadow effect from the characters. Z component is ignored.
Definition: gls_text_box.h:500
disti::GlsTextBox
Definition: gls_text_box.h:90
disti::GlsTextBox::_shadows
GlsQuadListVCT_2D _shadows
Quads used to render the shadows behind the text.
Definition: gls_text_box.h:100
disti::GlsTextBox::FormatVarArgList
char * FormatVarArgList(const char *format, va_list args)
disti::GlsTextBox::TabSpacing
float TabSpacing()
disti::GlsTextBox::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::VerticalAlignment
virtual Align_t VerticalAlignment() const
Definition: gls_text_box.h:214
disti::GlsTextBox::Draw
virtual void Draw() DISTI_METHOD_OVERRIDE
disti::GlsTextBox::_tabSpacing
float _tabSpacing
Space multiplier for tabs.
Definition: gls_text_box.h:350
disti::GlsTextBox::_cellWidthRatio
float _cellWidthRatio
Holds cell width / max char width ratio used for horizontal advance.
Definition: gls_text_box.h:415
disti::GlsTextBox::RecalcCellSize
void RecalcCellSize()
disti::GlsTextBox::_characters
GlsQuadListVCT_2D _characters
Quads used to render the characters in the foreground.
Definition: gls_text_box.h:102
disti::GlsTextBox::EnablePerCharAttribs
void EnablePerCharAttribs()
Enable per character attribute drawing for this grid.
Definition: gls_text_box.h:339
disti::GlsTextBox::_unicodeText
UTF16String _unicodeText
Definition: gls_text_box.h:427
disti::GlsTextBox::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::_leftToRight
bool _leftToRight
true to render characters from left to right else, false for right to left.
Definition: gls_text_box.h:421
disti::GlsTextBox::CalculateRowData
virtual void CalculateRowData()
disti::GlsTextBox::VerticalAlignment
void VerticalAlignment(Align_t justification)
disti::GlsTextBox::GetNextRowInfo
void GetNextRowInfo(const unsigned int strIndex, unsigned int &rowLength, float &rowPixelWidth, unsigned int &nextRowStartIndex) const
disti::GlsTextBox::MaxLinesToDraw
virtual unsigned int MaxLinesToDraw()
disti::GlsTextBox::Align_t
Align_t
Different text justifications.
Definition: gls_text_box.h:200
disti::GlsTextBox::_resizeMaxWidth
float _resizeMaxWidth
The calculated maximum width in logical units based on the current resize behavior.
Definition: gls_text_box.h:424
disti::GlsTextBox::SetFromGloData
virtual void SetFromGloData(GlsGloFileAttribute &data) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::_perCharAttribs
bool _perCharAttribs
Definition: gls_text_box.h:336
disti::GlsTextBox::GetCharWidth
float GetCharWidth(const unsigned short c) const
disti::GlsTextBox::PopulateQuadStorage
void PopulateQuadStorage()
disti::GlsTextBox::_lineCount
unsigned int _lineCount
Number of rows of characters in the text grid (number of lines).
Definition: gls_text_box.h:410
disti::GlsTextBox::VaString
void VaString(const char *format,...)
disti::GlsTextBox::LeftToRight
void LeftToRight(bool leftToRight)
disti::GlsTextBox::_shadowLines
GlsQuadListVC_3D _shadowLines
Quads used to render the shadows for lines such as underlines and strikethroughs.
Definition: gls_text_box.h:101
disti::GlsTextBox::ResizeMode
virtual ResizeMode_t ResizeMode()
disti::GlsTextBox::SetVerticesToTextBounds
void SetVerticesToTextBounds()
Helper function that adjusts the vertices to contain the text based on the resize behavior.
disti::GlsTextBox::PreDraw
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::MaxWidth
virtual void MaxWidth(float value)
disti::GlsTextBox::RecalcVertices
void RecalcVertices()
disti::GlsTextBox::ClearChars
void ClearChars()
Definition: gls_text_box.h:238
disti::GlsTextBox::_resizeMode
ResizeMode_t _resizeMode
The current automatic resize behavior.
Definition: gls_text_box.h:423
disti::GlsTextBox::Calculate
virtual void Calculate(double time) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::CopyGeometry
virtual void CopyGeometry(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::SetVertices
virtual void SetVertices(unsigned int nPoints, Vertex *vertices) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::TabSpacing
void TabSpacing(float)
disti::GlsTextBox::SetString
void SetString(const char *s)
Definition: gls_text_box.h:253
disti::GlsTextBox::ResizeMode
virtual void ResizeMode(ResizeMode_t value)
disti::GlsTextBox::_maxLineLengthPixels
float _maxLineLengthPixels
Calculated maximimum line width in "pixels" (logical units).
Definition: gls_text_box.h:417
disti::GlsTextBox::MaxHeight
virtual float MaxHeight()
disti::GlsTextBox::Clear
void Clear()
Definition: gls_text_box.h:229
disti::GlsTextBox::_maxLinesToDraw
unsigned int _maxLinesToDraw
Calculated maximum number of lines that can fit.
Definition: gls_text_box.h:419
disti::GlsTextBox::MaxWidth
virtual float MaxWidth()
disti::GlsTextBox::_backgrounds
GlsQuadListVC_3D _backgrounds
Quads used to render the backgrounds. This is rendered behind the other quads associated with this te...
Definition: gls_text_box.h:99
disti::GlsTextBox::_lines
GlsQuadListVC_3D _lines
Quads used to render lines such as underlines and strikethroughs.
Definition: gls_text_box.h:103
disti::GlsTextBox::MaxHeight
virtual void MaxHeight(float value)
disti::GlsTextBox::_lineCountChanged
bool _lineCountChanged
If true, the line count has changed, and row information needs to be rebuilt.
Definition: gls_text_box.h:411
disti::GlsTextBox::Initialize
virtual void Initialize()
Sets the initial state of this object.
disti::GlsTextBox::Scale
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::DrawText
void DrawText()
disti::GlsTextBox::CopyProperties
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsTextBox::_rowInfo
RowInfo * _rowInfo
Definition: gls_text_box.h:413
disti::GlsTextBox::_verticalAlignment
Align_t _verticalAlignment
Justification setting (TOP, CENTER, BOTTOM).
Definition: gls_text_box.h:348
disti::GlsTextBox::ResizeMode_t
ResizeMode_t
The ResizeMode_t enumeration. Describes the resize behavior of this text object.
Definition: gls_text_box.h:113
disti::GlsTextBox::GetMaxLineLengthForResizeMode
float GetMaxLineLengthForResizeMode() const
disti::GlsTextBox::GlsTextBox
GlsTextBox()
disti::GlsTextBox::_resizeMaxHeight
float _resizeMaxHeight
The calculated maximim height in logical units based on the current resize behavior.
Definition: gls_text_box.h:425
disti::GlsTextBox::LeftToRight
bool LeftToRight()
disti::GlsTextBox::Rebuild
void Rebuild()
Rebuilds this text box layout. This may be an expensive call, so it should only be called when a prop...
disti::GlsTextBox::_maxTextHeightPixels
float _maxTextHeightPixels
Calculated maximimum height in "pixels" (logical units).
Definition: gls_text_box.h:418
disti::GlsText
Definition: gls_text.h:154
disti::GlsText::Underline
bool Underline()
disti::GlsText::CellHeight
float CellHeight() const
Definition: gls_text.h:260
disti::GlsText::CharAttr
CharAttr_t CharAttr(unsigned int index) const
Definition: gls_text.h:297
disti::GlsText::Baseline
float Baseline()
disti::GlsText::FauxBold
bool FauxBold()
disti::GlsText::CharScaling
float CharScaling()
disti::GlsText::CellWidth
float CellWidth() const
Definition: gls_text.h:274
disti::GlsText::_needToRebuild
bool _needToRebuild
Definition: gls_text.h:703
disti::GlsText::StrikeThru
bool StrikeThru()
disti::GlsText::Char
void Char(Char_t code)
disti::GlsText::SetRebuild
void SetRebuild()
Definition: gls_text.h:583
disti::GlsText::CharSpacing
float CharSpacing()
disti::GlsText::BgColor
GlsColor BgColor()
disti::GlsText::Erase
void Erase()
disti::GlsText::Char_t
GlsFontBase::Char_t Char_t
Typedef shorthand for GlsFontBase::Char_t.
Definition: gls_text.h:160
disti::GlsText::Inverse
bool Inverse()
disti::GlsText::String
std::string String() const
Definition: gls_text.h:539
disti::GlsText::_text
std::string _text
Definition: gls_text.h:714
disti::GlsText::TextColor
GlsColor TextColor()
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::VertexNoColor
Definition: vertex.h:85
disti::Vertex
Definition: vertex.h:420
gls_auto_lib.h
The gls_auto_lib.
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:246
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
gls_gl.h
The gls_gl.
gls_quad_storage.h
The disti::GlsQuadListVC_3D and GlsQuadListVCT_2D classes.
gls_state_manager.h
The disti::GlsStateManager factory class. Creates an instance of a state manager that manages the GL ...
gls_text.h
The disti::GlsText class.
GLSGEN_GLSTEXTBOX_EXPORT
#define GLSGEN_GLSTEXTBOX_EXPORT
Provides support for creating DLLs.
Definition: gls_text_box.h:52
disti
Definition: bmpimage.h:47
disti::operator<<
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
disti::operator>>
std::istream & operator>>(std::istream &instr, GlsColor &color)
disti::UTF16String
std::basic_string< unsigned short, CharTraitsUnsignedShort > UTF16String
A cross platform UTF-16 encoded string.
Definition: util.h:428
disti::GlsTextBox::RowInfo
Definition: gls_text_box.h:403
disti::GlsTextBox::RowInfo::startingIndex
unsigned int startingIndex
Definition: gls_text_box.h:404
disti::GlsTextBox::RowInfo::pixelWidth
float pixelWidth
Definition: gls_text_box.h:407
disti::GlsTextBox::RowInfo::length
unsigned int length
Definition: gls_text_box.h:406
disti::GlsText::CharAttr_t
Attributes for each character position in the grid.
Definition: gls_text.h:179
unhide_globals.h
The DistiUnhideGlobalsDummyClass class.