示例#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;
}
示例#2
0
static void create_app_window(void)
{
	char title[32] = {0};
	int width = 0;
	int height = 0;
	FtkWidget* win = ftk_app_window_create();
	FtkWidget* label = NULL;
	FtkWidget* button = NULL;
	
	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, "创建窗口");
	ftk_button_set_clicked_listener(button, button_open_clicked, win);

	button = ftk_button_create(win, 2*width/3, height/6, width/3, 50);
	ftk_widget_set_text(button, "关闭窗口");
	ftk_button_set_clicked_listener(button, button_close_clicked, win);

	ftk_snprintf(title, sizeof(title), "window%02d", g_index++);
	label = ftk_label_create(win, width/4, height/2, width/2, 30);
	ftk_widget_set_text(label, title);
	
	ftk_widget_set_text(win, title);
	ftk_widget_show_all(win, 1);
	ftk_widget_set_user_data(win, on_window_close, win);

	return;
}
示例#3
0
static FtkWidget* ftk_bluetooth_create_window(void)
{
	FtkWidget *widget;
	FtkListRender* render = NULL;

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

	ftk_widget_set_text(win, "블루투스");

	widget = ftk_label_create(win, 10, 10, 220, 30);
	ftk_widget_set_id(widget, IDC_INFO);
	ftk_widget_set_text(widget, "검색 중");

	widget = ftk_list_view_create(win, 10, 40, 220, 200);
	ftk_list_view_set_clicked_listener(widget, _bt_on_item_clicked, win);
	ftk_widget_set_id(widget, IDC_LIST);

	_model = ftk_list_model_default_create(10);
	render = ftk_list_render_default_create();

	ftk_list_render_default_set_marquee_attr(render,
			FTK_MARQUEE_AUTO | FTK_MARQUEE_RIGHT2LEFT | FTK_MARQUEE_FOREVER);

	ftk_list_view_init(widget, _model, render, 40);
	ftk_list_model_unref(_model);

	_timer = ftk_source_timer_create(300, _bt_scan_start, win);
	ftk_main_loop_add_source(ftk_default_main_loop(), _timer);

	return win;
}
示例#4
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkGc gc = {.mask = FTK_GC_BG};
	TimerInfo* info = NULL;

	FTK_INIT(argc, argv);
	info = (TimerInfo*)FTK_ZALLOC(sizeof(TimerInfo));
	info->times = 100;
		
	FtkSource* timer = ftk_source_timer_create(1000, timeout, info);
	FtkWidget* win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");

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

	FtkWidget* label = ftk_label_create(win, 10, 10, width - 20, 20);
	ftk_widget_set_text(label, "arabic bidi demo");
	
	label = ftk_label_create(win, 10, 40, width - 20, 20);
	ftk_widget_set_text(label, "English Text");
	assert(strcmp(ftk_widget_get_text(label), "English Text") == 0);
	
	gc.bg.a = 0xff;
	gc.bg.r = 0xF0;
	gc.bg.g = 0xF0;
	gc.bg.b = 0x80;
	label = ftk_label_create(win, 10, height/2, width - 20, 120);
	ftk_widget_set_gc(label, FTK_WIDGET_INSENSITIVE, &gc);
	ftk_widget_unset_attr(label, FTK_ATTR_TRANSPARENT);
	ftk_widget_set_text(label, "ان منح حياتك للمسيح تعد خطوة ايمان يمكنك القيام بها عن طريق الصلاة");
	
	label = ftk_label_create(win, 50, height/2-30, width, 20);
	info->label = label;
	
	ftk_widget_set_text(win, "label demo");
	ftk_widget_show_all(win, 1);

	ftk_widget_set_attr(win, FTK_ATTR_IGNORE_CLOSE);
	ftk_main_loop_add_source(ftk_default_main_loop(), timer);

	FTK_RUN();

	return 0;
}
示例#5
0
int main(int argc, char* argv[])
{
	ftk_init(argc, argv);
	FtkWidget* thiz = ftk_label_create(NULL, 0, 0, 60, 20);
	ftk_widget_set_text(thiz, "ok");
	assert(strcmp(ftk_widget_get_text(thiz), "ok") == 0);
	ftk_widget_destroy(thiz);

	return 0;
}
示例#6
0
Ret designer_select_file(const char* title, const char* init_path, FtkListener on_select, void* ctx)
{
	int width = 0;
	int height = 0;
	int y_offset = 0;
	
	Info* info = NULL;
	FtkWidget* win = NULL;
	FtkWidget* label = NULL;
	FtkWidget* entry = NULL;	
	FtkWidget* button = NULL;
	
	info = info_create();
	return_val_if_fail(info != NULL, RET_FAIL);

	win = ftk_app_window_create();
	ftk_widget_set_user_data(win, info_destroy, info);
	ftk_widget_set_text(win, title);
	
	width = ftk_widget_width(win);
	height = ftk_widget_height(win);

	info->on_select = on_select;
	info->on_select_ctx = ctx;
	info->init_path = ftk_strdup(init_path);

	y_offset = height/3 - 30;
	label = ftk_label_create(win, 0, y_offset, width/5, 30);
	ftk_widget_set_text(label, _("FileName:"));
	
	y_offset = height/3;
	info->widget_file_name = entry = ftk_entry_create(win, 5, y_offset, width*4/5-2, 30);
	if(s_last_file[0] == '\0')
	{
		ftk_fs_get_cwd(s_last_file);
	}
	ftk_widget_set_text(entry, s_last_file);
	
	button = ftk_button_create(win, width*4/5, y_offset-5, width/5, 40);
	ftk_widget_set_text(button, _("..."));
	ftk_button_set_clicked_listener(button, button_browse_clicked, win);

	button = ftk_button_create(win, width/5, height-60, width/5, 50);
	ftk_widget_set_text(button, _("OK"));
	ftk_button_set_clicked_listener(button, button_ok_clicked, win);

	button = ftk_button_create(win, width*3/5, height-60, width/5, 50);
	ftk_widget_set_text(button, _("Cancel"));
	ftk_button_set_clicked_listener(button, button_cancel_clicked, win);
	
	ftk_widget_show_all(win, 1);

	return RET_OK;
}
示例#7
0
static Ret button_dialog_clicked(void* ctx, void* obj)
{
	int id = 0;
	int width = 0;
	int height = 0;
	FtkWidget* label = NULL;
	FtkWidget* button = NULL;
	FtkWidget* dialog = NULL;
	FtkBitmap* icon = NULL;
	int modal = (int)ctx;
	
	ftk_logd("%s:%d begin\n", __func__, __LINE__);
	dialog = ftk_dialog_create(0, 40, 320, 240);
	
	icon = ftk_theme_load_image(ftk_default_theme(), "info-icon"FTK_STOCK_IMG_SUFFIX); 
	ftk_dialog_set_icon(dialog, icon);

	width = ftk_widget_width(dialog);
	height = ftk_widget_height(dialog);
	label = ftk_label_create(dialog, width/6, height/4, 5*width/6, 20);
	ftk_widget_set_text(label, "Are you sure to quit?");

	button = ftk_button_create(dialog, width/6, height/2, width/3, 50);
	ftk_widget_set_text(button, "yes");
	ftk_button_set_clicked_listener(button, button_quit_clicked, modal ? &id : NULL);
	
	button = ftk_button_create(dialog, width/2, height/2, width/3, 50);
	ftk_widget_set_text(button, "no");
	ftk_button_set_clicked_listener(button, button_quit_clicked, modal ? &id : NULL);
	ftk_window_set_focus(dialog, button);

	ftk_widget_set_text(dialog, modal ? "model dialog" : "normal dialog");
	ftk_widget_show_all(dialog, 1);

	if(modal)
	{
		assert(ftk_dialog_run(dialog) == id);
		ftk_widget_unref(dialog);
	}
	else
	{
		ftk_widget_show_all(dialog, 1);
	}
	ftk_logd("%s:%d end\n", __func__, __LINE__);

	return RET_OK;
}
示例#8
0
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
	int width = 0;
	int height = 0;
	FtkGc gc = {0};
	TimerInfo* info = NULL;
	FtkSource* timer = NULL;
	FtkWidget* win = NULL;
	FtkWidget* label = NULL;

	gc.mask = FTK_GC_BG;

	FTK_INIT(argc, argv);
	info = (TimerInfo*)FTK_ZALLOC(sizeof(TimerInfo));
	info->times = 5;
		
	timer = ftk_source_timer_create(1000, timeout, info);
	win = ftk_app_window_create();
	ftk_window_set_animation_hint(win, "app_main_window");

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

