diff options
Diffstat (limited to 'fw/fe310/eos/eve/widget/strw.c')
-rw-r--r-- | fw/fe310/eos/eve/widget/strw.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c index e78cf46..ae9ccab 100644 --- a/fw/fe310/eos/eve/widget/strw.c +++ b/fw/fe310/eos/eve/widget/strw.c @@ -10,9 +10,7 @@ #include "screen/window.h" #include "screen/page.h" -#include "label.h" #include "widget.h" -#include "strw.h" #define STRW_TOUCH_OPT EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_EXT_X | EVE_TOUCH_OPT_LPRESS @@ -29,20 +27,6 @@ #define CHAR_VALID_INPUT(c) ((c >= 0x20) && (c < 0x7f)) -int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEStrSpec *spec) { - EVEFont *font = spec->font ? spec->font : eve_window_font(page->v.window); - utf8_t *str; - uint16_t *line; - - str = eve_malloc(spec->str_size); - if (str == NULL) return EVE_ERR_NOMEM; - str[0] = '\0'; - - eve_strw_init(widget, g, page, font, str, spec->str_size); - - return EVE_OK; -} - void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *str, uint16_t str_size) { EVEWidget *_widget = &widget->w; int rv, str_len; @@ -71,10 +55,29 @@ int eve_strw_update(EVEStrWidget *widget) { widget->str[str_len] = '\0'; } widget->str_len = str_len; + widget->str_g.w = eve_font_str_w(widget->font, widget->str); return (rv == UTF_OK) ? EVE_OK : EVE_ERR; } -void eve_strw_destroy(EVEStrWidget *widget) { +int eve_strw_create(EVEWidget *_widget, EVEWidgetSpec *spec, EVEPage *page) { + EVEStrWidget *widget = (EVEStrWidget *)_widget; + EVEStrSpec *tspec = &spec->tspec.str; + EVEFont *font = tspec->font ? tspec->font : eve_window_font(page->v.window); + utf8_t *str; + uint16_t *line; + + str = eve_malloc(tspec->str_size); + if (str == NULL) return EVE_ERR_NOMEM; + str[0] = '\0'; + + eve_strw_init(widget, &spec->g, page, font, str, tspec->str_size); + + return EVE_OK; +} + +void eve_strw_destroy(EVEWidget *_widget) { + EVEStrWidget *widget = (EVEStrWidget *)_widget; + eve_free(widget->str); } @@ -86,7 +89,7 @@ static void set_focus(EVEStrWidget *widget) { focus.y = _widget->g.y; focus.w = _widget->g.w; focus.h = 2 * widget->font->h; - eve_widget_focus(_widget, &focus); + eve_widget_set_focus(_widget, &focus); } static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVETouch *touch, short *dx) { @@ -215,8 +218,8 @@ uint8_t eve_strw_draw(EVEWidget *_widget, uint8_t tag0) { } int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) { - EVEPage *page = _widget->page; EVEStrWidget *widget = (EVEStrWidget *)_widget; + EVEPage *page = _widget->page; EVEStrCursor *t_cursor = NULL; short dx; int ret = 0; @@ -290,6 +293,7 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) { widget->track.dx = 0; } + if (ret) eve_widget_set_focus(_widget, NULL); return ret; } @@ -305,7 +309,6 @@ void eve_strw_putc(void *w, int c) { int ins_c = 0, del_c = 0; int ins_w = 0, del_w = 0; - if (c == EVE_PAGE_KBDCH_CLOSE) { if (cursor1->on) eve_strw_cursor_clear(widget, cursor1); if (cursor2->on) eve_strw_cursor_clear(widget, cursor2); |