-
Notifications
You must be signed in to change notification settings - Fork 16
/
basic.c
74 lines (57 loc) · 1.78 KB
/
basic.c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* File: basic.c
* Author: AWTK Develop Team
* Brief: demo for open window and install event handlers
*
* Copyright (c) 2018 - 2021 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-08-18 Li XianJing <xianjimli@hotmail.com> created
*
*/
#include "awtk.h"
static ret_t on_inc(void* ctx, event_t* e) {
widget_t* win = WIDGET(ctx);
widget_t* bar1 = widget_child(win, "bar1");
widget_t* bar2 = widget_child(win, "bar2");
widget_add_value(bar1, 10);
widget_add_value(bar2, 10);
return RET_OK;
}
static ret_t on_dec(void* ctx, event_t* e) {
widget_t* win = WIDGET(ctx);
widget_t* bar1 = widget_child(win, "bar1");
widget_t* bar2 = widget_child(win, "bar2");
widget_add_value(bar1, -10);
widget_add_value(bar2, -10);
return RET_OK;
}
static ret_t on_close(void* ctx, event_t* e) {
widget_t* win = WIDGET(ctx);
widget_t* bar1 = widget_child(win, "bar1");
widget_t* bar2 = widget_child(win, "bar2");
log_debug("bar1->value=%d\n", (int)(widget_get_value_int(bar1)));
log_debug("bar2->value=%d\n", (int)(widget_get_value_int(bar2)));
tk_quit();
return RET_OK;
}
ret_t application_init() {
widget_t* win = window_open("basic");
widget_child_on(win, "inc_value", EVT_CLICK, on_inc, win);
widget_child_on(win, "dec_value", EVT_CLICK, on_dec, win);
widget_child_on(win, "close", EVT_CLICK, on_close, win);
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"