#ifdef WIN32	
	label = ftk_label_create(win, 10, 10, width - 20, 20);
	ftk_widget_set_text(label, "中文文本");
#else
#endif
	label = ftk_label_create(win, 10, 40, width - 20, 20);
	ftk_widget_set_text(label, "English Text(center)");
	ftk_label_set_alignment(label, FTK_ALIGN_CENTER);
	assert(strcmp(ftk_widget_get_text(label), "English Text(center)") == 0);
	
	label = ftk_label_create(win, 10, 70, width - 20, 20);
	ftk_widget_set_text(label, "English Text(right)");
	ftk_label_set_alignment(label, FTK_ALIGN_RIGHT);

	gc.bg.a = 0xff;
	gc.bg.r = 0xF0;
	gc.bg.g = 0xF0;
	gc.bg.b = 0x80;
	label = ftk_label_create(win, 10, height/2, width - 20, 120);
	ftk_widget_set_gc(label, FTK_WIDGET_INSENSITIVE, &gc);
	ftk_widget_unset_attr(label, FTK_ATTR_TRANSPARENT);
#ifdef WIN32	
	ftk_widget_set_text(label, "The linux mobile development(with background color)");
#else
	ftk_widget_set_text(label, "中英文混合多行文本显示:the linux mobile development.带有背景颜色。");
