summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/widget/widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/eve/widget/widget.c')
-rw-r--r--fw/fe310/eos/eve/widget/widget.c63
1 files changed, 25 insertions, 38 deletions
diff --git a/fw/fe310/eos/eve/widget/widget.c b/fw/fe310/eos/eve/widget/widget.c
index 96d2ddf..a157301 100644
--- a/fw/fe310/eos/eve/widget/widget.c
+++ b/fw/fe310/eos/eve/widget/widget.c
@@ -8,37 +8,11 @@
#include "screen/window.h"
#include "screen/page.h"
-#include "widgets.h"
-
-static const size_t _widget_size[] = {
- 0,
- sizeof(EVEFreeWidget),
- sizeof(EVESpacerWidget),
- sizeof(EVEPageWidget),
- sizeof(EVEStrWidget),
- sizeof(EVETextWidget),
- sizeof(EVESelectWidget),
-};
-
-static const eve_widget_create_t _widget_create[] = {
- NULL,
- (eve_widget_create_t)eve_freew_create,
- (eve_widget_create_t)eve_spacerw_create,
- (eve_widget_create_t)eve_pagew_create,
- (eve_widget_create_t)eve_strw_create,
- (eve_widget_create_t)eve_textw_create,
- (eve_widget_create_t)eve_selectw_create,
-};
-
-static const eve_widget_destroy_t _widget_destroy[] = {
- NULL,
- NULL,
- NULL,
- NULL,
- (eve_widget_destroy_t)eve_strw_destroy,
- (eve_widget_destroy_t)eve_textw_destroy,
- (eve_widget_destroy_t)eve_selectw_destroy,
-};
+#include "widget.h"
+
+extern const size_t _eve_widget_size[];
+extern const eve_widget_create_t _eve_widget_create[];
+extern const eve_widget_destroy_t _eve_widget_destroy[];
void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, EVEPage *page, eve_widget_draw_t draw, eve_widget_touch_t touch, eve_kbd_input_handler_t putc) {
if (g) widget->g = *g;
@@ -50,7 +24,7 @@ void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, EVEPage *page,
}
size_t eve_widget_size(uint8_t type) {
- return _widget_size[type];
+ return _eve_widget_size[type];
}
void eve_widget_set_label(EVEWidget *widget, EVELabel *label) {
@@ -59,19 +33,32 @@ void eve_widget_set_label(EVEWidget *widget, EVELabel *label) {
EVEWidget *eve_widget_next(EVEWidget *widget) {
char *_w = (char *)widget;
- return (EVEWidget *)(_w + _widget_size[widget->type]);
+ return (EVEWidget *)(_w + _eve_widget_size[widget->type]);
}
-int eve_widget_create(EVEWidget *widget, uint8_t type, EVERect *g, EVEPage *page, EVEWidgetSpecT *spec) {
- return _widget_create[type](widget, g, page, spec);
+int eve_widget_create(EVEWidget *widget, EVEWidgetSpec *spec, EVEPage *page) {
+ int rv;
+
+ rv = _eve_widget_create[spec->type](widget, spec, page);
+ if (!rv) eve_widget_set_flags(widget, spec->flags);
+
+ return rv;
}
void eve_widget_destroy(EVEWidget *widget) {
- if (_widget_destroy[widget->type]) _widget_destroy[widget->type](widget);
+ if (_eve_widget_destroy[widget->type]) _eve_widget_destroy[widget->type](widget);
}
-void eve_widget_focus(EVEWidget *widget, EVERect *rect) {
+void eve_widget_set_focus(EVEWidget *widget, EVERect *rect) {
EVEPage *page = widget->page;
- eve_page_focus_widget(page, widget, rect);
+ eve_page_set_focus(page, widget, rect);
+}
+
+void eve_widget_set_flags(EVEWidget *widget, uint8_t flags) {
+ widget->flags |= flags;
+}
+
+void eve_widget_clr_flags(EVEWidget *widget, uint8_t flags) {
+ widget->flags &= ~flags;
}