Code

Warning cleanup
[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 void addKnotHolderEntities(KnotHolder */*knotholder*/, SPDesktop */*desktop*/, SPItem */*item*/) {}
64     virtual void addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/) {};
66     virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
67     virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
69     virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/) {};
71     Glib::ustring param_key;
72     Inkscape::UI::Widget::Registry * param_wr;
73     Glib::ustring param_label;
75     bool oncanvas_editable;
77 protected:
78     Glib::ustring param_tooltip;
80     Effect* param_effect;
82     void param_write_to_repr(const char * svgd);
84 private:
85     Parameter(const Parameter&);
86     Parameter& operator=(const Parameter&);
87 };
90 class ScalarParam : public Parameter {
91 public:
92     ScalarParam(  const Glib::ustring& label,
93                 const Glib::ustring& tip,
94                 const Glib::ustring& key,
95                 Inkscape::UI::Widget::Registry* wr,
96                 Effect* effect,
97                 gdouble default_value = 1.0);
98     virtual ~ScalarParam();
100     virtual bool param_readSVGValue(const gchar * strvalue);
101     virtual gchar * param_getSVGValue() const;
103     virtual void param_set_default();
104     void param_set_value(gdouble val);
105     void param_make_integer(bool yes = true);
106     void param_set_range(gdouble min, gdouble max);
107     void param_set_digits(unsigned digits);
108     void param_set_increments(double step, double page);
110     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips);
112     inline operator gdouble()
113         { return value; };
115 protected:
116     gdouble value;
117     gdouble min;
118     gdouble max;
119     bool integer;
120     gdouble defvalue;
121     unsigned digits;
122     double inc_step;
123     double inc_page;
125 private:
126     ScalarParam(const ScalarParam&);
127     ScalarParam& operator=(const ScalarParam&);
128 };
130 } //namespace LivePathEffect
132 } //namespace Inkscape
134 #endif
136 /*
137   Local Variables:
138   mode:c++
139   c-file-style:"stroustrup"
140   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
141   indent-tabs-mode:nil
142   fill-column:99
143   End:
144 */
145 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :