41 #ifndef INCLUDED_GLS_CTL_TEXT_BOX_H
42 #define INCLUDED_GLS_CTL_TEXT_BOX_H
47 #if defined( EMSCRIPTEN )
48 # define GLS_CTL_FALLBACK_ENABLED
50 # error "GLES should always be enabled when using the CTL fallback code"
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 )
60 # define GLSGEN_GLSCTLTEXTBOX_EXPORT __declspec( dllimport )
63 # define GLSGEN_GLSCTLTEXTBOX_EXPORT
73 #ifndef GLS_CTL_FALLBACK_ENABLED
75 # define CTL_BASE_CLASS GlsText
78 # define CTL_BASE_CLASS GlsTextBox
81 #define LIB_BASE_NAME "gls_ctl_text_box"
87 # if !defined( NO_GLS_AUTOLIB ) && !defined( GLS_IMPORT_LIBRARY )
89 # define PANGO_SUFFIX "_64"
91 # define PANGO_SUFFIX ""
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" )
107 #ifndef GLS_CTL_FALLBACK_ENABLED
108 class GlsPangoWrapper;
111 class GlsTextBoxFontRenderer;
112 #endif // GLS_CTL_FALLBACK_ENABLED
115 class GlsGloFileAttribute;
116 class GlsStateManager;
117 class GlsQuadListVCT_2D;
131 DISTI_DEPRECATED(
"This identifier is forbidden by the C++ standard. Use BaseClass instead." )
140 friend class GlsCTLTextBoxEditor;
142 #ifndef GLS_CTL_FALLBACK_ENABLED
151 #endif // GLS_CTL_FALLBACK_ENABLED
156 VERTICAL_ALIGNMENT_CENTER = ALIGN_CENTER,
157 VERTICAL_ALIGNMENT_TOP = ALIGN_TOP,
158 VERTICAL_ALIGNMENT_BOTTOM = ALIGN_BOTTOM
165 ELLIPSIZE_MODE_START,
166 ELLIPSIZE_MODE_MIDDLE,
181 TEXT_DIRECTION_AUTOMATIC,
182 TEXT_DIRECTION_AUTO_BY_LINE
185 #ifndef GLS_CTL_FALLBACK_ENABLED
188 RESIZE_MODE_AUTO_WIDTH,
189 RESIZE_MODE_AUTO_HEIGHT
226 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void SetAvailableAttributes(
unsigned int value ) DISTI_METHOD_OVERRIDE;
228 #ifndef GLS_CTL_FALLBACK_ENABLED
242 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void Draw() DISTI_METHOD_OVERRIDE;
245 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void SetVertices(
unsigned int nPoints,
Vertex* vertices ) DISTI_METHOD_OVERRIDE;
248 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void Scale(
float px,
float py,
float pz,
Vertex* anchor,
int handleBar ) DISTI_METHOD_OVERRIDE;
254 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void VaString( const
char* format, ... );
259 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void VerticalAlignment( VerticalAlignment_t verticalAlignment );
266 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void VerticalAlignment( VerticalAlignment_t verticalAlignment ) { BaseClass::VerticalAlignment( verticalAlignment ); }
269 #endif // GLS_CTL_FALLBACK_ENABLED
279 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT InterfaceListType*
GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
287 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void Rebuild();
308 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
unsigned int GetLineCount();
314 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
unsigned int GetGlyphCount();
321 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT GlyphMetrics
GetGlyphMetrics(
const unsigned int glyphIndex );
335 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void SetAltWidth(
float width );
341 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void SetAltHeight(
float height );
377 #ifndef GLS_CTL_FALLBACK_ENABLED
378 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void ResizeMode( ResizeMode_t value );
379 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT ResizeMode_t ResizeMode();
381 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void MaxWidth(
float value );
382 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
float MaxWidth();
384 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void MaxHeight(
float value );
385 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
float MaxHeight();
393 GLSGEN_GLSCTLTEXTBOX_EXPORT
static void SetAutomaticPixelAlignmentEnabled(
const bool enabled );
397 #ifndef GLS_CTL_FALLBACK_ENABLED
417 void ApplyTextScale(
float textBoxWidth,
float textBoxHeight, PangoRect& verts );
418 void ClampToTextBoxSize(
float textBoxWidth,
float textBoxHeight, PangoRect& verts, PangoRect& texCoords );
419 void ApplyVerticalAlignment(
float textBoxHeight, PangoRect& verts );
423 static bool s_isAutomaticPixelAlignmentEnabled;
428 # ifndef GLS_CTL_FALLBACK_ENABLED
429 ResizeMode_t _resizeMode;
430 float _resizeMaxWidth;
431 float _resizeMaxHeight;
434 #endif // GLS_CTL_FALLBACK_ENABLED
439 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void SetFromGloData(
GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
441 # ifndef GLS_CTL_FALLBACK_ENABLED
448 bool _geometryRefreshDraw;
453 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void PopulateQuadStorage(
IGlsStateManager* stateManager );
459 # endif // GLS_CTL_FALLBACK_ENABLED
464 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void DrawText();
466 #ifndef GLS_CTL_FALLBACK_ENABLED
471 virtual GLSGEN_GLSCTLTEXTBOX_EXPORT
void SetVerticesToImageSize(
const PangoRect& verts,
bool keepWidth );
472 #endif // GLS_CTL_FALLBACK_ENABLED
476 void OnCellDimensionChanged() DISTI_METHOD_OVERRIDE
488 #ifndef GLS_CTL_FALLBACK_ENABLED
497 if( str ==
"ALIGN_TOP" || str ==
"VERTICAL_ALIGNMENT_TOP" )
499 verticalAlignment = disti::GlsCTLTextBox::ALIGN_TOP;
501 else if( str ==
"ALIGN_CENTER" || str ==
"VERTICAL_ALIGNMENT_CENTER" )
503 verticalAlignment = disti::GlsCTLTextBox::ALIGN_CENTER;
505 else if( str ==
"ALIGN_BOTTOM" || str ==
"VERTICAL_ALIGNMENT_BOTTOM" )
507 verticalAlignment = disti::GlsCTLTextBox::ALIGN_BOTTOM;
516 switch( verticalAlignment )
518 case disti::GlsCTLTextBox::ALIGN_TOP:
519 outstr <<
"ALIGN_TOP";
521 case disti::GlsCTLTextBox::ALIGN_CENTER:
522 outstr <<
"ALIGN_CENTER";
524 case disti::GlsCTLTextBox::ALIGN_BOTTOM:
525 outstr <<
"ALIGN_BOTTOM";
530 #endif // GLS_CTL_FALLBACK_ENABLED
539 if( str ==
"ELLIPSIZE_MODE_NONE" )
541 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE;
543 else if( str ==
"ELLIPSIZE_MODE_START" )
545 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_START;
547 else if( str ==
"ELLIPSIZE_MODE_MIDDLE" )
549 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE;
551 else if( str ==
"ELLIPSIZE_MODE_END" )
553 ellipsizeMode = disti::GlsCTLTextBox::ELLIPSIZE_MODE_END;
562 switch( ellipsizeMode )
564 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_NONE:
565 outstr <<
"ELLIPSIZE_MODE_NONE";
567 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_START:
568 outstr <<
"ELLIPSIZE_MODE_START";
570 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_MIDDLE:
571 outstr <<
"ELLIPSIZE_MODE_MIDDLE";
573 case disti::GlsCTLTextBox::ELLIPSIZE_MODE_END:
574 outstr <<
"ELLIPSIZE_MODE_END";
587 if( str ==
"TEXT_DIRECTION_LTR" )
589 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_LTR;
591 else if( str ==
"TEXT_DIRECTION_RTL" )
593 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_RTL;
595 else if( str ==
"TEXT_DIRECTION_AUTOMATIC" )
597 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC;
599 else if( str ==
"TEXT_DIRECTION_AUTO_BY_LINE" )
601 direction = disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE;
612 case disti::GlsCTLTextBox::TEXT_DIRECTION_LTR:
613 outstr <<
"TEXT_DIRECTION_LTR";
615 case disti::GlsCTLTextBox::TEXT_DIRECTION_RTL:
616 outstr <<
"TEXT_DIRECTION_RTL";
618 case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTOMATIC:
619 outstr <<
"TEXT_DIRECTION_AUTOMATIC";
621 case disti::GlsCTLTextBox::TEXT_DIRECTION_AUTO_BY_LINE:
622 outstr <<
"TEXT_DIRECTION_AUTO_BY_LINE";
628 #ifndef GLS_CTL_FALLBACK_ENABLED
631 inline std::istream& operator>>( std::istream& instr, disti::GlsCTLTextBox::ResizeMode_t& direction )
636 if( str ==
"RESIZE_MODE_FIXED" )
638 direction = disti::GlsCTLTextBox::RESIZE_MODE_FIXED;
640 else if( str ==
"RESIZE_MODE_AUTO_WIDTH" )
642 direction = disti::GlsCTLTextBox::RESIZE_MODE_AUTO_WIDTH;
644 else if( str ==
"RESIZE_MODE_AUTO_HEIGHT" )
646 direction = disti::GlsCTLTextBox::RESIZE_MODE_AUTO_HEIGHT;
653 inline std::ostream&
operator<<( std::ostream& outstr, disti::GlsCTLTextBox::ResizeMode_t direction )
657 case disti::GlsCTLTextBox::RESIZE_MODE_FIXED:
658 outstr <<
"RESIZE_MODE_FIXED";
660 case disti::GlsCTLTextBox::RESIZE_MODE_AUTO_WIDTH:
661 outstr <<
"RESIZE_MODE_AUTO_WIDTH";
663 case disti::GlsCTLTextBox::RESIZE_MODE_AUTO_HEIGHT:
664 outstr <<
"RESIZE_MODE_AUTO_HEIGHT";
673 #endif // INCLUDED_GLS_CTL_TEXT_BOX_H
The DistiUnhideGlobalsDummyClass class.
virtual VerticalAlignment_t VerticalAlignment()
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
The disti::GlsTextBox class.
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
ScopedPtr< GlsPangoWrapper > _glsPangoWrapper
Definition: gls_ctl_text_box.h:409
virtual float TextHorizontalScale()
void AdjustImageVertsAndCoords(PangoRect &verts, PangoRect &texCoords)
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:473
float _altWidth
Definition: gls_ctl_text_box.h:399
bool RequiresFontFile() const DISTI_METHOD_OVERRIDE
Definition: gls_ctl_text_box.h:372
EllipsizeMode_t
Definition: gls_ctl_text_box.h:162
virtual void VaString(const char *format,...)
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
virtual GlyphMetrics GetGlyphMetrics(const unsigned int glyphIndex)
float _cellHeight
Definition: gls_text.h:661
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
Definition: gls_state_manager_interface.h:67
virtual void RecalcVertices()
virtual unsigned int GetLineCount()
The disti::GlsText class.
float _altHeight
Definition: gls_ctl_text_box.h:401
Definition: gls_glo_file.h:988
virtual unsigned int GetGlyphCount()
std::ostream & operator<<(std::ostream &outstr, const AttributeName &name)
Defines the stream out operator.
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual float TextVerticalScale()
The Gls CTL (Complex Text Layout) Text Box.
Definition: gls_ctl_text_box.h:128
bool ControlCellSize() const
Definition: gls_text.h:341
VerticalAlignmentCTL_t
Definition: gls_ctl_text_box.h:154
static const unsigned int INTERNAL_BORDER
Definition: gls_ctl_text_box.h:138
virtual void SetLayoutAutoDir(bool)
Definition: gls_ctl_text_box.h:329
TextDirection_t
Definition: gls_ctl_text_box.h:177
Definition: gls_ctl_text_box.h:196
virtual void CopyGeometry(DisplayObject *src) DISTI_METHOD_OVERRIDE
VerticalAlignment_t
Definition: gls_ctl_text_box.h:144
virtual void PreDraw(const OpenGLMatrices ¤t, Culler &culler) DISTI_METHOD_OVERRIDE
float _cellWidth
Definition: gls_text.h:664
float _textVerticalScale
Definition: gls_ctl_text_box.h:406
virtual EllipsizeMode_t EllipsizeMode()
virtual void SetAltHeight(float height)
A smart pointer with unique ownership – poor man's std::unique_ptr.
virtual void Scale(float px, float py, float pz, Vertex *anchor, int handleBar) DISTI_METHOD_OVERRIDE
Macros and helper code to determine what subset of C++11/14/17 is available.
float _textHorizontalScale
Definition: gls_ctl_text_box.h:404
virtual TextDirection_t TextDirection()
virtual void SetVertices(unsigned int nPoints, Vertex *vertices) DISTI_METHOD_OVERRIDE
Definition: bmpimage.h:46
virtual void SetAltWidth(float width)
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE