78d12ca6917ef22d2aeb3969f31fd23ad73ba34a
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/point.h>
14 #include <2geom/path.h>
16 #include "ui/widget/registry.h"
17 #include "ui/widget/registered-widget.h"
19 struct SPDesktop;
20 struct SPItem;
22 namespace Gtk {
23 class Widget;
24 }
26 namespace Inkscape {
28 namespace NodePath {
29 class Path ;
30 }
32 namespace LivePathEffect {
34 class Effect;
36 class Parameter {
37 public:
38 Parameter( const Glib::ustring& label,
39 const Glib::ustring& tip,
40 const Glib::ustring& key,
41 Inkscape::UI::Widget::Registry* wr,
42 Effect* effect);
43 virtual ~Parameter() {};
45 virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
46 virtual gchar * param_writeSVGValue() const = 0;
48 virtual void param_set_default() = 0;
50 // This returns pointer to the parameter's widget to be put in the live-effects dialog. Must also create the
51 // necessary widget if it does not exist yet.
52 virtual Gtk::Widget * param_getWidget() = 0;
53 virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; };
55 virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
56 virtual void param_setup_notepath(Inkscape::NodePath::Path */*np*/) {};
58 Glib::ustring param_key;
59 Inkscape::UI::Widget::Registry * param_wr;
60 Glib::ustring param_label;
62 bool oncanvas_editable;
64 protected:
65 Glib::ustring param_tooltip;
67 Effect* param_effect;
69 private:
70 Parameter(const Parameter&);
71 Parameter& operator=(const Parameter&);
72 };
75 class ScalarParam : public Parameter {
76 public:
77 ScalarParam( const Glib::ustring& label,
78 const Glib::ustring& tip,
79 const Glib::ustring& key,
80 Inkscape::UI::Widget::Registry* wr,
81 Effect* effect,
82 gdouble default_value = 1.0);
83 virtual ~ScalarParam();
85 virtual bool param_readSVGValue(const gchar * strvalue);
86 virtual gchar * param_writeSVGValue() const;
88 virtual void param_set_default();
89 void param_set_value(gdouble val);
90 void param_make_integer(bool yes = true);
91 void param_set_range(gdouble min, gdouble max);
92 void param_set_digits(unsigned digits);
93 void param_set_increments(double step, double page);
95 virtual Gtk::Widget * param_getWidget();
97 inline operator gdouble()
98 { return value; };
100 protected:
101 gdouble value;
102 gdouble min;
103 gdouble max;
104 bool integer;
105 gdouble defvalue;
106 Inkscape::UI::Widget::RegisteredScalar * rsu;
107 unsigned digits;
108 double inc_step;
109 double inc_page;
111 private:
112 ScalarParam(const ScalarParam&);
113 ScalarParam& operator=(const ScalarParam&);
114 };
116 } //namespace LivePathEffect
118 } //namespace Inkscape
120 #endif
122 /*
123 Local Variables:
124 mode:c++
125 c-file-style:"stroustrup"
126 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
127 indent-tabs-mode:nil
128 fill-column:99
129 End:
130 */
131 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :