Code

Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in...
[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/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()); }
54  
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 &param_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;
77     bool widget_is_visible;
79 protected:
80     Glib::ustring param_tooltip;
82     Effect* param_effect;
84     void param_write_to_repr(const char * svgd);
86 private:
87     Parameter(const Parameter&);
88     Parameter& operator=(const Parameter&);
89 };
92 class ScalarParam : public Parameter {
93 public:
94     ScalarParam(  const Glib::ustring& label,
95                 const Glib::ustring& tip,
96                 const Glib::ustring& key,
97                 Inkscape::UI::Widget::Registry* wr,
98                 Effect* effect,
99                 gdouble default_value = 1.0);
100     virtual ~ScalarParam();
102     virtual bool param_readSVGValue(const gchar * strvalue);
103     virtual gchar * param_getSVGValue() const;
105     virtual void param_set_default();
106     void param_set_value(gdouble val);
107     void param_make_integer(bool yes = true);
108     void param_set_range(gdouble min, gdouble max);
109     void param_set_digits(unsigned digits);
110     void param_set_increments(double step, double page);
112     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips);
114     inline operator gdouble()
115         { return value; };
117 protected:
118     gdouble value;
119     gdouble min;
120     gdouble max;
121     bool integer;
122     gdouble defvalue;
123     unsigned digits;
124     double inc_step;
125     double inc_page;
127 private:
128     ScalarParam(const ScalarParam&);
129     ScalarParam& operator=(const ScalarParam&);
130 };
132 } //namespace LivePathEffect
134 } //namespace Inkscape
136 #endif
138 /*
139   Local Variables:
140   mode:c++
141   c-file-style:"stroustrup"
142   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
143   indent-tabs-mode:nil
144   fill-column:99
145   End:
146 */
147 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :