//**********************************************************
// Dialog Control - ProgressBar
// LABPP 2022
//**********************************************************

#include "items.h"
// 
string sProcName = "ProgressBar";

int main()
{
	cout << sProcName << "\n";

	int iarg1; double darg2; string sarg3;
	run_cpp("get_args",iarg1, darg2, sarg3);

	if (sarg3 == "Get PCG item name")
	{
		var_extern_set("PCG item name", sProcName);
		return 0;
	}


	if (sarg3 == "Help")
	{
		tsalert(-3, "Information", "",
			"");
		return 0;
	}

//	string genesis, v_type, varname, svalue, sdescription, sgroup;
//	programcodegen("get_bimmaster_cur_selected_parameter_info", genesis, v_type, varname, svalue, sdescription, sgroup);

	string prg_code_gen;
	string DialogSuffix="_DS";
	string DCName="_DCName";

	int res = ac_request("editstringdialog", "Enter Dialog Control Name", DCName);
	if (res == 1)
	{
		DCName = ac_getstrvalue();
	}
	res = ac_request("editstringdialog", "Enter Dialog Suffix", DialogSuffix);
	if (res == 1)
	{
		DialogSuffix = ac_getstrvalue();
	}
	string EditType = "ProgressBar";
	
	string EditName = "i"+EditType+DCName+DialogSuffix;
	
    prg_code_gen = "//---------------->\n\
	int	x,y,w,h,offset;\n\
	x =1; y= 1; w = 100; h = 10;\n\
	var_by_txt(\"init\", \""+EditName+"\", \"int\", \"global\",0);\n\
	object(\"create\", \"ts_dialogcontrol\", "+EditName+");\n\
	ts_dialogcontrol("+EditName+", \"init_control\", \""+EditType+"\", iDialog"+DialogSuffix+", x, y, w, h);\n";
	prg_code_gen +="\
	ts_dialogcontrol("+EditName+", \"SetMin\", 0);\n\
	ts_dialogcontrol("+EditName+", \"SetMax\", 100);\n\
	ts_dialogcontrol("+EditName+", \"SetValue\", 0);\n\
	ts_dialogcontrol("+EditName+", \"SetAnchorToPanelResize\", 0,1,1,0);";

	var_extern_set("PCG item result", prg_code_gen);
}

//<--------
