Inkscape
Vector Graphics Editor
frame.cpp
Go to the documentation of this file.
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
13namespace Inkscape::UI::Widget {
14
15Frame::Frame(Glib::ustring const &label_text /*= {}*/, bool label_bold /*= true*/ )
16 : _label(label_text, Gtk::Align::END, Gtk::Align::CENTER, true)
17{
18 add_css_class("flat");
19
20 set_label_widget(_label);
21 set_label(label_text, label_bold);
22}
23
24void
25Frame::add(Widget& widget)
26{
27 Gtk::Frame::set_child(widget);
28 set_padding(4, 0, 8, 0);
29}
30
31void
32Frame::set_label(Glib::ustring const &label_text, bool label_bold /*= true*/)
33{
34 if (label_bold) {
35 _label.set_markup(Glib::ustring("<b>") + label_text + "</b>");
36 } else {
37 _label.set_text(label_text);
38 }
39}
40
41void
42Frame::set_padding(unsigned const padding_top, unsigned const padding_bottom,
43 unsigned const padding_left, unsigned const padding_right)
44{
45 auto child = get_child();
46
47 if(child)
48 {
49 child->set_margin_top(padding_top);
50 child->set_margin_bottom(padding_bottom);
51 child->set_margin_start(padding_left);
52 child->set_margin_end(padding_right);
53 }
54}
55
56Gtk::Label const *
58{
59 return &_label;
60}
61
62} // namespace Inkscape::UI::Widget
63
64/*
65 Local Variables:
66 mode:c++
67 c-file-style:"stroustrup"
68 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
69 indent-tabs-mode:nil
70 fill-column:99
71 End:
72*/
73// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
void set_padding(unsigned padding_top, unsigned padding_bottom, unsigned padding_left, unsigned padding_right)
Set the frame padding.
Definition: frame.cpp:42
void add(Widget &widget)
Add a widget to this frame.
Definition: frame.cpp:25
Frame(Glib::ustring const &label={}, bool label_bold=true)
Construct a Frame Widget.
Definition: frame.cpp:15
void set_label(Glib::ustring const &label, bool label_bold=true)
Set the frame label text and if bold or not.
Definition: frame.cpp:32
Gtk::Label const * get_label_widget() const
Return the label widget.
Definition: frame.cpp:57
Align
Values for the <align> parameter of preserveAspectRatio.
Definition: rect.h:51
Definition: desktop.h:51
Custom widgets.
Definition: desktop.h:127
Ocnode * child[8]
Definition: quantize.cpp:33