my log
[synfig.git] / synfig-studio / trunk / src / synfigapp / actions / editmodeset.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file editmodeset.cpp
3 **      \brief Template File
4 **
5 **      $Id: editmodeset.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 "editmodeset.h"
32 #include <synfigapp/canvasinterface.h>
33
34 #endif
35
36 using namespace std;
37 using namespace etl;
38 using namespace synfig;
39 using namespace synfigapp;
40 using namespace Action;
41
42 /* === M A C R O S ========================================================= */
43
44 ACTION_INIT(Action::EditModeSet);
45 ACTION_SET_NAME(Action::EditModeSet,"edit_mode_set");
46 ACTION_SET_LOCAL_NAME(Action::EditModeSet,"Set Edit Mode");
47 ACTION_SET_TASK(Action::EditModeSet,"set");
48 ACTION_SET_CATEGORY(Action::EditModeSet,Action::CATEGORY_OTHER);
49 ACTION_SET_PRIORITY(Action::EditModeSet,0);
50 ACTION_SET_VERSION(Action::EditModeSet,"0.0");
51 ACTION_SET_CVS_ID(Action::EditModeSet,"$Id: editmodeset.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::EditModeSet::EditModeSet()
60 {
61 }
62
63 Action::ParamVocab
64 Action::EditModeSet::get_param_vocab()
65 {
66         ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
67         
68         ret.push_back(ParamDesc("edit_mode",Param::TYPE_EDITMODE)
69                 .set_local_name(_("New Edit Mode"))
70         );
71         
72         return ret;
73 }
74
75 bool
76 Action::EditModeSet::is_canidate(const ParamList &x)
77 {
78         return canidate_check(get_param_vocab(),x);
79 }
80
81 bool
82 Action::EditModeSet::set_param(const synfig::String& name, const Action::Param &param)
83 {
84 /*
85         if(name=="edit_mode" && param.get_type()==Param::TYPE_EDITMODE)
86         {
87                 set_edit_mode(param.get_edit_mode());
88                 
89                 return true;
90         }
91 */
92         
93         return Action::CanvasSpecific::set_param(name,param);
94 }
95
96 bool
97 Action::EditModeSet::is_ready()const
98 {
99         return Action::CanvasSpecific::is_ready() && get_canvas_interface();
100 }
101
102 void
103 Action::EditModeSet::perform()
104 {
105         set_dirty(false);
106
107         old_edit_mode=get_canvas_interface()->get_mode();
108
109         if(old_edit_mode==get_edit_mode())
110                 return;
111
112         get_canvas_interface()->mode_=get_edit_mode();
113                 
114         get_canvas_interface()->signal_mode_changed_(get_edit_mode());
115 }
116
117 void
118 Action::EditModeSet::undo()
119 {
120         set_dirty(false);
121
122         if(old_edit_mode==get_edit_mode())
123                 return;
124
125         get_canvas_interface()->mode_=old_edit_mode;
126                 
127         get_canvas_interface()->signal_mode_changed_(old_edit_mode);
128 }