JugiMap Framework
GuiTextField Class Reference

The GuiTextField class provides a widget for displaying text. More...

#include <jmGuiTextWidgets.h>

Inherits GuiWidget.

Public Types

enum  Alignment { LEFT, JUSTIFY }
 The text alignment. More...
 
enum  DrawingDelay { NONE, BY_ROWS, BY_WORDS, BY_CHARACTERS }
 The drawing delay of displayed text. More...
 
enum  ScrollingMode { NORMAL, FIXED_STEP }
 

Public Member Functions

 GuiTextField (VectorShape *_vectorShape, Map *_map)
 Construct a new GuiTextField from the given *_vectorShape* in the *_map*. More...
 
void SetDisabled (bool _disabled) override
 Set the disabled state of this widget. More...
 
void SetVisible (bool _visible) override
 Set the visibility of this widget. More...
 
TextSegmentGetTextSegment ()
 Returns the text segment if exists; otherwise returns nullptr. More...
 
int GetTextSegmentHeight (TextSegment *_textSegment)
 Returns the height of the given *_textSegment* in this text field. More...
 
std::string GetClickedButtonName ()
 Returns the name of the clicked button if such event happens; otherwise returns an empty string. More...
 
void SetScrollingMode (ScrollingMode _scrollingMode)
 Set the scrolling mode. More...
 
ScrollingMode GetScrollingMode ()
 Returns the scrolling mode of this text field. More...
 
void SetScrollingModeFixedStepProperties (int _numberOfLines, int _lineHeight, float _scrollDurationMS)
 Set the scrolling properties if scrolling mode is ScrollingMode::FIXED_STEP. More...
 
void SetDrawingDelay (DrawingDelay _drawingDelay, int _drawingdelayMS)
 Set the drawing delay to the given *_drawingDelay* and duration to *_drawingdelayMS* (in milliseconds). More...
 
DrawingDelay GetDrawingDelay ()
 Returns the drawing delay of this text field. More...
 
void SetTextAlignment (Alignment _textAlignment)
 Set the text alignment to the given *_textAlignment*. More...
 
Alignment GetTextAlignment ()
 Returns the text alignment of this text field. More...
 
void SetAlphaFadeAtMargin (bool _alphaFadeAtMargin)
 Set to true if alpha fade at margin between box and visible box is used. More...
 
void SetTextRect (Recti _box)
 Set the text area rectangle. More...
 
Recti GetTextRect ()
 Returns the text area rectangle. More...
 
void SetVisibleRect (Recti _visibleBox)
 Set the visible area rectangle. More...
 
Recti GetVisibleRect ()
 Returns the visible area rectangle. More...
 
void SetClickableRect (Recti _clickableBox)
 Set the clickable area rectangle. More...
 
Recti GetClickableRect ()
 Returns the clickable area rectangle. More...
 
void SetLocalLinesSpacingFactor (float _spacingFactor)
 Set the local factor for vertical lines spacing. More...
 
void Start (TextSegment *_textSegment)
 Start displaying the given *_textSegment*. More...
 
void Reset ()
 Reset the text field. More...
 
bool IsDelayedDrawingActive ()
 Returns true if a text segment is currently being drawn by the drawing delay; otherwise returns false. More...
 
void SkipDelay ()
 Skip drawing delay of a text segment and show entire text immediately. More...
 
bool ScrollTextUp ()
 Scroll the segment text up and returns true. If scrolling is not possible returns false. More...
 
bool ScrollTextDown ()
 Scroll the segment text down and return true. If scrolling is not possible returns false. More...
 
bool IsTextSegmentFirstLineDisplayed ()
 Returns true if the first line of the text segement is displayed; otherwise returns false. More...
 
bool IsTextSegmentLastLineDisplayed ()
 Returns true if the last line of the text segement is displayed; otherwise returns false. More...
 
- Public Member Functions inherited from GuiWidget
bool IsCursorDown ()
 Returns true if the cursor is hold down over this widget; otherwise returns false. More...
 
