Cavestory Mod API
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
TextInputInfo Class Reference

Show a text input box. More...

#include <CSMAPI_types.h>

Inheritance diagram for TextInputInfo:
GuiBase

Public Types

enum  CANCEL_KEY_TYPE { ENTER , ESCAPE , MOUSE_BUTTON }
 Cancel key types. More...
 
enum  EInputBoxStyle { STYLE_NORMAL , STYLE_WHITE_BG }
 
typedef bool(* ValidateInputCallbackFunc) (TextInputInfo *pTextInput, const char *pValue, char pValidateOutput[1024])
 Func callback for validating input. More...
 
- Public Types inherited from GuiBase
enum  ProcessReturnType {
  PRT_DIRTY = 0b000001 , PRT_IGNORE_MOUSE = 0b000010 , PRT_IGNORE_KEYS = 0b000100 , PRT_SELECTED = 0b001000 ,
  PRT_DISABLE_MOUSE_ON_MOVE = 0b010000 , PRT_CHANGED = 0b100000
}
 Return flags for GuiBase::process and GuiBase::processKeys. More...
 
typedef void(* OnHoverChangeCallbackFunc) (GuiBase *, int value)
 Hover callback.
 
typedef void(* OnValueChangeCallbackFunc) (GuiBase *, const char *&newValue)
 Value change callback.
 
typedef bool(* OnValidateChangeCallbackFunc) (GuiBase *, const char *oldValue, char *newValue)
 Validate change callback.
 

Public Member Functions

 TextInputInfo ()
 Default constructor.
 
 ~TextInputInfo ()
 Default deconstructor.
 
virtual const char * getClassName ()
 Get this class' name. More...
 
virtual void setSelected (int value)
 Set this GUI element as selected or not. More...
 
virtual void setHovered (int value)
 Set this GUI element as hovered over or not. More...
 
virtual bool isSelected ()
 Check selection status. More...
 
virtual bool isHovered ()
 Check hover status. More...
 
virtual bool isHoverable ()
 Check hoverability status. More...
 
virtual int getSelectableCount ()
 Get the selectable number of elements in this element. More...
 
virtual int getHoverableCount ()
 Get the number of elements that can be hovered over in this element. More...
 
virtual bool SelectOnMouseUp ()
 Select on mouse up. More...
 
void setValue (const char *value, bool bUseCallback=true)
 Set the value of the inputbox. More...
 
const char * getValue ()
 Get the value of the inputbox. More...
 
virtual void setFont (FontObject *pFont)
 Set the font for this element. More...
 
virtual FontObject * getFont ()
 Get the font for this GUI element. More...
 
void startInput (GUI_POINT mouse=GUI_POINT(0, 0))
 Set this inputbox as 'focused', and start inputting text. More...
 
void stopInput ()
 Stop inputting text.
 
int getStringOffsetByMouse (GUI_POINT mouse)
 Get input offset by mouse position. More...
 
virtual int processKeys ()
 Process key input for this element. More...
 
virtual int process (GUI_POINT mouse)
 Process mouse input for this element. More...
 
virtual void calculate ()
 Re-calculate this element's data. More...
 
virtual void render ()
 Render this element.
 
- Public Member Functions inherited from GuiBase
 GuiBase ()
 Default constructor.
 
virtual ~GuiBase ()
 Default deconstructor.
 
virtual GuiBasegetHoverable (int index)
 Get a hoverable sub-element. More...
 
virtual GuiBasegetSelectable (int index)
 Get a selectable sub-element. More...
 
virtual void importantRender ()
 Render the important bits of this element. More...
 
virtual int getMagnification ()
 
 GuiBase (const GuiBase &)=delete
 
GuiBaseoperator= (const GuiBase &)=delete
 
 GuiBase (GuiBase &&)=delete
 
GuiBaseoperator= (GuiBase &&)=delete
 

Public Attributes

EInputBoxStyle mInputStyle
 The style of this input box.
 
ValidateInputCallbackFunc ValidateInput
 Called when text is finalized (by pressing enter, cancel or clicking outside of the input box). More...
 
CANCEL_KEY_TYPE mCancelKey
 Which cancel key was pressed to lose focus.
 
int max_length
 Maximum input length.
 
int sel_start
 Selection start.
 
int sel_end
 Selection end.
 
bool is_selecting
 Is selecting.
 
bool is_password
 Is password box.
 
bool is_disabled
 Is disabled.
 
bool callback_on_change
 Call the OnValueChange callback on every keystroke.
 
int margin
 Text margin.
 
- Public Attributes inherited from GuiBase
GuiBasepNext
 
GuiBasepPrev
 
OnValueChangeCallbackFunc OnValueChange
 Called in specific GuiBase children classes to indicate that a value has been changed.
 
OnValidateChangeCallbackFunc OnValidateChange
 Called in specific GuiBase children classes to indicate that a value has been changed.
 
GUI_RECT rect
 The display rect this GUI element will use.
 
void * userData
 Custom user data.
 
void * userData2
 Custom user data.
 
unsigned int customMagnification
 The magnification to display this element at.
 
OnHoverChangeCallbackFunc OnHoverChange
 Called in specific GuiBase children classes to indicate that the GUI element is being hovered over.
 
bool has_special_mouse_processing
 Has special mouse processing.
 
GUI_RECT hotspot_rect
 The special hotspot rect.
 
