Ignore:
Timestamp:
Dec 4, 2010, 11:42:38 PM (14 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
f0f9a6
Parents:
0af7ef
git-author:
Frederik Heber <heber@…> (11/08/10 10:31:40)
git-committer:
Frederik Heber <heber@…> (12/04/10 23:42:38)
Message:

Added documentation on the new menu structure.

Location:
src/UIElements/Menu/TextMenu
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Menu/TextMenu/TextMenu.hpp

    r0af7ef r8f3f40  
    2525
    2626/** TextMenu is a specialization of MenuInterface to access TxMenu-like menus.
     27 *
     28 * Basically, this class is to be used in the MainWindow class of the TextUI.
     29 * There, we simply instantiate the class and call init() in order to add all
     30 * MenuItem's from MenuDescriptions and Action's ActionRegistry.
     31 *
    2732 * \sa QtMenu.
    2833 */
     
    3136{
    3237public:
     38  /** Constructor for class TextMenu.
     39   * Initializes outputter and token and takes note whether to delete the
     40   * MenuInstance or not.
     41   */
    3342  TextMenu(std::ostream &_outputter, const std::string &_token) :
    3443    MenuInterface(_token),
     
    4655  {}
    4756
     57  /** Destructor of MenuInstance.
     58   *
     59   */
    4860  virtual ~TextMenu()
    4961  {
     
    5264  }
    5365
     66  /** Display this MenuInstance.
     67   *
     68   */
    5469  void display()
    5570  {
     
    5772  }
    5873
     74  /** Returns a pointer to the contained/wrapped MenuInstance.
     75   * \return pointer to template class pointer
     76   */
    5977  T * const getMenuInstance()
    6078  {
     
    6280  }
    6381
     82  /** Reserves a specific trigger key such that it is not used during init().
     83   * \param trigger trigger key
     84   * \param &name token given for reference.
     85   */
    6486  void reserveShortcut(char trigger, const std::string &name)
    6587  {
     
    78100  MenuShortcutMap ShortcutMap;
    79101
     102  /** Adds an ActionItem by simply creating a new one.
     103   * \param &token token of Action (token in ActionRegistry)
     104   * \param &description descriptive text to be shown
     105   */
    80106  virtual void addActionItem(const std::string &token, const std::string &description)
    81107  {
     
    83109  }
    84110
     111  /** Adds a (dead) separator item.
     112   *
     113   */
    85114  virtual void addSeparatorItem()
    86115  {
     
    88117  }
    89118
     119  /** Adds a Menu to this current Menu.
     120   * We also create here a leave action for this submenu to be able to return
     121   * to the current one again
     122   * \param &token token of the menu
     123   * \param &description descriptive text
     124   */
    90125  virtual void addSubmenuItem(const std::string &token, const std::string &description)
    91126  {
     
    102137  }
    103138
     139  /** Return the next available trigger key suitable to this name.
     140   * This function is used internally to make sure that each key is unique to
     141   * each Action/Menu. The chosen trigger key is also stored in an internal ShortcutMap.
     142   * \param &name text shown in menu
     143   * \return trigger key
     144   */
    104145  char getSuitableShortForm(const std::string &name)
    105146  {
  • src/UIElements/Menu/TextMenu/TxMenu.cpp

    r0af7ef r8f3f40  
    3131
    3232
    33 /**
     33/** Constructor for class TxMenu.
     34 *
    3435 * produce a text menu with a given title.
    3536 * The text will later be displayed using the stream passed to the constructor.
     37 * \param &_outputter output stream to use for displaying the text
     38 * \param _title title of this menu
     39 * \param _spacer key to separate trigger key from descriptive text shown
     40 * \param _length maximum length of the descriptive text
    3641 */
    3742TxMenu::TxMenu(std::ostream& _outputter, const std::string _title, char _spacer,int _length) :
     
    4550}
    4651
     52/** Destructor for class TxMenu.
     53 *
     54 */
    4755TxMenu::~TxMenu()
    4856{
     
    5159}
    5260
     61/** Adds an MenuItem to the internal list.
     62 * \param *item item to add
     63 */
    5364void TxMenu::addItem(MenuItem* item) {
    5465  items.push_back(item);
    5566}
    5667
     68/** Removes an MenuItem to the internal list.
     69 * \param *item item to remove
     70 */
    5771void TxMenu::removeItem(MenuItem* item) {
    5872  items.remove(item);
    5973}
    6074
     75/** Function to quit this TxMenu.
     76 */
    6177void TxMenu::doQuit(){
    6278  quit = true;
    6379}
    6480
     81/** Return the current state of quitting.
     82 * \return quit boolean
     83 */
    6584bool TxMenu::hasQuit(){
    6685  return quit;
    6786}
    6887
     88/** Display in a formatted manner a given entry of this menu.
     89 * \param *entry MenuItem to show
     90 */
    6991void TxMenu::showEntry(MenuItem* entry){
    7092  if(entry->isActive()==false){
     
    78100}
    79101
     102/** Display this menu.
     103 *
     104 */
    80105void TxMenu::display() {
    81106  char choice;
     
    114139}
    115140
     141/**  Return the internally stored title of the menu.
     142 * \return title string
     143 */
    116144std::string TxMenu::getTitle(){
    117145  return title;
    118146}
    119147
     148/**  Return the internally stored outputter of the menu.
     149 * \return output stream reference
     150 */
    120151std::ostream& TxMenu::getOutputter()
    121152{
     
    123154}
    124155
    125 
     156/** Add a default item to the menu.
     157 * \param *_defaultItem MenuItem to act as default item.
     158 */
    126159void TxMenu::addDefault(MenuItem* _defaultItem) {
    127160  defaultItem = _defaultItem;
     
    130163/****************************** Contained Actions ****************/
    131164
     165/** Constructor for class TxMenu::LeaveAction.
     166 * \param _menu pointer to the containing TxMenu
     167 * \param &LeaveActionTrait ActionTraits for this Action
     168 */
    132169TxMenu::LeaveAction::LeaveAction(TxMenu* const _menu, const ActionTraits & LeaveActionTrait) :
    133170  Action(LeaveActionTrait, true),
     
    135172{}
    136173
     174/** Destructor for class TxMenu::LeaveAction.
     175 *
     176 */
    137177TxMenu::LeaveAction::~LeaveAction(){}
    138178
     179/** We can't undo the leave action.
     180 * \return false
     181 */
    139182bool TxMenu::LeaveAction::canUndo(){
    140183  return false;
    141184}
    142185
     186/** We should never undo the leave action.
     187 * \return false
     188 */
    143189bool TxMenu::LeaveAction::shouldUndo(){
    144190  return false;
    145191}
    146192
     193/** Internal function to obtain parameters from a storage.
     194 * We do not use this one as we don't need any parameters.
     195 */
    147196void TxMenu::LeaveAction::getParametersfromValueStorage()
    148197{}
    149198
     199/** Internal function to construct the dialog.
     200 * We do not need this function as there is no dialog to construct.
     201 */
    150202Dialog* TxMenu::LeaveAction::fillDialog(Dialog *dialog){
    151203  ASSERT(dialog,"No Dialog given when filling action dialog");
     
    153205}
    154206
    155 
     207/** Calls TxMenu::doQuit() on the stored menu reference.
     208 * \return ActionState pointer with success
     209 */
    156210Action::state_ptr TxMenu::LeaveAction::performCall(){
    157211  menu->doQuit();
     
    159213}
    160214
    161 
     215/** Implementation of undo function for an Action.
     216 * We do not use this functionality.
     217 * \return ActionState pointer with failure
     218 */
    162219Action::state_ptr TxMenu::LeaveAction::performUndo(Action::state_ptr){
    163220  ASSERT(0,"Cannot undo leaving a menu");
    164   return Action::success;
    165 }
    166 
     221  return Action::failure;
     222}
     223
     224/** Implementation of redo function for an Action.
     225 * We do not use this functionality.
     226 * \return ActionState pointer with failure
     227 */
    167228Action::state_ptr TxMenu::LeaveAction::performRedo(Action::state_ptr){
    168229  ASSERT(0,"Cannot redo leaving a menu");
    169   return Action::success;
    170 }
     230  return Action::failure;
     231}
  • src/UIElements/Menu/TextMenu/TxMenu.hpp

    r0af7ef r8f3f40  
    2020class MenuItem;
    2121
    22 /**
    23  * Used to produce any kind of text menu
     22/** Menu for the TextUI.
    2423 *
    25  * All Items are displayed and user is prompted for a key. The item corresponding to that key is then activated.
     24 * Used to produce any kind of text menu. This is a generic text menu user
     25 * interface, i.e. we have a list of MenuItem's, which can either be
     26 * -# Action's
     27 * -# Displayers
     28 * -# Separators
     29 * -# other Menu's
     30 *
     31 * In this manner we have a tree structure, the (sub)menus generating new
     32 * branches, the rest making up the leaves.
     33 *
     34 * All Items are displayed via a given output stream and user is prompted
     35 * for a key. The item corresponding to that key is then activated.
    2636 */
    2737class TxMenu
    2838{
    2939public:
     40  /** This specific action is used to leave a submenu and return to an upper one.
     41   * It differs from other Action's (and thus cannot be put into the usual
     42   * structure) that we have to store the reference to the menu it belongs to.
     43   * There, we call the doQuit() member function on performCall().
     44   */
    3045  class LeaveAction : public Action {
    3146  public:
Note: See TracChangeset for help on using the changeset viewer.