1 #ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
2 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_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 <glibmm/ustring.h>
13 #include <2geom/forward.h>
15 class KnotHolder;
16 struct SPDesktop;
17 struct SPItem;
19 namespace Gtk {
20 class Widget;
21 class Tooltips;
22 }
24 namespace Inkscape {
26 namespace NodePath {
27 class Path ;
28 }
30 namespace UI {
31 namespace Widget {
32 class Registry;
33 }
34 }
36 namespace LivePathEffect {
38 class Effect;
40 class Parameter {
41 public:
42 Parameter( const Glib::ustring& label,
43 const Glib::ustring& tip,
44 const Glib::ustring& key,
45 Inkscape::UI::Widget::Registry* wr,
46 Effect* effect);
47 virtual ~Parameter() {};
49 virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
50 virtual gchar * param_getSVGValue() const = 0;
51 void write_to_SVG() { param_write_to_repr(param_getSVGValue()); }
53 virtual void param_set_default() = 0;
55 // This creates a new widget (newed with Gtk::manage(new ...);)
56 virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips) = 0;
58 virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; };
60 virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {}
62 virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
63 virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
65 virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/) {};
67 Glib::ustring param_key;
68 Inkscape::UI::Widget::Registry * param_wr;
69 Glib::ustring param_label;
71 bool oncanvas_editable;
73 protected:
74 Glib::ustring param_tooltip;
76 Effect* param_effect;
78 void param_write_to_repr(const char * svgd);
80 private:
81 Parameter(const Parameter&);
82 Parameter& operator=(const Parameter&);
83 };
86 class ScalarParam : public Parameter {
87 public:
88 ScalarParam( const Glib::ustring& label,
89 const Glib::ustring& tip,
90 const Glib::ustring& key,
91 Inkscape::UI::Widget::Registry* wr,
92 Effect* effect,
93 gdouble default_value = 1.0);
94 virtual ~ScalarParam();
96 virtual bool param_readSVGValue(const gchar * strvalue);
97 virtual gchar * param_getSVGValue() const;
99 virtual void param_set_default();
100 void param_set_value(gdouble val);
101 void param_make_integer(bool yes = true);
102 void param_set_range(gdouble min, gdouble max);
103 void param_set_digits(unsigned digits);
104 void param_set_increments(double step, double page);
106 virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips);
108 inline operator gdouble()
109 { return value; };
111 protected:
112 gdouble value;
113 gdouble min;
114 gdouble max;
115 bool integer;
116 gdouble defvalue;
117 unsigned digits;
118 double inc_step;
119 double inc_page;
121 private:
122 ScalarParam(const ScalarParam&);
123 ScalarParam& operator=(const ScalarParam&);
124 };
126 } //namespace LivePathEffect
128 } //namespace Inkscape
130 #endif
132 /*
133 Local Variables:
134 mode:c++
135 c-file-style:"stroustrup"
136 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
137 indent-tabs-mode:nil
138 fill-column:99
139 End:
140 */
141 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :