Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_05 / synfig-core / 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-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "layer_mime.h"
33
34 #include "layer.h"
35 #include "time.h"
36 #include "string.h"
37 #include "vector.h"
38
39 #include "context.h"
40 #include "time.h"
41 #include "color.h"
42 #include "surface.h"
43 #include "renddesc.h"
44 #include "target.h"
45
46 #include "general.h"
47 #include "paramdesc.h"
48
49 #endif
50
51 /* === U S I N G =========================================================== */
52
53 using namespace std;
54 using namespace etl;
55 using namespace synfig;
56
57 /* === M A C R O S ========================================================= */
58
59 /* === G L O B A L S ======================================================= */
60
61 /* === P R O C E D U R E S ================================================= */
62
63 /* === M E T H O D S ======================================================= */
64
65 Layer_Mime::Layer_Mime(String x):name(x)
66 {
67         // Throw a bogus default version onto the parameter list.
68         param_list["Version"]="9";
69 }
70
71 String
72 Layer_Mime::get_version()const
73 {
74         return get_param("Version").get(String());
75 }
76
77 bool
78 Layer_Mime::set_version(const String &ver)
79 {
80         return set_param("Version",ver);
81 }
82
83 String
84 Layer_Mime::get_local_name()const
85 {
86         return _("[MIME]")+get_name();
87 }
88
89 bool
90 Layer_Mime::set_param(const String &param, const ValueBase &value)
91 {
92         // Don't try to set the name
93         if(param=="name" || param=="Name" || param=="name__")
94                 return false;
95
96         // Otherwise, remember this parameter's value
97         param_list[param]=value;
98         return true;
99 }
100
101 ValueBase
102 Layer_Mime::get_param(const String &param)const
103 {
104         // If they are requesting the name of
105         // the layer, just return it
106         if(param=="name" || param=="Name" || param=="name__")
107                 return ValueBase(name);
108
109         // Otherwise, return the stored parameter value
110         map<string,ValueBase>::const_iterator iter=param_list.find(param);
111         if(iter!=param_list.end())
112                 return iter->second;
113         return ValueBase();
114 }
115
116 Color
117 Layer_Mime::get_color(Context context, const Point &pos)const
118 {
119         // A Layer_Mime layer should do nothing at all.
120         return context.get_color(pos);
121 }
122
123 bool
124 Layer_Mime::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
125 {
126         // A Layer_Mime layer should do nothing at all.
127         return context.accelerated_render(surface,quality,renddesc,cb);
128 }
129
130 Layer::Vocab
131 Layer_Mime::get_param_vocab()const
132 {
133         Layer::Vocab ret;
134         map<string,ValueBase>::const_iterator iter;
135
136         // Construct the vocabulary from the stored
137         // parameters
138         for(iter=param_list.begin();iter!=param_list.end();iter++)
139         {
140                 // Make sure that we don't add the version
141                 // into the vocabulary
142                 if(iter->first!="Version")
143                         ret.push_back(ParamDesc(iter->first));
144         }
145         
146         // ... and return it
147         return ret;
148 }