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/RPi 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 ) || defined( RPI_ARCH )
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  /** The structure returned to the caller when getting the glyph metrics.
186  * These are in logical units, relative to the bottom-left corner of the text box.
187  */
189  {
190  float minX;
191  float minY;
192  float maxX;
193  float maxY;
194 
195  GlyphMetrics()
196  : minX( 0.0f )
197  , minY( 0.0f )
198  , maxX( 0.0f )
199  , maxY( 0.0f )
200  {}
201  };
202 
203  /** Default constructor. */
204  GLSGEN_GLSCTLTEXTBOX_EXPORT GlsCTLTextBox();
205 
206  /** The copy constructor for GlsCTLTextBox
207  *
208  * \param that The GlsCTLTextBox object that is being copied
209  * \param generateNames Whether or not to generate a new instance name
210  */
211  GLSGEN_GLSCTLTEXTBOX_EXPORT GlsCTLTextBox( const GlsCTLTextBox& that, const bool generateNames );
212 
213  /** Destructor.
214  */
215  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT ~GlsCTLTextBox();
216 
217  // See DisplayObject
218  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAvailableAttributes( unsigned int value );
219 
220 #ifndef GLS_CTL_FALLBACK_ENABLED
221  // See DisplayObject
222  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT DisplayObject* CloneObject( bool generateNames = false );
223 
224  // See DisplayObject
225  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void CopyGeometry( DisplayObject* src );
226 
227  // See DisplayObject
228  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void CopyProperties( DisplayObject* src );
229 
230  // See DisplayObject
231  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
232 
233  // See DisplayObject
234  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Draw();
235 
236  // See DisplayObject
237  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetVertices( unsigned int nPoints, Vertex* vertices );
238 
239  // See DisplayObject
240  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar );
241 
242  /** Print a string into this text object.
243  * Replaces the entire string.
244  * \param format printf style varargs formatting string.
245  */
246  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VaString( const char* format, ... );
247 
248  /** Set the vertical alignment for this text object
249  * \param[in] verticalAlignment The vertical alignment type.
250  */
251  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignment_t verticalAlignment );
252  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignmentCTL_t verticalAlignment ) { VerticalAlignment( static_cast<VerticalAlignment_t>( verticalAlignment ) ); }
253 #else
254 
255  /** Set the vertical alignment for this text object
256  * \param[in] verticalAlignment The vertical alignment type.
257  */
258  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignment_t verticalAlignment ) { BaseClass::VerticalAlignment( verticalAlignment ); }
259  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignmentCTL_t verticalAlignment );
260 
261 #endif // GLS_CTL_FALLBACK_ENABLED
262 
263  /** Get the vertical alignment for this text object
264  * \return The vertical alignment type.
265  */
266  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT VerticalAlignment_t VerticalAlignment();
267 
268 #ifndef GLES
269 
270  // See DisplayObject
271  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
272 
273  // See DisplayObject
274  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
275 
276 #endif // GLES
277 
278  /** Rebuilds this text box layout. This may be an expensive call, so it should only be called when a property changes.
279  * \note In CTL Fallback mode, GlsText::SetRebuild will be called instead, as this is a protected method in GlsTextBox.
280  */
281  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Rebuild();
282 
283  // NO CTL-only functions should be disabled when using the GlsTextBox fallback.
284  // They should be available to every runtime, even if they do nothing.
285 
286  /** Gets the type of automatic ellipsize if the text does not fit in the boundary.
287  * \return The type of automatic ellipsize if the text does not fit in the boundary.
288  * \note In CTL Fallback mode, returns ELLIPSIZE_MODE_NONE.
289  */
290  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT EllipsizeMode_t EllipsizeMode();
291 
292  /** Sets the type of automatic ellipsize if the text does not fit in the boundary.
293  * \param[in] ellipsizeMode The type of automatic ellipsize if the text does not fit in the boundary.
294  * \note In CTL Fallback mode, has no effect.
295  */
296  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void EllipsizeMode( const EllipsizeMode_t ellipsizeMode );
297 
298  /** Gets the number of lines in the layout.
299  * \return The number of lines in the layout.
300  * \note In CTL Fallback mode, returns 0.
301  */
302  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT unsigned int GetLineCount();
303 
304  /** Gets the number of glyphs in the layout.
305  * \return The number of glyphs in the layout.
306  * \note In CTL Fallback mode, returns 0.
307  */
308  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT unsigned int GetGlyphCount();
309 
310  /** Gets the glyph metrics for the given glyph index.
311  * \param[in] glyphIndex The index of the glyph in the layout line to get the glyph metrics for.
312  * \return The glyph metrics for the given glyph index.
313  * \note In CTL Fallback mode, returns a default GlyphMetrics struct.
314  */
315  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT GlyphMetrics GetGlyphMetrics( const unsigned int glyphIndex );
316 
317  /** Set the Pango Layout auto dir, exposes pango_layout_set_auto_dir ()
318  * see: https://developer.gnome.org/pango/stable/pango-Layout-Objects.html#pango-layout-set-auto-dir
319  * \param[in] autoDir Whether or not the layout should automatically determine base direction based on content
320  * \note In CTL Fallback mode, has no effect.
321  * \deprecated
322  */
323  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetLayoutAutoDir( bool ){};
324 
325  /** 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
326  * value is 0.0, the text will be rendered to the full width of the vertices
327  * \note In CTL Fallback mode, has no effect.
328  */
329  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAltWidth( float width );
330 
331  /** 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
332  * value is 0.0, the text will be rendered to the full height of the vertices
333  * \note In CTL Fallback mode, has no effect.
334  */
335  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAltHeight( float height );
336 
337  /** Scales the text horizontally by the given value. Text is still clamped by the bounds of the text box
338  * \param value the horizontal scale
339  */
340  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextHorizontalScale( float value );
341 
342  /** Get the horizontal scale */
343  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float TextHorizontalScale();
344 
345  /** Scales the text vertically by the given value. Text is still clamped by the bounds of the text box
346  * \param value the vertical scale
347  */
348  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextVerticalScale( float value );
349 
350  /** Get the vertical scale */
351  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float TextVerticalScale();
352 
353  /** Gets the base direction used in applying the Unicode bidirectional algorithm.
354  * \return the text direction
355  * \note In CTL Fallback mode, returns TEXT_DIRECTION_AUTOMATIC.
356  */
357  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT TextDirection_t TextDirection();
358 
359  /** Sets the base direction used in applying the Unicode bidirectional algorithm.
360  * \param[in] textDirection The text direction.
361  * \note In CTL Fallback mode, has no effect.
362  */
363  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextDirection( const TextDirection_t textDirection );
364 
365  /** \see GlsText */
366  bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
367  {
368  return true;
369  }
370 
371 #ifdef GLES20
372  /** Re-enables automatic pixel alignment behavior that was always active by default prior to 7.0
373  * 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.
374  * \param enabled the new state for the alignment behavior flag
375  */
376  GLSGEN_GLSCTLTEXTBOX_EXPORT static void SetAutomaticPixelAlignmentEnabled( const bool enabled );
377 #endif
378 
379 protected:
380 #ifndef GLS_CTL_FALLBACK_ENABLED
381  /** Width used to render the text */
382  float _altWidth;
383  /** Height used to render the text */
384  float _altHeight;
385 
386  /** the horizontal scale */
388  /** the vertical scale */
390 
391  /** Pointer to the internal data needed for Pango. */
393 
394  /** makes adjustment to the image verts and texture coords for the alt width / height and text scaling properties
395  * \param[inout] verts the image verts
396  * \param[inout] texCoords the image texture coords
397  */
398  void AdjustImageVertsAndCoords( PangoRect& verts, PangoRect& texCoords );
399 
400 # ifdef GLES20
401  /** State of automatic pixel alignment behavior flag */
402  static bool s_isAutomaticPixelAlignmentEnabled;
403 # endif
404 
405  TextDirection_t _textDirection;
406 
407 #endif // GLS_CTL_FALLBACK_ENABLED
408 
409 #ifdef GLES
410 
411  // See DisplayObject
412  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
413 
414 # ifndef GLS_CTL_FALLBACK_ENABLED
415  /** The list of quads to draw for the shadows. */
417  /** The list of quads to draw for the characters. */
418  ScopedPtr<GlsQuadListVCT_2D> _characters;
419 
420  /** True if _geometryRefresh was true in PreDraw. This is just so we can rebuild the quads in Draw(). */
421  bool _geometryRefreshDraw;
422 
423  /** Populate the quad storage
424  * \param stateManager
425  */
426  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void PopulateQuadStorage( IGlsStateManager* stateManager );
427 
428  /** Draws the polygons that make up the characters.
429  * \param stateManager
430  */
431  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void DrawText( IGlsStateManager* stateManager );
432 # endif // GLS_CTL_FALLBACK_ENABLED
433 
434 #else
435  /** Draws the polygons that make up the characters.
436  */
437  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void DrawText();
438 #endif // GLES
439 #ifndef GLS_CTL_FALLBACK_ENABLED
440  /** Rebuilds the vertices of the text box.
441  */
442  virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void RecalcVertices();
443 #endif // GLS_CTL_FALLBACK_ENABLED
444 
445 private:
446  /* See base class */
447  void OnCellDimensionChanged()
448  {
449  // Prevent changing cell dimensions for CTL Textbox
450  _cellHeight = 0;
451  _cellWidth = 0;
452  ControlCellSize( false );
453  }
454 
455  GlsCTLTextBox& operator=( const GlsCTLTextBox& ) DISTI_SPECIAL_MEM_FUN_DELETE;
456  GlsCTLTextBox( const GlsCTLTextBox& ) DISTI_SPECIAL_MEM_FUN_DELETE;
457 };
458 
459 #ifndef GLS_CTL_FALLBACK_ENABLED
460 
461 /** In stream operator for VerticalAlignment_t enumeration.
462  */
463 inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::VerticalAlignment_t& verticalAlignment )
464 {
465  std::string str;
466  instr >> str;
467 
468  if( str == "ALIGN_TOP" || str == "VERTICAL_ALIGNMENT_TOP" )
469  {
470  verticalAlignment = disti::GlsCTLTextBox::ALIGN_TOP;
471  }
472  else if( str == "ALIGN_CENTER" || str == "VERTICAL_ALIGNMENT_CENTER" )
473  {
474  verticalAlignment = disti::GlsCTLTextBox::ALIGN_CENTER;
475  }
476  else if( str == "ALIGN_BOTTOM" || str == "VERTICAL_ALIGNMENT_BOTTOM" )
477  {
478  verticalAlignment = disti::GlsCTLTextBox::ALIGN_BOTTOM;
479  }
480  return instr;
481 }
482 
483 /** Out stream operator for VerticalAlignment_t enumeration.
484  */
485 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::VerticalAlignment_t verticalAlignment )
486 {
487  switch( verticalAlignment )
488  {
489  case disti::GlsCTLTextBox::ALIGN_TOP:
490  outstr << "ALIGN_TOP";
491  break;
492  case disti::GlsCTLTextBox::ALIGN_CENTER:
493  outstr << "ALIGN_CENTER";
494  break;
495  case disti::GlsCTLTextBox::ALIGN_BOTTOM:
496  outstr << "ALIGN_BOTTOM";
497  break;
498  }
499  return outstr;
500 }
501 #endif // GLS_CTL_FALLBACK_ENABLED
502 
503 /** In stream operator for EllipsizeMode_t enumeration.
504  */
505 inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::EllipsizeMode_t& ellipsizeMode )
506 {
507  std::string str;
508  instr >> str;
509 
510  if( str == "ELLIPSIZE_MODE_NONE" )
511  {
512  ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE;
513  }
514  else if( str == "ELLIPSIZE_MODE_START" )
515  {
516  ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_START;
517  }
518  else if( str == "ELLIPSIZE_MODE_MIDDLE" )
519  {
520  ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE;
521  }
522  else if( str == "ELLIPSIZE_MODE_END" )
523  {
524  ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_END;
525  }
526  return instr;
527 }
528 
529 /** Out stream operator for EllipsizeMode_t enumeration.
530  */
531 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::EllipsizeMode_t ellipsizeMode )
532 {
533  switch( ellipsizeMode )
534  {
535  case disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE:
536  outstr << "ELLIPSIZE_MODE_NONE";
537  break;
538  case disti::GlsCTLTextBox::ELLIPSIZE_MODE_START:
539  outstr << "ELLIPSIZE_MODE_START";
540  break;
541  case disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE:
542  outstr << "ELLIPSIZE_MODE_MIDDLE";
543  break;
544  case disti::GlsCTLTextBox::ELLIPSIZE_MODE_END:
545  outstr << "ELLIPSIZE_MODE_END";
546  break;
547  }
548  return outstr;
549 }
550 
551 /** In stream operator for TextDirection_t enumeration.
552  */
553 inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::TextDirection_t& direction )
554 {
555  std::string str;
556  instr >> str;
557 
558  if( str == "TEXT_DIRECTION_LTR" )
559  {
560  direction = disti::GlsCTLTextBox::TEXT_DIRECTION_LTR;
561  }
562  else if( str == "TEXT_DIRECTION_RTL" )
563  {
564  direction = disti::GlsCTLTextBox::TEXT_DIRECTION_RTL;
565  }
566  else if( str == "TEXT_DIRECTION_AUTOMATIC" )
567  {
568  direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC;
569  }
570  else if( str == "TEXT_DIRECTION_AUTO_BY_LINE" )
571  {
572  direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE;
573  }
574  return instr;
575 }
576 
577 /** Out stream operator for TextDirection_t enumeration.
578  */
579 inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::TextDirection_t direction )
580 {
581  switch( direction )
582  {
583  case disti::GlsCTLTextBox::TEXT_DIRECTION_LTR:
584  outstr << "TEXT_DIRECTION_LTR";
585  break;
586  case disti::GlsCTLTextBox::TEXT_DIRECTION_RTL:
587  outstr << "TEXT_DIRECTION_RTL";
588  break;
589  case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC:
590  outstr << "TEXT_DIRECTION_AUTOMATIC";
591  break;
592  case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE:
593  outstr << "TEXT_DIRECTION_AUTO_BY_LINE";
594  break;
595  }
596  return outstr;
597 }
598 
599 } // namespace disti
600 
601 #endif // INCLUDED_GLS_CTL_TEXT_BOX_H
The DistiUnhideGlobalsDummyClass class.
Definition: cull.h:49
virtual VerticalAlignment_t VerticalAlignment()
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:392
virtual float TextHorizontalScale()
void AdjustImageVertsAndCoords(PangoRect &verts, PangoRect &texCoords)
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:296
virtual void CopyGeometry(DisplayObject *src)
virtual void SetVertices(unsigned int nPoints, Vertex *vertices)
float _altWidth
Definition: gls_ctl_text_box.h:382
bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
Definition: gls_ctl_text_box.h:366
virtual DisplayObject * CloneObject(bool generateNames=false)
EllipsizeMode_t
Definition: gls_ctl_text_box.h:162
virtual void SetAvailableAttributes(unsigned int value)
virtual void VaString(const char *format,...)
Definition: display.h:98
virtual GlyphMetrics GetGlyphMetrics(const unsigned int glyphIndex)
float _cellHeight
Definition: gls_text.h:787
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:384
Definition: gls_glo_file.h:982
virtual unsigned int GetGlyphCount()
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
Defines the stream out operator.
virtual ~GlsCTLTextBox()
virtual void CopyProperties(DisplayObject *src)
virtual float TextVerticalScale()
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar)
virtual void Draw()
The Gls CTL (Complex Text Layout) Text Box.
Definition: gls_ctl_text_box.h:128
bool ControlCellSize() const
Definition: gls_text.h:465
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:323
TextDirection_t
Definition: gls_ctl_text_box.h:177
Definition: gls_ctl_text_box.h:188
VerticalAlignment_t
Definition: gls_ctl_text_box.h:144
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
float _cellWidth
Definition: gls_text.h:790
The gls_auto_lib.
virtual void Rebuild()
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
float _textVerticalScale
Definition: gls_ctl_text_box.h:389
virtual EllipsizeMode_t EllipsizeMode()
virtual void SetAltHeight(float height)
A smart pointer with unique ownership – poor man's std::unique_ptr.
virtual void DrawText()
Macros and helper code to determine what subset of C++11/14/17 is available.
float _textHorizontalScale
Definition: gls_ctl_text_box.h:387
virtual TextDirection_t TextDirection()
Definition: bmpimage.h:46
virtual void SetAltWidth(float width)
The gls_gl.