Code

better fix for lpe stack forking
[inkscape.git] / src / live_effects / parameter / bool.cpp
1 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_CPP
3 /*
4  * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
5  *
6  * Released under GNU GPL, read the file 'COPYING' for more information
7  */
9 #include "live_effects/parameter/bool.h"
10 #include "live_effects/effect.h"
11 #include "svg/svg.h"
12 #include "svg/stringstream.h"
13 #include <gtkmm.h>
14 #include "widgets/icon.h"
15 #include "ui/widget/registered-widget.h"
16 #include "inkscape.h"
17 #include "verbs.h"
18 #include "helper-fns.h"
20 namespace Inkscape {
22 namespace LivePathEffect {
24 BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,
25                       const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
26                       Effect* effect, bool default_value )
27     : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)
28 {
29 }
31 BoolParam::~BoolParam()
32 {
33 }
35 void
36 BoolParam::param_set_default()
37 {
38     param_setValue(defvalue);
39 }
41 bool
42 BoolParam::param_readSVGValue(const gchar * strvalue)
43 {
44     param_setValue(helperfns_read_bool(strvalue, defvalue));
45     return true; // not correct: if value is unacceptable, should return false!
46 }
48 gchar *
49 BoolParam::param_getSVGValue() const
50 {
51     gchar * str = g_strdup(value ? "true" : "false");
52     return str;
53 }
55 Gtk::Widget *
56 BoolParam::param_newWidget(Gtk::Tooltips * /*tooltips*/)
57 {
58     Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage(
59         new Inkscape::UI::Widget::RegisteredCheckButton( param_label,
60                                                          param_tooltip,
61                                                          param_key,
62                                                          *param_wr,
63                                                          false,
64                                                          param_effect->getRepr(),
65                                                          param_effect->getSPDoc()) );
67     checkwdg->setActive(value);
68     checkwdg->setProgrammatically = false;
69     checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
71     return dynamic_cast<Gtk::Widget *> (checkwdg);
72 }
74 void
75 BoolParam::param_setValue(bool newvalue)
76 {
77     value = newvalue;
78 }
80 } /* namespace LivePathEffect */
82 } /* namespace Inkscape */
84 /*
85   Local Variables:
86   mode:c++
87   c-file-style:"stroustrup"
88   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
89   indent-tabs-mode:nil
90   fill-column:99
91   End:
92 */
93 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :