显示原文
A spangroup is the object that is used to display rich text. Different from the label object, spangroup
can render text styled with different fonts, colors, and sizes into the spangroup object.
spangroup 是用于显示富文本的对象。不同 从Label对象中,可以呈现样式为 spangroup
, 将不同的字体、颜色和大小添加到 SpanGroup 对象中。
显示原文
- :cpp
LV_PART_MAIN
The spangroup has only one part.
- :cpp
LV_PART_MAIN
spangroup只有一个部分。
显示原文
The spangroup object uses span to describe text and text style. so, first we need to create span
descriptor using lv_span_t * span = lv_spangroup_new_span(spangroup)
. Then use :cpplv_span_set_text(span, "text")
to set text. The style of the span is configured as with a normal style object by using its style
member, eg::cpplv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_RED))
.
If spangroup object mode != LV_SPAN_MODE_FIXED
you must call :cpplv_spangroup_refr_mode
after you have modified span
style(eg:set text, changed the font size, del span).
spangroup 对象使用 span 来描述文本和文本样式。所以 首先,我们需要使用 . 然后使用 lv_span_t * span = lv_spangroup_new_span(spangroup)
创建 span 描述符。跨度的样式是使用 style
其成员配置为使用普通样式对象, 例如::cpplv_style_set_text_color(&span->style, lv_palette_main(LV_PALETTE_RED))
。
显示原文
Spangroups store their children differently from normal objects, so normal functions for getting children won't work.
:cpplv_spangroup_get_child(spangroup, id)
will return a pointer to the child span at index id
. In addition, id
can be negative to index from the end of the spangroup where -1
is the youngest child, -2
is second youngest, etc.
E.g. lv_span_t* span = lv_spangroup_get_child(spangroup, 0)
will return the first child of the spangroup. lv_span_t* span = lv_spangroup_get_child(spangroup, -1)
will return the last (or most recent) child.
Spangroups 存储其子对象的方式与普通对象不同,因此子项的正常功能将不起作用。
:cpplv_spangroup_get_child(spangroup, id)
将返回指向 id
索引处的子跨度。此外, id
可以对指数负数从跨组的末尾开始, -1
最小的孩子在哪里, -2
是第二年轻的孩子,等等。
例如 lv_span_t* span = lv_spangroup_get_child(spangroup, 0)
将 lv_span_t* span = lv_spangroup_get_child(spangroup, -1)
返回 spangroup 的第一个子项。 lv_span_t* span = lv_spangroup_get_child(spangroup, -1)
将返回最后一个(或最近)的孩子。
显示原文
Use the function :cpplv_spangroup_get_span_count(spangroup)
to get back the number of spans the group is maintaining.
E.g. uint32_t size = lv_spangroup_get_span_count(spangroup)
使用函数 :cpplv_spangroup_get_span_count(spangroup)
返回组正在维护的跨度数。
例如 uint32_t size = lv_spangroup_get_span_count(spangroup)
显示原文
Like label object, the spangroup can be set to one the following modes:
- :cpp
LV_TEXT_ALIGN_LEFT
Align to left. - :cpp
LV_TEXT_ALIGN_CENTER
Align to center. - :cpp
LV_TEXT_ALIGN_RIGHT
Align to right. - :cpp
LV_TEXT_ALIGN_AUTO
Align auto.
Use function :cpplv_spangroup_set_align(spangroup, LV_TEXT_ALIGN_CENTER)
to set text align.
与标签对象一样,spangroup 可以设置为以下模式之一:
- :cpp
LV_TEXT_ALIGN_LEFT
向左对齐。 - :cpp
LV_TEXT_ALIGN_CENTER
居中对齐。 - :cpp
LV_TEXT_ALIGN_RIGHT
向右对齐。 - :cpp
LV_TEXT_ALIGN_AUTO
自动对齐。
使用函数 :cpplv_spangroup_set_align(spangroup, LV_TEXT_ALIGN_CENTER)
设置文本对齐。
显示原文
The spangroup can be set to one the following modes:
- :cpp
LV_SPAN_MODE_FIXED
Fixes the object size. - :cpp
LV_SPAN_MODE_EXPAND
Expand the object size to the text size but stay on a single line. - :cpp
LV_SPAN_MODE_BREAK
Keep width, break the too long lines and auto expand height.
Use the function :cpplv_spangroup_set_mode(spangroup, LV_SPAN_MODE_BREAK)
to set object mode.
spangroup 可以设置为以下模式之一:
- :cpp
LV_SPAN_MODE_FIXED
F固定对象大小。 - :cpp
LV_SPAN_MODE_EXPAND
将对象大小扩展到文本大小,但保留在一行上。 - :cpp
LV_SPAN_MODE_BREAK
保持宽度,打破太长的线条并自动扩展高度。
使用函数 :cpplv_spangroup_set_mode(spangroup, LV_SPAN_MODE_BREAK)
设置为对象模式。
显示原文
The spangroup can be set to one the following modes:
- :cpp
LV_SPAN_OVERFLOW_CLIP
truncates the text at the limit of the area. - :cpp
LV_SPAN_OVERFLOW_ELLIPSIS
will display an ellipsis (...
) when text overflows the area.
Use function :cpplv_spangroup_set_overflow(spangroup, LV_SPAN_OVERFLOW_CLIP)
to set object overflow mode.
spangroup 可以设置为以下模式之一:
- :cpp
LV_SPAN_OVERFLOW_CLIP
在区域的边界处截断文本。 - :cpp
LV_SPAN_OVERFLOW_ELLIPSIS
当文本溢出该区域时将显示省略号 (...
)。
使用函数 :cpplv_spangroup_set_overflow(spangroup, LV_SPAN_OVERFLOW_CLIP)
设置对象溢出模式。
显示原文
Use function :cpplv_spangroup_set_indent(spangroup, 20)
to set the indent of the first line. all modes support pixel units, in addition to :cppLV_SPAN_MODE_FIXED
and :cppLV_SPAN_MODE_BREAK
mode supports percentage units too.
使用函数 :cpplv_spangroup_set_indent(spangroup, 20)
设置第一行。所有模式都支持像素单位,此外, :cppLV_SPAN_MODE_FIXED
和 :cppLV_SPAN_MODE_BREAK
模式还支持百分比单位 。
显示原文
Use function :cpplv_spangroup_set_max_lines(spangroup, 10)
to set the maximum number of lines to be displayed in :cpp:enumerator::LV_SPAN_MODE_BREAK mode, negative values indicate no limit.
使用函数 :cpplv_spangroup_set_max_lines(spangroup, 10)
设置最大数量 在 :cpp:enumerator::LV_SPAN_MODE_BREAK 模式下显示的行数,负值表示没有限制。
显示原文
No special events are sent by this widget.
Learn more about events
.
此小组件不会发送任何特殊事件。
详细了解更多 events
。
显示原文
No Keys are processed by the object type.
Learn more about indev_keys
.
对象类型不处理任何 按键。
了解有关 indev_keys
的更多信息。