GL Studio C++ Runtime API
gls_ctl_text_box.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsCTLTextBox 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 
41 #ifndef INCLUDED_GLS_CTL_TEXT_BOX_H
42 #define INCLUDED_GLS_CTL_TEXT_BOX_H
43 
44 // CTL Text box does not work for WebGL due to issues with the Pango library and its dependencies
45 // CTL Text boxes will fall back to stock GlsTextBoxes, and any CTL functions will do nothing.
46 // GLS-5903: Remove Pango from CTL Text Box
47 #if defined( EMSCRIPTEN )
48 # define GLS_CTL_FALLBACK_ENABLED
49 # ifndef GLES
50 # error "GLES should always be enabled when using the CTL fallback code"
51 # endif
52 #endif
53 
54 //////////////////// Provides support for creating DLLs ////////////////////////
55 #if( defined( GLSGEN_EXPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_IMPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_GLSCTLTEXTBOX_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
56  && defined( _MSC_VER )
57 # if defined( GLSGEN_EXPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_GLSCTLTEXTBOX_EXPORT_GENERATED )
58 # define GLSGEN_GLSCTLTEXTBOX_EXPORT __declspec( dllexport )
59 # else
60 # define GLSGEN_GLSCTLTEXTBOX_EXPORT __declspec( dllimport )
61 # endif
62 #else
63 # define GLSGEN_GLSCTLTEXTBOX_EXPORT
64 #endif
65 ///////////////////////////////////////////////////////////////////////////////
66 
67 #include "gls_cpp_lang_support.h"
68 #include "gls_gl.h"
69 #include "scoped_ptr.h"
70 #include "unhide_globals.h"
71 #include <string>
72 
73 #ifndef GLS_CTL_FALLBACK_ENABLED
74 # include "gls_text.h"
75 # define CTL_BASE_CLASS GlsText
76 #else
77 # include "gls_text_box.h"
78 # define CTL_BASE_CLASS GlsTextBox
79 #endif
80 
81 #define LIB_BASE_NAME "gls_ctl_text_box"
82 #include "gls_auto_lib.h"
83 #undef LIB_BASE_NAME
84 
85 // Force inclusion of the pango libraries
86 #ifdef WIN32
87 # if !defined( NO_GLS_AUTOLIB ) && !defined( GLS_IMPORT_LIBRARY )
88 # ifdef _WIN64
89 # define PANGO_SUFFIX "_64"
90 # else
91 # define PANGO_SUFFIX ""
92 # endif
93 # pragma message( "Will automatically link with libfontconfig" PANGO_SUFFIX "-1.0.lib" )
94 # pragma message( "Will automatically link with libpango" PANGO_SUFFIX "-1.0.lib" )
95 # pragma message( "Will automatically link with libpangoft2" PANGO_SUFFIX "-1.0.lib" )
96 # pragma message( "Will automatically link with libgobject" PANGO_SUFFIX "-2.0.lib" )
97 # pragma comment( lib, "libfontconfig" PANGO_SUFFIX "-1.0.lib" )
98 # pragma comment( lib, "libpango" PANGO_SUFFIX "-1.0.lib" )
99 # pragma comment( lib, "libpangoft2" PANGO_SUFFIX "-1.0.lib" )
100 # pragma comment( lib, "libgobject" PANGO_SUFFIX "-2.0.lib" )
101 # endif
102 #endif
103 
104 namespace disti
105 {
106 // Forward Declarations
107 #ifndef GLS_CTL_FALLBACK_ENABLED
108 class GlsPangoWrapper;
109 struct PangoRect;
110 #else
111 class GlsTextBoxFontRenderer;
112 #endif // GLS_CTL_FALLBACK_ENABLED
113 
114 #ifdef GLES
115 class GlsGloFileAttribute;
116 class GlsStateManager;
117 class GlsQuadListVCT_2D;
118 #endif // GLES
119 
120 //===========================================================================
121 /** \brief The Gls CTL (Complex Text Layout) Text Box.
122  *
123  * On certain platforms, the text layout library is unavailable, and complex text rendering in the runtime will be missing.
124  *
125  * To account for this, the GlsCTLTextBox will 'Fallback' to being treated as a GlsTextBox. In those cases, certain
126  * GlsCTLTextBox functions will not have no effect.
127  */
128 class GlsCTLTextBox : public CTL_BASE_CLASS
129 {
130 public:
131  DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
132  typedef CTL_BASE_CLASS _BaseClass;
133  typedef CTL_BASE_CLASS BaseClass;
134 
135  /** The internal border between the layout edges and the glyph edges.
136  * This will keep the glyph edges from appearing cut-off when linear texture filtering is applied.
137  */
138  static const unsigned int INTERNAL_BORDER = 1;
139 
140  friend class GlsCTLTextBoxEditor;
141 
142 #ifndef GLS_CTL_FALLBACK_ENABLED
143  /** The vertical alignment types. */
145  ALIGN_CENTER,
146  ALIGN_TOP,
147  ALIGN_BOTTOM
148  };
149 #else
150  typedef Align_t VerticalAlignment_t;
151 #endif // GLS_CTL_FALLBACK_ENABLED
152 
153  /** Deprecated */
155  {
156  VERTICAL_ALIGNMENT_CENTER = ALIGN_CENTER,
157  VERTICAL_ALIGNMENT_TOP = ALIGN_TOP,
158  VERTICAL_ALIGNMENT_BOTTOM = ALIGN_BOTTOM
159  };
160 
161  /** The ellipsize mode types. */
163  {
164  ELLIPSIZE_MODE_NONE,
165  ELLIPSIZE_MODE_START,
166  ELLIPSIZE_MODE_MIDDLE,
167  ELLIPSIZE_MODE_END
168  };
169 
170  /**
171  * The text direction types.
172  * TEXT_DIRECTION_LTR - Use Left to Right as the base direction for rendering text.
173  * TEXT_DIRECTION_RTL - Use Right to Left as the base direction for rendering text.
174  * TEXT_DIRECTION_AUTOMATIC - Determine the base direction for rendering text from the first strongly directioned character.
175  * TEXT_DIRECTION_AUTO_BY_LINE - Determine the base direction for rendering text for each individual EOL-seperated line in the text string.
176  */
178  {
179  TEXT_DIRECTION_LTR,
180  TEXT_DIRECTION_RTL,
181  TEXT_DIRECTION_AUTOMATIC,
182  TEXT_DIRECTION_AUTO_BY_LINE
183  };
184 
185 #ifndef GLS_CTL_FALLBACK_ENABLED
186  enum ResizeMode_t{
187  RESIZE_MODE_FIXED,
188  RESIZE_MODE_AUTO_WIDTH,
189  RESIZE_MODE_AUTO_HEIGHT
190  };
191 #endif
192 
193  /** The structure returned to the caller when getting the glyph metrics.
194  * These are in logical units, relative to the bottom-left corner of the text box.
195  */
197  {
198  float minX;
199  float minY;
200  float maxX;
201  float maxY;
202 
203  GlyphMetrics()
204  : minX( 0.0f )
205  , minY( 0.0f )
206  , maxX( 0.0f )
207  , maxY( 0.0f )
208  {}
209  };
210 
211  /** Default constructor. */
212  GLSGEN_GLSCTLTEXTBOX_EXPORT GlsCTLTextBox();
213 
214  /** The copy constructor for GlsCTLTextBox
215  *
216  * \param that The GlsCTLTextBox object that is being copied
217  * \param generateNames Whether or not to generate a new instance name
218  */
219  GLSGEN_GLSCTLTEXTBOX_EXPORT GlsCTLTextBox( const GlsCTLTextBox& that, const bool generateNames );
220 
221  /** Destructor.
222  */
223  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT ~GlsCTLTextBox();
224 
225  // See DisplayObject
226  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
227 
228 #ifndef GLS_CTL_FALLBACK_ENABLED
229  // See DisplayObject
230  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
231 
232  // See DisplayObject
233  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void CopyGeometry( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
234 
235  // See DisplayObject
236  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
237 
238  // See DisplayObject
239  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) DISTI_METHOD_OVERRIDE;
240 
241  // See DisplayObject
242  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
243 
244  // See DisplayObject
245  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetVertices( unsigned int nPoints, Vertex* vertices ) DISTI_METHOD_OVERRIDE;
246 
247  // See DisplayObject
248  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
249 
250  /** Print a string into this text object.
251  * Replaces the entire string.
252  * \param format printf style varargs formatting string.
253  */
254  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VaString( const char* format, ... );
255 
256  /** Set the vertical alignment for this text object
257  * \param[in] verticalAlignment The vertical alignment type.
258  */
259  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignment_t verticalAlignment );
260  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignmentCTL_t verticalAlignment ) { VerticalAlignment( static_cast<VerticalAlignment_t>( verticalAlignment ) ); }
261 #else
262 
263  /** Set the vertical alignment for this text object
264  * \param[in] verticalAlignment The vertical alignment type.
265  */
266  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignment_t verticalAlignment ) { BaseClass::VerticalAlignment( verticalAlignment ); }
267  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignmentCTL_t verticalAlignment );
268 
269 #endif // GLS_CTL_FALLBACK_ENABLED
270 
271  /** Get the vertical alignment for this text object
272  * \return The vertical alignment type.
273  */
274  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT VerticalAlignment_t VerticalAlignment();
275 
276 #ifndef GLES
277 
278  // See DisplayObject
279  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
280 
281  // See DisplayObject
282  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
283 
284 #endif // GLES
285 
286  /** Rebuilds this text box layout. This may be an expensive call, so it should only be called when a property changes. */
287  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Rebuild();
288 
289  // NO CTL-only functions should be disabled when using the GlsTextBox fallback.
290  // They should be available to every runtime, even if they do nothing.
291 
292  /** Gets the type of automatic ellipsize if the text does not fit in the boundary.
293  * \return The type of automatic ellipsize if the text does not fit in the boundary.
294  * \note In CTL Fallback mode, returns ELLIPSIZE_MODE_NONE.
295  */
296  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT EllipsizeMode_t EllipsizeMode();
297 
298  /** Sets the type of automatic ellipsize if the text does not fit in the boundary.
299  * \param[in] ellipsizeMode The type of automatic ellipsize if the text does not fit in the boundary.
300  * \note In CTL Fallback mode, has no effect.
301  */
302  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void EllipsizeMode( const EllipsizeMode_t ellipsizeMode );
303 
304  /** Gets the number of lines in the layout.
305  * \return The number of lines in the layout.
306  * \note In CTL Fallback mode, returns 0.
307  */
308  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT unsigned int GetLineCount();
309 
310  /** Gets the number of glyphs in the layout.
311  * \return The number of glyphs in the layout.
312  * \note In CTL Fallback mode, returns 0.
313  */
314  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT unsigned int GetGlyphCount();
315 
316  /** Gets the glyph metrics for the given glyph index.
317  * \param[in] glyphIndex The index of the glyph in the layout line to get the glyph metrics for.
318  * \return The glyph metrics for the given glyph index.
319  * \note In CTL Fallback mode, returns a default GlyphMetrics struct.
320  */
321  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT GlyphMetrics GetGlyphMetrics( const unsigned int glyphIndex );
322 
323  /** Set the Pango Layout auto dir, exposes pango_layout_set_auto_dir ()
324  * see: https://developer.gnome.org/pango/stable/pango-Layout-Objects.html#pango-layout-set-auto-dir
325  * \param[in] autoDir Whether or not the layout should automatically determine base direction based on content
326  * \note In CTL Fallback mode, has no effect.
327  * \deprecated
328  */
329  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetLayoutAutoDir( bool ){};
330 
331  /** Set width used to render the text. If the width of the vertices is smaller than this width, the text will be truncated. If the
332  * value is 0.0, the text will be rendered to the full width of the vertices
333  * \note In CTL Fallback mode, has no effect.
334  */
335  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAltWidth( float width );
336 
337  /** Set height used to render the text. If the height of the vertices is smaller than this height, the text will be truncated. If the
338  * value is 0.0, the text will be rendered to the full height of the vertices
339  * \note In CTL Fallback mode, has no effect.
340  */
341  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAltHeight( float height );
342 
343  /** Scales the text horizontally by the given value. Text is still clamped by the bounds of the text box
344  * \param value the horizontal scale
345  */
346  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextHorizontalScale( float value );
347 
348  /** Get the horizontal scale */
349  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float TextHorizontalScale();
350 
351  /** Scales the text vertically by the given value. Text is still clamped by the bounds of the text box
352  * \param value the vertical scale
353  */
354  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextVerticalScale( float value );
355 
356  /** Get the vertical scale */
357  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float TextVerticalScale();
358 
359  /** Gets the base direction used in applying the Unicode bidirectional algorithm.
360  * \return the text direction
361  * \note In CTL Fallback mode, returns TEXT_DIRECTION_AUTOMATIC.
362  */
363  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT TextDirection_t TextDirection();
364 
365  /** Sets the base direction used in applying the Unicode bidirectional algorithm.
366  * \param[in] textDirection The text direction.
367  * \note In CTL Fallback mode, has no effect.
368  */
369  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextDirection( const TextDirection_t textDirection );
370 
371  /** \see GlsText */
372  bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
373  {
374  return true;
375  }
376 
377 #ifndef GLS_CTL_FALLBACK_ENABLED
378  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void ResizeMode( ResizeMode_t value );
379  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT ResizeMode_t ResizeMode();
380 
381  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void MaxWidth( float value );
382  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float MaxWidth();
383 
384  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void MaxHeight( float value );
385  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float MaxHeight();
386 #endif
387 
388 #ifdef GLES20
389  /** Re-enables automatic pixel alignment behavior that was always active by default prior to 7.0
390  * This flag should be enabled at the start of the program if your design relied on this behavior in a previous version of GL Studio.
391  * \param enabled the new state for the alignment behavior flag
392  */
393  GLSGEN_GLSCTLTEXTBOX_EXPORT static void SetAutomaticPixelAlignmentEnabled( const bool enabled );
394 #endif
395 
396 protected:
397 #ifndef GLS_CTL_FALLBACK_ENABLED
398  /** Width used to render the text */
399  float _altWidth;
400  /** Height used to render the text */
401  float _altHeight;
402 
403  /** the horizontal scale */
405  /** the vertical scale */
407 
408  /** Pointer to the internal data needed for Pango. */
410 
411  /** makes adjustment to the image verts and texture coords for the alt width / height and text scaling properties
412  * \param[inout] verts the image verts
413  * \param[inout] texCoords the image texture coords
414  */
415  void AdjustImageVertsAndCoords( PangoRect& verts, PangoRect& texCoords );
416 
417  void ApplyTextScale( float textBoxWidth, float textBoxHeight, PangoRect& verts );
418  void ClampToTextBoxSize( float textBoxWidth, float textBoxHeight, PangoRect& verts, PangoRect& texCoords );
419  void ApplyVerticalAlignment( float textBoxHeight, PangoRect& verts );
420 
421 # ifdef GLES20
422  /** State of automatic pixel alignment behavior flag */
423  static bool s_isAutomaticPixelAlignmentEnabled;
424 # endif
425 
426  TextDirection_t _textDirection;
427 
428 # ifndef GLS_CTL_FALLBACK_ENABLED
429  ResizeMode_t _resizeMode;
430  float _resizeMaxWidth;
431  float _resizeMaxHeight;
432 # endif
433 
434 #endif // GLS_CTL_FALLBACK_ENABLED
435 
436 #ifdef GLES
437 
438  // See DisplayObject
439  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
440 
441 # ifndef GLS_CTL_FALLBACK_ENABLED
442  /** The list of quads to draw for the shadows. */
444  /** The list of quads to draw for the characters. */
445  ScopedPtr<GlsQuadListVCT_2D> _characters;
446 
447  /** True if _geometryRefresh was true in PreDraw. This is just so we can rebuild the quads in Draw(). */
448  bool _geometryRefreshDraw;
449 
450  /** Populate the quad storage
451  * \param stateManager
452  */
453  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void PopulateQuadStorage( IGlsStateManager* stateManager );
454 
455  /** Draws the polygons that make up the characters.
456  * \param stateManager
457  */
458  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void DrawText( IGlsStateManager* stateManager );
459 # endif // GLS_CTL_FALLBACK_ENABLED
460 
461 #else
462  /** Draws the polygons that make up the characters.
463  */
464  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void DrawText();
465 #endif // GLES
466 #ifndef GLS_CTL_FALLBACK_ENABLED
467  /** Rebuilds the vertices of the text box.
468  */
469  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void RecalcVertices();
470 
471  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetVerticesToImageSize( const PangoRect& verts, bool keepWidth );
472 #endif // GLS_CTL_FALLBACK_ENABLED
473 
474 private:
475  /* See base class */
476  void OnCellDimensionChanged() DISTI_METHOD_OVERRIDE
477  {
478  // Prevent changing cell dimensions for CTL Textbox
479  _cellHeight = 0;
480  _cellWidth = 0;
481  ControlCellSize( false );
482  }
483 
484  GlsCTLTextBox& operator=( const GlsCTLTextBox& ) DISTI_SPECIAL_MEM_FUN_DELETE;
485  GlsCTLTextBox( const GlsCTLTextBox& ) DISTI_SPECIAL_MEM_FUN_DELETE;
486 };
487 
488 #ifndef GLS_CTL_FALLBACK_ENABLED
489 
490 /** In stream operator for VerticalAlignment_t enumeration.
491  */
492 inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::VerticalAlignment_t& verticalAlignment )
493 {
494  std::string str;
495  instr >> str;
496 
497  if( str == "ALIGN_TOP" || str == "VERTICAL_ALIGNMENT_TOP" )
498  {
499  verticalAlignment = disti::GlsCTLTextBox::ALIGN_TOP;
500  }
501  else if( str == "ALIGN_CENTER" || str == "VERTICAL_ALIGNMENT_CENTER" )
502  {
503  verticalAlignment = disti::GlsCTLTextBox::ALIGN_CENTER;
504  }
505  else if( str == "ALIGN_BOTTOM" || str == "VERTICAL_ALIGNMENT_BOTTOM" )
506  {
507  verticalAlignment = disti::GlsCTLTextBox::ALIGN_BOTTOM;
508  }
509  return instr;
510 }
511 
512 /** Out stream operator for VerticalAlignment_t enumeration.
513  */
514 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::VerticalAlignment_t verticalAlignment )
515 {
516  switch( verticalAlignment )
517  {
518  case disti::GlsCTLTextBox::ALIGN_TOP:
519  outstr << "ALIGN_TOP";
520  break;
521  case disti::GlsCTLTextBox::ALIGN_CENTER:
522  outstr << "ALIGN_CENTER";
523  break;
524  case disti::GlsCTLTextBox::ALIGN_BOTTOM:
525  outstr << "ALIGN_BOTTOM";
526  break;
527  }
528  return outstr;
529 }
530 #endif // GLS_CTL_FALLBACK_ENABLED
531 
532 /** In stream operator for EllipsizeMode_t enumeration.
533  */
534 inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::EllipsizeMode_t& ellipsizeMode )
535 {
536  std::string str;
537  instr >> str;
538 
539  if( str == "ELLIPSIZE_MODE_NONE" )
540  {
541  ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE;
542  }
543  else if( str == "ELLIPSIZE_MODE_START" )
544  {
545  ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_START;
546  }
547  else if( str == "ELLIPSIZE_MODE_MIDDLE" )
548  {
549  ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE;
550  }
551  else if( str == "ELLIPSIZE_MODE_END" )
552  {
553  ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_END;
554  }
555  return instr;
556 }
557 
558 /** Out stream operator for EllipsizeMode_t enumeration.
559  */
560 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::EllipsizeMode_t ellipsizeMode )
561 {
562  switch( ellipsizeMode )
563  {
564  case disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE:
565  outstr << "ELLIPSIZE_MODE_NONE";
566  break;
567  case disti::GlsCTLTextBox::ELLIPSIZE_MODE_START:
568  outstr << "ELLIPSIZE_MODE_START";
569  break;
570  case disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE:
571  outstr << "ELLIPSIZE_MODE_MIDDLE";
572  break;
573  case disti::GlsCTLTextBox::ELLIPSIZE_MODE_END:
574  outstr << "ELLIPSIZE_MODE_END";
575  break;
576  }
577  return outstr;
578 }
579 
580 /** In stream operator for TextDirection_t enumeration.
581  */
582 inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::TextDirection_t& direction )
583 {
584  std::string str;
585  instr >> str;
586 
587  if( str == "TEXT_DIRECTION_LTR" )
588  {
589  direction = disti::GlsCTLTextBox::TEXT_DIRECTION_LTR;
590  }
591  else if( str == "TEXT_DIRECTION_RTL" )
592  {
593  direction = disti::GlsCTLTextBox::TEXT_DIRECTION_RTL;
594  }
595  else if( str == "TEXT_DIRECTION_AUTOMATIC" )
596  {
597  direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC;
598  }
599  else if( str == "TEXT_DIRECTION_AUTO_BY_LINE" )
600  {
601  direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE;
602  }
603  return instr;
604 }
605 
606 /** Out stream operator for TextDirection_t enumeration.
607  */
608 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::TextDirection_t direction )
609 {
610  switch( direction )
611  {
612  case disti::GlsCTLTextBox::TEXT_DIRECTION_LTR:
613  outstr << "TEXT_DIRECTION_LTR";
614  break;
615  case disti::GlsCTLTextBox::TEXT_DIRECTION_RTL:
616  outstr << "TEXT_DIRECTION_RTL";
617  break;
618  case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC:
619  outstr << "TEXT_DIRECTION_AUTOMATIC";
620  break;
621  case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE:
622  outstr << "TEXT_DIRECTION_AUTO_BY_LINE";
623  break;
624  }
625  return outstr;
626 }
627 
628 #ifndef GLS_CTL_FALLBACK_ENABLED
629 /** In stream operator for ResizeMode_t enumeration.
630  */
631 inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::ResizeMode_t& direction )
632 {
633  std::string str;
634  instr >> str;
635 
636  if( str == "RESIZE_MODE_FIXED" )
637  {
638  direction = disti::GlsCTLTextBox::RESIZE_MODE_FIXED;
639  }
640  else if( str == "RESIZE_MODE_AUTO_WIDTH" )
641  {
642  direction = disti::GlsCTLTextBox::RESIZE_MODE_AUTO_WIDTH;
643  }
644  else if( str == "RESIZE_MODE_AUTO_HEIGHT" )
645  {
646  direction = disti::GlsCTLTextBox::RESIZE_MODE_AUTO_HEIGHT;
647  }
648  return instr;
649 }
650 
651 /** Out stream operator for ResizeMode_t enumeration.
652  */
653 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::ResizeMode_t direction )
654 {
655  switch( direction )
656  {
657  case disti::GlsCTLTextBox::RESIZE_MODE_FIXED:
658  outstr << "RESIZE_MODE_FIXED";
659  break;
660  case disti::GlsCTLTextBox::RESIZE_MODE_AUTO_WIDTH:
661  outstr << "RESIZE_MODE_AUTO_WIDTH";
662  break;
663  case disti::GlsCTLTextBox::RESIZE_MODE_AUTO_HEIGHT:
664  outstr << "RESIZE_MODE_AUTO_HEIGHT";
665  break;
666  }
667  return outstr;
668 }
669 #endif
670 
671 } // namespace disti
672 
673 #endif // INCLUDED_GLS_CTL_TEXT_BOX_H
The DistiUnhideGlobalsDummyClass class.
Definition: cull.h:49
virtual VerticalAlignment_t VerticalAlignment()
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
Definition: vertex.h:409
The disti::GlsTextBox class.
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
ScopedPtr< GlsPangoWrapper > _glsPangoWrapper
Definition: gls_ctl_text_box.h:409
virtual float TextHorizontalScale()
void AdjustImageVertsAndCoords(PangoRect &verts, PangoRect &texCoords)
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:471
float _altWidth
Definition: gls_ctl_text_box.h:399
bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
Definition: gls_ctl_text_box.h:372
EllipsizeMode_t
Definition: gls_ctl_text_box.h:162
virtual void VaString(const char *format,...)
Definition: display.h:98
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
virtual GlyphMetrics GetGlyphMetrics(const unsigned int glyphIndex)
float _cellHeight
Definition: gls_text.h:661
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
Definition: gls_state_manager_interface.h:67
virtual void RecalcVertices()
virtual unsigned int GetLineCount()
The disti::GlsText class.
float _altHeight
Definition: gls_ctl_text_box.h:401
Definition: gls_glo_file.h:988
virtual unsigned int GetGlyphCount()
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
Defines the stream out operator.
virtual ~GlsCTLTextBox()
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual float TextVerticalScale()
The Gls CTL (Complex Text Layout) Text Box.
Definition: gls_ctl_text_box.h:128
bool ControlCellSize() const
Definition: gls_text.h:341
VerticalAlignmentCTL_t
Definition: gls_ctl_text_box.h:154
static const unsigned int INTERNAL_BORDER
Definition: gls_ctl_text_box.h:138
virtual void SetLayoutAutoDir(bool)
Definition: gls_ctl_text_box.h:329
TextDirection_t
Definition: gls_ctl_text_box.h:177
Definition: gls_ctl_text_box.h:196
virtual void CopyGeometry(DisplayObject *src) DISTI_METHOD_OVERRIDE
VerticalAlignment_t
Definition: gls_ctl_text_box.h:144
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) DISTI_METHOD_OVERRIDE
float _cellWidth
Definition: gls_text.h:664
The gls_auto_lib.
virtual void Rebuild()
float _textVerticalScale
Definition: gls_ctl_text_box.h:406
virtual EllipsizeMode_t EllipsizeMode()
virtual void SetAltHeight(float height)
A smart pointer with unique ownership – poor man's std::unique_ptr.
virtual void DrawText()
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
Macros and helper code to determine what subset of C++11/14/17 is available.
float _textHorizontalScale
Definition: gls_ctl_text_box.h:404
virtual TextDirection_t TextDirection()
virtual void SetVertices(unsigned int nPoints, Vertex *vertices) DISTI_METHOD_OVERRIDE
Definition: bmpimage.h:46
virtual void SetAltWidth(float width)
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
The gls_gl.