Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
message.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 *
5 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
6 */
7
8#include <glibmm/i18n.h>
9#include <gtkmm.h>
10
11#include <utility>
12
15#include "live_effects/effect.h"
16
17namespace Inkscape {
18
19namespace LivePathEffect {
20
21MessageParam::MessageParam( const Glib::ustring& label, const Glib::ustring& tip,
22 const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
23 Effect* effect, const gchar * default_message, Glib::ustring legend,
24 Gtk::Align halign, Gtk::Align valign, double marginstart, double marginend)
25 : Parameter(label, tip, key, wr, effect),
26 defmessage(default_message),
27 _legend(std::move(legend)),
28 _halign(halign),
29 _valign(valign),
30 _marginstart(marginstart),
31 _marginend(marginend)
32{
33 if (_legend == Glib::ustring("Use Label")) {
34 _legend = label;
35 }
36 _label = nullptr;
37 _min_height = -1;
38}
39
40void
42{
43 // do nothing
44}
45
46void
47MessageParam::param_update_default(const gchar * default_message)
48{
49 defmessage = default_message;
50}
51
52bool MessageParam::param_readSVGValue(const gchar *strvalue)
53{
54 if (g_strcmp0(strvalue, "")) {
55 param_setValue(strvalue);
56 } else {
57 // do nothing if the strvalue is empty, stick to default value
58 }
59 return true;
60}
61
62Glib::ustring
64{
65 return ""; // we dorn want to store messages in the SVG we store in LPE volatile
66 // variables and get content with
67 // param_getDefaultSVGValue() instead
68}
69
70Glib::ustring
75
76void
78{
80 if (_label) {
81 _label->set_size_request(-1, _min_height);
82 }
83}
84
85
86Gtk::Widget *
88{
89 auto const frame = Gtk::make_managed<Gtk::Frame>(_legend);
90 auto const widg_frame = frame->get_label_widget();
91 widg_frame->set_margin_end(_marginend);
92 widg_frame->set_margin_start(_marginstart);
93
94 _label = Gtk::make_managed<Gtk::Label>(defmessage, Gtk::Align::END);
95 _label->set_use_underline (true);
96 _label->set_use_markup();
97 _label->set_wrap(true);
98 _label->set_size_request(-1, _min_height);
99 _label->set_halign(_halign);
100 _label->set_valign(_valign);
101 _label->set_margin_end(_marginend);
102 _label->set_margin_start(_marginstart);
103
104 frame->set_child(*_label);
105 return frame;
106}
107
108void MessageParam::param_setValue(const gchar *strvalue)
109{
110 if (g_strcmp0(strvalue, defmessage.c_str())) {
112 }
113 defmessage = strvalue;
114}
115
116} /* namespace LivePathEffect */
117
118} /* namespace Inkscape */
119
120/*
121 Local Variables:
122 mode:c++
123 c-file-style:"stroustrup"
124 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
125 indent-tabs-mode:nil
126 fill-column:99
127 End:
128*/
129// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Glib::ustring param_getSVGValue() const override
Definition message.cpp:63
bool param_readSVGValue(const gchar *strvalue) override
Definition message.cpp:52
void param_setValue(const gchar *message)
Definition message.cpp:108
MessageParam(const Glib::ustring &label, const Glib::ustring &tip, const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, Effect *effect, const gchar *default_message="Default message", Glib::ustring legend="Use Label", Gtk::Align halign=Gtk::Align::START, Gtk::Align valign=Gtk::Align::CENTER, double marginstart=6, double marginend=6)
Definition message.cpp:21
void param_update_default(const gchar *default_value) override
Definition message.cpp:47
Gtk::Widget * param_newWidget() override
Definition message.cpp:87
Glib::ustring param_getDefaultSVGValue() const override
Definition message.cpp:71
macro for checking gtkmm version
Glib::ustring label
Helper class to stream background task notifications as a series of messages.
STL namespace.
static cairo_user_data_key_t key
double height