Code

08af7f928b6c2f4f99c38123d55a824f58e8d75b
[inkscape.git] / src / live_effects / parameter / parameter.h
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 &param_tooltip; };
55     virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
56     virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
58     virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/) {};
60     Glib::ustring param_key;
61     Inkscape::UI::Widget::Registry * param_wr;
62     Glib::ustring param_label;
64     bool oncanvas_editable;
66 protected:
67     Glib::ustring param_tooltip;
69     Effect* param_effect;
71 private:
72     Parameter(const Parameter&);
73     Parameter& operator=(const Parameter&);
74 };
77 class ScalarParam : public Parameter {
78 public:
79     ScalarParam(  const Glib::ustring& label,
80                 const Glib::ustring& tip,
81                 const Glib::ustring& key,
82                 Inkscape::UI::Widget::Registry* wr,
83                 Effect* effect,
84                 gdouble default_value = 1.0);
85     virtual ~ScalarParam();
87     virtual bool param_readSVGValue(const gchar * strvalue);
88     virtual gchar * param_writeSVGValue() const;
90     virtual void param_set_default();
91     void param_set_value(gdouble val);
92     void param_make_integer(bool yes = true);
93     void param_set_range(gdouble min, gdouble max);
94     void param_set_digits(unsigned digits);
95     void param_set_increments(double step, double page);
97     virtual Gtk::Widget * param_getWidget();
99     inline operator gdouble()
100         { return value; };
102 protected:
103     gdouble value;
104     gdouble min;
105     gdouble max;
106     bool integer;
107     gdouble defvalue;
108     Inkscape::UI::Widget::RegisteredScalar * rsu;
109     unsigned digits;
110     double inc_step;
111     double inc_page;
113 private:
114     ScalarParam(const ScalarParam&);
115     ScalarParam& operator=(const ScalarParam&);
116 };
118 } //namespace LivePathEffect
120 } //namespace Inkscape
122 #endif
124 /*
125   Local Variables:
126   mode:c++
127   c-file-style:"stroustrup"
128   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
129   indent-tabs-mode:nil
130   fill-column:99
131   End:
132 */
133 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :