moreupdates
[synfig.git] / synfig-core / trunk / src / synfig / layer_mime.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file layer_mime.cpp
3 **      \brief Template File
4 **
5 **      $Id: layer_mime.cpp,v 1.1.1.1 2005/01/04 01:23:14 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 "layer_mime.h"
32
33 #include "layer.h"
34 #include "time.h"
35 #include "string.h"
36 #include "vector.h"
37
38 #include "context.h"
39 #include "time.h"
40 #include "color.h"
41 #include "surface.h"
42 #include "renddesc.h"
43 #include "target.h"
44
45 #include "general.h"
46 #include "paramdesc.h"
47
48 #endif
49
50 /* === U S I N G =========================================================== */
51
52 using namespace std;
53 using namespace etl;
54 using namespace synfig;
55
56 /* === M A C R O S ========================================================= */
57
58 /* === G L O B A L S ======================================================= */
59
60 /* === P R O C E D U R E S ================================================= */
61
62 /* === M E T H O D S ======================================================= */
63
64 Layer_Mime::Layer_Mime(String x):name(x)
65 {
66         // Throw a bogus default version onto the parameter list.
67         param_list["Version"]="9";
68 }
69
70 String
71 Layer_Mime::get_version()const
72 {
73         return get_param("Version").get(String());
74 }
75
76 bool
77 Layer_Mime::set_version(const String &ver)
78 {
79         return set_param("Version",ver);
80 }
81
82 String
83 Layer_Mime::get_local_name()const
84 {
85         return _("[MIME]")+get_name();
86 }
87
88 bool
89 Layer_Mime::set_param(const String &param, const ValueBase &value)
90 {
91         // Don't try to set the name
92         if(param=="name" || param=="Name" || param=="name__")
93                 return false;
94
95         // Otherwise, remember this parameter's value
96         param_list[param]=value;
97         return true;
98 }
99
100 ValueBase
101 Layer_Mime::get_param(const String &param)const
102 {
103         // If they are requesting the name of
104         // the layer, just return it
105         if(param=="name" || param=="Name" || param=="name__")
106                 return ValueBase(name);
107
108         // Otherwise, return the stored parameter value
109         map<string,ValueBase>::const_iterator iter=param_list.find(param);
110         if(iter!=param_list.end())
111                 return iter->second;
112         return ValueBase();
113 }
114
115 Color
116 Layer_Mime::get_color(Context context, const Point &pos)const
117 {
118         // A Layer_Mime layer should do nothing at all.
119         return context.get_color(pos);
120 }
121
122 bool
123 Layer_Mime::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
124 {
125         // A Layer_Mime layer should do nothing at all.
126         return context.accelerated_render(surface,quality,renddesc,cb);
127 }
128
129 Layer::Vocab
130 Layer_Mime::get_param_vocab()const
131 {
132         Layer::Vocab ret;
133         map<string,ValueBase>::const_iterator iter;
134
135         // Construct the vocabulary from the stored
136         // parameters
137         for(iter=param_list.begin();iter!=param_list.end();iter++)
138         {
139                 // Make sure that we don't add the version
140                 // into the vocabulary
141                 if(iter->first!="Version")
142                         ret.push_back(ParamDesc(iter->first));
143         }
144         
145         // ... and return it
146         return ret;
147 }