//**********************************************************
// Dialog Control - MultiSelListBox
// LABPP 2022
//**********************************************************

#include "items.h"
// 
string sProcName = "MultiSelListBox";

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 = "MultiSelListBox";
//	int iTable;
//	object("create","ts_table",iTable);
//	ts_table(iTable,"add_column",-1,"string","name");
//	ts_table(iTable,"add_row",0,"TextEdit");
//	ts_table(iTable,"add_row",0,"RealEdit");
//	ts_table(iTable,"add_row",0,"IntEdit");
//	ts_table(iTable,"add_row",0,"PosintEdit");
//	res = ac_request("EditStringListDialog", "Select Edit Type", iTable, 2);
//	if (res == 1)
//	{
//		EditType = ac_getstrvalue();
//		coutvar << EditType;
//	}
	
	string ToolTipText="Tool Tip Text";
	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;\n\
	x =1; y= 1; w = 100; h = 100;\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, 48, 20);\n\
	ts_dialogcontrol("+EditName+", \"settooltip\", \""+ToolTipText+"\");\n\
	//ts_dialogcontrol("+EditName+", \"eventreaction\", \"Event_ListBoxSelectionChanged\",\"Event_ListBoxSelectionChanged"+DCName+DialogSuffix+"\");\n\
	//ts_dialogcontrol("+EditName+", \"eventreaction\", \"Event_ListBoxClicked\",\"Event_ListBoxClicked"+DCName+DialogSuffix+");\n\
	//ts_dialogcontrol("+EditName+", \"eventreaction\", \"Event_ListBoxDoubleClicked\",\"Event_ListBoxDoubleClicked"+DCName+DialogSuffix+");\n";

	prg_code_gen +="\n\
// Events\n\
//int Event_ListBoxSelectionChanged"+DCName+DialogSuffix+"(int iDescr, string sDescr)\n\
//{\n\
//   if (sDescr == \""+EditName+"\"){\n\
//      int item;\n\
//		ts_dialogcontrol(iListBoxElements, \"GetSelectedItem\", item);\n\
//		if(item == 0) {\n\
//			return -1;\n\
//		}\n\
//	}\n\
//}";

	var_extern_set("PCG item result", prg_code_gen);
}

//<--------
