Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

key_menu.H

Go to the documentation of this file.
00001 #ifndef KEY_MENU_H_IS_INCLUDED
00002 #define KEY_MENU_H_IS_INCLUDED
00003 
00004 /*!
00005  *  \file key_menu.H
00006  *  \brief Contains the definition of the KeyMenu class.
00007  *
00008  *  \sa key_menu.C
00009  *
00010  */
00011 
00012 #include <iostream>
00013 #include <vector>
00014 #include <string>
00015 
00016 #include "geom/fsa.H"
00017 #include "geom/geom.H"
00018 
00019 struct KeyMenuItem;
00020 
00021 /*!
00022  *  \brief An Interactor that provides a menu of operations that can be
00023  *  triggered by pressing a single key on the keyboard.
00024  *
00025  *  Each key/operation pair also has a corresponding description so that the
00026  *  menu can be displayed to a standard output stream.
00027  *
00028  */
00029 class KeyMenu : public Interactor<KeyMenu, Event, State> {
00030    
00031    public:
00032    
00033       typedef int (*key_callback_t)(const Event&, State *&);
00034    
00035       KeyMenu(State *start_in);
00036       
00037       //! \brief Add a single key/operation pair to the menu.
00038       void add_menu_item(char key, const std::string &desc, key_callback_t cb);
00039       //! \brief Add multiple keys all with the same operation and description.
00040       void add_menu_item(const char *keys, const std::string &desc, key_callback_t cb);
00041       
00042       //! \brief Remove a single key/operation pair from the menu.
00043       void remove_menu_item(char key);
00044       //! \brief Remove multiple key/operation pairs from the menu.
00045       void remove_menu_item(const char *keys);
00046       
00047       //! \brief Get the description for the supplied key.
00048       std::string get_item_desc(char key);
00049       
00050       //! \brief Display the menu to the supplied output stream.
00051       void display_menu(std::ostream &out);
00052    
00053    private:
00054    
00055       State *start;
00056       State button_down;
00057       
00058       std::vector<KeyMenuItem> menu_items;
00059 
00060 };
00061 
00062 #endif // KEY_MENU_H_IS_INCLUDED

Generated on Mon Sep 18 11:39:31 2006 for jot by  doxygen 1.4.4