Exemplo n.º 1
0
static Ret ftk_app_movie_run(FtkApp* thiz, int argc, char* argv[])
{
	FtkWidget *label;

	FtkWidget *win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");

	ftk_widget_set_text(win, "영화");

	ftk_app_window_set_user_on_event(win, _movie_user_on_event);

	label = ftk_label_create(win, 10, 50, 220, 100);
	ftk_widget_set_id(label, IDC_TITLE);

	_app_movie_create_button(win, 35, IDC_PLAY, "play");
	_app_movie_create_button(win, 137, IDC_STOP, "stop");

	ftk_app_window_set_on_prepare_options_menu(win, ftk_clock_on_prepare_options_menu, win);
	ftk_widget_show_all(win, 1);

#ifdef HAS_MAIN
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
#endif	
	return RET_OK;
}
Exemplo n.º 2
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;
	
	FTK_INIT(argc, argv);

	win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");
	width = ftk_widget_width(win);
	height = ftk_widget_height(win);

	button = ftk_button_create(win, 0, height/6, width/3, 50);
	ftk_widget_set_text(button, "Normal");
	ftk_button_set_clicked_listener(button, button_dialog_clicked, NULL);

	button = ftk_button_create(win, 2*width/3, height/6, width/3, 50);
	ftk_widget_set_text(button, "Modal");
	ftk_button_set_clicked_listener(button, button_dialog_clicked, (void*)1);

	button = ftk_button_create(win, width/4, height/2, width/2, 60);
	ftk_widget_set_text(button, "quit");
	ftk_button_set_clicked_listener(button, button_close_clicked, win);

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

	FTK_RUN();

	return 0;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;
	FtkWidget* icon_view = NULL;
	FtkIconViewItem item;
	FTK_INIT(argc, argv);
	
	win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");
	width = ftk_widget_width(win);
	height = ftk_widget_height(win);

	button = ftk_button_create(win, 10, 0, width/3-10, 60);
	ftk_widget_set_text(button, "more");
	ftk_button_set_clicked_listener(button, button_more_clicked, win);
	ftk_window_set_focus(win, button);
	
	button = ftk_button_create(win, 2*width/3, 0, width/3-10, 60);
	ftk_widget_set_text(button, "quit");
	ftk_button_set_clicked_listener(button, button_quit_clicked, win);
	ftk_window_set_focus(win, button);

	item.icon = ftk_theme_load_image(ftk_default_theme(), "flag-32.png");
	icon_view = ftk_icon_view_create(win, 5, 70, width-10, height-80);
	ftk_widget_set_id(icon_view, 100);
	ftk_icon_view_set_clicked_listener(icon_view, item_clicked, win);
	for(; i < 4; i++)
	{
		char text[100] = {0};
		ftk_snprintf(text, sizeof(text), "%d", i);
		item.text = text;
		item.user_data = (void*)i;
		ftk_icon_view_add(icon_view, &item);
	}
	
	ftk_bitmap_unref(item.icon);
	ftk_widget_set_text(win, "icon view demo");
	ftk_widget_show_all(win, 1);
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);

	FTK_RUN();

	return 0;
}
Exemplo n.º 5
0
static Ret ftk_app_bluetooth_run(FtkApp* thiz, int argc, char* argv[])
{
	
	DECL_PRIV(thiz, priv);
	FtkWidget* win = NULL;
	return_val_if_fail(priv != NULL, RET_FAIL);

	win = ftk_bluetooth_create_window();
	ftk_app_window_set_on_prepare_options_menu(win, ftk_bluetooth_on_prepare_options_menu, win);
	ftk_widget_show_all(win, 1);

#ifdef HAS_MAIN
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
#endif	

	return RET_OK;
}
Exemplo n.º 6
0
#include "ftk.h"
#include <assert.h>

FtkWidget* text_view1  = NULL;

static Ret button_quit_clicked(void* ctx, void* obj)
{
	ftk_widget_unref(ctx);

	return RET_OK;
}

static Ret scroll_bar_on_scroll(void* ctx, void* scroll_bar)
{
	static int old_at_line = 0;

	int total_lines = ftk_text_view_get_total_lines(text_view1);
	int per = ftk_scroll_bar_get_value(scroll_bar);
	int at_line = total_lines * per / 100;

	if (0 == old_at_line) old_at_line = total_lines;

	int offset = at_line - old_at_line;

	ftk_text_view_v_move_caret(text_view1, offset);

	printf("%s: value=%d, totals = %d, offset = %d\n", __func__, per, total_lines, offset);

	old_at_line = at_line;
	return RET_OK;
}

