Пример #1
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	FtkWidget* image = NULL;
	FtkWidget* win = NULL;
	char filename[FTK_MAX_PATH+1] = {0};
	FTK_INIT(argc, argv);
	
	win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");

	ftk_snprintf(filename, FTK_MAX_PATH, "%s/earth.png", 
		ftk_config_get_test_data_dir(ftk_default_config()));

	image = ftk_image_create(win, 0, 0, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
	ftk_image_set_image(image, 
		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
	
	ftk_snprintf(filename, FTK_MAX_PATH, "%s/png_RGB_tRNS.png", 
		ftk_config_get_test_data_dir(ftk_default_config()));
	image = ftk_image_create(win, 0, 0, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
	ftk_image_set_image(image, 
		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
	ftk_widget_set_attr(image, FTK_ATTR_TRANSPARENT);

	ftk_snprintf(filename, FTK_MAX_PATH, "%s/Calculator.png", 
		ftk_config_get_test_data_dir(ftk_default_config()));
	image = ftk_image_create(win, ftk_widget_width(win)/2, 0, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
	ftk_image_set_image(image, 
		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
	ftk_widget_set_attr(image, FTK_ATTR_BG_TILE);

	ftk_snprintf(filename, FTK_MAX_PATH, "%s/t8.bmp", 
		ftk_config_get_test_data_dir(ftk_default_config()));
	image = ftk_image_create(win, 0, ftk_widget_height(win)/2, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
	ftk_image_set_image(image, 
		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
	ftk_widget_set_attr(image, FTK_ATTR_BG_CENTER);
	
	ftk_snprintf(filename, FTK_MAX_PATH,  "%s/jpeg1.jpg", 
		ftk_config_get_test_data_dir(ftk_default_config()));
	image = ftk_image_create(win, ftk_widget_width(win)/2, ftk_widget_height(win)/2, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
	ftk_image_set_image(image, 
		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
	ftk_widget_set_attr(image, FTK_ATTR_BG_TILE);

	ftk_widget_set_text(win, "image demo");
	ftk_widget_show_all(win, 1);
	
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);

	FTK_RUN();

	return 0;
}
Пример #2
0
static Ret ftk_init_font(void)
{
	FtkFont* font = NULL;
#if defined(USE_FREETYPE) && defined(ANDROID) && defined(ANDROID_NDK)
	font = ftk_font_freetype_create(FTK_FONT, 0, 0, FTK_FONT_SIZE);
#else
	char filename[FTK_MAX_PATH + 1] = {0};
	ftk_strs_cat(filename, FTK_MAX_PATH, 
		ftk_config_get_data_dir(ftk_default_config()), "/data/", FTK_FONT, NULL);
	ftk_normalize_path(filename);
#ifdef USE_FREETYPE
	font = ftk_font_freetype_create(filename, 0, 0, FTK_FONT_SIZE);
#else
	font = ftk_font_default_create(filename, 0, 0, 0);
#endif
#endif
	
	if(font != NULL)
	{
		ftk_set_font(font);
	}
	else
	{
		ftk_deinit();
		ftk_loge("load font failed.\n");
		exit(0);
	}

	return RET_OK;
}
FtkAnimationTrigger* ftk_animation_trigger_default_create(const char* theme, const char* name)
{
	FtkAnimationTrigger* thiz = FTK_NEW_PRIV(FtkAnimationTrigger);

	if(thiz != NULL)
	{
		char filename[FTK_MAX_PATH + 1] = {0};

		ftk_strs_cat(filename, FTK_MAX_PATH, 
			ftk_config_get_data_dir(ftk_default_config()), "/theme/", theme, "/", name, NULL);

		ftk_normalize_path(filename);
		thiz->on_event = ftk_animation_trigger_default_on_event;
		thiz->destroy = ftk_animation_trigger_default_destroy;

		if(ftk_animation_trigger_parse_file(thiz, filename) == RET_OK)
		{	
			//ftk_animation_trigger_default_dump(thiz);
			ftk_logd("%s: them=%s\n", __func__, theme);
		}
		else
		{
			FTK_FREE(thiz);
		}
	}

	return thiz;
}
Пример #4
0
static int lua_ftk_default_config(lua_State* L)
{
	FtkConfig* retv;
	retv = ftk_default_config();
	tolua_pushusertype(L, (FtkConfig*)retv, "FtkConfig");

	return 1;
}
Пример #5
0
static Ret ftk_init_theme(const char* theme)
{
	char filename[FTK_MAX_PATH + 1] = {0};

	ftk_set_theme(ftk_theme_create(theme == NULL));

	if(theme != NULL)
	{
#if !defined(ANDROID) && !defined(ANDROID_NDK)
		ftk_strs_cat(filename, FTK_MAX_PATH, 
			ftk_config_get_data_dir(ftk_default_config()), "/theme/", theme, "/theme.xml", NULL);
#else
		ftk_strs_cat(filename, FTK_MAX_PATH, 
			ftk_config_get_data_dir(ftk_default_config()), "/theme/", theme, "/theme.wav", NULL);
#endif
		ftk_normalize_path(filename);
		ftk_theme_parse_file(ftk_default_theme(), filename);
	}

	return RET_OK;
}
Пример #6
0
void ftk_deinit(void)
{
	if(ftk_default_input_method_preeditor() != NULL)
	{
		ftk_input_method_preeditor_destroy(ftk_default_input_method_preeditor());
	}

	if(ftk_default_wnd_manager() != NULL)
	{
		ftk_wnd_manager_destroy(ftk_default_wnd_manager());
	}
	
	if(ftk_default_main_loop() != NULL)
	{
		ftk_main_loop_destroy(ftk_default_main_loop());
	}

	if(ftk_default_sources_manager() != NULL)
	{
		ftk_sources_manager_destroy(ftk_default_sources_manager());
	}

	if(ftk_default_bitmap_factory() != NULL)
	{
		ftk_bitmap_factory_destroy(ftk_default_bitmap_factory());
	}

	if(ftk_default_text_layout() != NULL)
	{
		ftk_text_layout_destroy(ftk_default_text_layout());
	}

	if(ftk_default_display() != NULL)
	{
		ftk_display_destroy(ftk_default_display());
	}

	if(ftk_default_theme() != NULL)
	{
		ftk_theme_destroy(ftk_default_theme());
	}

	if(ftk_shared_canvas() != NULL)
	{
		ftk_canvas_destroy(ftk_shared_canvas());
	}

	if(ftk_default_input_method_manager() != NULL)
	{
		ftk_input_method_manager_destroy(ftk_default_input_method_manager());
	}

	if(ftk_default_config() != NULL)
	{
		ftk_config_destroy(ftk_default_config());
	}

	ftk_platform_deinit();

#ifndef USE_STD_MALLOC
	if(ftk_default_allocator() != NULL)
	{
		ftk_allocator_destroy(ftk_default_allocator());
	}
#endif

	ftk_logd("%s: ftk exit.\n", __func__);

	ftk_clear_globals();

	return;
}
Пример #7
0
Ret ftk_init(int argc, char* argv[])
{
	FtkColor bg = {0};
	FtkConfig* config = NULL;
	FtkDisplay* display = NULL;
	static int ftk_inited = 0;

	if(ftk_inited)
	{
		return RET_OK;
	}
	else
	{
		ftk_inited = 1;
	}

	ftk_clear_globals();
	PROFILE_START();
#ifndef USE_STD_MALLOC
	ftk_set_allocator(FTK_ALLOC_PROFILE(ftk_allocator_default_create()));
	quit_if_fail(ftk_default_allocator(), "Init allocator failed.\n");
#endif

	ftk_platform_init(argc, argv);
	config = ftk_config_create();
	ftk_set_config(config);
	ftk_config_init(config, argc, argv);
	quit_if_fail(ftk_default_config(), "Init config failed.\n");

	PROFILE_END("config init");

	ftk_set_text_layout(ftk_text_layout_create());
	PROFILE_START();
	ftk_set_sources_manager(ftk_sources_manager_create(64));
	ftk_set_main_loop(ftk_main_loop_create(ftk_default_sources_manager()));
	ftk_set_wnd_manager(ftk_wnd_manager_default_create(ftk_default_main_loop()));
	quit_if_fail(ftk_default_wnd_manager(), "Init windows manager failed.\n");
	PROFILE_END("source main loop wnd manager init");

	ftk_init_bitmap_factory();
	
	PROFILE_START();
	ftk_init_theme(ftk_config_get_theme(config));
	ftk_backend_init(argc, argv);
	PROFILE_END("theme and backend init");

	display = ftk_display_rotate_create(ftk_default_display(), ftk_config_get_rotate(ftk_default_config()));
	ftk_set_display(display);
	quit_if_fail(ftk_default_display(), "Init display failed.\n");

	PROFILE_START();
	bg.a = 0xff;
	ftk_set_shared_canvas(ftk_canvas_create(ftk_display_width(display), ftk_display_height(display), &bg));
	ftk_logd("canvas init: %d %d\n", ftk_display_width(display), ftk_display_height(display));
	PROFILE_END("canvas init");

	PROFILE_START();
	ftk_set_input_method_manager(ftk_input_method_manager_create());
	ftk_set_input_method_preeditor(ftk_input_method_preeditor_default_create());
	quit_if_fail(ftk_default_input_method_manager(), "Init input method failed.\n");
	PROFILE_END("input method init");

	PROFILE_START();
	if(ftk_config_get_enable_status_bar(config))
	{
		ftk_init_panel();
	}
	PROFILE_END("panel init");

	if(ftk_config_get_enable_cursor(config))
	{
#ifndef USE_LINUX_DFB
		ftk_enable_curosr();
#endif
	}

	return RET_OK;
}