1 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_TEXT_CPP
3 /*
4 * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
5 *
6 * Authors:
7 * Maximilian Albert
8 * Johan Engelen
9 *
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
13 #include "live_effects/parameter/text.h"
14 #include "live_effects/effect.h"
15 #include "svg/svg.h"
16 #include "svg/stringstream.h"
17 #include <gtkmm.h>
18 #include "widgets/icon.h"
19 #include "ui/widget/registered-widget.h"
20 #include "inkscape.h"
21 #include "verbs.h"
23 namespace Inkscape {
25 namespace LivePathEffect {
27 TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip,
28 const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
29 Effect* effect, const Glib::ustring default_value )
30 : Parameter(label, tip, key, wr, effect),
31 defvalue(default_value)
32 {
33 canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(inkscape_active_desktop()), Geom::Point(0,0), "");
34 sp_canvastext_set_text (canvas_text, default_value.c_str());
35 sp_canvastext_set_coords (canvas_text, 0, 0);
36 }
38 TextParam::~TextParam()
39 {
40 }
42 void
43 TextParam::param_set_default()
44 {
45 param_setValue(defvalue);
46 }
48 void
49 TextParam::setPos(Geom::Point pos)
50 {
51 sp_canvastext_set_coords (canvas_text, pos);
52 }
54 void
55 TextParam::setAnchor(double x_value, double y_value)
56 {
57 anchor_x = x_value;
58 anchor_y = y_value;
59 sp_canvastext_set_anchor (canvas_text, anchor_x, anchor_y);
60 }
62 bool
63 TextParam::param_readSVGValue(const gchar * strvalue)
64 {
65 param_setValue(strvalue);
66 return true;
67 }
69 gchar *
70 TextParam::param_getSVGValue() const
71 {
72 return (gchar *) defvalue.c_str();
73 }
75 Gtk::Widget *
76 TextParam::param_newWidget(Gtk::Tooltips * /*tooltips*/)
77 {
78 /**
79 Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText(
80 param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc()));
82 rsu->setText("");
83 rsu->setProgrammatically = false;
85 rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter"));
87 return dynamic_cast<Gtk::Widget *> (rsu);
88 **/
90 // widget is disabled until it works correctly
91 return NULL;
92 }
94 void
95 TextParam::param_setValue(const Glib::ustring newvalue)
96 {
97 defvalue = newvalue;
99 sp_canvastext_set_text (canvas_text, newvalue.c_str());
100 }
102 } /* namespace LivePathEffect */
104 } /* namespace Inkscape */
106 /*
107 Local Variables:
108 mode:c++
109 c-file-style:"stroustrup"
110 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
111 indent-tabs-mode:nil
112 fill-column:99
113 End:
114 */
115 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :