Code

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