1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Authors:
4  *   Murray C
5  *
6  * Copyright (C) 2012 Authors
7  *
8  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9  */
10 
11 #include "frame.h"
12 
13 
14 // Inkscape::UI::Widget::Frame
15 
16 namespace Inkscape {
17 namespace UI {
18 namespace Widget {
19 
Frame(Glib::ustring const & label_text,gboolean label_bold)20 Frame::Frame(Glib::ustring const &label_text /*= ""*/, gboolean label_bold /*= TRUE*/ )
21     : _label(label_text, Gtk::ALIGN_END, Gtk::ALIGN_CENTER, true)
22 {
23     set_shadow_type(Gtk::SHADOW_NONE);
24 
25     set_label_widget(_label);
26     set_label(label_text, label_bold);
27 }
28 
29 void
add(Widget & widget)30 Frame::add(Widget& widget)
31 {
32     Gtk::Frame::add(widget);
33     set_padding(4, 0, 8, 0);
34     show_all_children();
35 }
36 
37 void
set_label(const Glib::ustring & label_text,gboolean label_bold)38 Frame::set_label(const Glib::ustring &label_text, gboolean label_bold /*= TRUE*/)
39 {
40     if (label_bold) {
41         _label.set_markup(Glib::ustring("<b>") + label_text + "</b>");
42     } else {
43         _label.set_text(label_text);
44     }
45 }
46 
47 void
set_padding(guint padding_top,guint padding_bottom,guint padding_left,guint padding_right)48 Frame::set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right)
49 {
50     auto child = get_child();
51 
52     if(child)
53     {
54         child->set_margin_top(padding_top);
55         child->set_margin_bottom(padding_bottom);
56         child->set_margin_start(padding_left);
57         child->set_margin_end(padding_right);
58     }
59 }
60 
61 Gtk::Label const *
get_label_widget() const62 Frame::get_label_widget() const
63 {
64     return &_label;
65 }
66 
67 } // namespace Widget
68 } // namespace UI
69 } // namespace Inkscape
70 
71 /*
72   Local Variables:
73   mode:c++
74   c-file-style:"stroustrup"
75   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
76   indent-tabs-mode:nil
77   fill-column:99
78   End:
79 */
80 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
81