GL Studio C++ Runtime API
gls_ctl_text_box.h
Go to the documentation of this file.
1/// \file gls_ctl_text_box.h
2/// \brief The disti::GlsCTLTextBox class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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#ifndef INCLUDED_GLS_CTL_TEXT_BOX_H
40#define INCLUDED_GLS_CTL_TEXT_BOX_H
41
42// CTL Text box does not work for WebGL due to issues with the Pango library and its dependencies
43// CTL Text boxes will fall back to stock GlsTextBoxes, and any CTL functions will do nothing.
44// GLS-5903: Remove Pango from CTL Text Box
45#if defined( EMSCRIPTEN )
46# define GLS_CTL_FALLBACK_ENABLED
47# ifndef GLES
48# error "GLES should always be enabled when using the CTL fallback code"
49# endif
50#endif
51
52/// Provides support for creating DLLs.
53#if( defined( GLSGEN_EXPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_IMPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_GLSCTLTEXTBOX_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
54 && defined( _MSC_VER )
55# if defined( GLSGEN_EXPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_GLSCTLTEXTBOX_EXPORT_GENERATED )
56# define GLSGEN_GLSCTLTEXTBOX_EXPORT __declspec( dllexport )
57# else
58# define GLSGEN_GLSCTLTEXTBOX_EXPORT __declspec( dllimport )
59# endif
60#else
61# define GLSGEN_GLSCTLTEXTBOX_EXPORT
62#endif
63///////////////////////////////////////////////////////////////////////////////
64
66#include "gls_gl.h"
67#include "scoped_ptr.h"
68#include "unhide_globals.h"
69#include <string>
70
71#ifndef GLS_CTL_FALLBACK_ENABLED
72# include "gls_text.h"
73/// Base class to use for GlsCTLTextBox, used to support platforms that don't support CTL.
74# define CTL_BASE_CLASS GlsText
75#else
76# include "gls_text_box.h"
77# define CTL_BASE_CLASS GlsTextBox
78#endif
79
80/// Automatically link the runtime library plugin (on Windows).
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
104namespace disti
105{
106// Forward Declarations
107#ifndef GLS_CTL_FALLBACK_ENABLED
108class GlsPangoWrapper;
109struct PangoRect;
110#else
111class GlsTextBoxFontRenderer;
112#endif // GLS_CTL_FALLBACK_ENABLED
113
114#ifdef GLES
115class GlsGloFileAttribute;
116class GlsStateManager;
117class 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 */
129{
130public:
131 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
132 typedef CTL_BASE_CLASS _BaseClass; ///< Deprecated typedef for the base class.
133 typedef CTL_BASE_CLASS BaseClass; ///< Typedef for the base class.
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 /// The resize behavior types.
188 RESIZE_MODE_FIXED,
189 RESIZE_MODE_AUTO_WIDTH,
190 RESIZE_MODE_AUTO_HEIGHT
191 };
192#endif
193
194 /** The structure returned to the caller when getting the glyph metrics.
195 * These are in logical units, relative to the bottom-left corner of the text box.
196 */
198 {
199 float minX; ///< Minimum X in logical units.
200 float minY; ///< Minimum Y in logical units.
201 float maxX; ///< Maximum X in logical units.
202 float maxY; ///< Maximum Y in logical units.
203
205 : minX( 0.0f )
206 , minY( 0.0f )
207 , maxX( 0.0f )
208 , maxY( 0.0f )
209 {}
210 };
211
212 /** Default constructor. */
214
215 /** The copy constructor for GlsCTLTextBox
216 *
217 * \param that The GlsCTLTextBox object that is being copied
218 * \param generateNames Whether or not to generate a new instance name
219 */
220 GLSGEN_GLSCTLTEXTBOX_EXPORT GlsCTLTextBox( const GlsCTLTextBox& that, const bool generateNames );
221
222 /** Destructor.
223 */
225
226 // See DisplayObject
228
229#ifndef GLS_CTL_FALLBACK_ENABLED
230 // See DisplayObject
232
233 // See DisplayObject
235
236 // See DisplayObject
238
239 // See DisplayObject
241
242 // See DisplayObject
244
245 // See DisplayObject
247
248 // See DisplayObject
249 GLSGEN_GLSCTLTEXTBOX_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
250
251 /** Print a string into this text object.
252 * Replaces the entire string.
253 * \param format printf style varargs formatting string.
254 */
255 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VaString( const char* format, ... );
256
257 /// Set the vertical alignment for this text object.
258 /// \param verticalAlignment The vertical alignment type.
260
261 /// Set the vertical alignment for this text object.
262 /// \param verticalAlignment The vertical alignment type.
263 virtual void VerticalAlignment( VerticalAlignmentCTL_t verticalAlignment ) { VerticalAlignment( static_cast<VerticalAlignment_t>( verticalAlignment ) ); }
264
265 /** Get the vertical alignment for this text object
266 * \return The vertical alignment type.
267 */
269
270#else
271
272 /** Set the vertical alignment for this text object
273 * \param[in] verticalAlignment The vertical alignment type.
274 */
275 virtual void VerticalAlignment( VerticalAlignment_t verticalAlignment ) { BaseClass::VerticalAlignment( verticalAlignment ); }
277
278 /** Get the vertical alignment for this text object
279 * \return The vertical alignment type.
280 */
282
283#endif // GLS_CTL_FALLBACK_ENABLED
284
285#ifndef GLES
286
287 // See DisplayObject
289
290 // See DisplayObject
292
293#endif // GLES
294
295 /** Rebuilds this text box layout. This may be an expensive call, so it should only be called when a property changes. */
297
298 // NO CTL-only functions should be disabled when using the GlsTextBox fallback.
299 // They should be available to every runtime, even if they do nothing.
300
301 /** Gets the type of automatic ellipsize if the text does not fit in the boundary.
302 * \return The type of automatic ellipsize if the text does not fit in the boundary.
303 * \note In CTL Fallback mode, returns ELLIPSIZE_MODE_NONE.
304 */
306
307 /** Sets the type of automatic ellipsize if the text does not fit in the boundary.
308 * \param[in] ellipsizeMode The type of automatic ellipsize if the text does not fit in the boundary.
309 * \note In CTL Fallback mode, has no effect.
310 */
311 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void EllipsizeMode( const EllipsizeMode_t ellipsizeMode );
312
313 /** Gets the number of lines in the layout.
314 * \return The number of lines in the layout.
315 * \note In CTL Fallback mode, returns 0.
316 */
318
319 /** Gets the number of glyphs in the layout.
320 * \return The number of glyphs in the layout.
321 * \note In CTL Fallback mode, returns 0.
322 */
324
325 /** Gets the glyph metrics for the given glyph index.
326 * \param[in] glyphIndex The index of the glyph in the layout line to get the glyph metrics for.
327 * \return The glyph metrics for the given glyph index.
328 * \note In CTL Fallback mode, returns a default GlyphMetrics struct.
329 */
330 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT GlyphMetrics GetGlyphMetrics( const unsigned int glyphIndex );
331
332 /// Set the Pango Layout auto dir, exposes pango_layout_set_auto_dir ()
333 /// see: https://developer.gnome.org/pango/stable/pango-Layout-Objects.html#pango-layout-set-auto-dir
334 /// \param[in] autoDir Whether or not the layout should automatically determine base direction based on content
335 /// \note In CTL Fallback mode, has no effect.
336 /// \deprecated
337 virtual void SetLayoutAutoDir( bool autoDir ){};
338
339 /// 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
340 /// value is 0.0, the text will be rendered to the full width of the vertices
341 /// \note In CTL Fallback mode, has no effect.
342 /// \param width The new width to set.
343 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAltWidth( float width );
344
345 /// 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
346 /// value is 0.0, the text will be rendered to the full height of the vertices
347 /// \note In CTL Fallback mode, has no effect.
348 /// \param height The new height to set.
349 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAltHeight( float height );
350
351 /** Scales the text horizontally by the given value. Text is still clamped by the bounds of the text box
352 * \param value the horizontal scale
353 */
355
356 /// \return The current horizontal scale.
358
359 /** Scales the text vertically by the given value. Text is still clamped by the bounds of the text box
360 * \param value the vertical scale
361 */
363
364 /// \return The current vertical scale.
366
367 /** Gets the base direction used in applying the Unicode bidirectional algorithm.
368 * \return the text direction
369 * \note In CTL Fallback mode, returns TEXT_DIRECTION_AUTOMATIC.
370 */
372
373 /** Sets the base direction used in applying the Unicode bidirectional algorithm.
374 * \param[in] textDirection The text direction.
375 * \note In CTL Fallback mode, has no effect.
376 */
377 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextDirection( const TextDirection_t textDirection );
378
380 {
381 return true;
382 }
383
384#ifndef GLS_CTL_FALLBACK_ENABLED
385 /// Set the resize behavior for this object.
386 /// \param value The new resize behavior.
388
389 /// \return The current resize behavior for this object.
391
392 /// Set the maximum resize width for this object in logical units.
393 /// \param value The new maximum width.
394 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void MaxWidth( float value );
395
396 /// \return The current maximum resize width for this object in logical units.
398
399 /// Set the maximum resize height for this object in logical units.
400 /// \param value The new maximum height.
401 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void MaxHeight( float value );
402
403 /// \return The current maximum resize height for this object in logical units.
405#endif
406
407#ifdef GLES20
408 /** Re-enables automatic pixel alignment behavior that was always active by default prior to 7.0
409 * 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.
410 * \param enabled the new state for the alignment behavior flag
411 */
412 GLSGEN_GLSCTLTEXTBOX_EXPORT static void SetAutomaticPixelAlignmentEnabled( const bool enabled );
413#endif
414
415protected:
416#ifndef GLS_CTL_FALLBACK_ENABLED
417 /** Width used to render the text */
419 /** Height used to render the text */
421
422 /** the horizontal scale */
424 /** the vertical scale */
426
427 /** Pointer to the internal data needed for Pango. */
429
430 /** makes adjustment to the image verts and texture coords for the alt width / height and text scaling properties
431 * \param[inout] verts the image verts
432 * \param[inout] texCoords the image texture coords
433 */
434 void AdjustImageVertsAndCoords( PangoRect& verts, PangoRect& texCoords );
435
436 /// Used internally to apply scale when rendering text.
437 /// \note Not normally called by users.
438 /// \param textBoxWidth The width of the box in logical units.
439 /// \param textBoxHeight The height of the box in logical units.
440 /// \param verts The returned bounding rectangle.
441 void ApplyTextScale( float textBoxWidth, float textBoxHeight, PangoRect& verts );
442
443 /// Used internally to clamp when rendering text.
444 /// \note Not normally called by users.
445 /// \param textBoxWidth The width of the box in logical units.
446 /// \param textBoxHeight The height of the box in logical units.
447 /// \param verts The returned bounding rectangle.
448 /// \param texCoords The returned texture coordinate rectangle.
449 void ClampToTextBoxSize( float textBoxWidth, float textBoxHeight, PangoRect& verts, PangoRect& texCoords );
450
451 /// Used internally to apply vertical alignment when rendering text.
452 /// \note Not normally called by users.
453 /// \param textBoxHeight The height of the box in logical units.
454 /// \param verts The returned bounding rectangle.
455 void ApplyVerticalAlignment( float textBoxHeight, PangoRect& verts );
456
457# ifdef GLES20
458 /** State of automatic pixel alignment behavior flag */
459 static bool s_isAutomaticPixelAlignmentEnabled;
460# endif
461
462 TextDirection_t _textDirection; ///< Text direction behavior for this object.
463
464# ifndef GLS_CTL_FALLBACK_ENABLED
465 ResizeMode_t _resizeMode; ///< Resize behavior for this object.
466 float _resizeMaxWidth; ///< Maximum resize width in logical units.
467 float _resizeMaxHeight; ///< Maximum resize height in logical units.
468# endif
469
470#endif // GLS_CTL_FALLBACK_ENABLED
471
472#ifdef GLES
473
474 // See DisplayObject
476
477# ifndef GLS_CTL_FALLBACK_ENABLED
478 /** The list of quads to draw for the shadows. */
480 /** The list of quads to draw for the characters. */
482
483 /** True if _geometryRefresh was true in PreDraw. This is just so we can rebuild the quads in Draw(). */
484 bool _geometryRefreshDraw;
485
486 /** Populate the quad storage
487 * \param stateManager
488 */
489 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void PopulateQuadStorage( IGlsStateManager* stateManager );
490
491 /** Draws the polygons that make up the characters.
492 * \param stateManager
493 */
494 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void DrawText( IGlsStateManager* stateManager );
495# endif // GLS_CTL_FALLBACK_ENABLED
496
497#else
498 /** Draws the polygons that make up the characters.
499 */
501#endif // GLES
502#ifndef GLS_CTL_FALLBACK_ENABLED
503 /** Rebuilds the vertices of the text box.
504 */
506
507 /// Set the size of the CTL text box to the incoming Pango rectangle's size.
508 /// \param verts The new size to set to.
509 /// \param keepWidth Whether or not to ignore changes to the object's width.
510 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetVerticesToImageSize( const PangoRect& verts, bool keepWidth );
511#endif // GLS_CTL_FALLBACK_ENABLED
512
513private:
514 void OnCellDimensionChanged() DISTI_METHOD_OVERRIDE
515 {
516 // Prevent changing cell dimensions for CTL Textbox
517 _cellHeight = 0;
518 _cellWidth = 0;
519 ControlCellSize( false );
520 }
521
524};
525
526#ifndef GLS_CTL_FALLBACK_ENABLED
527
528/// In stream operator for VerticalAlignment_t enumeration.
529/// \param instr The stream to read from.
530/// \param verticalAlignment The returned alignment to be read from stream.
531/// \return The stream in its current state.
532inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::VerticalAlignment_t& verticalAlignment )
533{
534 std::string str;
535 instr >> str;
536
537 if( str == "ALIGN_TOP" || str == "VERTICAL_ALIGNMENT_TOP" )
538 {
539 verticalAlignment = disti::GlsCTLTextBox::ALIGN_TOP;
540 }
541 else if( str == "ALIGN_CENTER" || str == "VERTICAL_ALIGNMENT_CENTER" )
542 {
543 verticalAlignment = disti::GlsCTLTextBox::ALIGN_CENTER;
544 }
545 else if( str == "ALIGN_BOTTOM" || str == "VERTICAL_ALIGNMENT_BOTTOM" )
546 {
547 verticalAlignment = disti::GlsCTLTextBox::ALIGN_BOTTOM;
548 }
549 return instr;
550}
551
552/// Out stream operator for VerticalAlignment_t enumeration.
553/// \param outstr The stream to write to.
554/// \param verticalAlignment The alignment to write to the stream.
555/// \return The stream in its current state.
556inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::VerticalAlignment_t verticalAlignment )
557{
558 switch( verticalAlignment )
559 {
560 case disti::GlsCTLTextBox::ALIGN_TOP:
561 outstr << "ALIGN_TOP";
562 break;
563 case disti::GlsCTLTextBox::ALIGN_CENTER:
564 outstr << "ALIGN_CENTER";
565 break;
566 case disti::GlsCTLTextBox::ALIGN_BOTTOM:
567 outstr << "ALIGN_BOTTOM";
568 break;
569 }
570 return outstr;
571}
572#endif // GLS_CTL_FALLBACK_ENABLED
573
574/// In stream operator for EllipsizeMode_t enumeration.
575/// \param instr The stream to read from.
576/// \param ellipsizeMode The returned mode to be read from stream.
577/// \return The stream in its current state.
578inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::EllipsizeMode_t& ellipsizeMode )
579{
580 std::string str;
581 instr >> str;
582
583 if( str == "ELLIPSIZE_MODE_NONE" )
584 {
585 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE;
586 }
587 else if( str == "ELLIPSIZE_MODE_START" )
588 {
589 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_START;
590 }
591 else if( str == "ELLIPSIZE_MODE_MIDDLE" )
592 {
593 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE;
594 }
595 else if( str == "ELLIPSIZE_MODE_END" )
596 {
597 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_END;
598 }
599 return instr;
600}
601
602/// Out stream operator for EllipsizeMode_t enumeration.
603/// \param outstr The stream to write to.
604/// \param ellipsizeMode The mode to write to the stream.
605/// \return The stream in its current state.
606inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::EllipsizeMode_t ellipsizeMode )
607{
608 switch( ellipsizeMode )
609 {
610 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE:
611 outstr << "ELLIPSIZE_MODE_NONE";
612 break;
613 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_START:
614 outstr << "ELLIPSIZE_MODE_START";
615 break;
616 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE:
617 outstr << "ELLIPSIZE_MODE_MIDDLE";
618 break;
619 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_END:
620 outstr << "ELLIPSIZE_MODE_END";
621 break;
622 }
623 return outstr;
624}
625
626/// In stream operator for TextDirection_t enumeration.
627/// \param instr The stream to read from.
628/// \param direction The returned direction to be read from stream.
629/// \return The stream in its current state.
630inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::TextDirection_t& direction )
631{
632 std::string str;
633 instr >> str;
634
635 if( str == "TEXT_DIRECTION_LTR" )
636 {
637 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_LTR;
638 }
639 else if( str == "TEXT_DIRECTION_RTL" )
640 {
641 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_RTL;
642 }
643 else if( str == "TEXT_DIRECTION_AUTOMATIC" )
644 {
645 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC;
646 }
647 else if( str == "TEXT_DIRECTION_AUTO_BY_LINE" )
648 {
649 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE;
650 }
651 return instr;
652}
653
654/// Out stream operator for TextDirection_t enumeration.
655/// \param outstr The stream to write to.
656/// \param direction The direction to write to the stream.
657/// \return The stream in its current state.
658inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::TextDirection_t direction )
659{
660 switch( direction )
661 {
662 case disti::GlsCTLTextBox::TEXT_DIRECTION_LTR:
663 outstr << "TEXT_DIRECTION_LTR";
664 break;
665 case disti::GlsCTLTextBox::TEXT_DIRECTION_RTL:
666 outstr << "TEXT_DIRECTION_RTL";
667 break;
668 case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC:
669 outstr << "TEXT_DIRECTION_AUTOMATIC";
670 break;
671 case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE:
672 outstr << "TEXT_DIRECTION_AUTO_BY_LINE";
673 break;
674 }
675 return outstr;
676}
677
678#ifndef GLS_CTL_FALLBACK_ENABLED
679/// In stream operator for ResizeMode_t enumeration.
680/// \param instr The stream to read from.
681/// \param resizeMode The returned mode to be read from stream.
682/// \return The stream in its current state.
683inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::ResizeMode_t& resizeMode )
684{
685 std::string str;
686 instr >> str;
687
688 if( str == "RESIZE_MODE_FIXED" )
689 {
690 resizeMode = disti::GlsCTLTextBox::RESIZE_MODE_FIXED;
691 }
692 else if( str == "RESIZE_MODE_AUTO_WIDTH" )
693 {
694 resizeMode = disti::GlsCTLTextBox::RESIZE_MODE_AUTO_WIDTH;
695 }
696 else if( str == "RESIZE_MODE_AUTO_HEIGHT" )
697 {
698 resizeMode = disti::GlsCTLTextBox::RESIZE_MODE_AUTO_HEIGHT;
699 }
700 return instr;
701}
702
703/// Out stream operator for ResizeMode_t enumeration.
704/// \param outstr The stream to write to.
705/// \param resizeMode The mode to write to the stream.
706/// \return The stream in its current state.
707inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::ResizeMode_t resizeMode )
708{
709 switch( resizeMode )
710 {
711 case disti::GlsCTLTextBox::RESIZE_MODE_FIXED:
712 outstr << "RESIZE_MODE_FIXED";
713 break;
714 case disti::GlsCTLTextBox::RESIZE_MODE_AUTO_WIDTH:
715 outstr << "RESIZE_MODE_AUTO_WIDTH";
716 break;
717 case disti::GlsCTLTextBox::RESIZE_MODE_AUTO_HEIGHT:
718 outstr << "RESIZE_MODE_AUTO_HEIGHT";
719 break;
720 }
721 return outstr;
722}
723#endif
724
725} // namespace disti
726
727#endif // INCLUDED_GLS_CTL_TEXT_BOX_H
Definition: cull.h:49
Definition: display.h:95
Definition: dynamic_array.h:79
The Gls CTL (Complex Text Layout) Text Box.
Definition: gls_ctl_text_box.h:129
void CopyGeometry(DisplayObject *src) DISTI_METHOD_OVERRIDE
virtual void DrawText()
virtual void TextHorizontalScale(float value)
float _altHeight
Definition: gls_ctl_text_box.h:420
static const unsigned int INTERNAL_BORDER
Definition: gls_ctl_text_box.h:138
void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
virtual void VaString(const char *format,...)
float _resizeMaxWidth
Maximum resize width in logical units.
Definition: gls_ctl_text_box.h:466
void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
TextDirection_t
Definition: gls_ctl_text_box.h:178
VerticalAlignment_t
Definition: gls_ctl_text_box.h:144
virtual ResizeMode_t ResizeMode()
virtual unsigned int GetGlyphCount()
virtual void MaxWidth(float value)
float _textHorizontalScale
Definition: gls_ctl_text_box.h:423
virtual EllipsizeMode_t EllipsizeMode()
virtual void VerticalAlignment(VerticalAlignmentCTL_t verticalAlignment)
Definition: gls_ctl_text_box.h:263
virtual TextDirection_t TextDirection()
void SetVertices(unsigned int nPoints, Vertex *vertices) DISTI_METHOD_OVERRIDE
ResizeMode_t _resizeMode
Resize behavior for this object.
Definition: gls_ctl_text_box.h:465
float _textVerticalScale
Definition: gls_ctl_text_box.h:425
void Draw() DISTI_METHOD_OVERRIDE
void ApplyTextScale(float textBoxWidth, float textBoxHeight, PangoRect &verts)
bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
Definition: gls_ctl_text_box.h:379
void ClampToTextBoxSize(float textBoxWidth, float textBoxHeight, PangoRect &verts, PangoRect &texCoords)
void PreDraw(const OpenGLMatrices &current, Culler &culler) DISTI_METHOD_OVERRIDE
virtual ~GlsCTLTextBox()
virtual void ResizeMode(ResizeMode_t value)
virtual float MaxHeight()
GlsCTLTextBox(const GlsCTLTextBox &that, const bool generateNames)
virtual void TextVerticalScale(float value)
TextDirection_t _textDirection
Text direction behavior for this object.
Definition: gls_ctl_text_box.h:462
virtual float MaxWidth()
void ApplyVerticalAlignment(float textBoxHeight, PangoRect &verts)
virtual void Rebuild()
virtual VerticalAlignment_t VerticalAlignment() const
virtual void MaxHeight(float value)
virtual float TextVerticalScale()
void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
VerticalAlignmentCTL_t
Definition: gls_ctl_text_box.h:155
virtual GlyphMetrics GetGlyphMetrics(const unsigned int glyphIndex)
virtual void SetAltWidth(float width)
ScopedPtr< GlsPangoWrapper > _glsPangoWrapper
Definition: gls_ctl_text_box.h:428
virtual void RecalcVertices()
virtual void SetAltHeight(float height)
virtual float TextHorizontalScale()
virtual void SetVerticesToImageSize(const PangoRect &verts, bool keepWidth)
virtual unsigned int GetLineCount()
float _altWidth
Definition: gls_ctl_text_box.h:418
EllipsizeMode_t
Definition: gls_ctl_text_box.h:163
DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
void AdjustImageVertsAndCoords(PangoRect &verts, PangoRect &texCoords)
virtual void TextDirection(const TextDirection_t textDirection)
ResizeMode_t
The resize behavior types.
Definition: gls_ctl_text_box.h:187
virtual void EllipsizeMode(const EllipsizeMode_t ellipsizeMode)
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
float _resizeMaxHeight
Maximum resize height in logical units.
Definition: gls_ctl_text_box.h:467
virtual void SetLayoutAutoDir(bool autoDir)
Definition: gls_ctl_text_box.h:337
Definition: gls_glo_file.h:1241
float _cellWidth
Definition: gls_text.h:667
float _cellHeight
Definition: gls_text.h:664
virtual bool ControlCellSize() const
Definition: gls_text.h:342
Definition: gls_state_manager_interface.h:65
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: vertex.h:419
The gls_auto_lib.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:245
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
#define GLSGEN_GLSCTLTEXTBOX_EXPORT
Provides support for creating DLLs.
Definition: gls_ctl_text_box.h:61
#define CTL_BASE_CLASS
Base class to use for GlsCTLTextBox, used to support platforms that don't support CTL.
Definition: gls_ctl_text_box.h:74
The gls_gl.
The disti::GlsText class.
The disti::GlsTextBox class.
Definition: bmpimage.h:46
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
std::istream & operator>>(std::istream &instr, GlsColor &color)
A smart pointer with unique ownership – poor man's std::unique_ptr.
Definition: gls_ctl_text_box.h:198
float minX
Minimum X in logical units.
Definition: gls_ctl_text_box.h:199
float maxX
Maximum X in logical units.
Definition: gls_ctl_text_box.h:201
float maxY
Maximum Y in logical units.
Definition: gls_ctl_text_box.h:202
float minY
Minimum Y in logical units.
Definition: gls_ctl_text_box.h:200
The DistiUnhideGlobalsDummyClass class.