9
9
#ifndef XWIDGETS_LABEL_HPP
10
10
#define XWIDGETS_LABEL_HPP
11
11
12
- #include " xhtml.hpp"
12
+ #include < string>
13
+
14
+ #include < xtl/xoptional.hpp>
15
+
13
16
#include " xmaterialize.hpp"
14
17
#include " xstring.hpp"
18
+ #include " xstyle.hpp"
15
19
16
20
namespace xw
17
21
{
22
+
23
+ /* ****************************
24
+ * label_style declaration *
25
+ *****************************/
26
+
27
+ template <class D >
28
+ class xlabel_style : public xstyle <D>
29
+ {
30
+ public:
31
+
32
+ using base_type = xstyle<D>;
33
+ using derived_type = D;
34
+
35
+ void serialize_state (nl::json&, xeus::buffer_sequence&) const ;
36
+ void apply_patch (const nl::json&, const xeus::buffer_sequence&);
37
+
38
+ XPROPERTY (xtl::xoptional<std::string>, derived_type, background);
39
+ XPROPERTY (std::string, derived_type, description_width);
40
+ XPROPERTY (xtl::xoptional<std::string>, derived_type, font_family);
41
+ XPROPERTY (xtl::xoptional<std::string>, derived_type, font_size);
42
+ XPROPERTY (xtl::xoptional<std::string>, derived_type, font_style);
43
+ XPROPERTY (xtl::xoptional<std::string>, derived_type, font_variant);
44
+ XPROPERTY (xtl::xoptional<std::string>, derived_type, font_weight);
45
+ XPROPERTY (xtl::xoptional<std::string>, derived_type, text_color);
46
+ XPROPERTY (xtl::xoptional<std::string>, derived_type, text_decoration);
47
+
48
+ protected:
49
+
50
+ xlabel_style ();
51
+
52
+ private:
53
+
54
+ void set_defaults ();
55
+ };
56
+
57
+ using label_style = xmaterialize<xlabel_style>;
58
+
18
59
/* ********************
19
60
* label declaration *
20
61
*********************/
@@ -30,12 +71,11 @@ namespace xw
30
71
void serialize_state (nl::json&, xeus::buffer_sequence&) const ;
31
72
void apply_patch (const nl::json&, const xeus::buffer_sequence&);
32
73
33
- XPROPERTY (::xw::html_style , derived_type, style);
74
+ XPROPERTY (::xw::label_style , derived_type, style);
34
75
35
76
protected:
36
77
37
78
xlabel ();
38
- using base_type::base_type;
39
79
40
80
private:
41
81
@@ -44,6 +84,56 @@ namespace xw
44
84
45
85
using label = xmaterialize<xlabel>;
46
86
87
+ /* ********************************
88
+ * xlabel_style implementation *
89
+ *********************************/
90
+
91
+ template <class D >
92
+ inline void xlabel_style<D>::serialize_state(nl::json& state, xeus::buffer_sequence& buffers) const
93
+ {
94
+ base_type::serialize_state (state, buffers);
95
+
96
+ xwidgets_serialize (background (), state[" background" ], buffers);
97
+ xwidgets_serialize (description_width (), state[" description_width" ], buffers);
98
+ xwidgets_serialize (font_family (), state[" font_family" ], buffers);
99
+ xwidgets_serialize (font_size (), state[" font_size" ], buffers);
100
+ xwidgets_serialize (font_style (), state[" font_style" ], buffers);
101
+ xwidgets_serialize (font_variant (), state[" font_variant" ], buffers);
102
+ xwidgets_serialize (font_weight (), state[" font_weight" ], buffers);
103
+ xwidgets_serialize (text_color (), state[" text_color" ], buffers);
104
+ xwidgets_serialize (text_decoration (), state[" text_decoration" ], buffers);
105
+ }
106
+
107
+ template <class D >
108
+ inline void xlabel_style<D>::apply_patch(const nl::json& patch, const xeus::buffer_sequence& buffers)
109
+ {
110
+ base_type::apply_patch (patch, buffers);
111
+
112
+ set_property_from_patch (background, patch, buffers);
113
+ set_property_from_patch (description_width, patch, buffers);
114
+ set_property_from_patch (font_family, patch, buffers);
115
+ set_property_from_patch (font_size, patch, buffers);
116
+ set_property_from_patch (font_style, patch, buffers);
117
+ set_property_from_patch (font_variant, patch, buffers);
118
+ set_property_from_patch (font_weight, patch, buffers);
119
+ set_property_from_patch (text_color, patch, buffers);
120
+ set_property_from_patch (text_decoration, patch, buffers);
121
+ }
122
+
123
+ template <class D >
124
+ inline xlabel_style<D>::xlabel_style()
125
+ {
126
+ set_defaults ();
127
+ }
128
+
129
+ template <class D >
130
+ inline void xlabel_style<D>::set_defaults()
131
+ {
132
+ this ->_model_module () = " @jupyter-widgets/controls" ;
133
+ this ->_model_module_version () = XWIDGETS_CONTROLS_VERSION;
134
+ this ->_model_name () = " LabelStyleModel" ;
135
+ }
136
+
47
137
/* ************************
48
138
* xlabel implementation *
49
139
*************************/
@@ -74,8 +164,8 @@ namespace xw
74
164
template <class D >
75
165
inline void xlabel<D>::set_defaults()
76
166
{
77
- this ->_model_name () = " HTMLModel " ;
78
- this ->_view_name () = " HTMLView " ;
167
+ this ->_model_name () = " LabelModel " ;
168
+ this ->_view_name () = " LabelView " ;
79
169
}
80
170
81
171
/* ********************
0 commit comments