improve rich text

This commit is contained in:
lixianjing 2023-07-27 18:22:34 +08:00
parent 9cff5d0f79
commit 2ba951d1c6
2 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@
2023/07/27
* 修改克隆label控件时没有拷贝ellipses属性的问题(感谢朝泽提供补丁)
* 修复克隆 rich_text 对象失败的问题(感谢智明提供补丁)
2023/07/26
* 修改Windows下路径带中文时fs\_os\_get\_exe的返回结果不是utf8的问题(感谢朝泽提供补丁)

View File

@ -513,12 +513,23 @@ static ret_t rich_text_on_event(widget_t* widget, event_t* e) {
return ret;
}
static ret_t rich_text_set_text_form_value(widget_t* widget, const value_t* v) {
rich_text_t* rich_text = RICH_TEXT(widget);
return_value_if_fail(rich_text != NULL, RET_BAD_PARAMS);
wstr_from_value(&(widget->text), v);
rich_text->need_reset = TRUE;
rich_text->line_gap = 5;
rich_text->margin = 2;
return RET_OK;
}
static ret_t rich_text_set_prop(widget_t* widget, const char* name, const value_t* v) {
rich_text_t* rich_text = RICH_TEXT(widget);
return_value_if_fail(rich_text != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, WIDGET_PROP_TEXT)) {
return rich_text_set_text(widget, value_str(v));
return rich_text_set_text_form_value(widget, v);
} else if (tk_str_eq(name, WIDGET_PROP_LINE_GAP)) {
rich_text->line_gap = value_int(v);
rich_text->need_reset = TRUE;