mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 19:49:11 +08:00
get edit/mledit margin value from style
This commit is contained in:
parent
b15d3c9f6e
commit
a57f360f62
@ -2,6 +2,7 @@
|
||||
|
||||
* 2019/09/30
|
||||
* 修改文档的BUG(感谢俊杰提供补丁)。
|
||||
* edit/mledit的margin从style中获取,从属性获取仍然保留(但不支持在IDE中设置)。
|
||||
|
||||
* 2019/09/29
|
||||
* 修改combo\_box\_ex获取type的问题(感谢尧燊提供补丁)。
|
||||
|
@ -104,7 +104,8 @@ static align_h_t widget_get_text_align_h(widget_t* widget) {
|
||||
|
||||
static ret_t widget_get_text_layout_info(widget_t* widget, text_layout_info_t* info) {
|
||||
value_t v;
|
||||
return_value_if_fail(widget != NULL && info != NULL, RET_BAD_PARAMS);
|
||||
style_t* style = widget->astyle;
|
||||
return_value_if_fail(widget != NULL && info != NULL && style != NULL, RET_BAD_PARAMS);
|
||||
|
||||
value_set_int(&v, 0);
|
||||
info->widget_w = widget->w;
|
||||
@ -114,26 +115,50 @@ static ret_t widget_get_text_layout_info(widget_t* widget, text_layout_info_t* i
|
||||
|
||||
if (widget_get_prop(widget, WIDGET_PROP_LEFT_MARGIN, &v) == RET_OK) {
|
||||
info->margin_l = value_int(&v);
|
||||
} else {
|
||||
info->margin_l = 1;
|
||||
}
|
||||
|
||||
if (info->margin_l == 0) {
|
||||
info->margin_l = style_get_int(style, STYLE_ID_MARGIN_LEFT, 1);
|
||||
}
|
||||
|
||||
if (info->margin_l == 0) {
|
||||
info->margin_l = style_get_int(style, STYLE_ID_MARGIN, 1);
|
||||
}
|
||||
|
||||
if (widget_get_prop(widget, WIDGET_PROP_RIGHT_MARGIN, &v) == RET_OK) {
|
||||
info->margin_r = value_int(&v);
|
||||
} else {
|
||||
info->margin_r = 1;
|
||||
}
|
||||
|
||||
if (info->margin_r == 0) {
|
||||
info->margin_r = style_get_int(style, STYLE_ID_MARGIN_RIGHT, 1);
|
||||
}
|
||||
|
||||
if (info->margin_r == 0) {
|
||||
info->margin_r = style_get_int(style, STYLE_ID_MARGIN, 1);
|
||||
}
|
||||
|
||||
if (widget_get_prop(widget, WIDGET_PROP_TOP_MARGIN, &v) == RET_OK) {
|
||||
info->margin_t = value_int(&v);
|
||||
} else {
|
||||
info->margin_t = 1;
|
||||
}
|
||||
|
||||
if (info->margin_t == 0) {
|
||||
info->margin_t = style_get_int(style, STYLE_ID_MARGIN_TOP, 1);
|
||||
}
|
||||
|
||||
if (info->margin_t == 0) {
|
||||
info->margin_t = style_get_int(style, STYLE_ID_MARGIN, 1);
|
||||
}
|
||||
|
||||
if (widget_get_prop(widget, WIDGET_PROP_BOTTOM_MARGIN, &v) == RET_OK) {
|
||||
info->margin_b = value_int(&v);
|
||||
} else {
|
||||
info->margin_b = 1;
|
||||
}
|
||||
|
||||
if (info->margin_b == 0) {
|
||||
info->margin_b = style_get_int(style, STYLE_ID_MARGIN_BOTTOM, 1);
|
||||
}
|
||||
|
||||
if (info->margin_b == 0) {
|
||||
info->margin_b = style_get_int(style, STYLE_ID_MARGIN, 1);
|
||||
}
|
||||
|
||||
info->w = info->widget_w - info->margin_l - info->margin_r;
|
||||
|
@ -67,25 +67,25 @@ typedef struct _mledit_t {
|
||||
bool_t readonly;
|
||||
/**
|
||||
* @property {uint8_t} top_margin
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* @annotation ["set_prop","get_prop","readable"]
|
||||
* 上边距。
|
||||
*/
|
||||
uint8_t top_margin;
|
||||
/**
|
||||
* @property {uint8_t} bottom_margin
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* @annotation ["set_prop","get_prop","readable"]
|
||||
* 下边距。
|
||||
*/
|
||||
uint8_t bottom_margin;
|
||||
/**
|
||||
* @property {uint8_t} left_margin
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* @annotation ["set_prop","get_prop","readable"]
|
||||
* 左边距。
|
||||
*/
|
||||
uint8_t left_margin;
|
||||
/**
|
||||
* @property {uint8_t} right_margin
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* @annotation ["set_prop","get_prop","readable"]
|
||||
* 右边距。
|
||||
*/
|
||||
uint8_t right_margin;
|
||||
|
@ -151,6 +151,23 @@ static ret_t combo_box_on_layout_children(widget_t* widget) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static uint32_t edit_get_right_margin(widget_t* widget) {
|
||||
int32_t right_margin = 0;
|
||||
style_t* style = widget->astyle;
|
||||
|
||||
right_margin = widget_get_prop_int(widget, WIDGET_PROP_RIGHT_MARGIN, 0);
|
||||
|
||||
if (right_margin == 0) {
|
||||
right_margin = style_get_int(style, STYLE_ID_MARGIN_RIGHT, 0);
|
||||
}
|
||||
|
||||
if (right_margin == 0) {
|
||||
right_margin = style_get_int(style, STYLE_ID_MARGIN, 0);
|
||||
}
|
||||
|
||||
return right_margin;
|
||||
}
|
||||
|
||||
static ret_t combo_box_on_event(widget_t* widget, event_t* e) {
|
||||
combo_box_t* combo_box = COMBO_BOX(widget);
|
||||
edit_t* edit = EDIT(WIDGET(combo_box));
|
||||
@ -159,8 +176,10 @@ static ret_t combo_box_on_event(widget_t* widget, event_t* e) {
|
||||
switch (e->type) {
|
||||
case EVT_RESIZE:
|
||||
case EVT_MOVE_RESIZE:
|
||||
edit->right_margin = widget->h;
|
||||
edit->left_margin = 4;
|
||||
if (edit_get_right_margin(widget) == 0) {
|
||||
edit->right_margin = widget->h;
|
||||
edit->left_margin = 4;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -189,8 +208,8 @@ widget_t* combo_box_create_self(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h
|
||||
edit_t* edit = EDIT(WIDGET(combo_box));
|
||||
return_value_if_fail(combo_box != NULL, NULL);
|
||||
|
||||
edit->right_margin = h;
|
||||
edit->left_margin = 4;
|
||||
edit->left_margin = 0;
|
||||
edit->right_margin = 0;
|
||||
str_init(&(combo_box->text), 32);
|
||||
combo_box->localize_options = TRUE;
|
||||
|
||||
|
@ -114,25 +114,25 @@ typedef struct _edit_t {
|
||||
bool_t auto_fix;
|
||||
/**
|
||||
* @property {uint8_t} top_margin
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* @annotation ["set_prop","get_prop","readable"]
|
||||
* 上边距。
|
||||
*/
|
||||
uint8_t top_margin;
|
||||
/**
|
||||
* @property {uint8_t} bottom_margin
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* @annotation ["set_prop","get_prop","readable"]
|
||||
* 下边距。
|
||||
*/
|
||||
uint8_t bottom_margin;
|
||||
/**
|
||||
* @property {uint8_t} left_margin
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* @annotation ["set_prop","get_prop","readable"]
|
||||
* 左边距。
|
||||
*/
|
||||
uint8_t left_margin;
|
||||
/**
|
||||
* @property {uint8_t} right_margin
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* @annotation ["set_prop","get_prop","readable"]
|
||||
* 右边距。
|
||||
*/
|
||||
uint8_t right_margin;
|
||||
|
@ -147,8 +147,6 @@ TEST(ComboBox, resize) {
|
||||
widget_t* w = combo_box_create(NULL, 0, 0, 100, 100);
|
||||
edit_t* edit = EDIT(w);
|
||||
|
||||
ASSERT_EQ(edit->right_margin, 100);
|
||||
|
||||
widget_resize(w, 200, 30);
|
||||
ASSERT_EQ(edit->right_margin, 30);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user