Code

RegisteredScalar subclassed from RegisteredWidget<Scalar> instead of old RegisteredWdg
[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     class Tooltips;
25 }
27 namespace Inkscape {
29 namespace NodePath {
30     class Path ;
31 }
33 namespace LivePathEffect {
35 class Effect;
37 class Parameter {
38 public:
39     Parameter(  const Glib::ustring& label,
40                 const Glib::ustring& tip,
41                 const Glib::ustring& key,
42                 Inkscape::UI::Widget::Registry* wr,
43                 Effect* effect);
44     virtual ~Parameter() {};
46     virtual bool param_readSVGValue(const gchar * strvalue) = 0;   // returns true if new value is valid / accepted.
47     virtual gchar * param_writeSVGValue() const = 0;
49     virtual void param_set_default() = 0;
51     // This creates a new widget (newed with Gtk::manage(new ...);)
52     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips) = 0;
54     virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
56     virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
57     virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
59     virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/) {};
61     Glib::ustring param_key;
62     Inkscape::UI::Widget::Registry * param_wr;
63     Glib::ustring param_label;
65     bool oncanvas_editable;
67 protected:
68     Glib::ustring param_tooltip;
70     Effect* param_effect;
72     void param_write_to_repr(const char * svgd);
74 private:
75     Parameter(const Parameter&);
76     Parameter& operator=(const Parameter&);
77 };
80 class ScalarParam : public Parameter {
81 public:
82     ScalarParam(  const Glib::ustring& label,
83                 const Glib::ustring& tip,
84                 const Glib::ustring& key,
85                 Inkscape::UI::Widget::Registry* wr,
86                 Effect* effect,
87                 gdouble default_value = 1.0);
88     virtual ~ScalarParam();
90     virtual bool param_readSVGValue(const gchar * strvalue);
91     virtual gchar * param_writeSVGValue() const;
93     virtual void param_set_default();
94     void param_set_value(gdouble val);
95     void param_make_integer(bool yes = true);
96     void param_set_range(gdouble min, gdouble max);
97     void param_set_digits(unsigned digits);
98     void param_set_increments(double step, double page);
100     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips);
102     inline operator gdouble()
103         { return value; };
105 protected:
106     gdouble value;
107     gdouble min;
108     gdouble max;
109     bool integer;
110     gdouble defvalue;
111     unsigned digits;
112     double inc_step;
113     double inc_page;
115 private:
116     ScalarParam(const ScalarParam&);
117     ScalarParam& operator=(const ScalarParam&);
118 };
120 } //namespace LivePathEffect
122 } //namespace Inkscape
124 #endif
126 /*
127   Local Variables:
128   mode:c++
129   c-file-style:"stroustrup"
130   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
131   indent-tabs-mode:nil
132   fill-column:99
133   End:
134 */
135 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :