2018-03-09 21:54:46 +08:00
|
|
|
/**
|
|
|
|
* File: demo1_app.c
|
2018-05-15 09:31:58 +08:00
|
|
|
* Author: AWTK Develop Team
|
2018-03-09 21:54:46 +08:00
|
|
|
* Brief: basic class of all widget
|
|
|
|
*
|
2018-05-08 10:22:32 +08:00
|
|
|
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
|
2018-03-09 21:54:46 +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 "base/timer.h"
|
|
|
|
#include "base/button.h"
|
|
|
|
#include "base/check_button.h"
|
|
|
|
#include "base/dialog.h"
|
|
|
|
#include "base/image.h"
|
|
|
|
#include "base/image_manager.h"
|
|
|
|
#include "base/label.h"
|
|
|
|
#include "base/mem.h"
|
|
|
|
#include "base/progress_bar.h"
|
|
|
|
#include "base/utils.h"
|
|
|
|
#include "base/window.h"
|
|
|
|
#include "ui_loader/ui_builder_default.h"
|
2018-05-12 18:28:38 +08:00
|
|
|
#include "common.inc"
|
2018-03-09 21:54:46 +08:00
|
|
|
|
2018-06-06 16:18:14 +08:00
|
|
|
#ifdef TK_MEM_SPEED_TEST
|
|
|
|
uint32_t g_memcpy_speed;
|
|
|
|
uint32_t g_memset_speed;
|
|
|
|
#endif/*TK_MEM_SPEED_TEST*/
|
|
|
|
|
2018-03-09 21:54:46 +08:00
|
|
|
static ret_t on_show_dialog(void* ctx, event_t* e) {
|
|
|
|
uint32_t code = 0;
|
2018-03-10 19:11:37 +08:00
|
|
|
const char* name = (const char*)ctx;
|
|
|
|
widget_t* win = window_open(name);
|
2018-03-09 21:54:46 +08:00
|
|
|
|
|
|
|
widget_child_on(win, "ok", EVT_CLICK, on_ok, win);
|
|
|
|
widget_child_on(win, "cancel", EVT_CLICK, on_cancel, win);
|
|
|
|
|
|
|
|
code = dialog_modal(win);
|
|
|
|
|
2018-05-24 11:18:46 +08:00
|
|
|
tk_mem_info_dump();
|
2018-03-09 21:54:46 +08:00
|
|
|
(void)e;
|
2018-03-18 11:29:31 +08:00
|
|
|
(void)code;
|
2018-03-09 21:54:46 +08:00
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|
|
|
|
|
2018-04-21 17:21:55 +08:00
|
|
|
static ret_t on_show_window1(void* ctx, event_t* e) {
|
2018-04-21 07:43:02 +08:00
|
|
|
const char* name = (const char*)ctx;
|
|
|
|
widget_t* win = window_open(name);
|
|
|
|
|
2018-04-21 17:21:55 +08:00
|
|
|
widget_child_on(win, "bottom", EVT_CLICK, on_show_dialog, "bottom");
|
|
|
|
widget_child_on(win, "top", EVT_CLICK, on_show_dialog, "top");
|
|
|
|
widget_child_on(win, "close", EVT_CLICK, on_close, win);
|
|
|
|
|
|
|
|
(void)e;
|
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ret_t on_show_window2(void* ctx, event_t* e) {
|
|
|
|
const char* name = (const char*)ctx;
|
|
|
|
widget_t* win = window_open(name);
|
|
|
|
|
|
|
|
widget_child_on(win, "fade", EVT_CLICK, on_show_dialog, "fade");
|
|
|
|
widget_child_on(win, "top", EVT_CLICK, on_show_dialog, "top");
|
2018-04-21 07:43:02 +08:00
|
|
|
widget_child_on(win, "close", EVT_CLICK, on_close, win);
|
|
|
|
|
|
|
|
(void)e;
|
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|
|
|
|
|
2018-03-09 21:54:46 +08:00
|
|
|
ret_t application_init() {
|
2018-06-06 16:18:14 +08:00
|
|
|
char text[32];
|
2018-04-21 07:43:02 +08:00
|
|
|
widget_t* win = window_open("window");
|
2018-03-18 11:29:31 +08:00
|
|
|
widget_t* bar1 = widget_lookup(win, "bar1", TRUE);
|
|
|
|
widget_t* bar2 = widget_lookup(win, "bar2", TRUE);
|
2018-06-06 16:18:14 +08:00
|
|
|
#ifdef TK_MEM_SPEED_TEST
|
|
|
|
widget_t* left = widget_lookup(win, "left", TRUE);
|
|
|
|
widget_t* right = widget_lookup(win, "right", TRUE);
|
|
|
|
|
|
|
|
tk_snprintf(text, sizeof(text), "set:%uK", g_memset_speed);
|
|
|
|
widget_set_text_utf8(left, text);
|
|
|
|
|
|
|
|
tk_snprintf(text, sizeof(text), "cpy:%uK", g_memcpy_speed);
|
|
|
|
widget_set_text_utf8(right, text);
|
|
|
|
#endif/*TK_MEM_SPEED_TEST*/
|
|
|
|
|
2018-03-18 11:29:31 +08:00
|
|
|
widget_child_on(win, "inc", EVT_CLICK, on_inc, bar2);
|
|
|
|
widget_child_on(win, "dec", EVT_CLICK, on_dec, bar2);
|
2018-04-21 07:43:02 +08:00
|
|
|
widget_child_on(win, "dialog1", EVT_CLICK, on_show_dialog, "dialog1");
|
2018-03-10 19:11:37 +08:00
|
|
|
widget_child_on(win, "dialog2", EVT_CLICK, on_show_dialog, "dialog2");
|
2018-04-21 17:21:55 +08:00
|
|
|
widget_child_on(win, "window1", EVT_CLICK, on_show_window1, "window1");
|
|
|
|
widget_child_on(win, "window2", EVT_CLICK, on_show_window2, "window2");
|
2018-06-06 16:18:14 +08:00
|
|
|
timer_add(on_timer, bar1, 500);
|
2018-03-09 21:54:46 +08:00
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
}
|