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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State of Florida and the United States of America.
38
39*/
40
41#ifndef INCLUDED_GLS_CTL_TEXT_BOX_H
42#define INCLUDED_GLS_CTL_TEXT_BOX_H
43
44// CTL Text box does not work for WebGL due to issues with the Pango library and its dependencies
45// CTL Text boxes will fall back to stock GlsTextBoxes, and any CTL functions will do nothing.
46// GLS-5903: Remove Pango from CTL Text Box
47#if defined( EMSCRIPTEN )
48# define GLS_CTL_FALLBACK_ENABLED
49# ifndef GLES
50# error "GLES should always be enabled when using the CTL fallback code"
51# endif
52#endif
53
54/// Provides support for creating DLLs.
55#if( defined( GLSGEN_EXPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_IMPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_GLSCTLTEXTBOX_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
56 && defined( _MSC_VER )
57# if defined( GLSGEN_EXPORT_GLSCTLTEXTBOX ) || defined( GLSGEN_GLSCTLTEXTBOX_EXPORT_GENERATED )
58# define GLSGEN_GLSCTLTEXTBOX_EXPORT __declspec( dllexport )
59# else
60# define GLSGEN_GLSCTLTEXTBOX_EXPORT __declspec( dllimport )
61# endif
62#else
63# define GLSGEN_GLSCTLTEXTBOX_EXPORT
64#endif
65///////////////////////////////////////////////////////////////////////////////
66
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/// Base class to use for GlsCTLTextBox, used to support platforms that don't support CTL.
76# define CTL_BASE_CLASS GlsText
77#else
78# include "gls_text_box.h"
79# define CTL_BASE_CLASS GlsTextBox
80#endif
81
82/// Automatically link the runtime library plugin (on Windows).
83#define LIB_BASE_NAME "gls_ctl_text_box"
84#include "gls_auto_lib.h"
85#undef LIB_BASE_NAME
86
87// Force inclusion of the pango libraries
88#ifdef WIN32
89# if !defined( NO_GLS_AUTOLIB ) && !defined( GLS_IMPORT_LIBRARY )
90# ifdef _WIN64
91# define PANGO_SUFFIX "_64"
92# else
93# define PANGO_SUFFIX ""
94# endif
95# pragma message( "Will automatically link with libfontconfig" PANGO_SUFFIX "-1.0.lib" )
96# pragma message( "Will automatically link with libpango" PANGO_SUFFIX "-1.0.lib" )
97# pragma message( "Will automatically link with libpangoft2" PANGO_SUFFIX "-1.0.lib" )
98# pragma message( "Will automatically link with libgobject" PANGO_SUFFIX "-2.0.lib" )
99# pragma comment( lib, "libfontconfig" PANGO_SUFFIX "-1.0.lib" )
100# pragma comment( lib, "libpango" PANGO_SUFFIX "-1.0.lib" )
101# pragma comment( lib, "libpangoft2" PANGO_SUFFIX "-1.0.lib" )
102# pragma comment( lib, "libgobject" PANGO_SUFFIX "-2.0.lib" )
103# endif
104#endif
105
106namespace disti
107{
108// Forward Declarations
109#ifndef GLS_CTL_FALLBACK_ENABLED
110class GlsPangoWrapper;
111struct PangoRect;
112#else
113class GlsTextBoxFontRenderer;
114#endif // GLS_CTL_FALLBACK_ENABLED
115
116#ifdef GLES
117class GlsGloFileAttribute;
118class GlsStateManager;
119class GlsQuadListVCT_2D;
120#endif // GLES
121
122//===========================================================================
123/** \brief The Gls CTL (Complex Text Layout) Text Box.
124 *
125 * On certain platforms, the text layout library is unavailable, and complex text rendering in the runtime will be missing.
126 *
127 * To account for this, the GlsCTLTextBox will 'Fallback' to being treated as a GlsTextBox. In those cases, certain
128 * GlsCTLTextBox functions will not have no effect.
129 */
131{
132public:
133 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
134 typedef CTL_BASE_CLASS _BaseClass; ///< Deprecated typedef for the base class.
135 typedef CTL_BASE_CLASS BaseClass; ///< Typedef for the base class.
136
137 /** The internal border between the layout edges and the glyph edges.
138 * This will keep the glyph edges from appearing cut-off when linear texture filtering is applied.
139 */
140 static const unsigned int INTERNAL_BORDER = 1;
141
142 friend class GlsCTLTextBoxEditor;
143
144#ifndef GLS_CTL_FALLBACK_ENABLED
145 /** The vertical alignment types. */
147 ALIGN_CENTER,
148 ALIGN_TOP,
149 ALIGN_BOTTOM
150 };
151#else
152 typedef Align_t VerticalAlignment_t;
153#endif // GLS_CTL_FALLBACK_ENABLED
154
155 /** Deprecated */
157 {
158 VERTICAL_ALIGNMENT_CENTER = ALIGN_CENTER,
159 VERTICAL_ALIGNMENT_TOP = ALIGN_TOP,
160 VERTICAL_ALIGNMENT_BOTTOM = ALIGN_BOTTOM
161 };
162
163 /** The ellipsize mode types. */
165 {
166 ELLIPSIZE_MODE_NONE,
167 ELLIPSIZE_MODE_START,
168 ELLIPSIZE_MODE_MIDDLE,
169 ELLIPSIZE_MODE_END
170 };
171
172 /**
173 * The text direction types.
174 * TEXT_DIRECTION_LTR - Use Left to Right as the base direction for rendering text.
175 * TEXT_DIRECTION_RTL - Use Right to Left as the base direction for rendering text.
176 * TEXT_DIRECTION_AUTOMATIC - Determine the base direction for rendering text from the first strongly directioned character.
177 * TEXT_DIRECTION_AUTO_BY_LINE - Determine the base direction for rendering text for each individual EOL-seperated line in the text string.
178 */
180 {
181 TEXT_DIRECTION_LTR,
182 TEXT_DIRECTION_RTL,
183 TEXT_DIRECTION_AUTOMATIC,
184 TEXT_DIRECTION_AUTO_BY_LINE
185 };
186
187#ifndef GLS_CTL_FALLBACK_ENABLED
188 /// The resize behavior types.
190 RESIZE_MODE_FIXED,
191 RESIZE_MODE_AUTO_WIDTH,
192 RESIZE_MODE_AUTO_HEIGHT
193 };
194#endif
195
196 /** The structure returned to the caller when getting the glyph metrics.
197 * These are in logical units, relative to the bottom-left corner of the text box.
198 */
200 {
201 float minX; ///< Minimum X in logical units.
202 float minY; ///< Minimum Y in logical units.
203 float maxX; ///< Maximum X in logical units.
204 float maxY; ///< Maximum Y in logical units.
205
207 : minX( 0.0f )
208 , minY( 0.0f )
209 , maxX( 0.0f )
210 , maxY( 0.0f )
211 {}
212 };
213
214 /** Default constructor. */
216
217 /** The copy constructor for GlsCTLTextBox
218 *
219 * \param that The GlsCTLTextBox object that is being copied
220 * \param generateNames Whether or not to generate a new instance name
221 */
222 GLSGEN_GLSCTLTEXTBOX_EXPORT GlsCTLTextBox( const GlsCTLTextBox& that, const bool generateNames );
223
224 /** Destructor.
225 */
227
228 // See DisplayObject
230
231#ifndef GLS_CTL_FALLBACK_ENABLED
232 // See DisplayObject
234
235 // See DisplayObject
237
238 // See DisplayObject
240
241 // See DisplayObject
243
244 // See DisplayObject
246
247 // See DisplayObject
248 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetVertices( unsigned int nPoints, Vertex* vertices ) DISTI_METHOD_OVERRIDE;
249
250 // See DisplayObject
251 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Scale( float px, float py, float pz, Vertex* anchor, int handleBar ) DISTI_METHOD_OVERRIDE;
252
253 /** Print a string into this text object.
254 * Replaces the entire string.
255 * \param format printf style varargs formatting string.
256 */
257 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VaString( const char* format, ... );
258
259 /// Set the vertical alignment for this text object.
260 /// \param verticalAlignment The vertical alignment type.
262
263 /// Set the vertical alignment for this text object.
264 /// \param verticalAlignment The vertical alignment type.
265 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignmentCTL_t verticalAlignment ) { VerticalAlignment( static_cast<VerticalAlignment_t>( verticalAlignment ) ); }
266#else
267
268 /** Set the vertical alignment for this text object
269 * \param[in] verticalAlignment The vertical alignment type.
270 */
271 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignment_t verticalAlignment ) { BaseClass::VerticalAlignment( verticalAlignment ); }
273
274#endif // GLS_CTL_FALLBACK_ENABLED
275
276 /** Get the vertical alignment for this text object
277 * \return The vertical alignment type.
278 */
280
281#ifndef GLES
282
283 // See DisplayObject
285
286 // See DisplayObject
288
289#endif // GLES
290
291 /** Rebuilds this text box layout. This may be an expensive call, so it should only be called when a property changes. */
293
294 // NO CTL-only functions should be disabled when using the GlsTextBox fallback.
295 // They should be available to every runtime, even if they do nothing.
296
297 /** Gets the type of automatic ellipsize if the text does not fit in the boundary.
298 * \return The type of automatic ellipsize if the text does not fit in the boundary.
299 * \note In CTL Fallback mode, returns ELLIPSIZE_MODE_NONE.
300 */
302
303 /** Sets the type of automatic ellipsize if the text does not fit in the boundary.
304 * \param[in] ellipsizeMode The type of automatic ellipsize if the text does not fit in the boundary.
305 * \note In CTL Fallback mode, has no effect.
306 */
307 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void EllipsizeMode( const EllipsizeMode_t ellipsizeMode );
308
309 /** Gets the number of lines in the layout.
310 * \return The number of lines in the layout.
311 * \note In CTL Fallback mode, returns 0.
312 */
314
315 /** Gets the number of glyphs in the layout.
316 * \return The number of glyphs in the layout.
317 * \note In CTL Fallback mode, returns 0.
318 */
320
321 /** Gets the glyph metrics for the given glyph index.
322 * \param[in] glyphIndex The index of the glyph in the layout line to get the glyph metrics for.
323 * \return The glyph metrics for the given glyph index.
324 * \note In CTL Fallback mode, returns a default GlyphMetrics struct.
325 */
326 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT GlyphMetrics GetGlyphMetrics( const unsigned int glyphIndex );
327
328 /// Set the Pango Layout auto dir, exposes pango_layout_set_auto_dir ()
329 /// see: https://developer.gnome.org/pango/stable/pango-Layout-Objects.html#pango-layout-set-auto-dir
330 /// \param[in] autoDir Whether or not the layout should automatically determine base direction based on content
331 /// \note In CTL Fallback mode, has no effect.
332 /// \deprecated
333 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetLayoutAutoDir( bool autoDir ){};
334
335 /// 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
336 /// value is 0.0, the text will be rendered to the full width of the vertices
337 /// \note In CTL Fallback mode, has no effect.
338 /// \param width The new width to set.
339 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAltWidth( float width );
340
341 /// 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
342 /// value is 0.0, the text will be rendered to the full height of the vertices
343 /// \note In CTL Fallback mode, has no effect.
344 /// \param height The new height to set.
345 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAltHeight( float height );
346
347 /** Scales the text horizontally by the given value. Text is still clamped by the bounds of the text box
348 * \param value the horizontal scale
349 */
351
352 /// \return The current horizontal scale.
354
355 /** Scales the text vertically by the given value. Text is still clamped by the bounds of the text box
356 * \param value the vertical scale
357 */
359
360 /// \return The current vertical scale.
362
363 /** Gets the base direction used in applying the Unicode bidirectional algorithm.
364 * \return the text direction
365 * \note In CTL Fallback mode, returns TEXT_DIRECTION_AUTOMATIC.
366 */
368
369 /** Sets the base direction used in applying the Unicode bidirectional algorithm.
370 * \param[in] textDirection The text direction.
371 * \note In CTL Fallback mode, has no effect.
372 */
373 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextDirection( const TextDirection_t textDirection );
374
376 {
377 return true;
378 }
379
380#ifndef GLS_CTL_FALLBACK_ENABLED
381 /// Set the resize behavior for this object.
382 /// \param value The new resize behavior.
384
385 /// \return The current resize behavior for this object.
387
388 /// Set the maximum resize width for this object in logical units.
389 /// \param value The new maximum width.
390 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void MaxWidth( float value );
391
392 /// \return The current maximum resize width for this object in logical units.
394
395 /// Set the maximum resize height for this object in logical units.
396 /// \param value The new maximum height.
397 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void MaxHeight( float value );
398
399 /// \return The current maximum resize height for this object in logical units.
401#endif
402
403#ifdef GLES20
404 /** Re-enables automatic pixel alignment behavior that was always active by default prior to 7.0
405 * 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.
406 * \param enabled the new state for the alignment behavior flag
407 */
408 GLSGEN_GLSCTLTEXTBOX_EXPORT static void SetAutomaticPixelAlignmentEnabled( const bool enabled );
409#endif
410
411protected:
412#ifndef GLS_CTL_FALLBACK_ENABLED
413 /** Width used to render the text */
415 /** Height used to render the text */
417
418 /** the horizontal scale */
420 /** the vertical scale */
422
423 /** Pointer to the internal data needed for Pango. */
425
426 /** makes adjustment to the image verts and texture coords for the alt width / height and text scaling properties
427 * \param[inout] verts the image verts
428 * \param[inout] texCoords the image texture coords
429 */
430 void AdjustImageVertsAndCoords( PangoRect& verts, PangoRect& texCoords );
431
432 /// Used internally to apply scale when rendering text.
433 /// \note Not normally called by users.
434 /// \param textBoxWidth The width of the box in logical units.
435 /// \param textBoxHeight The height of the box in logical units.
436 /// \param verts The returned bounding rectangle.
437 void ApplyTextScale( float textBoxWidth, float textBoxHeight, PangoRect& verts );
438
439 /// Used internally to clamp when rendering text.
440 /// \note Not normally called by users.
441 /// \param textBoxWidth The width of the box in logical units.
442 /// \param textBoxHeight The height of the box in logical units.
443 /// \param verts The returned bounding rectangle.
444 /// \param texCoords The returned texture coordinate rectangle.
445 void ClampToTextBoxSize( float textBoxWidth, float textBoxHeight, PangoRect& verts, PangoRect& texCoords );
446
447 /// Used internally to apply vertical alignment when rendering text.
448 /// \note Not normally called by users.
449 /// \param textBoxHeight The height of the box in logical units.
450 /// \param verts The returned bounding rectangle.
451 void ApplyVerticalAlignment( float textBoxHeight, PangoRect& verts );
452
453# ifdef GLES20
454 /** State of automatic pixel alignment behavior flag */
455 static bool s_isAutomaticPixelAlignmentEnabled;
456# endif
457
458 TextDirection_t _textDirection; ///< Text direction behavior for this object.
459
460# ifndef GLS_CTL_FALLBACK_ENABLED
461 ResizeMode_t _resizeMode; ///< Resize behavior for this object.
462 float _resizeMaxWidth; ///< Maximum resize width in logical units.
463 float _resizeMaxHeight; ///< Maximum resize height in logical units.
464# endif
465
466#endif // GLS_CTL_FALLBACK_ENABLED
467
468#ifdef GLES
469
470 // See DisplayObject
471 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
472
473# ifndef GLS_CTL_FALLBACK_ENABLED
474 /** The list of quads to draw for the shadows. */
476 /** The list of quads to draw for the characters. */
478
479 /** True if _geometryRefresh was true in PreDraw. This is just so we can rebuild the quads in Draw(). */
480 bool _geometryRefreshDraw;
481
482 /** Populate the quad storage
483 * \param stateManager
484 */
485 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void PopulateQuadStorage( IGlsStateManager* stateManager );
486
487 /** Draws the polygons that make up the characters.
488 * \param stateManager
489 */
490 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void DrawText( IGlsStateManager* stateManager );
491# endif // GLS_CTL_FALLBACK_ENABLED
492
493#else
494 /** Draws the polygons that make up the characters.
495 */
497#endif // GLES
498#ifndef GLS_CTL_FALLBACK_ENABLED
499 /** Rebuilds the vertices of the text box.
500 */
502
503 /// Set the size of the CTL text box to the incoming Pango rectangle's size.
504 /// \param verts The new size to set to.
505 /// \param keepWidth Whether or not to ignore changes to the object's width.
506 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetVerticesToImageSize( const PangoRect& verts, bool keepWidth );
507#endif // GLS_CTL_FALLBACK_ENABLED
508
509private:
510 void OnCellDimensionChanged() DISTI_METHOD_OVERRIDE
511 {
512 // Prevent changing cell dimensions for CTL Textbox
513 _cellHeight = 0;
514 _cellWidth = 0;
515 ControlCellSize( false );
516 }
517
520};
521
522#ifndef GLS_CTL_FALLBACK_ENABLED
523
524/// In stream operator for VerticalAlignment_t enumeration.
525/// \param instr The stream to read from.
526/// \param verticalAlignment The returned alignment to be read from stream.
527/// \return The stream in its current state.
528inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::VerticalAlignment_t& verticalAlignment )
529{
530 std::string str;
531 instr >> str;
532
533 if( str == "ALIGN_TOP" || str == "VERTICAL_ALIGNMENT_TOP" )
534 {
535 verticalAlignment = disti::GlsCTLTextBox::ALIGN_TOP;
536 }
537 else if( str == "ALIGN_CENTER" || str == "VERTICAL_ALIGNMENT_CENTER" )
538 {
539 verticalAlignment = disti::GlsCTLTextBox::ALIGN_CENTER;
540 }
541 else if( str == "ALIGN_BOTTOM" || str == "VERTICAL_ALIGNMENT_BOTTOM" )
542 {
543 verticalAlignment = disti::GlsCTLTextBox::ALIGN_BOTTOM;
544 }
545 return instr;
546}
547
548/// Out stream operator for VerticalAlignment_t enumeration.
549/// \param outstr The stream to write to.
550/// \param verticalAlignment The alignment to write to the stream.
551/// \return The stream in its current state.
552inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::VerticalAlignment_t verticalAlignment )
553{
554 switch( verticalAlignment )
555 {
556 case disti::GlsCTLTextBox::ALIGN_TOP:
557 outstr << "ALIGN_TOP";
558 break;
559 case disti::GlsCTLTextBox::ALIGN_CENTER:
560 outstr << "ALIGN_CENTER";
561 break;
562 case disti::GlsCTLTextBox::ALIGN_BOTTOM:
563 outstr << "ALIGN_BOTTOM";
564 break;
565 }
566 return outstr;
567}
568#endif // GLS_CTL_FALLBACK_ENABLED
569
570/// In stream operator for EllipsizeMode_t enumeration.
571/// \param instr The stream to read from.
572/// \param ellipsizeMode The returned mode to be read from stream.
573/// \return The stream in its current state.
574inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::EllipsizeMode_t& ellipsizeMode )
575{
576 std::string str;
577 instr >> str;
578
579 if( str == "ELLIPSIZE_MODE_NONE" )
580 {
581 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE;
582 }
583 else if( str == "ELLIPSIZE_MODE_START" )
584 {
585 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_START;
586 }
587 else if( str == "ELLIPSIZE_MODE_MIDDLE" )
588 {
589 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE;
590 }
591 else if( str == "ELLIPSIZE_MODE_END" )
592 {
593 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_END;
594 }
595 return instr;
596}
597
598/// Out stream operator for EllipsizeMode_t enumeration.
599/// \param outstr The stream to write to.
600/// \param ellipsizeMode The mode to write to the stream.
601/// \return The stream in its current state.
602inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::EllipsizeMode_t ellipsizeMode )
603{
604 switch( ellipsizeMode )
605 {
606 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE:
607 outstr << "ELLIPSIZE_MODE_NONE";
608 break;
609 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_START:
610 outstr << "ELLIPSIZE_MODE_START";
611 break;
612 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE:
613 outstr << "ELLIPSIZE_MODE_MIDDLE";
614 break;
615 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_END:
616 outstr << "ELLIPSIZE_MODE_END";
617 break;
618 }
619 return outstr;
620}
621
622/// In stream operator for TextDirection_t enumeration.
623/// \param instr The stream to read from.
624/// \param direction The returned direction to be read from stream.
625/// \return The stream in its current state.
626inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::TextDirection_t& direction )
627{
628 std::string str;
629 instr >> str;
630
631 if( str == "TEXT_DIRECTION_LTR" )
632 {
633 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_LTR;
634 }
635 else if( str == "TEXT_DIRECTION_RTL" )
636 {
637 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_RTL;
638 }
639 else if( str == "TEXT_DIRECTION_AUTOMATIC" )
640 {
641 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC;
642 }
643 else if( str == "TEXT_DIRECTION_AUTO_BY_LINE" )
644 {
645 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE;
646 }
647 return instr;
648}
649
650/// Out stream operator for TextDirection_t enumeration.
651/// \param outstr The stream to write to.
652/// \param direction The direction to write to the stream.
653/// \return The stream in its current state.
654inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::TextDirection_t direction )
655{
656 switch( direction )
657 {
658 case disti::GlsCTLTextBox::TEXT_DIRECTION_LTR:
659 outstr << "TEXT_DIRECTION_LTR";
660 break;
661 case disti::GlsCTLTextBox::TEXT_DIRECTION_RTL:
662 outstr << "TEXT_DIRECTION_RTL";
663 break;
664 case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC:
665 outstr << "TEXT_DIRECTION_AUTOMATIC";
666 break;
667 case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE:
668 outstr << "TEXT_DIRECTION_AUTO_BY_LINE";
669 break;
670 }
671 return outstr;
672}
673
674#ifndef GLS_CTL_FALLBACK_ENABLED
675/// In stream operator for ResizeMode_t enumeration.
676/// \param instr The stream to read from.
677/// \param resizeMode The returned mode to be read from stream.
678/// \return The stream in its current state.
679inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::ResizeMode_t& resizeMode )
680{
681 std::string str;
682 instr >> str;
683
684 if( str == "RESIZE_MODE_FIXED" )
685 {
686 resizeMode = disti::GlsCTLTextBox::RESIZE_MODE_FIXED;
687 }
688 else if( str == "RESIZE_MODE_AUTO_WIDTH" )
689 {
690 resizeMode = disti::GlsCTLTextBox::RESIZE_MODE_AUTO_WIDTH;
691 }
692 else if( str == "RESIZE_MODE_AUTO_HEIGHT" )
693 {
694 resizeMode = disti::GlsCTLTextBox::RESIZE_MODE_AUTO_HEIGHT;
695 }
696 return instr;
697}
698
699/// Out stream operator for ResizeMode_t enumeration.
700/// \param outstr The stream to write to.
701/// \param resizeMode The mode to write to the stream.
702/// \return The stream in its current state.
703inline std::ostream& operator<<( std::ostream& outstr, disti::GlsCTLTextBox::ResizeMode_t resizeMode )
704{
705 switch( resizeMode )
706 {
707 case disti::GlsCTLTextBox::RESIZE_MODE_FIXED:
708 outstr << "RESIZE_MODE_FIXED";
709 break;
710 case disti::GlsCTLTextBox::RESIZE_MODE_AUTO_WIDTH:
711 outstr << "RESIZE_MODE_AUTO_WIDTH";
712 break;
713 case disti::GlsCTLTextBox::RESIZE_MODE_AUTO_HEIGHT:
714 outstr << "RESIZE_MODE_AUTO_HEIGHT";
715 break;
716 }
717 return outstr;
718}
719#endif
720
721} // namespace disti
722
723#endif // INCLUDED_GLS_CTL_TEXT_BOX_H
Definition: cull.h:50
Definition: display.h:96
Definition: dynamic_array.h:79
The Gls CTL (Complex Text Layout) Text Box.
Definition: gls_ctl_text_box.h:131
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
virtual void DrawText()
virtual void TextHorizontalScale(float value)
float _altHeight
Definition: gls_ctl_text_box.h:416
static const unsigned int INTERNAL_BORDER
Definition: gls_ctl_text_box.h:140
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
virtual VerticalAlignment_t VerticalAlignment()
virtual void VaString(const char *format,...)
float _resizeMaxWidth
Maximum resize width in logical units.
Definition: gls_ctl_text_box.h:462
TextDirection_t
Definition: gls_ctl_text_box.h:180
VerticalAlignment_t
Definition: gls_ctl_text_box.h:146
virtual ResizeMode_t ResizeMode()
virtual unsigned int GetGlyphCount()
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) DISTI_METHOD_OVERRIDE
virtual void MaxWidth(float value)
float _textHorizontalScale
Definition: gls_ctl_text_box.h:419
virtual EllipsizeMode_t EllipsizeMode()
virtual void VerticalAlignment(VerticalAlignmentCTL_t verticalAlignment)
Definition: gls_ctl_text_box.h:265
virtual TextDirection_t TextDirection()
ResizeMode_t _resizeMode
Resize behavior for this object.
Definition: gls_ctl_text_box.h:461
float _textVerticalScale
Definition: gls_ctl_text_box.h:421
virtual void CopyGeometry(DisplayObject *src) DISTI_METHOD_OVERRIDE
virtual void SetVertices(unsigned int nPoints, Vertex *vertices) DISTI_METHOD_OVERRIDE
void ApplyTextScale(float textBoxWidth, float textBoxHeight, PangoRect &verts)
bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
Definition: gls_ctl_text_box.h:375
void ClampToTextBoxSize(float textBoxWidth, float textBoxHeight, PangoRect &verts, PangoRect &texCoords)
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:458
virtual float MaxWidth()
void ApplyVerticalAlignment(float textBoxHeight, PangoRect &verts)
virtual void Rebuild()
virtual void MaxHeight(float value)
virtual float TextVerticalScale()
VerticalAlignmentCTL_t
Definition: gls_ctl_text_box.h:157
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
virtual GlyphMetrics GetGlyphMetrics(const unsigned int glyphIndex)
virtual void SetAltWidth(float width)
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
ScopedPtr< GlsPangoWrapper > _glsPangoWrapper
Definition: gls_ctl_text_box.h:424
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:414
EllipsizeMode_t
Definition: gls_ctl_text_box.h:165
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:189
virtual void EllipsizeMode(const EllipsizeMode_t ellipsizeMode)
float _resizeMaxHeight
Maximum resize height in logical units.
Definition: gls_ctl_text_box.h:463
virtual void SetLayoutAutoDir(bool autoDir)
Definition: gls_ctl_text_box.h:333
Definition: gls_glo_file.h:1243
float _cellWidth
Definition: gls_text.h:669
float _cellHeight
Definition: gls_text.h:666
bool ControlCellSize() const
Definition: gls_text.h:344
Definition: gls_state_manager_interface.h:69
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
Definition: vertex.h:420
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:235
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
#define GLSGEN_GLSCTLTEXTBOX_EXPORT
Provides support for creating DLLs.
Definition: gls_ctl_text_box.h:63
#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:76
The gls_gl.
The disti::GlsText class.
The disti::GlsTextBox class.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
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:200
float minX
Minimum X in logical units.
Definition: gls_ctl_text_box.h:201
float maxX
Maximum X in logical units.
Definition: gls_ctl_text_box.h:203
float maxY
Maximum Y in logical units.
Definition: gls_ctl_text_box.h:204
float minY
Minimum Y in logical units.
Definition: gls_ctl_text_box.h:202
The DistiUnhideGlobalsDummyClass class.