bool has_special_hotspot_rect
 Has special hotspot rect; If true, 'process' will be called everytime the mouse is inside of 'hotspot_rect' instead of 'rect'.
 

Protected Member Functions

void resizeTextSize ()
 Resize the text size.
 
- Protected Member Functions inherited from GuiBase
void Link ()
 Link ourselves to the global GUI element linkage.
 
void Unlink ()
 Unlink ourselves from the global GUI element linkage.
 

Additional Inherited Members

- Static Public Attributes inherited from GuiBase
static unsigned int defaultCustomMagnification
 
static GuiBasegFirst
 

Detailed Description

Show a text input box.

Member Typedef Documentation

◆ ValidateInputCallbackFunc

typedef bool(* TextInputInfo::ValidateInputCallbackFunc) (TextInputInfo *pTextInput, const char *pValue, char pValidateOutput[1024])

Func callback for validating input.

Parameters
pTextInputThe GUI element.
pValueThe value the user entered.
pValidateOutputA buffer that this function should populate with the validated output.
Returns
Returns true if pValidateOutput shouldn't be used, false if it should be used.

Member Enumeration Documentation

◆ CANCEL_KEY_TYPE

Cancel key types.

Enumerator
ENTER 

Enter button todo: Make pressing enter call a callback.

ESCAPE 

Escape button.

MOUSE_BUTTON 

Mouse button (clicked outside of the input box)

Member Function Documentation

◆ calculate()

virtual void TextInputInfo::calculate ( )
virtual

Re-calculate this element's data.

Warning
You should ALWAYS call this at least once BEFORE you call render()!

Implements GuiBase.

◆ getClassName()

virtual const char* TextInputInfo::getClassName ( )
inlinevirtual

Get this class' name.

Returns
Should return the name of this class.

Reimplemented from GuiBase.

◆ getFont()

virtual FontObject* TextInputInfo::getFont ( )
inlinevirtual

Get the font for this GUI element.

Returns
Returns the font object for this element.

Reimplemented from GuiBase.

◆ getHoverableCount()

virtual int TextInputInfo::getHoverableCount ( )
inlinevirtual

Get the number of elements that can be hovered over in this element.

Returns
Returns the amount of elements that can be hovered over in this element.

Reimplemented from GuiBase.

◆ getSelectableCount()

virtual int TextInputInfo::getSelectableCount ( )
inlinevirtual

Get the selectable number of elements in this element.

Returns
Returns the amount of selectable elements in this element.

Reimplemented from GuiBase.

◆ getStringOffsetByMouse()

int TextInputInfo::getStringOffsetByMouse ( GUI_POINT  mouse)

Get input offset by mouse position.

Parameters
mouseThe mouse position.
Returns
Returns the index in this input box's value where the mouse position is at

◆ getValue()

const char* TextInputInfo::getValue ( )

Get the value of the inputbox.

Returns
Returns the current inputted value.

◆ isHoverable()

virtual bool TextInputInfo::isHoverable ( )
virtual

Check hoverability status.

Returns
Returns true if this element can be hovered over.

Implements GuiBase.

◆ isHovered()

virtual bool TextInputInfo::isHovered ( )
virtual

Check hover status.

Returns
Returns true if this element is being hovered over.

Implements GuiBase.

◆ isSelected()

virtual bool TextInputInfo::isSelected ( )
virtual

Check selection status.

Returns
Returns true if this element is selected.

Implements GuiBase.

◆ process()

virtual int TextInputInfo::process ( GUI_POINT  mouse)
virtual

Process mouse input for this element.

Returns
Returns ProcessReturnType flags.
See also
ProcessReturnType

Implements GuiBase.

◆ processKeys()

virtual int TextInputInfo::processKeys ( )
virtual

Process key input for this element.

Returns
Returns ProcessReturnType flags.
See also
ProcessReturnType

Reimplemented from GuiBase.

◆ SelectOnMouseUp()

virtual bool TextInputInfo::SelectOnMouseUp ( )
inlinevirtual

Select on mouse up.

Returns
Return false if you want this element to be selected on mousedown instead of mouseup

Reimplemented from GuiBase.

◆ setFont()

virtual void TextInputInfo::setFont ( FontObject *  pFont)
virtual

Set the font for this element.

Parameters
pFontThe font to use.

Reimplemented from GuiBase.

◆ setHovered()

virtual void TextInputInfo::setHovered ( int  value)
virtual

Set this GUI element as hovered over or not.

Parameters
valueThe hover value.

Implements GuiBase.

◆ setSelected()

virtual void TextInputInfo::setSelected ( int  value)
virtual

Set this GUI element as selected or not.

Parameters
valueThe selection value.

Implements GuiBase.

◆ setValue()

void TextInputInfo::setValue ( const char *  value,
bool  bUseCallback = true 
)

Set the value of the inputbox.

Parameters
bUseCallbackUse the OnValueChange callback.
valueThe new value.

◆ startInput()

void TextInputInfo::startInput ( GUI_POINT  mouse = GUI_POINT(0, 0))

Set this inputbox as 'focused', and start inputting text.

Parameters
mouseThe mouse's position. Used for selecting an initial place in the textbox to start inputting text at

Member Data Documentation

◆ ValidateInput

ValidateInputCallbackFunc TextInputInfo::ValidateInput

Called when text is finalized (by pressing enter, cancel or clicking outside of the input box).

Should validate the text. Can be NULL.


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