1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#include <stdlib.h>
#include <string.h>
#include "eve.h"
#include "eve_kbd.h"
#include "eve_font.h"
#include "screen/window.h"
#include "screen/page.h"
#include "widget.h"
void eve_pagew_init(EVEPageWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, char *title, eve_view_constructor_t constructor) {
EVEWidget *_widget = &widget->w;
memset(widget, 0, sizeof(EVEPageWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_PAGE, g, page, eve_pagew_draw, eve_pagew_touch, NULL);
widget->font = font;
widget->title = title;
widget->constructor = constructor;
if (_widget->g.h == 0) _widget->g.h = eve_font_h(widget->font);
}
int eve_pagew_create(EVEWidget *_widget, EVEWidgetSpec *spec, EVEPage *page) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
EVEPageSpec *tspec = &spec->tspec.page;
EVEFont *font = tspec->font ? tspec->font : eve_window_font(page->v.window);
eve_pagew_init(widget, &spec->g, page, font, tspec->title, tspec->constructor);
return EVE_OK;
}
uint8_t eve_pagew_draw(EVEWidget *_widget, uint8_t tag0) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
_widget->tag0 = tag0;
if (tag0 != EVE_NOTAG) {
eve_cmd_dl(TAG(tag0));
tag0++;
}
_widget->tagN = tag0;
eve_cmd(CMD_TEXT, "hhhhs", _widget->g.x, _widget->g.y, widget->font->id, 0, widget->title);
return _widget->tagN;
}
int eve_pagew_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
EVEPage *parent = _widget->page;
EVEPageWidget *widget = (EVEPageWidget *)_widget;
if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
eve_page_open(parent, widget->constructor);
return 1;
}
return 0;
}
|