add new style id

This commit is contained in:
xianjimli 2018-11-14 17:39:16 +08:00
parent 680a22a3fb
commit 61ce4ebddf
3 changed files with 30 additions and 3 deletions

View File

@ -115,6 +115,7 @@ ret_t edit_on_paint_self(widget_t* widget, canvas_t* c) {
edit_t* edit = EDIT(widget);
style_t* style = widget->astyle;
wchar_t temp_str[TEMP_STR_LEN + 1];
color_t trans = color_init(0, 0, 0, 0);
uint8_t left_margin = edit->left_margin;
uint8_t right_margin = edit->right_margin;
uint8_t top_margin = edit->top_margin;
@ -122,7 +123,14 @@ ret_t edit_on_paint_self(widget_t* widget, canvas_t* c) {
wh_t w = widget->w - left_margin - right_margin;
wh_t h = widget->h - top_margin - bottom_margin;
align_h_t align_h = (align_h_t)style_get_int(style, STYLE_ID_TEXT_ALIGN_H, ALIGN_H_CENTER);
/*
color_t selected_bg = style_get_color(style, STYLE_ID_SELECTED_FG_COLOR, trans);
color_t selected_fg = style_get_color(style, STYLE_ID_SELECTED_BG_COLOR, trans);
color_t selected_tc = style_get_color(style, STYLE_ID_SELECTED_TEXT_COLOR, trans);
log_debug("selected_bg=0x%08X selected_fg=%08X selected_tc=%08X\n",
selected_bg.color, selected_fg.color, selected_tc.color);
*/
memset(temp_str, 0x00, sizeof(temp_str));
return_value_if_fail(widget_prepare_text_style(widget, c) == RET_OK, RET_FAIL);
return_value_if_fail(edit_get_display_text(widget, c, &text, temp_str) == RET_OK, RET_FAIL);

View File

@ -46,7 +46,11 @@ static const key_type_value_t style_id_name_value[] = {
{"icon_at", TYPE_STRING, STYLE_ID_ICON_AT},
{"x_offset", TYPE_INT, STYLE_ID_X_OFFSET},
{"y_offset", TYPE_INT, STYLE_ID_Y_OFFSET},
{"margin", TYPE_INT, STYLE_ID_MARGIN}};
{"margin", TYPE_INT, STYLE_ID_MARGIN},
{"selected_bg_color", TYPE_COLOR, STYLE_ID_SELECTED_BG_COLOR},
{"selected_fg_color", TYPE_COLOR, STYLE_ID_SELECTED_FG_COLOR},
{"selected_text_color", TYPE_COLOR, STYLE_ID_SELECTED_TEXT_COLOR},
};
static const key_type_value_t widget_state_name_value[] = {
{"normal", 0, WIDGET_STATE_NORMAL},

View File

@ -39,7 +39,7 @@ typedef enum _style_id_t {
*/
STYLE_ID_BG_COLOR = 1,
/**
* @const STYLE_ID_BG_COLOR
* @const STYLE_ID_FG_COLOR
*
*/
STYLE_ID_FG_COLOR,
@ -137,7 +137,22 @@ typedef enum _style_id_t {
* @const STYLE_ID_Y_OFFSET
* Y方向的偏移便
*/
STYLE_ID_Y_OFFSET
STYLE_ID_Y_OFFSET,
/**
* @const STYLE_ID_SELECTED_BG_COLOR
*
*/
STYLE_ID_SELECTED_BG_COLOR,
/**
* @const STYLE_ID_SELECTED_FG_COLOR
*
*/
STYLE_ID_SELECTED_FG_COLOR,
/**
* @const STYLE_ID_SELECTED_TEXT_COLOR
*
*/
STYLE_ID_SELECTED_TEXT_COLOR,
} style_id_t;
struct _style_t;