Ejemplo n.º 1
0
static void ftk_init_panel(void)
{
	FtkGc gc;
	FtkWidget* item = NULL;	
	FtkWidget* panel = ftk_status_panel_create(FTK_STATUS_PANEL_HEIGHT);
	size_t width = ftk_widget_width(panel);

	ftk_set_status_panel(panel);
	quit_if_fail(ftk_default_status_panel(), "Init status panel failed.\n");

	memset(&gc, 0x00, sizeof(gc));
	gc.mask   = FTK_GC_BITMAP;
	gc.bitmap = ftk_theme_load_image(ftk_default_theme(), "status-bg"FTK_STOCK_IMG_SUFFIX);
	ftk_widget_set_gc(panel, FTK_WIDGET_NORMAL, &gc);
	ftk_widget_set_gc(panel, FTK_WIDGET_ACTIVE, &gc);
	ftk_widget_set_gc(panel, FTK_WIDGET_FOCUSED, &gc);
	ftk_gc_reset(&gc);
	
	item = ftk_status_item_create(panel, -100, 32);
	ftk_widget_set_id(item, IDC_CLOSE_ITEM);
	gc.bitmap = ftk_theme_load_image(ftk_default_theme(), "close-32"FTK_STOCK_IMG_SUFFIX);
	if(gc.bitmap != NULL)
	{
		gc.mask = FTK_GC_BITMAP;
		ftk_widget_set_gc(item, FTK_WIDGET_NORMAL, &gc);
		ftk_widget_set_gc(item, FTK_WIDGET_FOCUSED, &gc);
		ftk_gc_reset(&gc);
		gc.mask = FTK_GC_BITMAP;
		gc.bitmap = ftk_theme_load_image(ftk_default_theme(), "close-pressed-32"FTK_STOCK_IMG_SUFFIX);
		ftk_widget_set_gc(item, FTK_WIDGET_ACTIVE, &gc);
		ftk_gc_reset(&gc);
	}
	ftk_status_item_set_clicked_listener(item, button_close_top_clicked, NULL);

	gc.bitmap = ftk_theme_load_image(ftk_default_theme(), "flag-32"FTK_STOCK_IMG_SUFFIX);
	item = ftk_status_item_create(panel, 1, gc.bitmap ? min(ftk_bitmap_width(gc.bitmap), 100) : 32);
	ftk_widget_set_id(item, IDC_ICON_ITEM);
	if(gc.bitmap != NULL)
	{
		gc.mask = FTK_GC_BITMAP;
		ftk_widget_set_gc(item, FTK_WIDGET_NORMAL, &gc);
		ftk_widget_set_gc(item, FTK_WIDGET_ACTIVE, &gc);
		ftk_widget_set_gc(item, FTK_WIDGET_FOCUSED, &gc);
		ftk_gc_reset(&gc);
	}
	ftk_widget_show(item, 1);

	item = ftk_status_item_create(panel, 2, width/2);
	ftk_widget_set_id(item, IDC_TITLE_ITEM);
	ftk_widget_show(item, 1);

	ftk_wnd_manager_add_global_listener(ftk_default_wnd_manager(), on_wnd_manager_global_event, NULL);
	ftk_widget_show(panel, 1);
	
	return;
}
Ejemplo n.º 2
0
int main(int argc, char* argv[])
{
	int i = 0;
	int j = 0;
	int width = 0;
	int height = 0;
	FtkGc gc = {0};
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;
	ftk_init(argc, argv);

	width = ftk_display_width(ftk_default_display());
	height = ftk_display_height(ftk_default_display());
	gc.mask = FTK_GC_BITMAP;
	win = ftk_window_create(0, 0, width, height);

	for(i = 0; i < height/80; i++)
	{
		for(j = 0; j < width/80; j++)
		{
			gc.bitmap = ftk_bitmap_factory_load(ftk_default_bitmap_factory(), pngs[i + 1]);
			button = ftk_button_create(1000, j * 80, i * 80, ftk_bitmap_width(gc.bitmap), ftk_bitmap_height(gc.bitmap));
			ftk_widget_set_gc(button, FTK_WIDGET_NORMAL, &gc);
			ftk_widget_set_gc(button, FTK_WIDGET_FOCUSED, &gc);
			ftk_widget_append_child(win, button);
			ftk_widget_show(button, 1);
			ftk_bitmap_unref(gc.bitmap);

			if(i == 0 && j == 0)
			{
				ftk_button_set_clicked_listener(button, button_clicked, NULL);
				ftk_button_set_text(button, "Quit");
			}
		}
	}

	ftk_window_set_title(win, "button demo");
	ftk_widget_show(win, 1);

	ftk_run();

	return 0;
}
Ejemplo n.º 3
0
static void _app_music_create_button(FtkWidget *win, int x, int id, const char *icons)
{
	FtkGc gc = {0};
	char temp[100];
	char path[FTK_MAX_PATH+1] = {0};

	FtkWidget* button = NULL;
	FtkBitmap* bitmap_normal = NULL;
	FtkBitmap* bitmap_active = NULL;
	FtkBitmap* bitmap_focus = NULL;

	gc.mask = FTK_GC_BITMAP;

	sprintf(temp, "icons/%s_normal.png", icons);
	bitmap_normal =  ftk_bitmap_factory_load(ftk_default_bitmap_factory(),
			ftk_translate_path(temp, path));

	sprintf(temp, "icons/%s_pressed.png", icons);
	bitmap_active =  ftk_bitmap_factory_load(ftk_default_bitmap_factory(),
			ftk_translate_path(temp, path));

	sprintf(temp, "icons/%s_selected.png", icons);
	bitmap_focus =  ftk_bitmap_factory_load(ftk_default_bitmap_factory(),
			ftk_translate_path(temp, path));

	button = ftk_button_create(win, x, 170, 68, 68);
	ftk_widget_set_id(button, id);
	ftk_button_set_clicked_listener(button, ftk_music_on_button_clicked, win);

	gc.bitmap = bitmap_normal;
	ftk_widget_set_gc(button, FTK_WIDGET_NORMAL, &gc);
	gc.bitmap = bitmap_focus;
	ftk_widget_set_gc(button, FTK_WIDGET_FOCUSED, &gc);
	gc.bitmap = bitmap_active;
	ftk_widget_set_gc(button, FTK_WIDGET_ACTIVE, &gc);

	ftk_bitmap_unref(bitmap_normal);
	ftk_bitmap_unref(bitmap_active);
	ftk_bitmap_unref(bitmap_focus);

}
Ejemplo n.º 4
0
Ret ftk_image_set_image(FtkWidget* thiz, FtkBitmap* image)
{
	FtkGc gc = {0};
	return_val_if_fail(thiz != NULL && image != NULL, RET_FAIL);

	gc.mask = FTK_GC_BITMAP;
	gc.bitmap = image;
	ftk_widget_set_gc(thiz, FTK_WIDGET_INSENSITIVE, &gc);
	ftk_bitmap_unref(image);

	ftk_widget_invalidate(thiz);

	return RET_OK;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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;
}