#endif
	label = ftk_label_create(win, 50, height/2-30, width, 20);
	info->label = label;
	
	ftk_widget_set_text(win, "label demo");
	ftk_widget_show_all(win, 1);

	ftk_widget_set_attr(win, FTK_ATTR_IGNORE_CLOSE);
	ftk_main_loop_add_source(ftk_default_main_loop(), timer);

	FTK_RUN();

	return 0;
}
示例#9
0
int ftk_message_box(FtkBitmap* icon, const char* title, const char* text, const char* buttons[FTK_MSGBOX_MAX_BUTTONS])
{
	int i = 0;
	int w = 0;
	int h = 0;
	int id = 0;
	int ret = 0;
	int width = 0;
	int height = 0;
	int xoffset = 0;
	int yoffset = 0;
	int h_margin = 0;
	int has_title = icon != NULL || title != NULL;
	int buttons_nr = ftk_count_strings(buttons);

	FtkWidget* label = NULL;
	FtkWidget* button = NULL;
	FtkWidget* dialog = NULL;
	
	return_val_if_fail(text != NULL, -1);

	ftk_message_box_size(has_title, buttons_nr, text, &width, &height);
	dialog = ftk_dialog_create(0, 0, width, height);
	ftk_window_set_animation_hint(dialog, "msgbox");
	if(has_title) 
	{
		ftk_dialog_set_icon(dialog, icon);
		ftk_widget_set_text(dialog, title);
	}
	else
	{
		ftk_dialog_hide_title(dialog);
		ftk_widget_set_attr(dialog, FTK_ATTR_POPUP);
	}

	width  = ftk_widget_width(dialog);
	height = ftk_widget_height(dialog);

	/*create label.*/
	xoffset = FTK_H_MARGIN;
	yoffset = FTK_V_MARGIN;
	w = width - 2 * (FTK_DIALOG_BORDER + FTK_H_MARGIN);
	h = height - FTK_DIALOG_BORDER - 4 * FTK_V_MARGIN;
	h -= has_title ? ftk_dialog_get_title_height() : 0;
	h -= buttons_nr > 0 ? FTK_BUTTON_DEFAULT_HEIGHT : 0;

	label = ftk_label_create(dialog, xoffset, yoffset, w, h);
	ftk_widget_set_text(label, text);

	/*create buttons*/

	if(buttons_nr > 0)
	{
		xoffset = 0;
		w = FTK_BUTTON_DEFAULT_WIDTH;
		h = FTK_BUTTON_DEFAULT_HEIGHT;
		w = ((buttons_nr + 1) * w) < width ? w : (width / (buttons_nr + 1));
		yoffset = height - h - FTK_V_MARGIN - (has_title ? ftk_dialog_get_title_height() : 0);
		h_margin = (width - buttons_nr * w) / (buttons_nr + 1);

		for(i = 0; i < buttons_nr; i++)
		{
			xoffset += h_margin;
			button = ftk_button_create(dialog, xoffset, yoffset, w, h);
			ftk_widget_set_id(button, i + 1);
			ftk_widget_set_text(button, buttons[i]);
			ftk_button_set_clicked_listener(button, message_box_on_button_clicked, &id);
			xoffset += w;
		}
	}
	else
	{
		/*if no buttons, quit when timeout.*/
		ftk_dialog_quit_after(dialog, 3000);
	}

	ftk_widget_show_all(dialog, 1);
	ret = ftk_dialog_run(dialog);
	ftk_widget_unref(dialog);
	
	if(icon != NULL)
	{
		ftk_bitmap_unref(icon);
	}

	return ret;
}