cmdfx 0.2.1
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
CmdFX::Button Class Reference

A C++ wrapper around the CmdFX_Button struct. More...

#include <button.hpp>

Inheritance diagram for CmdFX::Button:
CmdFX::Switch

Public Member Functions

 Button (CmdFX_Button *btn)
 
 Button (Sprite &sprite, CmdFX_ButtonCallback callback)
 
 Button (int width, int height, char c, char *ansi, int z, CmdFX_ButtonCallback callback)
 
CmdFX_ButtongetButton () const
 
CmdFX_SpritegetSprite () const
 Gets the value of the button's sprite.
 
int draw (int x, int y)
 
int remove ()
 
bool isHidden () const
 
int hide ()
 
int show ()
 
int setData (char **data, char ***ansi)
 
int setData (std::vector< std::string > data, std::vector< std::vector< std::string > > ansi)
 Sets the data for the button using vectors.
 
int moveTo (int x, int y)
 
int moveBy (int dx, int dy)
 

Detailed Description

A C++ wrapper around the CmdFX_Button struct.

This class represents a button in the CmdFX UI system. It provides methods to interact with the button, such as setting data, showing, hiding, and checking if the button is hidden. The button will be freed automatically when the Button object is destroyed.

Member Function Documentation

◆ getSprite()

CmdFX_Sprite * CmdFX::Button::getSprite ( ) const
inline

Gets the value of the button's sprite.

Returns
A pointer to the CmdFX_Sprite associated with this button.

◆ setData()

int CmdFX::Button::setData ( std::vector< std::string > data,
std::vector< std::vector< std::string > > ansi )
inline

Sets the data for the button using vectors.

Parameters
dataA 1D vector of strings representing the data to set for the button.
ansiA 2D vector of strings representing the ANSI escape codes to apply to the data.
Returns
0 if successful, else -1

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