Inkscape
Vector Graphics Editor
font-button.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 *
4 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
5 */
6
7#include "font-button.h"
8
9#include <utility>
10#include <gtkmm/fontbutton.h>
11
12namespace Inkscape::UI::Widget {
13
14FontButton::FontButton(Glib::ustring const &label, Glib::ustring const &tooltip,
15 Glib::ustring const &icon, bool mnemonic)
16 : Labelled{label, tooltip, new Gtk::FontButton{"Sans 10"}, icon, mnemonic}
17{
18}
19
20Glib::ustring FontButton::getValue() const
21{
22 return getFontButton().get_font();
23}
24
25void FontButton::setValue(Glib::ustring const &fontspec)
26{
27 getFontButton().set_font(fontspec);
28}
29
30Glib::SignalProxy<void()> FontButton::signal_font_value_changed()
31{
32 return getFontButton().signal_font_set();
33}
34
35Gtk::FontButton const &FontButton::getFontButton() const
36{
37 auto const fontButton = dynamic_cast<Gtk::FontButton const *>(getWidget());
38 g_assert(fontButton);
39 return *fontButton;
40}
41
42Gtk::FontButton &FontButton::getFontButton()
43{
44 return const_cast<Gtk::FontButton &>(std::as_const(*this).getFontButton());
45}
46
47} // namespace Inkscape::UI::Widget
48
49/*
50 Local Variables:
51 mode:c++
52 c-file-style:"stroustrup"
53 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
54 indent-tabs-mode:nil
55 fill-column:99
56 End:
57*/
58// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
A labelled font button for entering font values.
Definition: font-button.h:24
Gtk::FontButton const & getFontButton() const
Definition: font-button.cpp:35
FontButton(Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &icon={}, bool mnemonic=true)
Construct a FontButton Widget.
Definition: font-button.cpp:14
Glib::ustring getValue() const
Definition: font-button.cpp:20
void setValue(Glib::ustring const &fontspec)
Definition: font-button.cpp:25
Glib::SignalProxy< void()> signal_font_value_changed()
Signal raised when the font button's value changes.
Definition: font-button.cpp:30
Adds a label with optional icon to another widget.
Definition: labelled.h:31
Gtk::Widget const * getWidget() const
Definition: labelled.h:48
Definition: desktop.h:51
Custom widgets.
Definition: desktop.h:127