bool IsCursorOver ()
 Returns true if the cursor is over this widget; otherwise returns false. More...
 
bool IsPressed ()
 Returns true if the cursor is pressed while over this widget; otherwise returns false. More...
 
bool IsValueChanged ()
 Returns true if this widget's value is changed; otherwise returns false. More...
 
bool IsDisabled ()
 Returns true if this widget is disabled; otherwise returns false. More...
 
bool IsVisible ()
 Returns true if this widget is visible; otherwise returns false. More...
 
void SetName (const std::string &_name)
 Set the name of this widget. More...
 
std::string GetName ()
 Returns the name of this widget. More...
 
void SetTag (int _tag)
 Set the tag of this widget. More...
 
int GetTag ()
 Returns the tag of this widget. More...
 
GuiWidgetKind GetKind ()
 Returns the kind of this widget. More...
 
std::string GetDesignKind ()
 Returns the design kind of this widget. More...
 
void AssignCustomObject (CustomObject *_customObject)
 Assign the given *_customObject* to this widget. More...
 
CustomObjectGetCustomObject ()
 Returns the custom object of this widget or nullptr if none. More...
 
void AssignCallback (GuiWidgetCallback *_callback)
 Assign the given *_callback* to this widget. More...
 
GuiWidgetCallbackGetCallback ()
 Returns the callback of this widget or nullptr if none. More...
 

Static Public Attributes

static float globalLinesSpacingFactor = 0.1
 Global factor for vertical lines spacing. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from GuiWidget
static GuiWidgetGetInteracted ()
 Returns the interacted widget. More...
 
static GuiWidgetGetInteracted (const std::string &_name)
 Returns the interacted widget with the given *_name*. More...
 
static GuiWidgetGetInteracted (int _tag)
 Returns the interacted widget with the given *_tag*. More...
 
static GuiWidgetGetInteracted (CustomObject *_customObject)
 Returns the interacted widget which has assigned the given *_customObject*. More...
 
static GuiWidgetGetInteracted_Pressed ()
 Returns the interacted widget which is pressed. More...
 
static GuiWidgetGetInteracted_Pressed (const std::string &_name)
 Returns the interacted widget with the given *_name* which is pressed. More...
 
static GuiWidgetGetInteracted_Pressed (int _tag)
 Returns the interacted widget with the given *_tag* which is pressed. More...
 
static GuiWidgetGetInteracted_Pressed (CustomObject *_customObject)
 Returns the interacted widget with assigned *_customObject* which is pressed. More...
 
static GuiWidgetGetInteracted_ValueChanged ()
 Returns the interacted widget which has changed value. More...
 
static GuiWidgetGetInteracted_ValueChanged (const std::string &_name)
 Returns the interacted widget with the given *_name* which has changed value. More...
 
static GuiWidgetGetInteracted_ValueChanged (int _tag)
 Returns the interacted widget with the given *_tag* which has changed value. More...
 
static GuiWidgetGetInteracted_ValueChanged (CustomObject *_customObject)
 Returns the interacted widget with assigned *_customObject* which has changed value. More...
 
static GuiWidgetGetInteracted_CursorOver ()
 Returns the interacted widget which has the cursor over. More...
 
static GuiWidgetGetInteracted_CursorOver (const std::string &_name)
 Returns the interacted widget with the given *_name* which has the cursor over. More...
 
static GuiWidgetGetInteracted_CursorOver (int _tag)
 Returns the interacted widget with the given *_tag* which has the cursor over. More...
 
static GuiWidgetGetInteracted_CursorOver (CustomObject *_customObject)
 Returns the interacted widget with assigned *_customObject* which has the cursor over. More...
 
static GuiWidgetGetInteracted_cursorDown ()
 Returns the interacted widget which has the cursor hold down. More...
 
static GuiWidgetGetInteracted_CursorDown (const std::string &_name)
 Returns the interacted widget with the given *_name* which has the cursor hold down. More...
 
