awtk/demos/demo_main.c

95 lines
2.1 KiB
C
Raw Normal View History

2018-02-21 19:36:38 +08:00
/**
2018-03-10 22:01:10 +08:00
* File: demo_main.c
2018-05-15 09:31:58 +08:00
* Author: AWTK Develop Team
2018-03-10 22:01:10 +08:00
* Brief: demo main
2018-02-21 19:36:38 +08:00
*
2019-01-07 10:58:36 +08:00
* Copyright (c) 2018 - 2019 Guangzhou ZHIYUAN Electronics Co.,Ltd.
2018-02-21 19:36:38 +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
*
*/
2018-08-05 18:56:46 +08:00
#include "awtk.h"
2018-08-24 07:45:37 +08:00
#include "assets.h"
#include "tkc/mem.h"
#include "tkc/fs.h"
#include "tkc/path.h"
2018-04-26 16:09:53 +08:00
#include "base/system_info.h"
2018-10-22 12:34:47 +08:00
#include "base/window_manager.h"
2018-02-22 18:07:22 +08:00
ret_t application_init(void);
2018-02-21 19:36:38 +08:00
2018-05-07 17:50:05 +08:00
#ifdef USE_GUI_MAIN
2018-05-14 11:53:05 +08:00
int gui_app_start(int lcd_w, int lcd_h) {
2018-08-19 19:12:35 +08:00
tk_init(lcd_w, lcd_h, APP_MOBILE, NULL, NULL);
2019-08-03 10:53:19 +08:00
#elif defined(MOBILE_APP)
int SDL_main(int argc, char* argv[]) {
int32_t lcd_w = 320;
int32_t lcd_h = 480;
tk_init(lcd_w, lcd_h, APP_MOBILE, "", "");
system_info_set_default_font(system_info(), "default_full");
2018-08-28 18:20:17 +08:00
#else
#if defined(WIN32)
2018-02-21 19:36:38 +08:00
#include <windows.h>
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) {
2019-03-08 18:51:09 +08:00
int32_t lcd_w = 320;
int32_t lcd_h = 480;
2018-02-21 19:36:38 +08:00
#else
2019-03-08 18:51:09 +08:00
int main(int argc, char* argv[]) {
int32_t lcd_w = 320;
int32_t lcd_h = 480;
if (argc >= 2) {
lcd_w = tk_atoi(argv[1]);
}
if (argc >= 3) {
lcd_h = tk_atoi(argv[2]);
}
#endif
2018-10-26 18:25:30 +08:00
2019-08-29 10:55:16 +08:00
TK_ENABLE_CONSOLE();
2018-10-26 18:25:30 +08:00
2019-06-14 17:16:00 +08:00
tk_init(lcd_w, lcd_h, APP_SIMULATOR, NULL, NULL);
2018-05-14 11:53:05 +08:00
#endif
2018-02-21 19:36:38 +08:00
2018-06-14 15:53:44 +08:00
//#define WITH_LCD_PORTRAIT 1
2018-06-27 15:47:30 +08:00
#if defined(USE_GUI_MAIN) && defined(WITH_LCD_PORTRAIT)
2018-06-14 15:50:32 +08:00
if (lcd_w > lcd_h) {
tk_set_lcd_orientation(LCD_ORIENTATION_90);
}
2018-06-14 15:50:32 +08:00
#endif /*WITH_LCD_PORTRAIT*/
#ifdef WITH_LCD_LANDSCAPE
2018-06-14 15:50:32 +08:00
if (lcd_w < lcd_h) {
tk_set_lcd_orientation(LCD_ORIENTATION_90);
}
2018-06-14 15:50:32 +08:00
#endif /*WITH_LCD_PORTRAIT*/
2019-05-29 17:24:46 +08:00
#ifdef WITH_FS_RES
system_info_set_default_font(system_info(), "default_full");
#endif /*WITH_FS_RES*/
2019-05-29 17:24:46 +08:00
2018-10-25 14:56:34 +08:00
log_debug("Build at: %s %s\n", __DATE__, __TIME__);
2018-08-24 07:45:37 +08:00
assets_init();
2018-02-21 19:36:38 +08:00
application_init();
2018-10-22 12:34:47 +08:00
#ifdef ENABLE_CURSOR
window_manager_set_cursor(window_manager(), "cursor");
#endif /*ENABLE_CURSOR*/
2018-04-27 11:23:09 +08:00
tk_run();
2018-02-21 19:36:38 +08:00
return 0;
}