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"
|
2018-12-15 17:22:05 +08:00
|
|
|
#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);
|
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;
|
|
|
|
char res_root[MAX_PATH + 1];
|
|
|
|
char app_root[MAX_PATH + 1];
|
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;
|
2018-08-28 18:20:17 +08:00
|
|
|
char res_root[MAX_PATH + 1];
|
|
|
|
char app_root[MAX_PATH + 1];
|
2019-03-08 18:51:09 +08:00
|
|
|
|
|
|
|
if (argc >= 2) {
|
|
|
|
lcd_w = tk_atoi(argv[1]);
|
|
|
|
}
|
|
|
|
if (argc >= 3) {
|
|
|
|
lcd_h = tk_atoi(argv[2]);
|
|
|
|
}
|
|
|
|
#endif
|
2018-08-28 18:20:17 +08:00
|
|
|
path_app_root(app_root);
|
|
|
|
memset(res_root, 0x00, sizeof(res_root));
|
|
|
|
|
|
|
|
path_build(res_root, MAX_PATH, app_root, "demos", NULL);
|
2018-11-29 13:49:59 +08:00
|
|
|
if (!path_exist(res_root)) {
|
2018-11-29 10:25:45 +08:00
|
|
|
strcpy(res_root, app_root);
|
|
|
|
log_debug("%s not exist, try %s\n", res_root, app_root);
|
|
|
|
}
|
2018-10-26 18:25:30 +08:00
|
|
|
|
2018-10-27 18:34:18 +08:00
|
|
|
#if defined(WIN32)
|
2018-10-26 18:25:30 +08:00
|
|
|
#if !defined(NDEBUG)
|
|
|
|
{
|
|
|
|
AllocConsole();
|
2018-10-27 18:34:18 +08:00
|
|
|
FILE* fp = NULL;
|
2018-10-26 18:25:30 +08:00
|
|
|
freopen_s(&fp, "CONOUT$", "w+t", stdout);
|
|
|
|
}
|
2018-10-27 18:34:18 +08:00
|
|
|
#endif /*NDEBUG*/
|
|
|
|
#endif /*WIN32*/
|
2018-10-26 18:25:30 +08:00
|
|
|
|
2019-03-08 18:51:09 +08:00
|
|
|
tk_init(lcd_w, lcd_h, APP_SIMULATOR, NULL, res_root);
|
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) {
|
2018-06-14 11:32:46 +08:00
|
|
|
tk_set_lcd_orientation(LCD_ORIENTATION_90);
|
|
|
|
}
|
2018-06-14 15:50:32 +08:00
|
|
|
#endif /*WITH_LCD_PORTRAIT*/
|
2018-06-14 11:32:46 +08:00
|
|
|
|
|
|
|
#ifdef WITH_LCD_LANDSCAPE
|
2018-06-14 15:50:32 +08:00
|
|
|
if (lcd_w < lcd_h) {
|
2018-06-14 11:32:46 +08:00
|
|
|
tk_set_lcd_orientation(LCD_ORIENTATION_90);
|
|
|
|
}
|
2018-06-14 15:50:32 +08:00
|
|
|
#endif /*WITH_LCD_PORTRAIT*/
|
2018-06-14 11:32:46 +08:00
|
|
|
|
2019-05-29 17:24:46 +08:00
|
|
|
#ifdef WITH_FS_RES
|
|
|
|
system_info_set_default_font(system_info(), "default_full");
|
2019-05-30 09:47:26 +08:00
|
|
|
#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;
|
|
|
|
}
|