| [f0f9a6] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [94d5ac6] | 5 |  * 
 | 
|---|
 | 6 |  *
 | 
|---|
 | 7 |  *   This file is part of MoleCuilder.
 | 
|---|
 | 8 |  *
 | 
|---|
 | 9 |  *    MoleCuilder is free software: you can redistribute it and/or modify
 | 
|---|
 | 10 |  *    it under the terms of the GNU General Public License as published by
 | 
|---|
 | 11 |  *    the Free Software Foundation, either version 2 of the License, or
 | 
|---|
 | 12 |  *    (at your option) any later version.
 | 
|---|
 | 13 |  *
 | 
|---|
 | 14 |  *    MoleCuilder is distributed in the hope that it will be useful,
 | 
|---|
 | 15 |  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 16 |  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 17 |  *    GNU General Public License for more details.
 | 
|---|
 | 18 |  *
 | 
|---|
 | 19 |  *    You should have received a copy of the GNU General Public License
 | 
|---|
 | 20 |  *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
 | 
|---|
| [f0f9a6] | 21 |  */
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 | /*
 | 
|---|
 | 24 |  * TxMenuLeaveAction.cpp
 | 
|---|
 | 25 |  *
 | 
|---|
 | 26 |  *  Created on: Nov 8, 2010
 | 
|---|
 | 27 |  *      Author: heber
 | 
|---|
 | 28 |  */
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | // include config.h
 | 
|---|
 | 31 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 32 | #include <config.h>
 | 
|---|
 | 33 | #endif
 | 
|---|
 | 34 | 
 | 
|---|
| [ad011c] | 35 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| [f0f9a6] | 36 | 
 | 
|---|
 | 37 | #include "Actions/Action.hpp"
 | 
|---|
| [3139b2] | 38 | #include "Actions/ActionTrait.hpp"
 | 
|---|
| [f0f9a6] | 39 | #include "Menu/TextMenu/TxMenuLeaveAction.hpp"
 | 
|---|
| [ad011c] | 40 | #include "CodePatterns/Assert.hpp"
 | 
|---|
| [f0f9a6] | 41 | 
 | 
|---|
| [ce7fdc] | 42 | using namespace MoleCuilder;
 | 
|---|
 | 43 | 
 | 
|---|
| [f0f9a6] | 44 | /** Constructor for class TxMenu::LeaveAction.
 | 
|---|
 | 45 |  * \param _menu pointer to the containing TxMenu
 | 
|---|
| [3139b2] | 46 |  * \param &LeaveActionTrait ActionTrait for this Action
 | 
|---|
| [f0f9a6] | 47 |  */
 | 
|---|
| [3139b2] | 48 | TxMenu::LeaveAction::LeaveAction(TxMenu* const _menu, const ActionTrait & LeaveActionTrait) :
 | 
|---|
| [f0f9a6] | 49 |   Action(LeaveActionTrait, true),
 | 
|---|
 | 50 |   menu(_menu)
 | 
|---|
 | 51 | {}
 | 
|---|
 | 52 | 
 | 
|---|
 | 53 | /** Destructor for class TxMenu::LeaveAction.
 | 
|---|
 | 54 |  *
 | 
|---|
 | 55 |  */
 | 
|---|
 | 56 | TxMenu::LeaveAction::~LeaveAction(){}
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 | /** We can't undo the leave action.
 | 
|---|
 | 59 |  * \return false
 | 
|---|
 | 60 |  */
 | 
|---|
 | 61 | bool TxMenu::LeaveAction::canUndo(){
 | 
|---|
 | 62 |   return false;
 | 
|---|
 | 63 | }
 | 
|---|
 | 64 | 
 | 
|---|
 | 65 | /** We should never undo the leave action.
 | 
|---|
 | 66 |  * \return false
 | 
|---|
 | 67 |  */
 | 
|---|
 | 68 | bool TxMenu::LeaveAction::shouldUndo(){
 | 
|---|
 | 69 |   return false;
 | 
|---|
 | 70 | }
 | 
|---|
 | 71 | 
 | 
|---|
 | 72 | /** Internal function to construct the dialog.
 | 
|---|
 | 73 |  * We do not need this function as there is no dialog to construct.
 | 
|---|
 | 74 |  */
 | 
|---|
 | 75 | Dialog* TxMenu::LeaveAction::fillDialog(Dialog *dialog){
 | 
|---|
 | 76 |   ASSERT(dialog,"No Dialog given when filling action dialog");
 | 
|---|
 | 77 |   return dialog;
 | 
|---|
 | 78 | }
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | /** Calls TxMenu::doQuit() on the stored menu reference.
 | 
|---|
 | 81 |  * \return ActionState pointer with success
 | 
|---|
 | 82 |  */
 | 
|---|
 | 83 | Action::state_ptr TxMenu::LeaveAction::performCall(){
 | 
|---|
 | 84 |   menu->doQuit();
 | 
|---|
 | 85 |   return Action::success;
 | 
|---|
 | 86 | }
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 | /** Implementation of undo function for an Action.
 | 
|---|
 | 89 |  * We do not use this functionality.
 | 
|---|
 | 90 |  * \return ActionState pointer with failure
 | 
|---|
 | 91 |  */
 | 
|---|
 | 92 | Action::state_ptr TxMenu::LeaveAction::performUndo(Action::state_ptr){
 | 
|---|
 | 93 |   ASSERT(0,"Cannot undo leaving a menu");
 | 
|---|
 | 94 |   return Action::failure;
 | 
|---|
 | 95 | }
 | 
|---|
 | 96 | 
 | 
|---|
 | 97 | /** Implementation of redo function for an Action.
 | 
|---|
 | 98 |  * We do not use this functionality.
 | 
|---|
 | 99 |  * \return ActionState pointer with failure
 | 
|---|
 | 100 |  */
 | 
|---|
 | 101 | Action::state_ptr TxMenu::LeaveAction::performRedo(Action::state_ptr){
 | 
|---|
 | 102 |   ASSERT(0,"Cannot redo leaving a menu");
 | 
|---|
 | 103 |   return Action::failure;
 | 
|---|
 | 104 | }
 | 
|---|