summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/widget/textw.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/eve/widget/textw.c')
-rw-r--r--fw/fe310/eos/eve/widget/textw.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c
index e994c0e..70a1e06 100644
--- a/fw/fe310/eos/eve/widget/textw.c
+++ b/fw/fe310/eos/eve/widget/textw.c
@@ -10,9 +10,7 @@
#include "screen/window.h"
#include "screen/page.h"
-#include "label.h"
#include "widget.h"
-#include "textw.h"
#define TEXTW_TOUCH_OPT EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT_XY | EVE_TOUCH_OPT_LPRESS
@@ -32,27 +30,6 @@
#define DIVC(x,y) ((x) / (y) + ((x) % (y) != 0))
-int eve_textw_create(EVETextWidget *widget, EVERect *g, EVEPage *page, EVETextSpec *spec) {
- EVEFont *font = spec->font ? spec->font : eve_window_font(page->v.window);
- utf8_t *text;
- uint16_t *line;
-
- text = eve_malloc(spec->text_size);
- if (text == NULL) {
- return EVE_ERR_NOMEM;
- }
- text[0] = '\0';
- line = eve_malloc(sizeof(uint16_t) * spec->line_size);
- if (line == NULL) {
- free(text);
- return EVE_ERR_NOMEM;
- }
-
- eve_textw_init(widget, g, page, font, text, spec->text_size, line, spec->line_size);
-
- return EVE_OK;
-}
-
void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size) {
EVEWidget *_widget = &widget->w;
int rv, text_len;
@@ -74,7 +51,32 @@ void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEPage *page, EVEFont *f
eve_textw_text_update(widget, 0, 0);
}
-void eve_textw_destroy(EVETextWidget *widget) {
+int eve_textw_create(EVEWidget *_widget, EVEWidgetSpec *spec, EVEPage *page) {
+ EVETextWidget *widget = (EVETextWidget *)_widget;
+ EVETextSpec *tspec = &spec->tspec.text;
+ EVEFont *font = tspec->font ? tspec->font : eve_window_font(page->v.window);
+ utf8_t *text;
+ uint16_t *line;
+
+ text = eve_malloc(tspec->text_size);
+ if (text == NULL) {
+ return EVE_ERR_NOMEM;
+ }
+ text[0] = '\0';
+ line = eve_malloc(sizeof(uint16_t) * tspec->line_size);
+ if (line == NULL) {
+ free(text);
+ return EVE_ERR_NOMEM;
+ }
+
+ eve_textw_init(widget, &spec->g, page, font, text, tspec->text_size, line, tspec->line_size);
+
+ return EVE_OK;
+}
+
+void eve_textw_destroy(EVEWidget *_widget) {
+ EVETextWidget *widget = (EVETextWidget *)_widget;
+
eve_free(widget->line);
eve_free(widget->text);
}
@@ -87,7 +89,7 @@ static void set_focus(EVETextWidget *widget, EVETextCursor *cursor) {
focus.y = _widget->g.y + cursor->line * widget->font->h;
focus.w = _widget->g.w;
focus.h = 2 * widget->font->h;
- eve_widget_focus(_widget, &focus);
+ eve_widget_set_focus(_widget, &focus);
}
static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, EVETouch *touch, short *dx, short *dl) {
@@ -144,8 +146,8 @@ static void draw_cursor(EVETextWidget *widget, EVETextCursor *cursor) {
}
uint8_t eve_textw_draw(EVEWidget *_widget, uint8_t tag0) {
- EVEPage *page = _widget->page;
EVETextWidget *widget = (EVETextWidget *)_widget;
+ EVEPage *page = _widget->page;
int line0, lineN;
int _line0, _lineN;
char lineNvisible;
@@ -237,8 +239,8 @@ uint8_t eve_textw_draw(EVEWidget *_widget, uint8_t tag0) {
}
int eve_textw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
- EVEPage *page = _widget->page;
EVETextWidget *widget = (EVETextWidget *)_widget;
+ EVEPage *page = _widget->page;
EVETextCursor *t_cursor = NULL;
short dx, dl;
int ret = 0;
@@ -289,6 +291,7 @@ int eve_textw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
widget->track.dl = 0;
}
+ if (ret) eve_widget_set_focus(_widget, NULL);
return ret;
}