Example #1
0
Tab* CreateTabFromXML(ticpp::Element* elem, TabbedPane* parent, Dialog* dlg){
	int tmpInt;
	Tab* tab = new Tab(parent);

	tab->SetName(elem->GetAttribute("NAME").c_str());
	if(elem->GetAttribute("ID", &tmpInt))		tab->SetID(tmpInt);
	if(elem->GetAttribute("X", &tmpInt))		tab->SetPositionX(tmpInt);
	if(elem->GetAttribute("Y", &tmpInt))		tab->SetPositionY(tmpInt);
	if(elem->GetAttribute("WIDTH", &tmpInt))	tab->SetSizeX(tmpInt);
	if(elem->GetAttribute("HEIGHT", &tmpInt))	tab->SetSizeY(tmpInt);

	for(ticpp::Element* child = elem->FirstChildElement(false); child; child = child->NextSiblingElement(false)){
		if(child->Value() == "TABBUTTON"){
			tab->SetTabButton((RadioButton*)CreateControlFromXML(child, dlg));
		}else if(child->Value() == "RADIOBUTTON"){
			RadioButton* btn = (RadioButton*)CreateControlFromXML(child, dlg);
			if(int id = btn->RadioBoxID()){
				RadioBox* box = (RadioBox*)tab->GetControlByID(id);
				if(box && box->ControlType() == CT_RADIOBOX)
					box->AddButton(btn);
			}

			tab->AddChild(btn);
		}else{
			tab->AddChild(CreateControlFromXML(child, dlg));
		}
	}

	return tab;
}