-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
66 lines (54 loc) · 1.57 KB
/
main.cpp
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
//
// main.cpp
// awtktest
//
// Created by cbav on 2019/7/1.
// Copyright © 2019 cbav. All rights reserved.
//
#include "awtk.h"
#include "demos/assets.h"
static ret_t on_click(void* ctx, event_t* e) {
log_debug("on_click\n");
return RET_OK;
}
static ret_t on_long_press(void* ctx, event_t* e) {
log_debug("on_long_press\n");
return RET_OK;
}
void application_init() {
widget_t* win = window_create(NULL, 0, 0, 0, 0);
widget_t* ok = button_create(win, 0, 0, 0, 0);
widget_set_text(ok, L"ok");
widget_set_self_layout_params(ok, "center", "middle", "50%", "30");
widget_on(ok, EVT_CLICK, on_click, NULL);
widget_on(ok, EVT_LONG_PRESS, on_long_press, NULL);
widget_layout(win);
}
#ifdef USE_GUI_MAIN
int gui_app_start(int lcd_w, int lcd_h) {
tk_init(lcd_w, lcd_h, APP_MOBILE, NULL, NULL);
#elif defined(WIN32)
#include <windows.h>
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
tk_init(320, 480, APP_SIMULATOR, NULL, RES_ROOT);
#else
int main(void) {
tk_init(320, 480, APP_SIMULATOR, NULL, RES_ROOT);
#endif
//#define WITH_LCD_PORTRAIT 1
#if defined(USE_GUI_MAIN) && defined(WITH_LCD_PORTRAIT)
if (lcd_w > lcd_h) {
tk_set_lcd_orientation(LCD_ORIENTATION_90);
}
#endif /*WITH_LCD_PORTRAIT*/
#ifdef WITH_LCD_LANDSCAPE
if (lcd_w < lcd_h) {
tk_set_lcd_orientation(LCD_ORIENTATION_90);
}
#endif /*WITH_LCD_PORTRAIT*/
assets_init();
application_init();
tk_ext_widgets_init();
tk_run();
return 0;
}