nsnake
Classic snake game for the terminal
Public Member Functions | Public Attributes | List of all members
MenuItemNumberbox Struct Reference

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

#include <MenuItemNumberbox.hpp>

Inheritance diagram for MenuItemNumberbox:
Inheritance graph
[legend]
Collaboration diagram for MenuItemNumberbox:
Collaboration graph
[legend]

Public Member Functions

 MenuItemNumberbox (std::string label, int id, int min, int max, int initial, int jump=1)
 Create a new number box. More...
 
void draw (Window *window, int x, int y, int width, bool hilite=false)
 Shows this item at #x, #y with #width. More...
 
void handleInput ()
 Makes the menu item react to input, as seen on the global InputManager. More...
 
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. More...
 

Public Attributes

int min
 
int max
 
int initial
 
int current
 
int jump
 
- Public Attributes inherited from MenuItem
MenuItemType type
 Specific type of this widget. More...
 
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 ( 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.

Member Function Documentation

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.

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.


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