static GuiWidgetGetInteracted_CursorDown (int _tag)
 Returns the interacted widget with the given *_tag* which has the cursor hold down. More...
 
static GuiWidgetGetInteracted_CursorDown (CustomObject *_customObject)
 Returns the interacted widget with assigned *_customObject* which has the cursor hold down. More...
 

Detailed Description

The GuiTextField class provides a widget for displaying text.

Member Enumeration Documentation

◆ Alignment

enum Alignment
strong

The text alignment.

Enumerator
LEFT 

Text lines are aligned to the left edge.

JUSTIFY 

Extend text lines from the left to the right edge by increasing the gap between words. The gap has a maximum value which means that lines may not reach the right edge if the gap would become too big!

◆ DrawingDelay

enum DrawingDelay
strong

The drawing delay of displayed text.

Enumerator
NONE 

Text is displayed instantly.

BY_ROWS 

Text is displayed gradually by rows.

BY_WORDS 

Text is displayed gradually by words.

BY_CHARACTERS 

Text is displayed gradually by characters.

◆ ScrollingMode

enum ScrollingMode
strong

The scrolling mode of displayed text. This parameter allow different ways to display text segments which does not fit vertically into the text field.

Enumerator
NORMAL 

Scrolling range is determined from the text height and the height of the text field. This is a standard mode used with the scrolling slider and is suitable for general texts.

FIXED_STEP 

Scrolling range is a fixed number of lines. This ensure that on every scroll command unique lines get displayed. In practice this mode works better with texts like dialogs where repeated lines would be distracting. This mode does not work with the scrolling slider but require external calls to GuiTextField::ScrollTextUp or GuiTextField::ScrollTextDown. It is also not suitable for texts where different fonts with too much difference in size are used.

Constructor & Destructor Documentation

◆ GuiTextField()

GuiTextField ( VectorShape _vectorShape,
Map _map 
)

Construct a new GuiTextField from the given *_vectorShape* in the *_map*.

The widget properties are obtained from the vector shape custom parameters.

Member Function Documentation

◆ SetDisabled()

void SetDisabled ( bool  _disabled)
overridevirtual

Set the disabled state of this widget.

See also
IsDisabled

Reimplemented from GuiWidget.

◆ SetVisible()

void SetVisible ( bool  _visible)
overridevirtual

Set the visibility of this widget.

This function is not available for GuiTextField.

See also
IsVisible

Reimplemented from GuiWidget.

◆ GetTextSegment()

TextSegment* GetTextSegment ( )
inline

Returns the text segment if exists; otherwise returns nullptr.

◆ GetTextSegmentHeight()

int GetTextSegmentHeight ( TextSegment _textSegment)

Returns the height of the given *_textSegment* in this text field.

This function can be used if you want to manually set the height of the text field to fit a particular text segment. Calling this function will reset the text field so use it accordingly.

◆ GetClickedButtonName()

std::string GetClickedButtonName ( )
inline

Returns the name of the clicked button if such event happens; otherwise returns an empty string.

This a querry function for text segments with defined buttons.

◆ SetScrollingMode()

void SetScrollingMode ( ScrollingMode  _scrollingMode)

Set the scrolling mode.

◆ GetScrollingMode()

ScrollingMode GetScrollingMode ( )
inline

Returns the scrolling mode of this text field.

◆ SetScrollingModeFixedStepProperties()

void SetScrollingModeFixedStepProperties ( int  _numberOfLines,
int  _lineHeight,
float  _scrollDurationMS 
)

Set the scrolling properties if scrolling mode is ScrollingMode::FIXED_STEP.

Parameters
_numberOfLinesNumber of scrolled lines.
_lineHeightThe height of the lines.
_scrollDurationMSDuration of scrolling in milliseconds.

◆ SetDrawingDelay()

void SetDrawingDelay ( DrawingDelay  _drawingDelay,
int  _drawingdelayMS 
)

Set the drawing delay to the given *_drawingDelay* and duration to *_drawingdelayMS* (in milliseconds).

