2019-11-12 15:59:14 +08:00
|
|
|
/**
|
|
|
|
* File: demo1_app.c
|
|
|
|
* Author: AWTK Develop Team
|
|
|
|
* Brief: basic demo
|
|
|
|
*
|
2020-01-01 11:27:36 +08:00
|
|
|
* Copyright (c) 2018 - 2020 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
2019-11-12 15:59:14 +08:00
|
|
|
*
|
|
|
|
* 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-02-16 Li XianJing <xianjimli@hotmail.com> created
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "awtk.h"
|
|
|
|
|
|
|
|
static ret_t on_timer(const timer_info_t* timer) {
|
|
|
|
widget_t* win = WIDGET(timer->ctx);
|
|
|
|
widget_t* progress_bar = widget_lookup(win, "bar1", TRUE);
|
|
|
|
|
2021-06-24 08:10:31 +08:00
|
|
|
float_t value = ((int)(PROGRESS_BAR(progress_bar)->value + 2)) % 100;
|
2019-11-12 15:59:14 +08:00
|
|
|
progress_bar_set_value(progress_bar, value);
|
|
|
|
|
2021-06-24 08:10:31 +08:00
|
|
|
progress_bar = widget_lookup(win, "bar2", TRUE);
|
|
|
|
|
|
|
|
value = ((int)(PROGRESS_BAR(progress_bar)->value + 2)) % 100;
|
|
|
|
progress_bar_set_value(progress_bar, value);
|
2021-06-24 22:14:27 +08:00
|
|
|
|
2019-11-12 15:59:14 +08:00
|
|
|
return RET_REPEAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ret_t on_inc(void* ctx, event_t* e) {
|
2021-06-26 18:47:41 +08:00
|
|
|
window_manager_resize(window_manager(), 800, 480);
|
2019-11-12 15:59:14 +08:00
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ret_t on_dec(void* ctx, event_t* e) {
|
|
|
|
widget_t* win = WIDGET(ctx);
|
|
|
|
widget_t* progress_bar = widget_lookup(win, "bar2", TRUE);
|
|
|
|
|
|
|
|
float_t value = ((int)(PROGRESS_BAR(progress_bar)->value + 90)) % 100;
|
|
|
|
progress_bar_set_value(progress_bar, value);
|
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ret_t on_value_changed(void* ctx, event_t* e) {
|
|
|
|
widget_t* win = WIDGET(ctx);
|
|
|
|
widget_t* progress_bar = widget_lookup(win, "bar2", TRUE);
|
|
|
|
|
|
|
|
float_t value = widget_get_value(WIDGET(e->target));
|
|
|
|
progress_bar_set_value(progress_bar, value);
|
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ret_t on_close(void* ctx, event_t* e) {
|
|
|
|
dialog_confirm(NULL, "Hello AWTK!\nAre you sure to close?");
|
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_t application_init() {
|
|
|
|
widget_t* system_bar = window_open("system_bar");
|
|
|
|
widget_t* win = window_open("basic");
|
|
|
|
|
2020-09-17 14:42:41 +08:00
|
|
|
(void)system_bar;
|
2019-11-12 15:59:14 +08:00
|
|
|
widget_set_prop_str(win, WIDGET_PROP_CLICKABLE, "no");
|
|
|
|
|
2021-06-24 08:10:31 +08:00
|
|
|
widget_add_timer(win, on_timer, 200);
|
2019-11-12 15:59:14 +08:00
|
|
|
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);
|
|
|
|
widget_child_on(win, "slider", EVT_VALUE_CHANGED, on_value_changed, win);
|
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|
2020-03-19 11:11:32 +08:00
|
|
|
|
|
|
|
ret_t application_exit() {
|
|
|
|
log_debug("application_exit\n");
|
|
|
|
return RET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "awtk_main.inc"
|