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>
14 #include <2geom/pathvector.h>
16 class KnotHolder;
17 class SPLPEItem;
18 struct SPDesktop;
19 struct SPItem;
21 namespace Gtk {
22 class Widget;
23 class Tooltips;
24 }
26 namespace Inkscape {
28 namespace NodePath {
29 class Path ;
30 }
32 namespace UI {
33 namespace Widget {
34 class Registry;
35 }
36 }
38 namespace LivePathEffect {
40 class Effect;
42 class Parameter {
43 public:
44 Parameter( const Glib::ustring& label,
45 const Glib::ustring& tip,
46 const Glib::ustring& key,
47 Inkscape::UI::Widget::Registry* wr,
48 Effect* effect);
49 virtual ~Parameter() {};
51 virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
52 virtual gchar * param_getSVGValue() const = 0;
53 void write_to_SVG() { param_write_to_repr(param_getSVGValue()); }
55 virtual void param_set_default() = 0;
57 // This creates a new widget (newed with Gtk::manage(new ...);)
58 virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips) = 0;
60 virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; };
62 // overload these for your particular parameter to make it provide knotholder handles or canvas helperpaths
63 virtual bool providesKnotHolderEntities() { return false; }
64 virtual void addKnotHolderEntities(KnotHolder */*knotholder*/, SPDesktop */*desktop*/, SPItem */*item*/) {};
65 virtual void addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/) {};
67 virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
68 virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
70 virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/) {};
72 Glib::ustring param_key;
73 Inkscape::UI::Widget::Registry * param_wr;
74 Glib::ustring param_label;
76 bool oncanvas_editable;
78 protected:
79 Glib::ustring param_tooltip;
81 Effect* param_effect;
83 void param_write_to_repr(const char * svgd);
85 private:
86 Parameter(const Parameter&);
87 Parameter& operator=(const Parameter&);
88 };
91 class ScalarParam : public Parameter {
92 public:
93 ScalarParam( const Glib::ustring& label,
94 const Glib::ustring& tip,
95 const Glib::ustring& key,
96 Inkscape::UI::Widget::Registry* wr,
97 Effect* effect,
98 gdouble default_value = 1.0);
99 virtual ~ScalarParam();
101 virtual bool param_readSVGValue(const gchar * strvalue);
102 virtual gchar * param_getSVGValue() const;
104 virtual void param_set_default();
105 void param_set_value(gdouble val);
106 void param_make_integer(bool yes = true);
107 void param_set_range(gdouble min, gdouble max);
108 void param_set_digits(unsigned digits);
109 void param_set_increments(double step, double page);
111 virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips);
113 inline operator gdouble()
114 { return value; };
116 protected:
117 gdouble value;
118 gdouble min;
119 gdouble max;
120 bool integer;
121 gdouble defvalue;
122 unsigned digits;
123 double inc_step;
124 double inc_page;
126 private:
127 ScalarParam(const ScalarParam&);
128 ScalarParam& operator=(const ScalarParam&);
129 };
131 } //namespace LivePathEffect
133 } //namespace Inkscape
135 #endif
137 /*
138 Local Variables:
139 mode:c++
140 c-file-style:"stroustrup"
141 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
142 indent-tabs-mode:nil
143 fill-column:99
144 End:
145 */
146 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :