ScrollBar* CreateScrollBarFromXML(ticpp::Element* elem, Dialog* dlg){ int tmpInt; ScrollBar* bar = new ScrollBar(); bar->SetName(elem->GetAttribute("NAME").c_str()); if(elem->GetAttribute("ID", &tmpInt)) bar->SetID(tmpInt); if(elem->GetAttribute("X", &tmpInt)) bar->SetPositionX(tmpInt); if(elem->GetAttribute("Y", &tmpInt)) bar->SetPositionY(tmpInt); if(elem->GetAttribute("WIDTH", &tmpInt)) bar->SetSizeX(tmpInt); if(elem->GetAttribute("HEIGHT", &tmpInt)) bar->SetSizeY(tmpInt); if(elem->GetAttribute("TYPE", &tmpInt)) bar->SetType(tmpInt); if(elem->GetAttribute("LISTBOXID", &tmpInt))bar->SetListBoxID(tmpInt); for(ticpp::Element* child = elem->FirstChildElement(false); child; child = child->NextSiblingElement(false)){ if(child->Value() == "SCROLLBOX"){ ScrollBox* box = (ScrollBox*)CreateControlFromXML(child, dlg); box->SetScrollBar(bar); bar->SetScrollBox(box); } } if(int id = bar->ListBoxID()){ ListBox* lst = (ListBox*)dlg->GetControlByID(id); bar->SetModel(lst); } return bar; }
static ScrollBar* ScrollBarFromDef(TxtNode* structDef) { CrashIf(!structDef->IsStructWithName("ScrollBar")); ScrollBarDef* def = DeserializeScrollBarDef(structDef); ScrollBar* sb = new ScrollBar(); Style* style = StyleByName(def->style); sb->SetStyle(style); sb->SetName(def->name); // TODO: support def->cursor FreeScrollBarDef(def); return sb; }