mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
add widget_get_text_utf8
This commit is contained in:
parent
3e3141511f
commit
b998843476
2792
dllexports/awtk.def
2792
dllexports/awtk.def
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,8 @@
|
||||
* 修复 edit 编辑 ip/date/time 时,cancel 编辑时的问题。
|
||||
* 新增 [awtk-restful-httpd](https://github.com/zlgopen/awtk-restful-httpd)
|
||||
* 新增 [自动测试引擎](https://github.com/zlgopen/awtk-ui-automation)
|
||||
|
||||
* 新增函数 widget\_get\_text\_utf8
|
||||
|
||||
* 2020/08/21
|
||||
* 修复 main_loop_simple.c 事件部分成员没有初始化的问题(感谢梦幻櫻花提供补丁)。
|
||||
|
||||
|
@ -276,6 +276,27 @@ ret_t widget_set_text_utf8(widget_t* widget, const char* text) {
|
||||
return widget_set_prop(widget, WIDGET_PROP_TEXT, value_set_str(&v, text));
|
||||
}
|
||||
|
||||
ret_t widget_get_text_utf8(widget_t* widget, char* text, uint32_t size) {
|
||||
value_t v;
|
||||
ret_t ret = RET_OK;
|
||||
return_value_if_fail(widget != NULL && text != NULL && size > 0, RET_BAD_PARAMS);
|
||||
|
||||
value_set_str(&v, NULL);
|
||||
memset(text, 0x00, size);
|
||||
if (widget_get_prop(widget, WIDGET_PROP_TEXT, &v) == RET_OK) {
|
||||
if (v.type == VALUE_TYPE_STRING) {
|
||||
tk_strncpy(text, value_str(&v), size - 1);
|
||||
tk_utf8_from_utf16(value_wstr(&v), text, size);
|
||||
ret = RET_OK;
|
||||
} else if (v.type == VALUE_TYPE_WSTRING) {
|
||||
tk_utf8_from_utf16(value_wstr(&v), text, size);
|
||||
ret = RET_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
image_manager_t* widget_get_image_manager(widget_t* widget) {
|
||||
image_manager_t* ret = image_manager();
|
||||
return_value_if_fail(widget != NULL && widget->vt != NULL, ret);
|
||||
|
@ -779,6 +779,18 @@ ret_t widget_use_style(widget_t* widget, const char* style);
|
||||
*/
|
||||
ret_t widget_set_text_utf8(widget_t* widget, const char* text);
|
||||
|
||||
/**
|
||||
* @method widget_get_text_utf8
|
||||
* 获取控件的文本。
|
||||
* 只是对widget\_get\_prop的包装,文本的意义由子类控件决定。
|
||||
* @param {widget_t*} widget 控件对象。
|
||||
* @param {char*} text 用于返回文本。
|
||||
* @param {uint32_t} size text内存长度。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t widget_get_text_utf8(widget_t* widget, char* text, uint32_t size);
|
||||
|
||||
/**
|
||||
* @method widget_set_child_text_utf8
|
||||
* 设置子控件的文本。
|
||||
|
@ -1295,3 +1295,18 @@ TEST(Widget, is_parent_of) {
|
||||
|
||||
widget_destroy(view);
|
||||
}
|
||||
|
||||
TEST(Widget, get_text_utf8) {
|
||||
char text[32];
|
||||
widget_t* w = button_create(NULL, 0, 0, 0, 0);
|
||||
|
||||
widget_set_text(w, L"ok");
|
||||
ASSERT_EQ(widget_get_text_utf8(w, text, sizeof(text)), RET_OK);
|
||||
ASSERT_STREQ(text, "ok");
|
||||
|
||||
widget_set_text(w, L"中文");
|
||||
ASSERT_EQ(widget_get_text_utf8(w, text, sizeof(text)), RET_OK);
|
||||
ASSERT_STREQ(text, "中文");
|
||||
|
||||
widget_destroy(w);
|
||||
}
|
||||
|
@ -18898,6 +18898,32 @@
|
||||
"desc": "返回RET_OK表示成功,否则表示失败。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"type": "widget_t*",
|
||||
"name": "widget",
|
||||
"desc": "控件对象。"
|
||||
},
|
||||
{
|
||||
"type": "char*",
|
||||
"name": "text",
|
||||
"desc": "用于返回文本。"
|
||||
},
|
||||
{
|
||||
"type": "uint32_t",
|
||||
"name": "size",
|
||||
"desc": "text内存长度。"
|
||||
}
|
||||
],
|
||||
"annotation": {},
|
||||
"desc": "获取控件的文本。\n只是对widget\\_get\\_prop的包装,文本的意义由子类控件决定。",
|
||||
"name": "widget_get_text_utf8",
|
||||
"return": {
|
||||
"type": "ret_t",
|
||||
"desc": "返回RET_OK表示成功,否则表示失败。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
@ -33942,6 +33968,22 @@
|
||||
"desc": "成功返回 canvas ,失败返回 NULL。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"type": "canvas_t*",
|
||||
"name": "canvas",
|
||||
"desc": "离线 canvas 对象。"
|
||||
}
|
||||
],
|
||||
"annotation": {},
|
||||
"desc": "把离线 canvas 清除所有数据,并把背景设置为全透明\n该函数调用前必须要先 canvas_offline_begin_draw 函数。\n该函数用来解决离线 canvas 多次绘图半透效果后导致半透效果无效的问题。",
|
||||
"name": "canvas_offline_clear_canvas",
|
||||
"return": {
|
||||
"type": "ret_t",
|
||||
"desc": "返回RET_OK表示成功,否则表示失败。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user