Inkscape
Vector Graphics Editor
text.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 * Carl Hetherington <inkscape@carlh.net>
5 * Maximilian Albert <maximilian.albert@gmail.com>
6 *
7 * Copyright (C) 2004 Carl Hetherington
8 *
9 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
10 */
11
12#include "text.h"
13
14#include <gtkmm/entry.h>
15
16namespace Inkscape::UI::Widget {
17
18Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip,
19 Glib::ustring const &icon,
20 bool mnemonic)
21 : Labelled{label, tooltip, new Gtk::Entry{}, icon, mnemonic},
22 setProgrammatically(false)
23{
24}
25
26Glib::ustring const Text::getText() const
27{
28 return getEntry().get_text();
29}
30
31void Text::setText(Glib::ustring const text)
32{
33 setProgrammatically = true; // callback is supposed to reset back, if it cares
34 getEntry().set_text(text); // FIXME: set correctly
35}
36
37Glib::SignalProxy<void()> Text::signal_activate()
38{
39 return getEntry().signal_activate();
40}
41
42Gtk::Entry const &Text::getEntry() const
43{
44 auto const entry = dynamic_cast<Gtk::Entry const *>(getWidget());
45 g_assert(entry);
46 return *entry;
47}
48
49Gtk::Entry &Text::getEntry()
50{
51 return const_cast<Gtk::Entry &>(std::as_const(*this).getEntry());
52}
53
54} // namespace Inkscape::UI::Widget
55
56/*
57 Local Variables:
58 mode:c++
59 c-file-style:"stroustrup"
60 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
61 indent-tabs-mode:nil
62 fill-column:99
63 End:
64*/
65// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Helperclass for Gtk::Entry widgets.
Definition: entry.h:24
Adds a label with optional icon to another widget.
Definition: labelled.h:31
Gtk::Widget const * getWidget() const
Definition: labelled.h:48
void setText(Glib::ustring const text)
Sets the text of the text entry.
Definition: text.cpp:31
Gtk::Entry const & getEntry() const
Definition: text.cpp:42
Glib::SignalProxy< void()> signal_activate()
Signal raised when the spin button's value changes.
Definition: text.cpp:37
Glib::ustring const getText() const
Get the text in the entry.
Definition: text.cpp:26
Text(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &icon={}, bool mnemonic=true)
Construct a Text Widget.
Definition: text.cpp:18
Definition: desktop.h:51
Custom widgets.
Definition: desktop.h:127