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