Code

Warning cleanup.
[inkscape.git] / src / live_effects / parameter / unit.cpp
1 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_UNIT_CPP
3 /*
4  * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
5  *
6  * Released under GNU GPL, read the file 'COPYING' for more information
7  */
9 #include "live_effects/parameter/unit.h"
10 #include "live_effects/effect.h"
11 #include "ui/widget/registered-widget.h"
13 namespace Inkscape {
15 namespace LivePathEffect {
18 UnitParam::UnitParam( const Glib::ustring& label, const Glib::ustring& tip,
19                               const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
20                               Effect* effect, SPUnitId default_value)
21     : Parameter(label, tip, key, wr, effect)
22 {
23     defunit = &sp_unit_get_by_id(default_value);;
24     unit = defunit;
25 }
27 UnitParam::~UnitParam()
28 {
29 }
31 bool
32 UnitParam::param_readSVGValue(const gchar * strvalue)
33 {
34     SPUnit const *newval = sp_unit_get_by_abbreviation(strvalue);
35     if (newval) {
36         param_set_value(newval);
37         return true;
38     }
39     return false;
40 }
42 gchar *
43 UnitParam::param_getSVGValue() const
44 {
45     return g_strdup(sp_unit_get_abbreviation(unit));
46 }
48 void
49 UnitParam::param_set_default()
50 {
51     param_set_value(defunit);
52 }
54 void
55 UnitParam::param_set_value(SPUnit const *val)
56 {
57     unit = val;
58 }
60 const gchar *
61 UnitParam::get_abbreviation()
62 {
63     return sp_unit_get_abbreviation(unit);
64 }
66 Gtk::Widget *
67 UnitParam::param_newWidget(Gtk::Tooltips * /*tooltips*/)
68 {
69     Inkscape::UI::Widget::RegisteredUnitMenu* unit_menu = Gtk::manage(
70         new Inkscape::UI::Widget::RegisteredUnitMenu(param_label,
71                                                      param_key,
72                                                      *param_wr,
73                                                      param_effect->getRepr(),
74                                                      param_effect->getSPDoc()));
76     unit_menu->setUnit(unit);
77     unit_menu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change unit parameter"));
79     return dynamic_cast<Gtk::Widget *> (unit_menu);
80 }
82 } /* 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 :