1 #include "../../lv_examples.h"
2 #if LV_USE_SPAN && LV_BUILD_EXAMPLES
3 
4 /**
5  * Create span.
6  */
lv_example_span_1(void)7 void lv_example_span_1(void)
8 {
9     static lv_style_t style;
10     lv_style_init(&style);
11     lv_style_set_border_width(&style, 1);
12     lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_ORANGE));
13     lv_style_set_pad_all(&style, 2);
14 
15     lv_obj_t * spans = lv_spangroup_create(lv_scr_act());
16     lv_obj_set_width(spans, 300);
17     lv_obj_set_height(spans, 300);
18     lv_obj_center(spans);
19     lv_obj_add_style(spans, &style, 0);
20 
21     lv_spangroup_set_align(spans, LV_TEXT_ALIGN_LEFT);
22     lv_spangroup_set_overflow(spans, LV_SPAN_OVERFLOW_CLIP);
23     lv_spangroup_set_indent(spans, 20);
24     lv_spangroup_set_mode(spans, LV_SPAN_MODE_BREAK);
25 
26     lv_span_t * span = lv_spangroup_new_span(spans);
27     lv_span_set_text(span, "China is a beautiful country.");
28     lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_RED));
29     lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_UNDERLINE);
30     lv_style_set_text_opa(&span->style, LV_OPA_50);
31 
32     span = lv_spangroup_new_span(spans);
33     lv_span_set_text_static(span, "good good study, day day up.");
34 #if LV_FONT_MONTSERRAT_24
35     lv_style_set_text_font(&span->style,  &lv_font_montserrat_24);
36 #endif
37     lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_GREEN));
38 
39     span = lv_spangroup_new_span(spans);
40     lv_span_set_text_static(span, "LVGL is an open-source graphics library.");
41     lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_BLUE));
42 
43     span = lv_spangroup_new_span(spans);
44     lv_span_set_text_static(span, "the boy no name.");
45     lv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_GREEN));
46 #if LV_FONT_MONTSERRAT_20
47     lv_style_set_text_font(&span->style, &lv_font_montserrat_20);
48 #endif
49     lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_UNDERLINE);
50 
51     span = lv_spangroup_new_span(spans);
52     lv_span_set_text(span, "I have a dream that hope to come true.");
53     lv_style_set_text_decor(&span->style, LV_TEXT_DECOR_STRIKETHROUGH);
54 
55     lv_spangroup_refr_mode(spans);
56 }
57 
58 #endif
59