Bugz Door Project
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
door::Menu Class Reference
Inheritance diagram for door::Menu:
Inheritance graph
[legend]
Collaboration diagram for door::Menu:
Collaboration graph
[legend]

Public Member Functions

 Menu (int x, int y, int width)
 Construct a new Menu object. More...
 
 Menu (int width)
 Construct a new Menu:: Menu object. More...
 
 Menu (const Menu &)=delete
 
 Menu (Menu &&)
 
void addSelection (char c, const char *line)
 
void addSelection (char c, const char *line, updateFunction update)
 This allows for menus with updater functions. More...
 
void defaultSelection (int d)
 
void setRender (bool selected, renderFunction render)
 
int choose (Door &door)
 
char which (int d)
 
- Public Member Functions inherited from door::Panel
 Panel (int x, int y, int width)
 
 Panel (int width)
 
 Panel (Panel &)=delete
 
 Panel (Panel &&ref)
 
void set (int x, int y)
 Set the panels X and Y screen position. More...
 
void get (int &x, int &y)
 
void setTitle (std::unique_ptr< Line > T, int off=1)
 
void setStyle (BorderStyle bs)
 
void setColor (ANSIColor c)
 
int getWidth (void)
 
int getHeight (void)
 
void hide (void)
 
void show (void)
 
void addLine (std::unique_ptr< Line > l)
 
bool update (Door &d)
 Updates a panel. More...
 
void update (Door &d, int line)
 
void update (void)
 
door::Goto gotoEnd (void)
 
std::unique_ptr< Linespacer_line (bool single)
 Create a spacer line using block drawing characters. More...
 
void lineSetBack (ANSIColor back)
 Set background of all lines in the panel. More...
 

Static Public Member Functions

static renderFunction makeRender (ANSIColor c1, ANSIColor c2, ANSIColor c3, ANSIColor c4)
 

Static Public Attributes

static renderFunction defaultSelectedRender
 
static renderFunction defaultUnselectedRender
 

Private Attributes

unsigned int chosen
 
std::vector< char > options
 
renderFunction selectedRender
 
renderFunction unselectedRender
 

Additional Inherited Members

- Protected Attributes inherited from door::Panel
int x
 
int y
 
int width
 
BorderStyle border_style
 
ANSIColor border_color
 
std::vector< std::unique_ptr< Line > > lines
 
bool hidden
 
bool shown_once
 
std::unique_ptr< Linetitle
 
int offset
 

Detailed Description

Examples
menu-example.cpp.

Constructor & Destructor Documentation

◆ Menu() [1/2]

door::Menu::Menu ( int  x,
int  y,
int  width 
)

Construct a new Menu object.

Set the x, y screen location for the start of the menu, and the width. The location can be changed via Panel::set

Parameters
x
y
width

◆ Menu() [2/2]

door::Menu::Menu ( int  width)

Construct a new Menu:: Menu object.

This creates a panel with a default width. The location needs to be changed Panel::set

Parameters
width

Member Function Documentation

◆ addSelection()

void door::Menu::addSelection ( char  c,
const char *  line,
updateFunction  update 
)

This allows for menus with updater functions.

Note: The update function only needs to update just the line text. We wrap it with another updateFuntion to append the "[M] " part.

Parameters
c
line
update

◆ choose()

int door::Menu::choose ( Door door)
Todo:
Fix this, so it only updates the lines that have been changed when the user selects something. Also, add the "Up/Down Move" maybe to the bottom?

Needs timeout.

Should we return the index offset, or return the actual char? (Like in the case of Quit or Help?)

Parameters
door
Returns
int
Examples
menu-example.cpp.

◆ makeRender()

renderFunction door::Menu::makeRender ( ANSIColor  c1,
ANSIColor  c2,
ANSIColor  c3,
ANSIColor  c4 
)
static

make Render function for menus

[O] Menu Item Text

"[" and "]" are in c1, the "O" in c2

"Menu Item Text" upper case letters are in c3, everything else c4.

Member Data Documentation

◆ defaultSelectedRender

renderFunction door::Menu::defaultSelectedRender
static
Initial value:

◆ defaultUnselectedRender

renderFunction door::Menu::defaultUnselectedRender
static

The documentation for this class was generated from the following files:
door::ATTR::BOLD
@ BOLD
BOLD is the same as BRIGHT.
door::COLOR::YELLOW
@ YELLOW
YELLOW (3)
door::COLOR::WHITE
@ WHITE
WHITE (7)
door::Menu::makeRender
static renderFunction makeRender(ANSIColor c1, ANSIColor c2, ANSIColor c3, ANSIColor c4)
Definition: panel.cpp:712
door::COLOR::BLUE
@ BLUE
BLUE (4)