Code

Add BoolParam for LPE's
authorjohanengelen <johanengelen@users.sourceforge.net>
Wed, 29 Aug 2007 19:13:13 +0000 (19:13 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Wed, 29 Aug 2007 19:13:13 +0000 (19:13 +0000)
po/POTFILES.in
src/live_effects/parameter/Makefile_insert
src/live_effects/parameter/bool.cpp [new file with mode: 0644]
src/live_effects/parameter/bool.h [new file with mode: 0644]

index b3781edf76c51c1b995a75b588904c65f87939db..66779dc354cfc10211442315b6318f296eed77ac 100644 (file)
@@ -268,6 +268,8 @@ src/live_effects/lpe-gears.cpp
 src/live_effects/lpe-skeletalstrokes.cpp
 src/live_effects/parameter/parameter.cpp
 src/live_effects/parameter/path.cpp
+src/live_effects/parameter/point.cpp
+src/live_effects/parameter/bool.cpp
 src/main.cpp
 src/main-cmdlineact.cpp
 src/menus-skeleton.h
index a737da1f0b2c459a76bcc5b21ee15bf79ea7ac27..688af37de233af3b748cdcdd46a0ce4b986cae66 100644 (file)
@@ -8,6 +8,8 @@ live_effects/parameter/clean:
 live_effects_parameter_liblpeparam_a_SOURCES = \\r
        live_effects/parameter/parameter.cpp    \\r
        live_effects/parameter/parameter.h      \\r
+       live_effects/parameter/bool.cpp \\r
+       live_effects/parameter/bool.h   \\r
        live_effects/parameter/point.cpp        \\r
        live_effects/parameter/point.h  \\r
        live_effects/parameter/enum.h   \\r
diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp
new file mode 100644 (file)
index 0000000..af3449d
--- /dev/null
@@ -0,0 +1,93 @@
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_CPP\r
+\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 "live_effects/parameter/bool.h"\r
+#include "live_effects/effect.h"\r
+#include "svg/svg.h"\r
+#include "svg/stringstream.h"\r
+#include <gtkmm.h>\r
+#include "widgets/icon.h"\r
+\r
+#include "inkscape.h"\r
+#include "verbs.h"\r
+#include "helper-fns.h"\r
+\r
+#define noLPEBOOLPARAM_DEBUG\r
+\r
+namespace Inkscape {\r
+\r
+namespace LivePathEffect {\r
+\r
+BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,\r
+                      const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,\r
+                      Effect* effect, bool default_value )\r
+    : Parameter(label, tip, key, wr, effect), defvalue(default_value)\r
+{\r
+    checkwdg = NULL;\r
+}\r
+\r
+BoolParam::~BoolParam()\r
+{\r
+    if (checkwdg)\r
+        delete checkwdg;\r
+}\r
+\r
+void\r
+BoolParam::param_set_default()\r
+{\r
+    param_setValue(defvalue);\r
+}\r
+\r
+bool\r
+BoolParam::param_readSVGValue(const gchar * strvalue)\r
+{\r
+    param_setValue(helperfns_read_bool(strvalue, defvalue));\r
+    return true; // not correct: if value is unacceptable, should return false!\r
+}\r
+\r
+gchar *\r
+BoolParam::param_writeSVGValue() const\r
+{\r
+    gchar * str = g_strdup(value ? "true" : "false");\r
+    return str;\r
+}\r
+\r
+Gtk::Widget *\r
+BoolParam::param_getWidget()\r
+{\r
+    if (!checkwdg) {\r
+        checkwdg = new Inkscape::UI::Widget::RegisteredCheckButton();\r
+        checkwdg->init(param_label, param_tooltip, param_key, *param_wr, false, param_effect->getRepr(), param_effect->getSPDoc());\r
+        checkwdg->setActive(value);\r
+        checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));\r
+    }\r
+    return dynamic_cast<Gtk::Widget *> (checkwdg->_button);\r
+}\r
+\r
+void\r
+BoolParam::param_setValue(bool newvalue)\r
+{\r
+    value = newvalue;\r
+    if (checkwdg)\r
+        checkwdg->setActive(newvalue);\r
+}\r
+\r
+} /* namespace LivePathEffect */\r
+\r
+} /* namespace Inkscape */\r
+\r
+/*\r
+  Local Variables:\r
+  mode:c++\r
+  c-file-style:"stroustrup"\r
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
+  indent-tabs-mode:nil\r
+  fill-column:99\r
+  End:\r
+*/\r
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r
diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h
new file mode 100644 (file)
index 0000000..cf8c9c9
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_H\r
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_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-widget.h"\r
+\r
+#include "live_effects/parameter/parameter.h"\r
+\r
+namespace Inkscape {\r
+\r
+namespace LivePathEffect {\r
+\r
+\r
+class BoolParam : public Parameter {\r
+public:\r
+    BoolParam( const Glib::ustring& label,\r
+               const Glib::ustring& tip,\r
+               const Glib::ustring& key,\r
+               Inkscape::UI::Widget::Registry* wr,\r
+               Effect* effect,\r
+               bool default_value = false);\r
+    ~BoolParam();\r
+\r
+    Gtk::Widget * param_getWidget();\r
+\r
+    bool param_readSVGValue(const gchar * strvalue);\r
+    gchar * param_writeSVGValue() const;\r
+\r
+    void param_setValue(bool newvalue);\r
+    void param_set_default();\r
+\r
+private:\r
+    BoolParam(const BoolParam&);\r
+    BoolParam& operator=(const BoolParam&);\r
+\r
+    Inkscape::UI::Widget::RegisteredCheckButton * checkwdg;\r
+\r
+    bool value;\r
+    bool defvalue;\r
+};\r
+\r
+\r
+} //namespace LivePathEffect\r
+\r
+} //namespace Inkscape\r
+\r
+#endif\r