-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmulti_windows.c
71 lines (55 loc) · 1.82 KB
/
multi_windows.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
/**
* File: dialog.c
* Author: AWTK Develop Team
* Brief: dialog demo
*
* Copyright (c) 2018 - 2025 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:
* ================================================================
* 2019-03-04 Li XianJing <[email protected]> created
*
*/
#include "awtk.h"
static ret_t on_open_window(void* ctx, event_t* evt) {
widget_t* win = window_create(NULL, 0, 0, 0, 0);
widget_t* label = label_create(win, 0, 0, 0, 0);
widget_set_prop_str(win, WIDGET_PROP_ANIM_HINT, "htranslate");
widget_set_text(label, L"Press F2/F3 To CLose");
widget_set_self_layout_params(label, "center", "middle", "100%", "30");
widget_layout(win);
return RET_OK;
}
static ret_t on_key_back_or_back_to_home(void* ctx, event_t* e) {
key_event_t* evt = (key_event_t*)e;
if (evt->key == TK_KEY_F2) {
window_manager_back(WIDGET(ctx));
} else if (evt->key == TK_KEY_F3) {
window_manager_back_to_home(WIDGET(ctx));
}
return RET_OK;
}
ret_t application_init() {
widget_t* wm = window_manager();
widget_t* win = window_create(NULL, 0, 0, 0, 0);
widget_t* open_window = button_create(win, 0, 0, 0, 0);
widget_set_prop_str(win, WIDGET_PROP_CLOSABLE, "no");
widget_set_text(open_window, L"Open Window");
widget_set_self_layout_params(open_window, "center", "middle", "50%", "30");
widget_on(open_window, EVT_CLICK, on_open_window, NULL);
widget_layout(win);
widget_on(wm, EVT_KEY_DOWN, on_key_back_or_back_to_home, wm);
return RET_OK;
}
ret_t application_exit() {
log_debug("application_exit\n");
return RET_OK;
}
#include "awtk_main.inc"