//**********************************************************
// Dialog Control - PushMenuCheck
// LABPP 2022
//**********************************************************

#include "items.h"
// 
string sProcName = "PushMenuCheck";

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 = "PushMenuCheck";
	
	string IconFilePath="IconFilePath.png";
	string ToolTipText="Tool Tip Text";
	res = ac_request("editstringdialog", "Enter Icon Filepath", IconFilePath);
	if (res == 1)
	{
		IconFilePath = ac_getstrvalue();
	}
	res = ac_request("editstringdialog", "Enter Tool Tip Text", ToolTipText);
	if (res == 1)
	{
		ToolTipText = ac_getstrvalue();
	}
	
	string EditName = "i"+EditType+DCName+DialogSuffix;
	
    prg_code_gen = "//---------------->\n\
	int	x,y,w,h,offset;\n\
	x =1; y= 1; w = 100; h = 24;\n\
	var_by_txt(\"init\", \""+EditName+"\", \"int\", \"global\",0);\n\
	object(\"create\", \"ts_dialogcontrol\", "+EditName+");\n\
	int igroup = 1;\n\
	ts_dialogcontrol("+EditName+", \"init_control\", \""+EditType+"\", iDialog"+DialogSuffix+", x, y, w, h);\n\
	ts_dialogcontrol("+EditName+", \"settooltip\", \""+ToolTipText+"\");\n\
	//ts_dialogcontrol("+EditName+", \"eventreaction\", \"Event_PushMenuChanged\",\"Event_PushMenuChanged"+DCName+DialogSuffix+"\");\n";
	prg_code_gen +="\
	ts_dialogcontrol(" + EditName + ", \"SetItemCount\",2);\n\
	ts_dialogcontrol(" + EditName + ", \"SelectItem\",1);\n\
	string iconpath;\n\
    shell_func(\"get_path\", \"currentcppfiles\", iconpath);\n\
	ts_dialogcontrol("+EditName+", \"SetItemIcon\",1,\"+iconpath+\"\\\"+IconFilePath+\"\\\");\n\
	ts_dialogcontrol("+EditName+", \"SetItemIcon\",2,\"+iconpath+\"\\\"+IconFilePath+\"\\\");\n\
	ts_dialogcontrol("+EditName+", \"Select\");\n\
	ts_dialogcontrol("+EditName+", \"SelectItem\",1);\n";

	prg_code_gen +="\n\
// Events\n\
//int Event_PushMenuChanged"+DCName+DialogSuffix+"(int iDescr, string sDescr)\n\
//{\n\
//   if (sDescr == \""+EditName+"\"){\n\
//      bool bChecked;\n\
//      ts_dialogcontrol("+EditName+", \"GetCheck\", bChecked);\n\
//      coutvar << bSelected;\n\
//      bool bStateChanged;\n\
//      ts_dialogcontrol("+EditName+", \"GetNamedEventValue\",\"WasStateChange\", bStateChanged);\n\
//      int iPreviousMenuItem;\n\
//      ts_dialogcontrol("+EditName+", \"GetNamedEventValue\",\"PreviousMenuItem\", iPreviousMenuItem);\n\
//      int iSelectedItem;\n\
//      ts_dialogcontrol("+EditName+", \"GetSelectedItem\", iSelectedItem);\n\
//   }\n\
//}";

	var_extern_set("PCG item result", prg_code_gen);

}

//<--------
