void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parent) { /////// Rect, follows, tool_tip, enabled, visible attributes /////// initFromXML(node, parent); /////// Border attributes /////// BOOL border = mBorder != NULL; node->getAttributeBOOL("border", border); if (border) { LLViewBorder::EBevel bevel_style = LLViewBorder::BEVEL_OUT; LLViewBorder::getBevelFromAttribute(node, bevel_style); LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE; std::string border_string; node->getAttributeString("border_style", border_string); LLStringUtil::toLower(border_string); if (border_string == "texture") { border_style = LLViewBorder::STYLE_TEXTURE; } S32 border_thickness = LLPANEL_BORDER_WIDTH; node->getAttributeS32("border_thickness", border_thickness); addBorder(bevel_style, border_style, border_thickness); } else { removeBorder(); } /////// Background attributes /////// BOOL background_visible = mBgVisible; node->getAttributeBOOL("background_visible", background_visible); setBackgroundVisible(background_visible); BOOL background_opaque = mBgOpaque; node->getAttributeBOOL("background_opaque", background_opaque); setBackgroundOpaque(background_opaque); LLColor4 color; color = mBgColorOpaque; LLUICtrlFactory::getAttributeColor(node,"bg_opaque_color", color); setBackgroundColor(color); color = mBgColorAlpha; LLUICtrlFactory::getAttributeColor(node,"bg_alpha_color", color); setTransparentColor(color); std::string label = getLabel(); node->getAttributeString("label", label); setLabel(label); }
BOOL LLLayoutPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { std::string orientation_string; node->getAttributeString("orientation", orientation_string); if (orientation_string == "horizontal") { mOrientation = LLLayoutStack::HORIZONTAL; } else if (orientation_string == "vertical") { mOrientation = LLLayoutStack::VERTICAL; } if(node->hasAttribute("min_dim")) node->getAttributeS32("min_dim", mMinDim); else if(mOrientation == LLLayoutStack::HORIZONTAL) node->getAttributeS32("min_width", mMinDim); else if(mOrientation == LLLayoutStack::VERTICAL) node->getAttributeS32("min_height", mMinDim); node->getAttributeS32("expanded_min_dim", mExpandedMinDim); BOOL auto_resize = mAutoResize; BOOL user_resize = mUserResize; node->getAttributeBOOL("auto_resize", auto_resize); node->getAttributeBOOL("user_resize", user_resize); mAutoResize = auto_resize; mUserResize = user_resize; bool ret = LLPanel::initPanelXML(node,parent,factory); // panels initialized as hidden should not start out partially visible if (!getVisible()) { mVisibleAmt = 0.f; } setFollowsNone(); return ret; }
LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { std::string name("name_list"); node->getAttributeString("name", name); LLRect rect; createRect(node, rect, parent, LLRect()); BOOL multi_select = FALSE; node->getAttributeBOOL("multi_select", multi_select); BOOL draw_border = TRUE; node->getAttributeBOOL("draw_border", draw_border); BOOL draw_heading = FALSE; node->getAttributeBOOL("draw_heading", draw_heading); S32 name_column_index = 0; node->getAttributeS32("name_column_index", name_column_index); LLUICtrlCallback callback = NULL; LLNameListCtrl* name_list = new LLNameListCtrl(name, rect, callback, NULL, multi_select, draw_border, name_column_index); name_list->setDisplayHeading(draw_heading); if (node->hasAttribute("heading_height")) { S32 heading_height; node->getAttributeS32("heading_height", heading_height); name_list->setHeadingHeight(heading_height); } BOOL allow_calling_card_drop = FALSE; if (node->getAttributeBOOL("allow_calling_card_drop", allow_calling_card_drop)) { name_list->setAllowCallingCardDrop(allow_calling_card_drop); } name_list->setScrollListParameters(node); name_list->initFromXML(node, parent); LLSD columns; S32 index = 0; S32 total_static = 0; LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { if (child->hasName("column")) { std::string labelname(""); child->getAttributeString("label", labelname); std::string columnname(labelname); child->getAttributeString("name", columnname); BOOL columndynamicwidth = FALSE; child->getAttributeBOOL("dynamicwidth", columndynamicwidth); std::string sortname(columnname); child->getAttributeString("sort", sortname); S32 columnwidth = -1; if (child->hasAttribute("relwidth")) { F32 columnrelwidth = 0.f; child->getAttributeF32("relwidth", columnrelwidth); columns[index]["relwidth"] = columnrelwidth; } else { child->getAttributeS32("width", columnwidth); columns[index]["width"] = columnwidth; } LLFontGL::HAlign h_align = LLFontGL::LEFT; h_align = LLView::selectFontHAlign(child); if(!columndynamicwidth) total_static += llmax(0, columnwidth); columns[index]["name"] = columnname; columns[index]["label"] = labelname; columns[index]["halign"] = (S32)h_align; columns[index]["dynamicwidth"] = columndynamicwidth; columns[index]["sort"] = sortname; index++; } } name_list->setTotalStaticColumnWidth(total_static); name_list->setColumnHeadings(columns); for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { if (child->hasName("row")) { LLUUID id; child->getAttributeUUID("id", id); LLSD row; row["id"] = id; S32 column_idx = 0; LLXMLNodePtr row_child; for (row_child = node->getFirstChild(); row_child.notNull(); row_child = row_child->getNextSibling()) { if (row_child->hasName("column")) { std::string value = row_child->getTextContents(); std::string columnname(""); row_child->getAttributeString("name", columnname); std::string font(""); row_child->getAttributeString("font", font); std::string font_style(""); row_child->getAttributeString("font-style", font_style); row["columns"][column_idx]["column"] = columnname; row["columns"][column_idx]["value"] = value; row["columns"][column_idx]["font"] = font; row["columns"][column_idx]["font-style"] = font_style; column_idx++; } } name_list->addElement(row); } } std::string contents = node->getTextContents(); typedef boost::tokenizer<boost::char_separator<char> > tokenizer; boost::char_separator<char> sep("\t\n"); tokenizer tokens(contents, sep); tokenizer::iterator token_iter = tokens.begin(); while(token_iter != tokens.end()) { const std::string& line = *token_iter; name_list->addCommentText(line); ++token_iter; } return name_list; }
//static LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { std::string orientation_string("vertical"); node->getAttributeString("orientation", orientation_string); eLayoutOrientation orientation = VERTICAL; if (orientation_string == "horizontal") { orientation = HORIZONTAL; } else if (orientation_string == "vertical") { orientation = VERTICAL; } else { llwarns << "Unknown orientation " << orientation_string << ", using vertical" << llendl; } LLLayoutStack* layout_stackp = new LLLayoutStack(orientation); node->getAttributeS32("border_size", layout_stackp->mPanelSpacing); // don't allow negative spacing values layout_stackp->mPanelSpacing = llmax(layout_stackp->mPanelSpacing, 0); std::string name("stack"); node->getAttributeString("name", name); layout_stackp->setName(name); layout_stackp->initFromXML(node, parent); LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { S32 min_width = 0; S32 min_height = 0; BOOL auto_resize = TRUE; child->getAttributeS32("min_width", min_width); child->getAttributeS32("min_height", min_height); child->getAttributeBOOL("auto_resize", auto_resize); if (child->hasName("layout_panel")) { BOOL user_resize = TRUE; child->getAttributeBOOL("user_resize", user_resize); LLPanel* panelp = (LLPanel*)LLPanel::fromXML(child, layout_stackp, factory); if (panelp) { panelp->setFollowsNone(); layout_stackp->addPanel(panelp, min_width, min_height, auto_resize, user_resize); } } else { BOOL user_resize = FALSE; child->getAttributeBOOL("user_resize", user_resize); LLPanel* panelp = new LLPanel(std::string("auto_panel")); LLView* new_child = factory->createWidget(panelp, child); if (new_child) { // put child in new embedded panel layout_stackp->addPanel(panelp, min_width, min_height, auto_resize, user_resize); // resize panel to contain widget and move widget to be contained in panel panelp->setRect(new_child->getRect()); new_child->setOrigin(0, 0); } else { panelp->die(); } } } layout_stackp->updateLayout(); return layout_stackp; }