1 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_CPP\r
2 \r
3 /*\r
4 * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>\r
5 *\r
6 * Released under GNU GPL, read the file 'COPYING' for more information\r
7 */\r
8 \r
9 #include "live_effects/parameter/parameter.h"\r
10 #include "live_effects/effect.h"\r
11 #include "svg/svg.h"\r
12 \r
13 #include <gtkmm.h>\r
14 #include "ui/widget/scalar.h"\r
15 \r
16 #include "svg/stringstream.h"\r
17 \r
18 #include "verbs.h"\r
19 \r
20 #define noLPEREALPARAM_DEBUG\r
21 \r
22 namespace Inkscape {\r
23 \r
24 namespace LivePathEffect {\r
25 \r
26 \r
27 Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip,\r
28 const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,\r
29 Effect* effect )\r
30 {\r
31 param_label = label;\r
32 param_tooltip = tip;\r
33 param_key = key;\r
34 param_wr = wr;\r
35 param_effect = effect;\r
36 }\r
37 \r
38 \r
39 \r
40 /*###########################################\r
41 * REAL PARAM\r
42 */\r
43 RealParam::RealParam( const Glib::ustring& label, const Glib::ustring& tip,\r
44 const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,\r
45 Effect* effect, gdouble initial_value)\r
46 : Parameter(label, tip, key, wr, effect)\r
47 {\r
48 value = initial_value;\r
49 rsu = NULL;\r
50 }\r
51 \r
52 RealParam::~RealParam()\r
53 {\r
54 if (rsu)\r
55 delete rsu;\r
56 }\r
57 \r
58 bool\r
59 RealParam::param_readSVGValue(const gchar * strvalue)\r
60 {\r
61 double newval;\r
62 unsigned int success = sp_svg_number_read_d(strvalue, &newval);\r
63 if (success == 1) {\r
64 value = newval;\r
65 return true;\r
66 }\r
67 return false;\r
68 }\r
69 \r
70 gchar *\r
71 RealParam::param_writeSVGValue() const\r
72 {\r
73 Inkscape::SVGOStringStream os;\r
74 os << rsu->getS()->getValue();\r
75 gchar * str = g_strdup(os.str().c_str());\r
76 return str;\r
77 }\r
78 \r
79 Gtk::Widget *\r
80 RealParam::param_getWidget()\r
81 {\r
82 if (!rsu) {\r
83 rsu = new Inkscape::UI::Widget::RegisteredScalar();\r
84 rsu->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());\r
85 rsu->setValue(value);\r
86 rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));\r
87 }\r
88 return dynamic_cast<Gtk::Widget *> (rsu->getS());\r
89 }\r
90 \r
91 \r
92 }; /* namespace LivePathEffect */\r
93 \r
94 }; /* namespace Inkscape */\r
95 \r
96 /*\r
97 Local Variables:\r
98 mode:c++\r
99 c-file-style:"stroustrup"\r
100 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
101 indent-tabs-mode:nil\r
102 fill-column:99\r
103 End:\r
104 */\r
105 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r