//note: in progress. #ifndef MENU_BASE_CLASS #define MENU_BASE_CLASS /*****************************************************************************\ * * * Name : menu_base * * Author : Chris Koeritz * * * ******************************************************************************* * Copyright (c) 2003-$now By Author. This program is free software; you can * * redistribute it and/or modify it under the terms of the GNU General Public * * License as published by the Free Software Foundation; either version 2 of * * the License or (at your option) any later version. This is online at: * * http://www.fsf.org/copyleft/gpl.html * * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ #include // forward. class menu_common_amorph; ////////////// //! a common base class for referring to menu_items or menus polymorphically. class menu_common_base : public virtual root_object { public: virtual ~menu_common_base(); bool enabled() const { return _enabled; } void enable(bool enable = true) { _enabled = enable; } private: bool _enabled; //!< is this object enabled? }; ////////////// //! A base class for the active items that can be stored inside a menu. class menu_item : public menu_common_base { public: menu_item(const string_array &triggers, const astring &text, const astring &description); //!< constructs a menu item that shows the "text" and "description". /*!< the "triggers" is a list of characters that are used to activate this menu item. these correspond to hot keys that are often underlined. */ menu_item(const menu_item &to_copy); virtual ~menu_item(); menu_item &operator =(const menu_item &to_copy); DEFINE_CLASS_NAME("menu_item"); const string_array &triggers() const; const astring &text() const; const astring &description() const; virtual void menu_activation(char trigger); //!< invoked when the user chooses the menu item in question. /*!< the "trigger" holds the value that they actually chose. */ private: string_array *_triggers; //!< the trigger values for this menu item. astring *_text; //!< the text shown for this item. astring *_description; //!< the full description of the item. }; ////////////// //! A base class for a menu-driven interface model. /*! The base just provides functions for manipulating menu items and submenus. */ class menu_base : public menu_common_base { public: menu_base(const astring &title, const menu_item ¶meters); //