nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
MenuItemNumberbox Struct Reference

Allows to select a number, kinda like a slider. More...

#include <MenuItemNumberbox.hpp>

Inheritance diagram for MenuItemNumberbox:
Collaboration diagram for MenuItemNumberbox:

Public Member Functions

 MenuItemNumberbox (std::string label, int id, int min, int max, int initial, int jump=1)
 Create a new number box.
 
void draw (Window *window, int x, int y, int width, bool hilite=false)
 Shows this item at #x, #y with #width.
 
void handleInput ()
 Makes the menu item react to input, as seen on the global InputManager.
 
void increase ()
 
void decrease ()
 
void set (int value)
 
void reset ()
 
- Public Member Functions inherited from MenuItem
 MenuItem (std::string label, int id)
 Create a MenuItem, with user-defined id.
 

Public Attributes

int min
 
int max
 
int initial
 
int current
 
int jump
 
- Public Attributes inherited from MenuItem
MenuItemType type
 Specific type of this widget.
 
std::string label
 Text that will be shown on the screen.
 
int id
 User-defined id to identify this item.
 

Additional Inherited Members

- Public Types inherited from MenuItem
enum  MenuItemType {
  ITEM , LABEL , CHECKBOX , NUMBERBOX ,
  TEXTBOX , TEXTLIST
}
 All possible item types. More...
 

Detailed Description

Allows to select a number, kinda like a slider.

There's a number and by pressing left and right you add or remove units of it.

Note
When you press a number, it will allow you to directly set it for a while. For example, pressing '1', '2' and '3' would set the number first to '1', then to '12' and then to '123'.

Definition at line 17 of file MenuItemNumberbox.hpp.

Constructor & Destructor Documentation

◆ MenuItemNumberbox()

MenuItemNumberbox::MenuItemNumberbox ( std::string label,
int id,
int min,
int max,
int initial,
int jump = 1 )

Create a new number box.

Parameters
labelTextual label on the left of the item
idUnique identifier so the menu can know which item this is
minMinimal allowed value for the number
maxMaximum allowed value for the number
initialInitial value for the number
jumpHow many units will the number jump when user press left or right

Definition at line 7 of file MenuItemNumberbox.cpp.

◆ ~MenuItemNumberbox()

virtual MenuItemNumberbox::~MenuItemNumberbox ( )
inlinevirtual

Definition at line 29 of file MenuItemNumberbox.hpp.

Member Function Documentation

◆ decrease()

void MenuItemNumberbox::decrease ( )

Definition at line 144 of file MenuItemNumberbox.cpp.

◆ draw()

void MenuItemNumberbox::draw ( Window * window,
int x,
int y,
int width,
bool hilite = false )
virtual

Shows this item at #x, #y with #width.

If this is the current item, send #hilite as true.

Note
Yeah, height is always 1.

Reimplemented from MenuItem.

Definition at line 17 of file MenuItemNumberbox.cpp.

◆ handleInput()

void MenuItemNumberbox::handleInput ( )
virtual

Makes the menu item react to input, as seen on the global InputManager.

Each type of MenuItem might react to input differently. A text box might want to show printable characters, a check box might want to check if space bar was pressed, whatever.

When inheriting this, make sure to implement it.

Reimplemented from MenuItem.

Definition at line 57 of file MenuItemNumberbox.cpp.

◆ increase()

void MenuItemNumberbox::increase ( )

Definition at line 139 of file MenuItemNumberbox.cpp.

◆ reset()

void MenuItemNumberbox::reset ( )

Definition at line 149 of file MenuItemNumberbox.cpp.

◆ set()

void MenuItemNumberbox::set ( int value)

Definition at line 134 of file MenuItemNumberbox.cpp.

Member Data Documentation

◆ current

int MenuItemNumberbox::current

Definition at line 43 of file MenuItemNumberbox.hpp.

◆ initial

int MenuItemNumberbox::initial

Definition at line 42 of file MenuItemNumberbox.hpp.

◆ jump

int MenuItemNumberbox::jump

Definition at line 44 of file MenuItemNumberbox.hpp.

◆ max

int MenuItemNumberbox::max

Definition at line 41 of file MenuItemNumberbox.hpp.

◆ min

int MenuItemNumberbox::min

Definition at line 40 of file MenuItemNumberbox.hpp.


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