#define XX_STR  "hahah\n4\n5\n latst"

#define TEXT_STR "libpng is the official PNG reference library. It supports almost all PNG features, is extensible, and has been extensively tested for over 15 years. The home site for development versions (i.e., may be buggy or subject to change or include experimental features) is http://libpng.sourceforge.net/, and the place to go for questions about the library is the png-mng-implement mailing list.\n\nlibpng is available as ANSI C (C89) source code and requires zlib 1.0.4 or later (1.2.3 or later recommended for performance and security reasons). The current public release, libpng 1.4.3, contains fixes for two potential security issues: "

#define TEXT1_STR "Several versions of libpng through 1.4.2 (and through 1.2.43 in the older series) contain a bug whereby progressive applications such as web browsers (or the rpng2 demo app included in libpng) could receive an extra row of image data beyond the height reported in the header, potentially leading to an out-of-bounds write to memory (depending on how the application is written) and the possibility of execution of an attacker's code with the privileges of the libpng user (including remote compromise in the case of a libpng-based browser visiting a hostile web site). This vulnerability has been assigned ID CVE-2010-1205 (via Mozilla). \n\n4\n5\n6\n7\n8\nlast line"

#ifdef FTK_AS_PLUGIN
#include "ftk_app_demo.h"
FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
FtkApp* ftk_app_demo_text_view_create()
{
	return ftk_app_demo_create(_("text_view"), ftk_main);
}
#else
#define FTK_HIDE extern
#endif /*FTK_AS_PLUGIN*/
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;
	FtkWidget* text_view  = NULL;
	FtkWidget* scroll_bar = NULL;

	FTK_INIT(argc, argv);

	win = ftk_app_window_create();
	width = ftk_widget_width(win);
	height = ftk_widget_height(win);
	
	text_view1 = ftk_text_view_create(win, 10, 10, ftk_widget_width(win) - 40, height/3);
	ftk_widget_set_text(text_view1, XX_STR);
	ftk_text_view_set_readonly(text_view1, 1);


	scroll_bar = ftk_scroll_bar_create(win, width-30, 10, 20, height/3);
	ftk_scroll_bar_set_param(scroll_bar, 0, 120, 20);	
	ftk_scroll_bar_set_listener(scroll_bar, scroll_bar_on_scroll, NULL);
	ftk_scroll_bar_set_value(scroll_bar, 100);


	text_view = ftk_text_view_create(win, 10, 15 + height/3, ftk_widget_width(win) - 20, height/3);
	ftk_widget_set_text(text_view, TEXT_STR);
	assert(strcmp(TEXT_STR, ftk_widget_get_text(text_view)) == 0);
	ftk_text_view_set_readonly(text_view, 1);

	button = ftk_button_create(win, width/4, 3*height/4, width/2, 60);
	ftk_widget_set_text(button, "quit");
	ftk_button_set_clicked_listener(button, button_quit_clicked, win);
	ftk_window_set_focus(win, button);

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

	FTK_RUN();

	return 0;
}
Exemplo n.º 7
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;

	FTK_INIT(argc, argv);
	
	win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");
	width = ftk_widget_width(win);
	height = ftk_widget_height(win);
	
	width = width/2 - 10;
	button = ftk_button_create(win, 0, height/4, width, 50);
	ftk_widget_set_text(button, "Single Choose");
	ftk_button_set_clicked_listener(button, button_single_choose_clicked, win);

	button = ftk_button_create(win, width + 10, height/4, width, 50);
	ftk_widget_set_text(button, "Browser");
	ftk_button_set_clicked_listener(button, button_browser_clicked, win);
	
	button = ftk_button_create(win, 0, height/2, width, 50);
	ftk_widget_set_text(button, "Multi Choose");
	ftk_button_set_clicked_listener(button, button_multi_choose_clicked, win);

	button = ftk_button_create(win, width + 10, height/2, width, 50);
	ftk_widget_set_text(button, "Quit");
	ftk_button_set_clicked_listener(button, button_quit_clicked, win);
	ftk_window_set_focus(win, button);

	ftk_widget_set_text(win, "FileBrowser");
	ftk_widget_show_all(win, 1);
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);

	FTK_RUN();

	return 0;
}
Exemplo n.º 8
0
#include "ftk.h"

