Code

Translations. French translation minor update.
[inkscape.git] / src / live_effects / parameter / enum.h
1 #ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
2 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
4 /*
5  * Inkscape::LivePathEffectParameters
6  *
7 * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #include <glib/gtypes.h>
14 #include "ui/widget/registered-enums.h"
15 #include <gtkmm/tooltips.h>
17 #include "live_effects/effect.h"
18 #include "live_effects/parameter/parameter.h"
19 #include "verbs.h"
21 namespace Inkscape {
23 namespace LivePathEffect {
25 template<typename E> class EnumParam : public Parameter {
26 public:
27     EnumParam(  const Glib::ustring& label,
28                 const Glib::ustring& tip,
29                 const Glib::ustring& key,
30                 const Util::EnumDataConverter<E>& c,
31                 Inkscape::UI::Widget::Registry* wr,
32                 Effect* effect,
33                 E default_value)
34         : Parameter(label, tip, key, wr, effect)
35     {
36         enumdataconv = &c;
37         defvalue = default_value;
38         value = defvalue;
39     };
41     virtual ~EnumParam() { };
43     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * /*tooltips*/) {
44         Inkscape::UI::Widget::RegisteredEnum<E> *regenum = Gtk::manage ( 
45             new Inkscape::UI::Widget::RegisteredEnum<E>( param_label, param_tooltip,
46                        param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) );
48         regenum->set_active_by_id(value);
49         regenum->combobox()->setProgrammatically = false;
50         regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enumeration parameter"));
52         return dynamic_cast<Gtk::Widget *> (regenum);
53     };
55     bool param_readSVGValue(const gchar * strvalue) {
56         if (!strvalue) {
57             param_set_default();
58             return true;
59         }
61         param_set_value( enumdataconv->get_id_from_key(Glib::ustring(strvalue)) );
63         return true;
64     };
65     gchar * param_getSVGValue() const {
66         gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );
67         return str;
68     };
70     E get_value() const {
71         return value;
72     }
74     inline operator E()
75         { return value; };
77     void param_set_default() {
78         param_set_value(defvalue);
79     }
81     void param_set_value(E val) {
82         value = val;
83     }
85 private:
86     EnumParam(const EnumParam&);
87     EnumParam& operator=(const EnumParam&);
89     E value;
90     E defvalue;
92     const Util::EnumDataConverter<E> * enumdataconv;
93 };
96 }; //namespace LivePathEffect
98 }; //namespace Inkscape
100 #endif