Changed the "tagrelease" and "tagstable" make targets to use subversion. Also increme...
[synfig.git] / synfig-studio / tags / stable / src / sinfgapp / actions / canvasadd.cpp
1 /* === S I N F G =========================================================== */
2 /*!     \file canvasadd.cpp
3 **      \brief Template File
4 **
5 **      $Id: canvasadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
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.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include "canvasadd.h"
32 #include <sinfgapp/canvasinterface.h>
33
34 #endif
35
36 using namespace std;
37 using namespace etl;
38 using namespace sinfg;
39 using namespace sinfgapp;
40 using namespace Action;
41
42 /* === M A C R O S ========================================================= */
43
44 ACTION_INIT(Action::CanvasAdd);
45 ACTION_SET_NAME(Action::CanvasAdd,"canvas_add");
46 ACTION_SET_LOCAL_NAME(Action::CanvasAdd,"Add Child Canvas");
47 ACTION_SET_TASK(Action::CanvasAdd,"add");
48 ACTION_SET_CATEGORY(Action::CanvasAdd,Action::CATEGORY_CANVAS);
49 ACTION_SET_PRIORITY(Action::CanvasAdd,0);
50 ACTION_SET_VERSION(Action::CanvasAdd,"0.0");
51 ACTION_SET_CVS_ID(Action::CanvasAdd,"$Id: canvasadd.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
52
53 /* === G L O B A L S ======================================================= */
54
55 /* === P R O C E D U R E S ================================================= */
56
57 /* === M E T H O D S ======================================================= */
58
59 Action::CanvasAdd::CanvasAdd()
60 {
61         set_dirty(true);
62 }
63
64 Action::ParamVocab
65 Action::CanvasAdd::get_param_vocab()
66 {
67         ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
68         
69         ret.push_back(ParamDesc("src",Param::TYPE_CANVAS)
70                 .set_local_name(_("New Canvas"))
71                 .set_optional()
72         );
73
74         ret.push_back(ParamDesc("id",Param::TYPE_STRING)
75                 .set_local_name(_("ID"))
76                 .set_desc(_("The name that you want this canvas to be"))
77                 .set_user_supplied()
78         );
79         
80         return ret;
81 }
82
83 bool
84 Action::CanvasAdd::is_canidate(const ParamList &x)
85 {
86         return canidate_check(get_param_vocab(),x);
87 }
88
89 bool
90 Action::CanvasAdd::set_param(const sinfg::String& name, const Action::Param &param)
91 {
92         if(name=="src" && param.get_type()==Param::TYPE_CANVAS)
93         {
94                 new_canvas=param.get_canvas();
95                 
96                 return true;
97         }
98         if(name=="id" && param.get_type()==Param::TYPE_STRING)
99         {
100                 id=param.get_string();
101                 
102                 return true;
103         }
104
105         return Action::CanvasSpecific::set_param(name,param);
106 }
107
108 bool
109 Action::CanvasAdd::is_ready()const
110 {
111         return Action::CanvasSpecific::is_ready();
112 }
113
114 void
115 Action::CanvasAdd::perform()
116 {
117         if(!new_canvas)
118         {
119                 new_canvas=get_canvas()->new_child_canvas(id);
120         }
121         else
122         {
123                 if(new_canvas->is_inline())
124                 {
125                         inline_parent=new_canvas->parent();
126                 }
127                 get_canvas()->add_child_canvas(new_canvas,id);
128         }
129
130         if(get_canvas_interface())
131         {
132                 get_canvas_interface()->signal_canvas_added()(new_canvas);
133         }
134         else sinfg::warning("CanvasInterface not set on action");
135 }
136
137 void
138 Action::CanvasAdd::undo()
139 {
140         get_canvas()->remove_child_canvas(new_canvas);
141
142         if(inline_parent)
143                 new_canvas->set_inline(inline_parent);          
144         
145         if(get_canvas_interface())
146         {
147                 get_canvas_interface()->signal_canvas_removed()(new_canvas);
148         }
149         else sinfg::warning("CanvasInterface not set on action");
150 }