78ce179391264dc541eb6b59f80120dc369a24c6
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 checkwdg = NULL;
32 }
34 BoolParam::~BoolParam()
35 {
36 if (checkwdg)
37 delete checkwdg;
38 }
40 void
41 BoolParam::param_set_default()
42 {
43 param_setValue(defvalue);
44 }
46 bool
47 BoolParam::param_readSVGValue(const gchar * strvalue)
48 {
49 param_setValue(helperfns_read_bool(strvalue, defvalue));
50 return true; // not correct: if value is unacceptable, should return false!
51 }
53 gchar *
54 BoolParam::param_writeSVGValue() const
55 {
56 gchar * str = g_strdup(value ? "true" : "false");
57 return str;
58 }
60 Gtk::Widget *
61 BoolParam::param_getWidget()
62 {
63 if (!checkwdg) {
64 checkwdg = new Inkscape::UI::Widget::RegisteredCheckButton();
65 checkwdg->init(param_label, param_tooltip, param_key, *param_wr, false, param_effect->getRepr(), param_effect->getSPDoc());
66 checkwdg->setActive(value);
67 checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
68 }
69 return dynamic_cast<Gtk::Widget *> (checkwdg->_button);
70 }
72 void
73 BoolParam::param_setValue(bool newvalue)
74 {
75 value = newvalue;
76 if (checkwdg)
77 checkwdg->setActive(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 :