Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Menu/TextMenu/TxMenu.cpp

    rf0f9a6 rb59da6  
    2424#include <iostream>
    2525#include <cmath>
     26#include "Actions/Action.hpp"
     27#include "Actions/ActionTraits.hpp"
    2628#include "Menu/TextMenu/TxMenu.hpp"
    2729#include "Menu/TextMenu/MenuItem.hpp"
     30#include "Helpers/Assert.hpp"
    2831
    2932
    30 /** Constructor for class TxMenu.
    31  *
     33/**
    3234 * produce a text menu with a given title.
    3335 * The text will later be displayed using the stream passed to the constructor.
    34  * \param &_outputter output stream to use for displaying the text
    35  * \param _title title of this menu
    36  * \param _spacer key to separate trigger key from descriptive text shown
    37  * \param _length maximum length of the descriptive text
    3836 */
    3937TxMenu::TxMenu(std::ostream& _outputter, const std::string _title, char _spacer,int _length) :
     
    4745}
    4846
    49 /** Destructor for class TxMenu.
    50  *
    51  */
    5247TxMenu::~TxMenu()
    5348{
     
    5651}
    5752
    58 /** Adds an MenuItem to the internal list.
    59  * \param *item item to add
    60  */
    6153void TxMenu::addItem(MenuItem* item) {
    6254  items.push_back(item);
    6355}
    6456
    65 /** Removes an MenuItem to the internal list.
    66  * \param *item item to remove
    67  */
    6857void TxMenu::removeItem(MenuItem* item) {
    6958  items.remove(item);
    7059}
    7160
    72 /** Function to quit this TxMenu.
    73  */
    7461void TxMenu::doQuit(){
    7562  quit = true;
    7663}
    7764
    78 /** Return the current state of quitting.
    79  * \return quit boolean
    80  */
    8165bool TxMenu::hasQuit(){
    8266  return quit;
    8367}
    8468
    85 /** Display in a formatted manner a given entry of this menu.
    86  * \param *entry MenuItem to show
    87  */
    8869void TxMenu::showEntry(MenuItem* entry){
    8970  if(entry->isActive()==false){
     
    9778}
    9879
    99 /** Display this menu.
    100  *
    101  */
    10280void TxMenu::display() {
    10381  char choice;
     
    136114}
    137115
    138 /**  Return the internally stored title of the menu.
    139  * \return title string
    140  */
    141116std::string TxMenu::getTitle(){
    142117  return title;
    143118}
    144119
    145 /**  Return the internally stored outputter of the menu.
    146  * \return output stream reference
    147  */
    148120std::ostream& TxMenu::getOutputter()
    149121{
     
    151123}
    152124
    153 /** Add a default item to the menu.
    154  * \param *_defaultItem MenuItem to act as default item.
    155  */
     125
    156126void TxMenu::addDefault(MenuItem* _defaultItem) {
    157127  defaultItem = _defaultItem;
    158128}
    159129
     130/****************************** Contained Actions ****************/
     131
     132TxMenu::LeaveAction::LeaveAction(TxMenu* const _menu, const ActionTraits & LeaveActionTrait) :
     133  Action(LeaveActionTrait, true),
     134  menu(_menu)
     135{}
     136
     137TxMenu::LeaveAction::~LeaveAction(){}
     138
     139bool TxMenu::LeaveAction::canUndo(){
     140  return false;
     141}
     142
     143bool TxMenu::LeaveAction::shouldUndo(){
     144  return false;
     145}
     146
     147void TxMenu::LeaveAction::getParametersfromValueStorage()
     148{}
     149
     150Dialog* TxMenu::LeaveAction::fillDialog(Dialog *dialog){
     151  ASSERT(dialog,"No Dialog given when filling action dialog");
     152  return dialog;
     153}
     154
     155
     156Action::state_ptr TxMenu::LeaveAction::performCall(){
     157  menu->doQuit();
     158  return Action::success;
     159}
     160
     161
     162Action::state_ptr TxMenu::LeaveAction::performUndo(Action::state_ptr){
     163  ASSERT(0,"Cannot undo leaving a menu");
     164  return Action::success;
     165}
     166
     167Action::state_ptr TxMenu::LeaveAction::performRedo(Action::state_ptr){
     168  ASSERT(0,"Cannot redo leaving a menu");
     169  return Action::success;
     170}
Note: See TracChangeset for help on using the changeset viewer.