1 /* === S I N F G =========================================================== */
2 /*! \file canvasremove.cpp
3 ** \brief Template File
5 ** $Id: canvasremove.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "canvasremove.h"
32 #include <sinfgapp/canvasinterface.h>
38 using namespace sinfg;
39 using namespace sinfgapp;
40 using namespace Action;
42 /* === M A C R O S ========================================================= */
44 ACTION_INIT(Action::CanvasRemove);
45 ACTION_SET_NAME(Action::CanvasRemove,"canvas_remove");
46 ACTION_SET_LOCAL_NAME(Action::CanvasRemove,"Remove Canvas");
47 ACTION_SET_TASK(Action::CanvasRemove,"remove");
48 ACTION_SET_CATEGORY(Action::CanvasRemove,Action::CATEGORY_CANVAS);
49 ACTION_SET_PRIORITY(Action::CanvasRemove,0);
50 ACTION_SET_VERSION(Action::CanvasRemove,"0.0");
51 ACTION_SET_CVS_ID(Action::CanvasRemove,"$Id: canvasremove.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
53 /* === G L O B A L S ======================================================= */
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 Action::CanvasRemove::CanvasRemove()
64 Action::CanvasRemove::get_param_vocab()
66 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
72 Action::CanvasRemove::is_canidate(const ParamList &x)
74 if(canidate_check(get_param_vocab(),x))
76 Canvas::Handle canvas=x.find("canvas")->second.get_canvas();
78 // We cannot remove the root canvas.
88 Action::CanvasRemove::set_param(const sinfg::String& name, const Action::Param ¶m)
90 return Action::CanvasSpecific::set_param(name,param);
94 Action::CanvasRemove::is_ready()const
96 return Action::CanvasSpecific::is_ready();
100 Action::CanvasRemove::perform()
102 // We cannot remove the root canvas.
103 if(get_canvas()->is_root())
104 throw Error(_("You cannot remove the root canvas!"));
106 if(get_canvas()->is_inline())
107 throw Error(_("You cannot remove an inline canvas!"));
109 parent_canvas=get_canvas()->parent();
110 canvas_id=get_canvas()->get_id();
112 assert(parent_canvas);
114 parent_canvas->remove_child_canvas(get_canvas());
116 if(get_canvas_interface())
118 get_canvas_interface()->signal_canvas_removed()(get_canvas());
120 else sinfg::warning("CanvasInterface not set on action");
124 Action::CanvasRemove::undo()
126 parent_canvas->add_child_canvas(get_canvas(), canvas_id);
128 if(get_canvas_interface())
130 get_canvas_interface()->signal_canvas_added()(get_canvas());
132 else sinfg::warning("CanvasInterface not set on action");