static Ret on_prepare_options_menu(void* ctx, FtkWidget* menu_panel)
{
	int i = 0;
	for(i = 0; i < 3; i++)
	{
		char text[32] = {0};
		FtkWidget* item = ftk_menu_item_create(menu_panel);
		ftk_snprintf(text, sizeof(text), "Menu%02d", i);
		ftk_widget_set_text(item, text);
		ftk_widget_show(item, 1);
	}

	return i > 0 ? RET_OK : RET_FAIL;
}
#define IDC_TEST_BUTTON 1000
static Ret button_quit_clicked(void* ctx, void* obj)
{
	ftk_widget_unref(ctx);

	return RET_OK;
}

static const char* buttons[] = {"OK", NULL};
static Ret button_unfullscreen_clicked(void* ctx, void* obj)
{
	if(!ftk_window_is_fullscreen(ctx))
	{
		ftk_infomation("Infomation", "Windows is not fullscreen.", buttons);
	}
	else
	{
		ftk_window_set_fullscreen(ctx, 0);
	}
	ftk_logd("%s: width=%d height=%d\n", __func__, ftk_widget_width(ctx), ftk_widget_height(ctx));

	return RET_OK;
}

static Ret button_fullscreen_clicked(void* ctx, void* obj)
{
	if(ftk_window_is_fullscreen(ctx))
	{
		ftk_infomation("Infomation", "Windows is fullscreen.", buttons);
	}
	else
	{
		ftk_window_set_fullscreen(ctx, 1);
	}

	ftk_logd("%s: width=%d height=%d\n", __func__, ftk_widget_width(ctx), ftk_widget_height(ctx));
	return RET_OK;
}

#ifdef FTK_AS_PLUGIN
#include "ftk_app_demo.h"
FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
FtkApp* ftk_app_demo_fullscreen_create()
{
	return ftk_app_demo_create(_("fullscreen"), ftk_main);
}
#else
#define FTK_HIDE extern
#endif /*FTK_AS_PLUGIN*/
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;

	FTK_INIT(argc, argv);
	
	win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");
	width = ftk_widget_width(win);
	height = ftk_widget_height(win);
	
	width = width/2 - 10;
	button = ftk_button_create(win, 0, height/4, width, 50);
	ftk_widget_set_text(button, "Fullscreen");
	ftk_button_set_clicked_listener(button, button_fullscreen_clicked, win);

	button = ftk_button_create(win, width + 10, height/4, width, 50);
	ftk_widget_set_text(button, "Unfullscreen");
	ftk_button_set_clicked_listener(button, button_unfullscreen_clicked, win);
	
	button = ftk_button_create(win, width/2, height/2, width, 60);
	ftk_widget_set_text(button, "quit");
	ftk_button_set_clicked_listener(button, button_quit_clicked, win);
	ftk_window_set_focus(win, button);

	ftk_widget_set_text(win, "fullscreen");
	ftk_widget_show_all(win, 1);
	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
	ftk_app_window_set_on_prepare_options_menu(win, on_prepare_options_menu, win);

	FTK_RUN();

	return 0;
}
Exemplo n.º 9
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
    int width = 0;
    int height = 0;
    FtkWidget* win = NULL;
    FtkWidget* button = NULL;
    FtkWidget* wait_box = NULL;

    FTK_INIT(argc, argv);

    win = ftk_app_window_create();
    width = ftk_widget_width(win);
    height = ftk_widget_height(win);

    wait_box = ftk_wait_box_create(win, width/2 - 16, height/4, 0, 0);

    button = ftk_button_create(win, 0, height/2, width/3, 50);
    ftk_widget_set_text(button, "start");
    ftk_button_set_clicked_listener(button, button_start_clicked, wait_box);

    button = ftk_button_create(win, 2*width/3, height/2, width/3, 50);
    ftk_widget_set_text(button, "stop");
    ftk_button_set_clicked_listener(button, button_stop_clicked, wait_box);

    button = ftk_button_create(win, width/4, 3*height/4, width/2, 60);
    ftk_widget_set_text(button, "quit");
    ftk_button_set_clicked_listener(button, button_quit_clicked, win);
    ftk_window_set_focus(win, button);

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

    FTK_RUN();

    return 0;
}