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

Simplest type of item possible, with a label and user-defined id. More...

#include <MenuItem.hpp>

Inheritance diagram for MenuItem:
Inheritance graph
[legend]

Public Types

enum  MenuItemType {
  ITEM, LABEL, CHECKBOX, NUMBERBOX,
  TEXTBOX, TEXTLIST
}
 All possible item types. More...
 

Public Member Functions

 MenuItem (std::string label, int id)
 Create a MenuItem, with user-defined id. More...
 
virtual void draw (Window *window, int x, int y, int width, bool hilite=false)
 Shows this item at #x, #y with #width. More...
 
virtual void handleInput ()
 Makes the menu item react to input, as seen on the global InputManager. More...
 

Public Attributes

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.
 

Detailed Description

Simplest type of item possible, with a label and user-defined id.

Definition at line 11 of file MenuItem.hpp.

Member Enumeration Documentation

All possible item types.

When inheriting and creating your own, make sure to place it here.

Definition at line 17 of file MenuItem.hpp.

Constructor & Destructor Documentation

MenuItem::MenuItem ( std::string  label,
int  id 
)

Create a MenuItem, with user-defined id.

Note
MenuItems on the same menu should have different id s! If not, results are unpredictable.

Definition at line 6 of file MenuItem.cpp.

Member Function Documentation

void MenuItem::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 in MenuItemNumberbox, MenuItemTextlist, MenuItemCheckbox, MenuItemTextbox, and MenuItemLabel.

Definition at line 12 of file MenuItem.cpp.

void MenuItem::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 in MenuItemNumberbox, MenuItemTextlist, MenuItemCheckbox, MenuItemTextbox, and MenuItemLabel.

Definition at line 19 of file MenuItem.cpp.

Member Data Documentation

MenuItemType MenuItem::type

Specific type of this widget.

Note
It is set on the Constructor, don't change it manually!

Definition at line 51 of file MenuItem.hpp.


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