nsnake
Classic snake game for the terminal
MenuItemLabel.cpp
1 #include <Interface/Menu/MenuItemLabel.hpp>
2 #include <Config/Globals.hpp>
3 
4 MenuItemLabel::MenuItemLabel(std::string label, int id, std::string rightLabel):
5  MenuItem(label, id),
6  rightLabel(rightLabel)
7 {
8  this->type = MenuItem::LABEL;
9 }
10 
11 void MenuItemLabel::draw(Window* window, int x, int y, int width, bool hilite)
12 {
13  unsigned int rightLabelSize = this->rightLabel.size();
14 
15  MenuItem::draw(window, x, y, width - rightLabelSize - 1, hilite);
16 
17  window->print(this->rightLabel,
18  x + width - rightLabelSize,
19  y,
20  ((hilite) ?
21  Globals::Theme::hilite_text:
22  Globals::Theme::text));
23 }
24 
26 { }
27 
28 void MenuItemLabel::set(std::string str)
29 {
30  this->rightLabel = str;
31 }
32 
MenuItemType type
Specific type of this widget.
Definition: MenuItem.hpp:51
A segment of the terminal screen (2D char matrix).
Definition: Window.hpp:16
Simplest type of item possible, with a label and user-defined id.
Definition: MenuItem.hpp:11
void handleInput()
Makes the menu item react to input, as seen on the global InputManager.
virtual void draw(Window *window, int x, int y, int width, bool hilite=false)
Shows this item at #x, #y with #width.
Definition: MenuItem.cpp:12
void draw(Window *window, int x, int y, int width, bool hilite=false)
Shows this item at #x, #y with #width.
void print(std::string str, int x, int y, ColorPair pair=0)
Shows text #str at #x #y on the window with color #pair.
Definition: Window.cpp:94