◆ GetDrawingDelay()

DrawingDelay GetDrawingDelay ( )
inline

Returns the drawing delay of this text field.

◆ SetTextAlignment()

void SetTextAlignment ( Alignment  _textAlignment)

Set the text alignment to the given *_textAlignment*.

◆ GetTextAlignment()

Alignment GetTextAlignment ( )
inline

Returns the text alignment of this text field.

◆ SetAlphaFadeAtMargin()

void SetAlphaFadeAtMargin ( bool  _alphaFadeAtMargin)
inline

Set to true if alpha fade at margin between box and visible box is used.

◆ SetTextRect()

void SetTextRect ( Recti  _box)

Set the text area rectangle.

Important! The border Y-coordinates for text positioning are the minimum and maximum Y-coordinate of the text box. The used text sprites have their handle Y-coordinate in the middle. This means that half of their height reach out of the text area. Take this into account when designing the text field rectangle size.

A call to this function resets the text field.

◆ GetTextRect()

Recti GetTextRect ( )
inline

Returns the text area rectangle.

◆ SetVisibleRect()

void SetVisibleRect ( Recti  _visibleBox)

Set the visible area rectangle.

The visible area can be bigger (only height matters) then the text area in which case the text can alpha fade in and out at margins. Use function GuiTextField::SetAlphaFadeAtMargin to enable or disable alpha fade. By default the visible area has the same size as the text area.

A call to this function resets the text field.

◆ GetVisibleRect()

Recti GetVisibleRect ( )
inline

Returns the visible area rectangle.

◆ SetClickableRect()

void SetClickableRect ( Recti  _clickableBox)

Set the clickable area rectangle.

This is the area where the cursor interaction get registered to this text field. By default the clickable area has the same size as the text area.

◆ GetClickableRect()

Recti GetClickableRect ( )
inline

Returns the clickable area rectangle.

◆ SetLocalLinesSpacingFactor()

void SetLocalLinesSpacingFactor ( float  _spacingFactor)
inline

Set the local factor for vertical lines spacing.

This factor is added to the global factor GuiTextField::globalLinesSpacingFactor. It provides additional spacing between lines. The spacing is obtained by multiplying this factor with the text line height. A negative value will cause negative (reduced) spacing.

◆ Start()

void Start ( TextSegment _textSegment)

Start displaying the given *_textSegment*.

A call to this function resets the text field.

◆ Reset()

void Reset ( )

Reset the text field.

Calling this function is usually not needed as other function call it if required.

◆ IsDelayedDrawingActive()

bool IsDelayedDrawingActive ( )
inline

Returns true if a text segment is currently being drawn by the drawing delay; otherwise returns false.

◆ SkipDelay()

void SkipDelay ( )

Skip drawing delay of a text segment and show entire text immediately.

◆ ScrollTextUp()

bool ScrollTextUp ( )

Scroll the segment text up and returns true. If scrolling is not possible returns false.

This function scroll the text segement that does not fit into the text area. The scrolling up is possible until the last line of text is displayed.

◆ ScrollTextDown()

bool ScrollTextDown ( )

Scroll the segment text down and return true. If scrolling is not possible returns false.

This function scroll the text segement that does not fit into the text area. The scrolling down is possible until the first line of text is displayed.

◆ IsTextSegmentFirstLineDisplayed()

bool IsTextSegmentFirstLineDisplayed ( )

Returns true if the first line of the text segement is displayed; otherwise returns false.

◆ IsTextSegmentLastLineDisplayed()

bool IsTextSegmentLastLineDisplayed ( )

Returns true if the last line of the text segement is displayed; otherwise returns false.

Member Data Documentation

◆ globalLinesSpacingFactor

float globalLinesSpacingFactor = 0.1
static

Global factor for vertical lines spacing.

This factor provides additional spacing between lines. The spacing is obtained by multiplying this factor with the text line height. A negative value will cause negative (reduced) spacing.


The documentation for this class was generated from the following files: