From 0a11eb9d378d66387dca3178e1bd2c62e61174bd Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 28 Feb 2021 21:51:55 +0100 Subject: added app form --- fw/fe310/eos/app/app_form.c | 99 +++++++++++++++++++++++++++++++++++++++++++++ fw/fe310/eos/app/app_form.h | 7 ++++ 2 files changed, 106 insertions(+) create mode 100644 fw/fe310/eos/app/app_form.c create mode 100644 fw/fe310/eos/app/app_form.h diff --git a/fw/fe310/eos/app/app_form.c b/fw/fe310/eos/app/app_form.c new file mode 100644 index 0000000..ffb416b --- /dev/null +++ b/fw/fe310/eos/app/app_form.c @@ -0,0 +1,99 @@ +#include + +#include "unicode.h" + +#include "eve/eve.h" +#include "eve/eve_kbd.h" +#include "eve/eve_font.h" + +#include "eve/screen/screen.h" +#include "eve/screen/window.h" +#include "eve/screen/view.h" +#include "eve/screen/page.h" +#include "eve/screen/form.h" + +#include "eve/widget/widgets.h" + +#include "app_screen.h" +#include "app_form.h" + +static EVEFont font; + +static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { + int i; + + for (i=0; ilabel) eve_free(widget->label); + eve_widget_destroy(widget); + widget = eve_widget_next(widget); + } +} + +EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor) { + EVEWidget *widgets; + EVEWidget *widget; + EVELabel *label; + EVEForm *form; + EVEFont *_font; + int w_size = 0; + int i, r; + + for (i=0; ilabel && (widget->label->g.w == 0)) eve_font_str_w(label->font, label->title) + APP_LABEL_MARGIN; + if (widget->g.w == 0) widget->g.w = APP_SCREEN_W - (widget->label ? widget->label->g.w : 0); + widget = eve_widget_next(widget); + } + + if (destructor == NULL) destructor = app_form_destroy; + eve_form_init(form, window, stack, widgets, spec_size, action, destructor); + + return form; +} + +void app_form_destroy(EVEForm *form) { + widgets_destroy(form->widget, form->widget_size); + eve_free(form->widget); + eve_free(form); +} + +void app_form_init(void) { + eve_spi_start(); + eve_font_init(&font, APP_FONT_HANDLE); + eve_spi_stop(); +} diff --git a/fw/fe310/eos/app/app_form.h b/fw/fe310/eos/app/app_form.h new file mode 100644 index 0000000..ed62253 --- /dev/null +++ b/fw/fe310/eos/app/app_form.h @@ -0,0 +1,7 @@ +#include + +#define APP_FONT_HANDLE 31 +#define APP_LABEL_MARGIN 10 + +EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor); +void app_form_destroy(EVEForm *form); -- cgit v1.2.3