| [f0f9a6] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [f0f9a6] | 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | /*
 | 
|---|
 | 9 |  * TxMenuLeaveAction.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  *  Created on: Nov 8, 2010
 | 
|---|
 | 12 |  *      Author: heber
 | 
|---|
 | 13 |  */
 | 
|---|
 | 14 | 
 | 
|---|
 | 15 | // include config.h
 | 
|---|
 | 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 17 | #include <config.h>
 | 
|---|
 | 18 | #endif
 | 
|---|
 | 19 | 
 | 
|---|
| [ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| [f0f9a6] | 21 | 
 | 
|---|
 | 22 | #include "Actions/Action.hpp"
 | 
|---|
| [3139b2] | 23 | #include "Actions/ActionTrait.hpp"
 | 
|---|
| [f0f9a6] | 24 | #include "Menu/TextMenu/TxMenuLeaveAction.hpp"
 | 
|---|
| [ad011c] | 25 | #include "CodePatterns/Assert.hpp"
 | 
|---|
| [f0f9a6] | 26 | 
 | 
|---|
| [ce7fdc] | 27 | using namespace MoleCuilder;
 | 
|---|
 | 28 | 
 | 
|---|
| [f0f9a6] | 29 | /** Constructor for class TxMenu::LeaveAction.
 | 
|---|
 | 30 |  * \param _menu pointer to the containing TxMenu
 | 
|---|
| [3139b2] | 31 |  * \param &LeaveActionTrait ActionTrait for this Action
 | 
|---|
| [f0f9a6] | 32 |  */
 | 
|---|
| [3139b2] | 33 | TxMenu::LeaveAction::LeaveAction(TxMenu* const _menu, const ActionTrait & LeaveActionTrait) :
 | 
|---|
| [f0f9a6] | 34 |   Action(LeaveActionTrait, true),
 | 
|---|
 | 35 |   menu(_menu)
 | 
|---|
 | 36 | {}
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 | /** Destructor for class TxMenu::LeaveAction.
 | 
|---|
 | 39 |  *
 | 
|---|
 | 40 |  */
 | 
|---|
 | 41 | TxMenu::LeaveAction::~LeaveAction(){}
 | 
|---|
 | 42 | 
 | 
|---|
 | 43 | /** We can't undo the leave action.
 | 
|---|
 | 44 |  * \return false
 | 
|---|
 | 45 |  */
 | 
|---|
 | 46 | bool TxMenu::LeaveAction::canUndo(){
 | 
|---|
 | 47 |   return false;
 | 
|---|
 | 48 | }
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | /** We should never undo the leave action.
 | 
|---|
 | 51 |  * \return false
 | 
|---|
 | 52 |  */
 | 
|---|
 | 53 | bool TxMenu::LeaveAction::shouldUndo(){
 | 
|---|
 | 54 |   return false;
 | 
|---|
 | 55 | }
 | 
|---|
 | 56 | 
 | 
|---|
 | 57 | /** Internal function to obtain parameters from a storage.
 | 
|---|
 | 58 |  * We do not use this one as we don't need any parameters.
 | 
|---|
 | 59 |  */
 | 
|---|
 | 60 | void TxMenu::LeaveAction::getParametersfromValueStorage()
 | 
|---|
 | 61 | {}
 | 
|---|
 | 62 | 
 | 
|---|
 | 63 | /** Internal function to construct the dialog.
 | 
|---|
 | 64 |  * We do not need this function as there is no dialog to construct.
 | 
|---|
 | 65 |  */
 | 
|---|
 | 66 | Dialog* TxMenu::LeaveAction::fillDialog(Dialog *dialog){
 | 
|---|
 | 67 |   ASSERT(dialog,"No Dialog given when filling action dialog");
 | 
|---|
 | 68 |   return dialog;
 | 
|---|
 | 69 | }
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 | /** Calls TxMenu::doQuit() on the stored menu reference.
 | 
|---|
 | 72 |  * \return ActionState pointer with success
 | 
|---|
 | 73 |  */
 | 
|---|
 | 74 | Action::state_ptr TxMenu::LeaveAction::performCall(){
 | 
|---|
 | 75 |   menu->doQuit();
 | 
|---|
 | 76 |   return Action::success;
 | 
|---|
 | 77 | }
 | 
|---|
 | 78 | 
 | 
|---|
 | 79 | /** Implementation of undo function for an Action.
 | 
|---|
 | 80 |  * We do not use this functionality.
 | 
|---|
 | 81 |  * \return ActionState pointer with failure
 | 
|---|
 | 82 |  */
 | 
|---|
 | 83 | Action::state_ptr TxMenu::LeaveAction::performUndo(Action::state_ptr){
 | 
|---|
 | 84 |   ASSERT(0,"Cannot undo leaving a menu");
 | 
|---|
 | 85 |   return Action::failure;
 | 
|---|
 | 86 | }
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 | /** Implementation of redo function for an Action.
 | 
|---|
 | 89 |  * We do not use this functionality.
 | 
|---|
 | 90 |  * \return ActionState pointer with failure
 | 
|---|
 | 91 |  */
 | 
|---|
 | 92 | Action::state_ptr TxMenu::LeaveAction::performRedo(Action::state_ptr){
 | 
|---|
 | 93 |   ASSERT(0,"Cannot redo leaving a menu");
 | 
|---|
 | 94 |   return Action::failure;
 | 
|---|
 | 95 | }
 | 
|---|