Code

RegisteredWidget has been renamed to RegisteredWdg. This is a deprecated class, all...
[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     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_newWidget(Gtk::Tooltips * tooltips)
62 {
63     // WIDGET TODO: This implementation is incorrect, it should create a *new* widget for the caller, not just return an already created widget
64     g_warning("BoolParam::param_newWidget still needs recoding to work with multiple document views");
65     if (!checkwdg) {
66         checkwdg = new Inkscape::UI::Widget::RegisteredCheckButton();
67         checkwdg->init(param_label, param_tooltip, param_key, *param_wr, false, param_effect->getRepr(), param_effect->getSPDoc());
68         checkwdg->setActive(value);
69         checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
70     }
71     return dynamic_cast<Gtk::Widget *> (checkwdg->_button);
72 }
74 void
75 BoolParam::param_setValue(bool newvalue)
76 {
77     value = newvalue;
78     if (checkwdg)
79         checkwdg->setActive(newvalue);
80 }
82 } /* namespace LivePathEffect */
84 } /* namespace Inkscape */
86 /*
87   Local Variables:
88   mode:c++
89   c-file-style:"stroustrup"
90   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
91   indent-tabs-mode:nil
92   fill-column:99
93   End:
94 */
95 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :