| 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 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
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/// 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
106 namespace disti
107{
108// Forward Declarations
109#ifndef GLS_CTL_FALLBACK_ENABLED
110 class GlsPangoWrapper;
111 struct PangoRect;
112#else
113 class GlsTextBoxFontRenderer;
114#endif // GLS_CTL_FALLBACK_ENABLED
115
116#ifdef GLES
117 class GlsGloFileAttribute;
118 class GlsStateManager;
119 class 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 */
130 class GlsCTLTextBox : public CTL_BASE_CLASS
131{
132 public:
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. */
146 enum VerticalAlignment_t{
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 */
156 enum VerticalAlignmentCTL_t
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. */
164 enum EllipsizeMode_t
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 */
179 enum TextDirection_t
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.
189 enum ResizeMode_t{
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 */
199 struct GlyphMetrics
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
206 GlyphMetrics()
207 : minX( 0.0f )
208 , minY( 0.0f )
209 , maxX( 0.0f )
210 , maxY( 0.0f )
211 {}
212 };
213
214 /** Default constructor. */
215 GLSGEN_GLSCTLTEXTBOX_EXPORT GlsCTLTextBox();
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 */
226 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT ~GlsCTLTextBox();
227
228 // See DisplayObject
229 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
230
231#ifndef GLS_CTL_FALLBACK_ENABLED
232 // See DisplayObject
233 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
234
235 // See DisplayObject
236 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void CopyGeometry( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
237
238 // See DisplayObject
239 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
240
241 // See DisplayObject
242 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) DISTI_METHOD_OVERRIDE;
243
244 // See DisplayObject
245 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
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.
261 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignment_t verticalAlignment );
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 ); }
272 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void VerticalAlignment( VerticalAlignmentCTL_t 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 */
279 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT VerticalAlignment_t VerticalAlignment();
280
281#ifndef GLES
282
283 // See DisplayObject
284 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
285
286 // See DisplayObject
287 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
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. */
292 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void Rebuild();
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 */
301 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT EllipsizeMode_t EllipsizeMode();
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 */
313 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT unsigned int GetLineCount();
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 */
319 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT unsigned int GetGlyphCount();
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 */
350 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextHorizontalScale( float value );
351
352 /// \return The current horizontal scale.
353 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float TextHorizontalScale();
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 */
358 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void TextVerticalScale( float value );
359
360 /// \return The current vertical scale.
361 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float TextVerticalScale();
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 */
367 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT TextDirection_t TextDirection();
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
375 bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
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.
383 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void ResizeMode( ResizeMode_t value );
384
385 /// \return The current resize behavior for this object.
386 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT ResizeMode_t ResizeMode();
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.
393 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float MaxWidth();
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.
400 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT float MaxHeight();
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
411 protected:
412#ifndef GLS_CTL_FALLBACK_ENABLED
413 /** Width used to render the text */
414 float _altWidth;
415 /** Height used to render the text */
416 float _altHeight;
417
418 /** the horizontal scale */
419 float _textHorizontalScale;
420 /** the vertical scale */
421 float _textVerticalScale;
422
423 /** Pointer to the internal data needed for Pango. */
424 ScopedPtr<GlsPangoWrapper> _glsPangoWrapper;
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. */
475 ScopedPtr<GlsQuadListVCT_2D> _shadows;
476 /** The list of quads to draw for the characters. */
477 ScopedPtr<GlsQuadListVCT_2D> _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 */
496 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void DrawText();
497#endif // GLES
498#ifndef GLS_CTL_FALLBACK_ENABLED
499 /** Rebuilds the vertices of the text box.
500 */
501 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT void RecalcVertices();
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
509 private:
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
518 GlsCTLTextBox& operator=( const GlsCTLTextBox& ) DISTI_SPECIAL_MEM_FUN_DELETE;
519 GlsCTLTextBox( const GlsCTLTextBox& ) DISTI_SPECIAL_MEM_FUN_DELETE;
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.
528 inline 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.
552 inline 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.
574 inline 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.
602 inline 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.
626 inline 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.
654 inline 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.
679 inline 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.
703 inline 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
disti::Culler
Definition: cull.h:50
disti::DisplayObject
Definition: display.h:96
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsCTLTextBox
The Gls CTL (Complex Text Layout) Text Box.
Definition: gls_ctl_text_box.h:131
disti::GlsCTLTextBox::PopulateQuadStorage
virtual void PopulateQuadStorage(IGlsStateManager *stateManager)
disti::GlsCTLTextBox::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::Draw
virtual void Draw() DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::DrawText
virtual void DrawText(IGlsStateManager *stateManager)
disti::GlsCTLTextBox::TextHorizontalScale
virtual void TextHorizontalScale(float value)
disti::GlsCTLTextBox::_altHeight
float _altHeight
Definition: gls_ctl_text_box.h:416
disti::GlsCTLTextBox::INTERNAL_BORDER
static const unsigned int INTERNAL_BORDER
Definition: gls_ctl_text_box.h:140
disti::GlsCTLTextBox::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::_geometryRefreshDraw
bool _geometryRefreshDraw
Definition: gls_ctl_text_box.h:480
disti::GlsCTLTextBox::VerticalAlignment
virtual VerticalAlignment_t VerticalAlignment()
disti::GlsCTLTextBox::VaString
virtual void VaString(const char *format,...)
disti::GlsCTLTextBox::_resizeMaxWidth
float _resizeMaxWidth
Maximum resize width in logical units.
Definition: gls_ctl_text_box.h:462
disti::GlsCTLTextBox::SetFromGloData
virtual void SetFromGloData(GlsGloFileAttribute &data) DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::GlsCTLTextBox
GlsCTLTextBox()
disti::GlsCTLTextBox::TextDirection_t
TextDirection_t
Definition: gls_ctl_text_box.h:180
disti::GlsCTLTextBox::VerticalAlignment_t
VerticalAlignment_t
Definition: gls_ctl_text_box.h:146
disti::GlsCTLTextBox::ResizeMode
virtual ResizeMode_t ResizeMode()
disti::GlsCTLTextBox::GetGlyphCount
virtual unsigned int GetGlyphCount()
disti::GlsCTLTextBox::PreDraw
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::MaxWidth
virtual void MaxWidth(float value)
disti::GlsCTLTextBox::_textHorizontalScale
float _textHorizontalScale
Definition: gls_ctl_text_box.h:419
disti::GlsCTLTextBox::EllipsizeMode
virtual EllipsizeMode_t EllipsizeMode()
disti::GlsCTLTextBox::VerticalAlignment
virtual void VerticalAlignment(VerticalAlignmentCTL_t verticalAlignment)
Definition: gls_ctl_text_box.h:265
disti::GlsCTLTextBox::TextDirection
virtual TextDirection_t TextDirection()
disti::GlsCTLTextBox::_resizeMode
ResizeMode_t _resizeMode
Resize behavior for this object.
Definition: gls_ctl_text_box.h:461
disti::GlsCTLTextBox::_textVerticalScale
float _textVerticalScale
Definition: gls_ctl_text_box.h:421
disti::GlsCTLTextBox::_shadows
ScopedPtr< GlsQuadListVCT_2D > _shadows
Definition: gls_ctl_text_box.h:475
disti::GlsCTLTextBox::CopyGeometry
virtual void CopyGeometry(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::SetVertices
virtual void SetVertices(unsigned int nPoints, Vertex *vertices) DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::ApplyTextScale
void ApplyTextScale(float textBoxWidth, float textBoxHeight, PangoRect &verts)
disti::GlsCTLTextBox::RequiresFontFile
bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
Definition: gls_ctl_text_box.h:375
disti::GlsCTLTextBox::ClampToTextBoxSize
void ClampToTextBoxSize(float textBoxWidth, float textBoxHeight, PangoRect &verts, PangoRect &texCoords)
disti::GlsCTLTextBox::~GlsCTLTextBox
virtual ~GlsCTLTextBox()
disti::GlsCTLTextBox::ResizeMode
virtual void ResizeMode(ResizeMode_t value)
disti::GlsCTLTextBox::MaxHeight
virtual float MaxHeight()
disti::GlsCTLTextBox::GlsCTLTextBox
GlsCTLTextBox(const GlsCTLTextBox &that, const bool generateNames)
disti::GlsCTLTextBox::TextVerticalScale
virtual void TextVerticalScale(float value)
disti::GlsCTLTextBox::_textDirection
TextDirection_t _textDirection
Text direction behavior for this object.
Definition: gls_ctl_text_box.h:458
disti::GlsCTLTextBox::MaxWidth
virtual float MaxWidth()
disti::GlsCTLTextBox::ApplyVerticalAlignment
void ApplyVerticalAlignment(float textBoxHeight, PangoRect &verts)
disti::GlsCTLTextBox::Rebuild
virtual void Rebuild()
disti::GlsCTLTextBox::MaxHeight
virtual void MaxHeight(float value)
disti::GlsCTLTextBox::TextVerticalScale
virtual float TextVerticalScale()
disti::GlsCTLTextBox::VerticalAlignmentCTL_t
VerticalAlignmentCTL_t
Definition: gls_ctl_text_box.h:157
disti::GlsCTLTextBox::Scale
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::GetGlyphMetrics
virtual GlyphMetrics GetGlyphMetrics(const unsigned int glyphIndex)
disti::GlsCTLTextBox::SetAltWidth
virtual void SetAltWidth(float width)
disti::GlsCTLTextBox::CopyProperties
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsCTLTextBox::_glsPangoWrapper
ScopedPtr< GlsPangoWrapper > _glsPangoWrapper
Definition: gls_ctl_text_box.h:424
disti::GlsCTLTextBox::RecalcVertices
virtual void RecalcVertices()
disti::GlsCTLTextBox::SetAltHeight
virtual void SetAltHeight(float height)
disti::GlsCTLTextBox::_characters
ScopedPtr< GlsQuadListVCT_2D > _characters
Definition: gls_ctl_text_box.h:477
disti::GlsCTLTextBox::TextHorizontalScale
virtual float TextHorizontalScale()
disti::GlsCTLTextBox::SetVerticesToImageSize
virtual void SetVerticesToImageSize(const PangoRect &verts, bool keepWidth)
disti::GlsCTLTextBox::GetLineCount
virtual unsigned int GetLineCount()
disti::GlsCTLTextBox::_altWidth
float _altWidth
Definition: gls_ctl_text_box.h:414
disti::GlsCTLTextBox::EllipsizeMode_t
EllipsizeMode_t
Definition: gls_ctl_text_box.h:165
disti::GlsCTLTextBox::AdjustImageVertsAndCoords
void AdjustImageVertsAndCoords(PangoRect &verts, PangoRect &texCoords)
disti::GlsCTLTextBox::TextDirection
virtual void TextDirection(const TextDirection_t textDirection)
disti::GlsCTLTextBox::ResizeMode_t
ResizeMode_t
The resize behavior types.
Definition: gls_ctl_text_box.h:189
disti::GlsCTLTextBox::EllipsizeMode
virtual void EllipsizeMode(const EllipsizeMode_t ellipsizeMode)
disti::GlsCTLTextBox::_resizeMaxHeight
float _resizeMaxHeight
Maximum resize height in logical units.
Definition: gls_ctl_text_box.h:463
disti::GlsCTLTextBox::SetLayoutAutoDir
virtual void SetLayoutAutoDir(bool autoDir)
Definition: gls_ctl_text_box.h:333
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::GlsText::_cellWidth
float _cellWidth
Definition: gls_text.h:669
disti::GlsText::_cellHeight
float _cellHeight
Definition: gls_text.h:666
disti::GlsText::ControlCellSize
bool ControlCellSize() const
Definition: gls_text.h:344
disti::IGlsStateManager
Definition: gls_state_manager_interface.h:69
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::ScopedPtr< GlsPangoWrapper >
disti::Vertex
Definition: vertex.h:420
gls_auto_lib.h
The gls_auto_lib.
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#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:246
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
GLSGEN_GLSCTLTEXTBOX_EXPORT
#define GLSGEN_GLSCTLTEXTBOX_EXPORT
Provides support for creating DLLs.
Definition: gls_ctl_text_box.h:63
CTL_BASE_CLASS
#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
gls_gl.h
The gls_gl.
gls_text.h
The disti::GlsText class.
gls_text_box.h
The disti::GlsTextBox class.
disti
Definition: bmpimage.h:47
disti::operator<<
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
disti::operator>>
std::istream & operator>>(std::istream &instr, GlsColor &color)
scoped_ptr.h
A smart pointer with unique ownership – poor man's std::unique_ptr.
disti::GlsCTLTextBox::GlyphMetrics
Definition: gls_ctl_text_box.h:200
disti::GlsCTLTextBox::GlyphMetrics::minX
float minX
Minimum X in logical units.
Definition: gls_ctl_text_box.h:201
disti::GlsCTLTextBox::GlyphMetrics::maxX
float maxX
Maximum X in logical units.
Definition: gls_ctl_text_box.h:203
disti::GlsCTLTextBox::GlyphMetrics::maxY
float maxY
Maximum Y in logical units.
Definition: gls_ctl_text_box.h:204
disti::GlsCTLTextBox::GlyphMetrics::minY
float minY
Minimum Y in logical units.
Definition: gls_ctl_text_box.h:202
unhide_globals.h
The DistiUnhideGlobalsDummyClass class.