diff options
Diffstat (limited to 'fw/fe310/eos/eve/widget/selectw.c')
-rw-r--r-- | fw/fe310/eos/eve/widget/selectw.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/fw/fe310/eos/eve/widget/selectw.c b/fw/fe310/eos/eve/widget/selectw.c index 46ed3d1..5acf998 100644 --- a/fw/fe310/eos/eve/widget/selectw.c +++ b/fw/fe310/eos/eve/widget/selectw.c @@ -8,9 +8,7 @@ #include "screen/window.h" #include "screen/page.h" -#include "label.h" #include "widget.h" -#include "selectw.h" #define SELECTW_NOSELECT 0xffffffff @@ -59,21 +57,6 @@ static void selectw_update_sz(EVESelectWidget *widget, int uievt) { if (uievt) eve_view_uievt_push(&page->v, EVE_UIEVT_WIDGET_UPDATE_G, _widget); } -int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVEPage *page, EVESelectSpec *spec) { - EVEFont *font = spec->font ? spec->font : eve_window_font(page->v.window); - utf8_t *option; - - option = eve_malloc(spec->option_size); - if (option == NULL) { - return EVE_ERR_NOMEM; - } - memset(option, 0, spec->option_size); - - eve_selectw_init(widget, g, page, font, option, spec->option_size, spec->multi); - - return EVE_OK; -} - void eve_selectw_init(EVESelectWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *option, uint16_t option_size, uint8_t multi) { EVEWidget *_widget = &widget->w; int rv; @@ -92,13 +75,32 @@ void eve_selectw_init(EVESelectWidget *widget, EVERect *g, EVEPage *page, EVEFon widget->select = widget->multi ? 0 : SELECTW_NOSELECT; } -void eve_selectw_destroy(EVESelectWidget *widget) { +int eve_selectw_create(EVEWidget *_widget, EVEWidgetSpec *spec, EVEPage *page) { + EVESelectWidget *widget = (EVESelectWidget *)_widget; + EVESelectSpec *tspec = &spec->tspec.select; + EVEFont *font = tspec->font ? tspec->font : eve_window_font(page->v.window); + utf8_t *option; + + option = eve_malloc(tspec->option_size); + if (option == NULL) { + return EVE_ERR_NOMEM; + } + memset(option, 0, tspec->option_size); + + eve_selectw_init(widget, &spec->g, page, font, option, tspec->option_size, tspec->multi); + + return EVE_OK; +} + +void eve_selectw_destroy(EVEWidget *_widget) { + EVESelectWidget *widget = (EVESelectWidget *)_widget; + eve_free(widget->option); } uint8_t eve_selectw_draw(EVEWidget *_widget, uint8_t tag0) { - EVEPage *page = _widget->page; EVESelectWidget *widget = (EVESelectWidget *)_widget; + EVEPage *page = _widget->page; int o_len; int o_curr; int i, s; @@ -161,6 +163,7 @@ int eve_selectw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) { if (evt & EVE_TOUCH_ETYPE_TAG_UP) { int i = touch->tag0 - _widget->tag0 + widget->line0; + if (widget->multi) { uint32_t f = (0x1 << i); @@ -176,12 +179,15 @@ int eve_selectw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) { widget->select = i; } } + + eve_widget_set_focus(_widget, NULL); return 1; } + return 0; } -utf8_t *eve_selectw_option_get(EVESelectWidget *widget, int idx) { +utf8_t *eve_selectw_option(EVESelectWidget *widget, int idx) { int o_len; int o_curr; int i; @@ -199,11 +205,11 @@ utf8_t *eve_selectw_option_get(EVESelectWidget *widget, int idx) { return NULL; } -utf8_t *eve_selectw_option_get_select(EVESelectWidget *widget) { - return eve_selectw_option_get(widget, widget->select); +utf8_t *eve_selectw_option_selected(EVESelectWidget *widget) { + return eve_selectw_option(widget, widget->select); } -int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *option) { +int eve_selectw_add_option(EVESelectWidget *widget, utf8_t *option) { int o_len; int o_curr; int rv, i; @@ -231,7 +237,7 @@ int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *option) { return EVE_OK; } -int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *option, uint16_t option_size) { +int eve_selectw_set_option(EVESelectWidget *widget, utf8_t *option, uint16_t option_size) { int rv, i; rv = selectw_verify(option, option_size); |