Code

RegisteredCheckbutton is now subclassed from RegisteredWidget<CheckButton>
[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"
16 #include "inkscape.h"
17 #include "verbs.h"
18 #include "helper-fns.h"
20 #define noLPEBOOLPARAM_DEBUG
22 namespace Inkscape {
24 namespace LivePathEffect {
26 BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,
27                       const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
28                       Effect* effect, bool default_value )
29     : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)
30 {
31 }
33 BoolParam::~BoolParam()
34 {
35 }
37 void
38 BoolParam::param_set_default()
39 {
40     param_setValue(defvalue);
41 }
43 bool
44 BoolParam::param_readSVGValue(const gchar * strvalue)
45 {
46     param_setValue(helperfns_read_bool(strvalue, defvalue));
47     return true; // not correct: if value is unacceptable, should return false!
48 }
50 gchar *
51 BoolParam::param_writeSVGValue() const
52 {
53     gchar * str = g_strdup(value ? "true" : "false");
54     return str;
55 }
57 Gtk::Widget *
58 BoolParam::param_newWidget(Gtk::Tooltips * tooltips)
59 {
60     Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( 
61         new Inkscape::UI::Widget::RegisteredCheckButton( param_label,
62                                                          param_tooltip,
63                                                          param_key,
64                                                          *param_wr,
65                                                          false,
66                                                          param_effect->getRepr(),
67                                                          param_effect->getSPDoc()) );
69     checkwdg->setActive(value);
70     checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
72     return dynamic_cast<Gtk::Widget *> (checkwdg);
73 }
75 void
76 BoolParam::param_setValue(bool newvalue)
77 {
78     value = newvalue;
79 }
81 } /* namespace LivePathEffect */
83 } /* namespace Inkscape */
85 /*
86   Local Variables:
87   mode:c++
88   c-file-style:"stroustrup"
89   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
90   indent-tabs-mode:nil
91   fill-column:99
92   End:
93 */
94 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :