Ejemplo n.º 1
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;
	FtkWidget* combo_box = NULL;
	int modal = (int)ctx;
	
	ftk_logi("%s:%d begin\n", __func__, __LINE__);
	dialog = ftk_dialog_create(0, 40, 320, 240);
	
	icon = ftk_theme_load_image(ftk_default_theme(), "info"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?");
	
	combo_box = ftk_combo_box_create(dialog, width/6, height/4, 2*width/3, 30);
	ftk_combo_box_set_text(combo_box, "1 second");
	ftk_combo_box_append(combo_box, NULL, "1 second");
	ftk_combo_box_append(combo_box, NULL, "2 seconds");
	ftk_combo_box_append(combo_box, NULL, "3 seconds");
	ftk_entry_set_readonly(ftk_combo_box_get_entry(combo_box), modal);

	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");

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

	return RET_OK;
}
Ejemplo n.º 2
0
static int lua_ftk_combo_box_set_text(lua_State* L)
{
	tolua_Error err = {0};
	Ret retv;
	FtkWidget* thiz;
	const char* text;
	int param_ok = tolua_isusertype(L, 1, "FtkWidget", 0, &err) && tolua_isstring(L, 2, 0, &err);

	return_val_if_fail(param_ok, 0);

	thiz = tolua_tousertype(L, 1, 0);
	text = tolua_tostring(L, 2, 0);
	retv = ftk_combo_box_set_text(thiz, text);
	tolua_pushnumber(L, (lua_Number)retv);

	return 1;
}