summaryrefslogtreecommitdiff
path: root/code/fe310/eos/eve
diff options
context:
space:
mode:
Diffstat (limited to 'code/fe310/eos/eve')
-rw-r--r--code/fe310/eos/eve/screen/page.c12
-rw-r--r--code/fe310/eos/eve/screen/page.h2
-rw-r--r--code/fe310/eos/eve/widget/str.c31
-rw-r--r--code/fe310/eos/eve/widget/text.c2
4 files changed, 44 insertions, 3 deletions
diff --git a/code/fe310/eos/eve/screen/page.c b/code/fe310/eos/eve/screen/page.c
index 25acc49..d96a2ba 100644
--- a/code/fe310/eos/eve/screen/page.c
+++ b/code/fe310/eos/eve/screen/page.c
@@ -25,11 +25,19 @@ void eve_page_init(EVEPage *page, eve_view_touch_t touch, eve_view_draw_t draw,
}
int16_t eve_page_x(EVEPage *page, int16_t x) {
- x + page->win_x - page->window->g.x;
+ return x + page->win_x - page->window->g.x;
}
int16_t eve_page_y(EVEPage *page, int16_t y) {
- y + page->win_y - page->window->g.y;
+ return y + page->win_y - page->window->g.y;
+}
+
+int16_t eve_page_scrx(EVEPage *page, int16_t x) {
+ return x - page->win_x + page->window->g.x;
+}
+
+int16_t eve_page_scry(EVEPage *page, int16_t y) {
+ return y - page->win_y + page->window->g.y;
}
void eve_page_set_focus(EVEPage *page, EVEWidget *widget, EVERect *f) {
diff --git a/code/fe310/eos/eve/screen/page.h b/code/fe310/eos/eve/screen/page.h
index eb8dabc..1db859e 100644
--- a/code/fe310/eos/eve/screen/page.h
+++ b/code/fe310/eos/eve/screen/page.h
@@ -23,6 +23,8 @@ typedef struct EVEPage {
void eve_page_init(EVEPage *page, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_open_t open, eve_page_close_t close, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, EVEWindow *window);
int16_t eve_page_x(EVEPage *page, int16_t x);
int16_t eve_page_y(EVEPage *page, int16_t y);
+int16_t eve_page_scrx(EVEPage *page, int16_t x);
+int16_t eve_page_scry(EVEPage *page, int16_t y);
void eve_page_set_focus(EVEPage *page, struct EVEWidget *widget, EVERect *focus);
struct EVEWidget *eve_page_get_focus(EVEPage *page);
diff --git a/code/fe310/eos/eve/widget/str.c b/code/fe310/eos/eve/widget/str.c
index bf86d49..a0caa9d 100644
--- a/code/fe310/eos/eve/widget/str.c
+++ b/code/fe310/eos/eve/widget/str.c
@@ -29,7 +29,13 @@
#define CHAR_VALID_INPUT(c) ((c >= 0x20) && (c < 0x7f))
void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEFont *font, char *str, uint16_t str_size) {
+ EVEWidget *_widget = &widget->w;
+ memset(widget, 0, sizeof(EVEStrWidget));
+ eve_widget_init(_widget, EVE_WIDGET_TYPE_STR, g, eve_strw_touch, eve_strw_draw, eve_strw_putc);
+ widget->font = font;
+ widget->str = str;
+ widget->str_size = str_size;
}
static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVEPage *page, EVETouch *t, short *dx) {
@@ -142,7 +148,32 @@ int eve_strw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_id
}
uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
+ EVEStrWidget *widget = (EVEStrWidget *)_widget;
+ int16_t x = _widget->g.x - widget->str_g.x;
+ char cut = widget->str_g.x || (widget->str_g.w > _widget->g.w);
+
+ widget->tag = tag0;
+ if (tag0 != EVE_TAG_NOTAG) {
+ eve_cmd_dl(TAG(tag0));
+ tag0++;
+ }
+
+ if (cut && page) {
+ int16_t x = eve_page_scrx(page, _widget->g.x);
+ int16_t y = eve_page_scrx(page, _widget->g.y);
+
+ if (x < 0) x = 0;
+ if (y < 0) y = 0;
+ eve_cmd_dl(SAVE_CONTEXT());
+ eve_cmd_dl(SCISSOR_XY(x, y));
+ eve_cmd_dl(SCISSOR_SIZE(_widget->g.w, _widget->g.h));
+ }
+ eve_cmd(CMD_TEXT, "hhhhs", x, _widget->g.y, widget->font->id, 0, widget->str);
+ if (cut && page) {
+ eve_cmd_dl(RESTORE_CONTEXT());
+ }
+ return tag0;
}
void eve_strw_putc(void *_page, int c) {
diff --git a/code/fe310/eos/eve/widget/text.c b/code/fe310/eos/eve/widget/text.c
index a424b9d..a389fa7 100644
--- a/code/fe310/eos/eve/widget/text.c
+++ b/code/fe310/eos/eve/widget/text.c
@@ -37,11 +37,11 @@ void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, char *text
memset(widget, 0, sizeof(EVETextWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_TEXT, g, eve_textw_touch, eve_textw_draw, eve_textw_putc);
+ widget->font = font;
widget->text = text;
widget->text_size = text_size;
widget->line = line;
widget->line_size = line_size;
- widget->font = font;
if (text_size && line_size) eve_textw_update(widget, NULL, 0);
}