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