index bfc9fd35206fbac4b5bed31d2ed56390a5336707..4ee28f8959c74031273e4763964274d616023cc2 100644 (file)
-#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H\r
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H\r
-\r
-/*\r
- * Inkscape::LivePathEffectParameters\r
- *\r
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>\r
- *\r
- * Released under GNU GPL, read the file 'COPYING' for more information\r
- */\r
-\r
-#include <glib/gtypes.h>\r
-\r
-#include "ui/widget/registry.h"\r
-#include "ui/widget/registered-enums.h"\r
-#include <gtkmm/tooltips.h>\r
-\r
-#include "live_effects/parameter/parameter.h"\r
-#include "verbs.h"\r
-\r
-namespace Inkscape {\r
-\r
-namespace LivePathEffect {\r
-\r
-template<typename E> class EnumParam : public Parameter {\r
-public:\r
- EnumParam( const Glib::ustring& label,\r
- const Glib::ustring& tip,\r
- const Glib::ustring& key,\r
- const Util::EnumDataConverter<E>& c,\r
- Inkscape::UI::Widget::Registry* wr,\r
- Effect* effect,\r
- E defvalue)\r
- : Parameter(label, tip, key, wr, effect)\r
- {\r
- regenum = NULL;\r
- enumdataconv = &c;\r
- value = defvalue;\r
- };\r
- ~EnumParam() {\r
- if (regenum)\r
- delete regenum;\r
- };\r
-\r
- Gtk::Widget * param_getWidget() {\r
- if (!regenum) {\r
- regenum = new Inkscape::UI::Widget::RegisteredEnum<E>();\r
- regenum->init(param_label, param_tooltip, param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());\r
- regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));\r
- regenum->combobox()->set_active_by_id(value);\r
- }\r
- return dynamic_cast<Gtk::Widget *> (regenum->labelled);\r
- };\r
-\r
- bool param_readSVGValue(const gchar * strvalue) {\r
- if (!strvalue) return false;\r
-\r
- value = enumdataconv->get_id_from_key(Glib::ustring(strvalue));\r
-\r
- if (regenum)\r
- regenum->combobox()->set_active_by_id(value);\r
-\r
- return true;\r
- };\r
- gchar * param_writeSVGValue() const {\r
- gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );\r
- return str;\r
- };\r
-\r
- E get_value() const {\r
- return value;\r
- }\r
-\r
-private:\r
- EnumParam(const EnumParam&);\r
- EnumParam& operator=(const EnumParam&);\r
-\r
- UI::Widget::RegisteredEnum<E> * regenum;\r
- E value;\r
-\r
- const Util::EnumDataConverter<E> * enumdataconv;\r
-};\r
-\r
-\r
-}; //namespace LivePathEffect\r
-\r
-}; //namespace Inkscape\r
-\r
-#endif\r
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib/gtypes.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-enums.h"
+#include <gtkmm/tooltips.h>
+
+#include "live_effects/parameter/parameter.h"
+#include "verbs.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+template<typename E> class EnumParam : public Parameter {
+public:
+ EnumParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ const Util::EnumDataConverter<E>& c,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ E default_value)
+ : Parameter(label, tip, key, wr, effect)
+ {
+ regenum = NULL;
+ enumdataconv = &c;
+ defvalue = default_value;
+ value = defvalue;
+ };
+ ~EnumParam() {
+ if (regenum)
+ delete regenum;
+ };
+
+ Gtk::Widget * param_getWidget() {
+ if (!regenum) {
+ regenum = new Inkscape::UI::Widget::RegisteredEnum<E>();
+ regenum->init(param_label, param_tooltip, param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
+ regenum->combobox()->set_active_by_id(value);
+ regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));
+ }
+ return dynamic_cast<Gtk::Widget *> (regenum->labelled);
+ };
+
+ bool param_readSVGValue(const gchar * strvalue) {
+ if (!strvalue) {
+ param_set_default();
+ return true;
+ }
+
+ param_set_value( enumdataconv->get_id_from_key(Glib::ustring(strvalue)) );
+
+ return true;
+ };
+ gchar * param_writeSVGValue() const {
+ gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );
+ return str;
+ };
+
+ E get_value() const {
+ return value;
+ }
+
+ void param_set_default() {
+ param_set_value(defvalue);
+ }
+
+ void param_set_value(E val) {
+ value = val;
+ if (regenum)
+ regenum->combobox()->set_active_by_id(value);
+ }
+
+private:
+ EnumParam(const EnumParam&);
+ EnumParam& operator=(const EnumParam&);
+
+ UI::Widget::RegisteredEnum<E> * regenum;
+ E value;
+ E defvalue;
+
+ const Util::EnumDataConverter<E> * enumdataconv;
+};
+
+
+}; //namespace LivePathEffect
+
+}; //namespace Inkscape
+
+#endif