Ignore:
Timestamp:
Dec 16, 2009, 2:40:09 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
38546d
Parents:
c2c893
Message:

Improved documentation for menu framework.

Location:
molecuilder/src/Menu
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/Menu/ActionMenuItem.hpp

    rc2c893 rda09909  
    1515class Action;
    1616
     17/**
     18 * Produce MenuItems that take an appropriate action when called.
     19 */
    1720class ActionMenuItem : public MenuItem
    1821{
     
    2427
    2528private:
    26   Action* action;
     29  Action* action; //!< this action will be called when the trigger matches
    2730};
    2831
  • molecuilder/src/Menu/DisplayMenuItem.hpp

    rc2c893 rda09909  
    1414class StringView;
    1515
     16/**
     17 * Display any kind of StringView within a Menu
     18 *
     19 * Any trigger are ignored for this type of Item
     20 */
    1621class DisplayMenuItem : public MenuItem
    1722{
  • molecuilder/src/Menu/Menu.hpp

    rc2c893 rda09909  
    1313class MenuItem;
    1414
     15/**
     16 * Base class for all Types of menus
     17 * contains basic abstract functionality to add Items, remove Items and display the menu
     18 *
     19 * TODO: Make sure all items are only added once.
     20 */
    1521class Menu
    1622{
     
    1925  virtual ~Menu();
    2026
     27
     28  /**
     29   * Adding and removing should be handled by the items.
     30   */
    2131  virtual void addItem(MenuItem*)=0;
     32  /**
     33   * Adding and removing should be handled by the items.
     34   */
    2235  virtual void removeItem(MenuItem*)=0;
    2336  virtual void display()=0;
  • molecuilder/src/Menu/MenuItem.cpp

    rc2c893 rda09909  
    1313#include <iostream>
    1414
     15/**
     16 * produce a new MenuItem using with a description and a trigger.
     17 * The MenuItem is then added to the menu passed to it.
     18 */
    1519MenuItem::MenuItem(char _trigger, const char* _description,Menu* menu) :
    1620trigger(_trigger),
     
    2630}
    2731
     32/**
     33 * check if the trigger matches and call doTrigger if it does.
     34 */
    2835void MenuItem::checkTrigger(char key) {
    2936  if(key == trigger)
     
    3946}
    4047
     48/**
     49 * Produce a formated output of this item containing trigger and description
     50 * Normal format is: "<trigger> - <description>"
     51 */
    4152const string MenuItem::formatEntry(){
    4253  stringstream s;
     
    4657}
    4758
     59
     60/**
     61 * check if this item is within a menu and add to menu if it is not yet contained anywhere
     62 *
     63 * TODO: include funtionality to move Items from one menu to another
     64 */
    4865void MenuItem::add_to_menu(Menu* menu) {
    4966  if(!wasAdded()) {
  • molecuilder/src/Menu/MenuItem.hpp

    rc2c893 rda09909  
    1515class Menu;
    1616
     17/**
     18 * Base class for all kinds of MenuItems
     19 *
     20 * This class takes care of checking the triggers and performing appropriate actions.
     21 */
    1722class MenuItem {
    1823private:
  • molecuilder/src/Menu/SeperatorItem.hpp

    rc2c893 rda09909  
    1111#include "Menu/MenuItem.hpp"
    1212
     13/**
     14 * Produce a Seperator within a Menu.
     15 *
     16 * All triggers are ignored for this Item.
     17 */
    1318class SeperatorItem : public MenuItem
    1419{
  • molecuilder/src/Menu/TextMenu.cpp

    rc2c893 rda09909  
    99#include <iostream>
    1010#include <cmath>
    11 #include "defs.hpp"
    1211#include "Menu/TextMenu.hpp"
    1312#include "Menu/MenuItem.hpp"
    1413
     14
     15/**
     16 * produce a text menu with a given title.
     17 * The text will later be displayed using the stream passed to the constructor.
     18 */
    1519TextMenu::TextMenu(ostream& _outputter, string _title, char _spacer,int _length) :
    1620outputter(_outputter),
     
    1822spacer(_spacer),
    1923length(_length),
    20 quit(false)
    21 {
    22 }
    23 
    24 TextMenu::TextMenu(ostream& _outputter, string _title) :
    25 outputter(_outputter),
    26 title(_title),
    27 spacer(STD_MENU_TITLE_SPACER),
    28 length(STD_MENU_LENGTH),
    2924quit(false)
    3025{
  • molecuilder/src/Menu/TextMenu.hpp

    rc2c893 rda09909  
    1414
    1515#include "Menu/Menu.hpp"
     16#include "defs.hpp"
    1617
    1718class MenuItem;
    1819
     20/**
     21 * Used to produce any kind of text menu
     22 *
     23 * All Items are displayed and user is prompted for a key. The item corresponding to that key is then activated.
     24 */
    1925class TextMenu : public Menu
    2026{
    2127public:
    22   TextMenu(ostream&,string,char,int);
    23   TextMenu(ostream&,string);
     28  TextMenu(ostream& _outputter, string _title, char _spacer=STD_MENU_TITLE_SPACER,int _length=STD_MENU_LENGTH);
    2429  virtual ~TextMenu();
    2530
     
    2833  virtual void display();
    2934
     35  /**
     36   * Call doQuit if you want to return from this menu.
     37   */
    3038  virtual void doQuit();
     39  /**
     40   * Check wether someone has chosen to quit
     41   */
    3142  virtual bool hasQuit();
    3243
Note: See TracChangeset for help on using the changeset viewer.