a6b05bf362ad8185393ba4650b5ac42f7ecbc5ba
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 namespace Gtk {
20 class Widget;
21 }
23 namespace Inkscape {
25 namespace LivePathEffect {
27 class Effect;
29 class Parameter {
30 public:
31 Parameter( const Glib::ustring& label,
32 const Glib::ustring& tip,
33 const Glib::ustring& key,
34 Inkscape::UI::Widget::Registry* wr,
35 Effect* effect);
36 virtual ~Parameter() {};
38 virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
39 virtual gchar * param_writeSVGValue() const = 0;
41 virtual void param_set_default() = 0;
43 // This returns pointer to the parameter's widget to be put in the live-effects dialog. Must also create the
44 // necessary widget if it does not exist yet.
45 virtual Gtk::Widget * param_getWidget() = 0;
46 virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; };
48 Glib::ustring param_key;
49 Inkscape::UI::Widget::Registry * param_wr;
50 Glib::ustring param_label;
52 protected:
53 Glib::ustring param_tooltip;
55 Effect* param_effect;
57 private:
58 Parameter(const Parameter&);
59 Parameter& operator=(const Parameter&);
60 };
63 class ScalarParam : public Parameter {
64 public:
65 ScalarParam( const Glib::ustring& label,
66 const Glib::ustring& tip,
67 const Glib::ustring& key,
68 Inkscape::UI::Widget::Registry* wr,
69 Effect* effect,
70 gdouble default_value = 1.0);
71 virtual ~ScalarParam();
73 virtual bool param_readSVGValue(const gchar * strvalue);
74 virtual gchar * param_writeSVGValue() const;
76 virtual void param_set_default();
77 void param_set_value(gdouble val);
78 void param_make_integer(bool yes = true);
79 void param_set_range(gdouble min, gdouble max);
80 void param_set_digits(unsigned digits);
81 void param_set_increments(double step, double page);
83 virtual Gtk::Widget * param_getWidget();
85 inline operator gdouble()
86 { return value; };
88 protected:
89 gdouble value;
90 gdouble min;
91 gdouble max;
92 bool integer;
93 gdouble defvalue;
94 Inkscape::UI::Widget::RegisteredScalar * rsu;
95 unsigned digits;
96 double inc_step;
97 double inc_page;
99 private:
100 ScalarParam(const ScalarParam&);
101 ScalarParam& operator=(const ScalarParam&);
102 };
104 } //namespace LivePathEffect
106 } //namespace Inkscape
108 #endif