//----------------------------------------------------------------------------- // buildMenu() //----------------------------------------------------------------------------- LLMenuGL *LLUICtrlFactory::buildMenu(const std::string &filename, LLView* parentp) { // TomY TODO: Break this function into buildMenu and buildMenuBar LLXMLNodePtr root; LLMenuGL* menu; if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { return NULL; } // root must be called panel if( !root->hasName( "menu_bar" ) && !root->hasName( "menu" )) { llwarns << "Root node should be named menu bar or menu in : " << filename << llendl; return NULL; } if (root->hasName("menu")) { menu = (LLMenuGL*)LLMenuGL::fromXML(root, parentp, this); } else { menu = (LLMenuGL*)LLMenuBarGL::fromXML(root, parentp, this); } if (LLUI::sShowXUINames) { menu->setToolTip(filename); } return menu; }
void LLUICtrlFactory::buildFloaterInternal(LLFloater *floaterp, LLXMLNodePtr &root, const std::string &filename, const LLCallbackMap::map_t *factory_map, BOOL open) /* Flawfinder: ignore */ { // root must be called floater if( !(root->hasName("floater") || root->hasName("multi_floater") ) ) { llwarns << "Root node should be named floater in: " << filename << llendl; return; } if (factory_map) { mFactoryStack.push_front(factory_map); } floaterp->initFloaterXML(root, NULL, this, open); /* Flawfinder: ignore */ if (LLUI::sShowXUINames) { floaterp->setToolTip(filename); } if (factory_map) { mFactoryStack.pop_front(); } LLHandle<LLFloater> handle = floaterp->getHandle(); mBuiltFloaters[handle] = filename; }
void LLUICtrlFactory::buildFloaterInternal(LLFloater *floaterp, LLXMLNodePtr &root, const std::string &filename, const LLCallbackMap::map_t *factory_map, BOOL open) /* Flawfinder: ignore */ { // root must be called floater if( !(root->hasName("floater") || root->hasName("multi_floater") ) ) { llwarns << "Root node should be named floater in: " << filename << llendl; return; } if (factory_map) { mFactoryStack.push_front(factory_map); } // for local registry callbacks; define in constructor, referenced in XUI or postBuild floaterp->getCommitCallbackRegistrar().pushScope(); floaterp->getEnableCallbackRegistrar().pushScope(); floaterp->initFloaterXML(root, NULL, this, open); /* Flawfinder: ignore */ floaterp->getCommitCallbackRegistrar().popScope(); floaterp->getEnableCallbackRegistrar().popScope(); if (LLUI::sShowXUINames) { floaterp->setToolTip(filename); } if (factory_map) { mFactoryStack.pop_front(); } LLHandle<LLFloater> handle = floaterp->getHandle(); mBuiltFloaters[handle] = filename; }
void LLPanel::initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory) { std::string kidstring(node->getName()->mString); kidstring += ".string"; LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { // look for string declarations for programmatic text if (child->hasName("string") || child->hasName(kidstring)) { std::string string_name; child->getAttributeString("name", string_name); if (!string_name.empty()) { std::string contents = child->getTextContents(); child->getAttributeString("value", contents); mUIStrings[string_name] = contents; } } else { factory->createWidget(this, child); } } }
//----------------------------------------------------------------------------- // buildFloater() //----------------------------------------------------------------------------- bool LLUICtrlFactory::buildFloater(LLFloater* floaterp, const std::string& filename, LLXMLNodePtr output_node) { LLFastTimer timer(FTM_BUILD_FLOATERS); LLXMLNodePtr root; //if exporting, only load the language being exported, //instead of layering localized version on top of english if (output_node) { if (!LLUICtrlFactory::getLocalizedXMLNode(filename, root)) { llwarns << "Couldn't parse floater from: " << LLUI::getLocalizedSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl; return false; } } else if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { llwarns << "Couldn't parse floater from: " << LLUI::getSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl; return false; } // root must be called floater if( !(root->hasName("floater") || root->hasName("multi_floater")) ) { llwarns << "Root node should be named floater in: " << filename << llendl; return false; } bool res = true; lldebugs << "Building floater " << filename << llendl; mFileNames.push_back(gDirUtilp->findSkinnedFilename(LLUI::getSkinPath(), filename)); { if (!floaterp->getFactoryMap().empty()) { mFactoryStack.push_front(&floaterp->getFactoryMap()); } // for local registry callbacks; define in constructor, referenced in XUI or postBuild floaterp->getCommitCallbackRegistrar().pushScope(); floaterp->getEnableCallbackRegistrar().pushScope(); res = floaterp->initFloaterXML(root, floaterp->getParent(), output_node); floaterp->setXMLFilename(filename); floaterp->getCommitCallbackRegistrar().popScope(); floaterp->getEnableCallbackRegistrar().popScope(); if (!floaterp->getFactoryMap().empty()) { mFactoryStack.pop_front(); } } mFileNames.pop_back(); return res; }
bool LLFontRegistry::initFromXML(LLXMLNodePtr node) { LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { std::string child_name; child->getAttributeString("name",child_name); if (child->hasName("font")) { LLFontDescriptor desc; bool font_succ = fontDescInitFromXML(child, desc); LLFontDescriptor norm_desc = desc.normalize(); if (font_succ) { // if this is the first time we've seen this font name, // create a new template map entry for it. const LLFontDescriptor *match_desc = getMatchingFontDesc(desc); if (match_desc == NULL) { // Create a new entry (with no corresponding font). mFontMap[norm_desc] = NULL; } // otherwise, find the existing entry and combine data. else { // Prepend files from desc. // A little roundabout because the map key is const, // so we have to fetch it, make a new map key, and // replace the old entry. string_vec_t match_file_names = match_desc->getFileNames(); match_file_names.insert(match_file_names.begin(), desc.getFileNames().begin(), desc.getFileNames().end()); LLFontDescriptor new_desc = *match_desc; new_desc.getFileNames() = match_file_names; mFontMap.erase(*match_desc); mFontMap[new_desc] = NULL; } } } else if (child->hasName("font_size")) { std::string size_name; F32 size_value; if (child->getAttributeString("name",size_name) && child->getAttributeF32("size",size_value)) { mFontSizes[size_name] = size_value; } } } return true; }
bool LLNotificationTemplates::loadTemplates() { LL_INFOS() << "Reading notifications template" << LL_ENDL; // Passing findSkinnedFilenames(constraint=LLDir::ALL_SKINS) makes it // output all relevant pathnames instead of just the ones from the most // specific skin. std::vector<std::string> search_paths = gDirUtilp->findSkinnedFilenames(LLDir::XUI, "notifications.xml", LLDir::ALL_SKINS); std::string base_filename = search_paths.front(); LLXMLNodePtr root; BOOL success = LLXMLNode::getLayeredXMLNode(root, search_paths); if (!success || root.isNull() || !root->hasName( "notifications" )) { LL_ERRS() << "Problem reading XML from UI Notifications file: " << base_filename << LL_ENDL; return false; } clearTemplates(); for (LLXMLNodePtr item = root->getFirstChild(); item.notNull(); item = item->getNextSibling()) { if (item->hasName("global")) { std::string global_name; if (item->getAttributeString("name", global_name)) { mGlobalStrings[global_name] = item->getTextContents(); } continue; } if (item->hasName("template")) { // store an xml template; templates must have a single node (can contain // other nodes) std::string name; item->getAttributeString("name", name); LLXMLNodePtr ptr = item->getFirstChild(); mXmlTemplates[name] = ptr; continue; } if (!item->hasName("notification")) { LL_WARNS() << "Unexpected entity " << item->getName()->mString << " found in notifications.xml [language=]" << LLUI::getLanguage() << LL_ENDL; continue; } } return true; }
bool LLNotificationTemplates::loadTemplates() { const std::string xml_filename = "notifications.xml"; LLXMLNodePtr root; BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); if (!success || root.isNull() || !root->hasName( "notifications" )) { llerrs << "Problem reading UI Notifications file: " << xml_filename << llendl; return false; } clearTemplates(); for (LLXMLNodePtr item = root->getFirstChild(); item.notNull(); item = item->getNextSibling()) { if (item->hasName("global")) { std::string global_name; if (item->getAttributeString("name", global_name)) { mGlobalStrings[global_name] = item->getTextContents(); } continue; } if (item->hasName("template")) { // store an xml template; templates must have a single node (can contain // other nodes) std::string name; item->getAttributeString("name", name); LLXMLNodePtr ptr = item->getFirstChild(); mXmlTemplates[name] = ptr; continue; } if (!item->hasName("notification")) { llwarns << "Unexpected entity " << item->getName()->mString << " found in " << xml_filename << llendl; continue; } } return true; }
BOOL LLUICtrlFactory::buildPanelInternal(LLPanel* panelp, LLXMLNodePtr &root, const std::string &filename, const LLCallbackMap::map_t* factory_map) { BOOL didPost = FALSE; // root must be called panel if( !root->hasName("panel" ) ) { llwarns << "Root node should be named panel in : " << filename << llendl; return didPost; } if (factory_map) { mFactoryStack.push_front(factory_map); } didPost = panelp->initPanelXML(root, NULL, this); if (LLUI::sShowXUINames) { panelp->setToolTip(filename); } LLHandle<LLPanel> handle = panelp->getHandle(); mBuiltPanels[handle] = filename; if (factory_map) { mFactoryStack.pop_front(); } return didPost; }
// virtual LLXMLNodePtr LLFlyoutButton::getXML(bool save_children) const { LLXMLNodePtr node = LLComboBox::getXML(); node->setName(LL_FLYOUT_BUTTON_TAG); LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull();) { if (child->hasName("combo_item")) { child->setName(LL_FLYOUT_BUTTON_ITEM_TAG); //setName does a delete and add, so we have to start over child = node->getFirstChild(); } else { child = child->getNextSibling(); } } return node; }
bool LLUIColorTable::loadFromFilename(const std::string& filename, string_color_map_t& table) { LLXMLNodePtr root; if(!LLXMLNode::parseFile(filename, root, NULL)) { llwarns << "Unable to parse color file " << filename << llendl; return false; } if(!root->hasName("colors")) { llwarns << filename << " is not a valid color definition file" << llendl; return false; } Params params; LLXUIParser parser; parser.readXUI(root, params, filename); if(params.validateBlock()) { insertFromParams(params, table); } else { llwarns << filename << " failed to load" << llendl; return false; } return true; }
//static bool LLUITrans::parseStrings(const std::string& xml_filename) { LLXMLNodePtr root; BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); if (!success || root.isNull() || !root->hasName( "strings" )) { llwarns << "Problem reading strings: " << xml_filename << llendl; return false; } for (LLXMLNode* string = root->getFirstChild(); string != NULL; string = string->getNextSibling()) { if (!string->hasName("string")) { continue; } std::string string_name; if (! string->getAttributeString("name", string_name)) { llwarns << "Unable to parse string with no name" << llendl; continue; } LLUITransTemplate xml_template(string_name, string->getTextContents()); sStringTemplates[xml_template.mName] = xml_template; } return true; }
//----------------------------------------------------------------------------- // buildMenu() //----------------------------------------------------------------------------- LLContextMenu* LLUICtrlFactory::buildContextMenu(const std::string& filename, LLView* parentp) { LLXMLNodePtr root; if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { return NULL; } // root must be called panel if( !root->hasName( LL_PIE_MENU_TAG )) { LL_WARNS() << "Root node should be named " << LL_PIE_MENU_TAG << " in : " << filename << LL_ENDL; return NULL; } std::string name("menu"); root->getAttributeString("name", name); static LLUICachedControl<bool> context("LiruUseContextMenus", false); LLContextMenu* menu = context ? new LLContextMenu(name) : new LLPieMenu(name); parentp->addChild(menu); menu->initXML(root, parentp, this, context); if (LLUI::sShowXUINames) { menu->setToolTip(filename); } return menu; }
//----------------------------------------------------------------------------- // buildMenu() //----------------------------------------------------------------------------- LLPieMenu *LLUICtrlFactory::buildPieMenu(const std::string &filename, LLView* parentp) { LLXMLNodePtr root; if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { return NULL; } // root must be called panel if( !root->hasName( LL_PIE_MENU_TAG )) { llwarns << "Root node should be named " << LL_PIE_MENU_TAG << " in : " << filename << llendl; return NULL; } std::string name("menu"); root->getAttributeString("name", name); LLPieMenu *menu = new LLPieMenu(name); parentp->addChild(menu); menu->initXML(root, parentp, this); if (LLUI::sShowXUINames) { menu->setToolTip(filename); } return menu; }
//static bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) { std::string xml_filename = "(language strings file)"; if (!root->hasName("strings")) { llerrs << "Invalid root node name in " << xml_filename << ": was " << root->getName() << ", expected \"strings\"" << llendl; } StringTable string_table; LLXUIParser parser; parser.readXUI(root, string_table, xml_filename); if (!string_table.validateBlock()) { llerrs << "Problem reading strings: " << xml_filename << llendl; return false; } for(LLInitParam::ParamIterator<StringDef>::const_iterator it = string_table.strings.begin(); it != string_table.strings.end(); ++it) { // share the same map with parseStrings() so we can search the strings using the same getString() function.- angela LLTransTemplate xml_template(it->name, it->value); sStringTemplates[xml_template.mName] = xml_template; } return true; }
// private to this file // returns true if the template request was invalid and there's nothing else we // can do with this node, false if you should keep processing (it may have // replaced the contents of the node referred to) LLXMLNodePtr LLNotifications::checkForXMLTemplate(LLXMLNodePtr item) { if (item->hasName("usetemplate")) { std::string replacementName; if (item->getAttributeString("name", replacementName)) { StringMap replacements; for (LLXMLAttribList::const_iterator it=item->mAttributes.begin(); it != item->mAttributes.end(); ++it) { replacements[it->second->getName()->mString] = it->second->getValue(); } if (mXmlTemplates.count(replacementName)) { item=LLXMLNode::replaceNode(item, mXmlTemplates[replacementName]); // walk the nodes looking for $(substitution) here and replace replaceSubstitutionStrings(item, replacements); } else { llwarns << "XML template lookup failure on '" << replacementName << "' " << llendl; } } } return item; }
//----------------------------------------------------------------------------- // buildPanel() //----------------------------------------------------------------------------- BOOL LLUICtrlFactory::buildPanel(LLPanel* panelp, const std::string& filename, LLXMLNodePtr output_node) { LLFastTimer timer(FTM_BUILD_PANELS); BOOL didPost = FALSE; LLXMLNodePtr root; //if exporting, only load the language being exported, //instead of layering localized version on top of english if (output_node) { if (!LLUICtrlFactory::getLocalizedXMLNode(filename, root)) { llwarns << "Couldn't parse panel from: " << LLUI::getLocalizedSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl; return didPost; } } else if (!LLUICtrlFactory::getLayeredXMLNode(filename, root)) { llwarns << "Couldn't parse panel from: " << LLUI::getSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl; return didPost; } // root must be called panel if( !root->hasName("panel" ) ) { llwarns << "Root node should be named panel in : " << filename << llendl; return didPost; } lldebugs << "Building panel " << filename << llendl; mFileNames.push_back(gDirUtilp->findSkinnedFilename(LLUI::getSkinPath(), filename)); { if (!panelp->getFactoryMap().empty()) { mFactoryStack.push_front(&panelp->getFactoryMap()); } // for local registry callbacks; define in constructor, referenced in XUI or postBuild panelp->getCommitCallbackRegistrar().pushScope(); panelp->getEnableCallbackRegistrar().pushScope(); didPost = panelp->initPanelXML(root, NULL, output_node); panelp->getCommitCallbackRegistrar().popScope(); panelp->getEnableCallbackRegistrar().popScope(); panelp->setXMLFilename(filename); if (!panelp->getFactoryMap().empty()) { mFactoryStack.pop_front(); } } mFileNames.pop_back(); return didPost; }
// static LLView* LLComboBox::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { std::string name("combo_box"); node->getAttributeString("name", name); std::string label(""); node->getAttributeString("label", label); LLRect rect; createRect(node, rect, parent, LLRect()); BOOL allow_text_entry = FALSE; node->getAttributeBOOL("allow_text_entry", allow_text_entry); S32 max_chars = 20; node->getAttributeS32("max_chars", max_chars); LLUICtrlCallback callback = NULL; LLComboBox* combo_box = new LLComboBox(name, rect, label, callback, NULL); combo_box->setAllowTextEntry(allow_text_entry, max_chars); combo_box->initFromXML(node, parent); const std::string& contents = node->getValue(); if (contents.find_first_not_of(" \n\t") != contents.npos) { llerrs << "Legacy combo box item format used! Please convert to <combo_item> tags!" << llendl; } else { LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { if (child->hasName("combo_item")) { std::string label = child->getTextContents(); std::string value = label; child->getAttributeString("value", value); combo_box->add(label, LLSD(value) ); } } } combo_box->selectFirstItem(); return combo_box; }
bool LLFontRegistry::parseFontInfo(const std::string& xml_filename) { bool success = false; // Succeed if we find and read at least one XUI file const string_vec_t xml_paths = gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename); if (xml_paths.empty()) { // We didn't even find one single XUI file return false; } for (string_vec_t::const_iterator path_it = xml_paths.begin(); path_it != xml_paths.end(); ++path_it) { LLXMLNodePtr root; bool parsed_file = LLXMLNode::parseFile(*path_it, root, NULL); if (!parsed_file) continue; if ( root.isNull() || ! root->hasName( "fonts" ) ) { LL_WARNS() << "Bad font info file: " << *path_it << LL_ENDL; continue; } std::string root_name; root->getAttributeString("name",root_name); if (root->hasName("fonts")) { // Expect a collection of children consisting of "font" or "font_size" entries bool init_succ = init_from_xml(this, root); success = success || init_succ; } } //if (success) // dump(); return success; }
LLNotificationForm::LLNotificationForm(const std::string& name, const LLXMLNodePtr xml_node) : mFormData(LLSD::emptyArray()), mIgnore(IGNORE_NO), mInvertSetting(false) { if (!xml_node->hasName("form")) { llwarns << "Bad xml node for form: " << xml_node->getName() << llendl; } LLXMLNodePtr child = xml_node->getFirstChild(); while(child) { child = LLNotificationTemplates::instance().checkForXMLTemplate(child); LLSD item_entry; std::string element_name = child->getName()->mString; if (element_name == "ignore") { bool save_option = false; child->getAttribute_bool("save_option", save_option); if (!save_option) { mIgnore = IGNORE_WITH_DEFAULT_RESPONSE; } else { // remember last option chosen by user and automatically respond with that in the future mIgnore = IGNORE_WITH_LAST_RESPONSE; LLUI::sIgnoresGroup->declareLLSD(std::string("Default") + name, "", std::string("Default response for notification " + name)); } child->getAttributeString("text", mIgnoreMsg); mIgnoreSetting = LLUI::sIgnoresGroup->addWarning(name); } else { // flatten xml form entry into single LLSD map with type==name item_entry["type"] = element_name; const LLXMLAttribList::iterator attrib_end = child->mAttributes.end(); for(LLXMLAttribList::iterator attrib_it = child->mAttributes.begin(); attrib_it != attrib_end; ++attrib_it) { item_entry[std::string(attrib_it->second->getName()->mString)] = attrib_it->second->getValue(); } item_entry["value"] = child->getTextContents(); mFormData.append(item_entry); } child = child->getNextSibling(); } }
bool fontDescInitFromXML(LLXMLNodePtr node, LLFontDescriptor& desc) { if (node->hasName("font")) { std::string attr_name; if (node->getAttributeString("name",attr_name)) { desc.setName(attr_name); } std::string attr_style; if (node->getAttributeString("font_style",attr_style)) { desc.setStyle(LLFontGL::getStyleFromString(attr_style)); } desc.setSize(s_template_string); } LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { std::string child_name; child->getAttributeString("name",child_name); if (child->hasName("file")) { std::string font_file_name = child->getTextContents(); desc.getFileNames().push_back(font_file_name); } else if (child->hasName("os")) { if (child_name == currentOsName()) { fontDescInitFromXML(child, desc); } } } return true; }
//static LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) { std::string name = "flyout_button"; node->getAttributeString("name", name); std::string label(""); node->getAttributeString("label", label); LLRect rect; createRect(node, rect, parent, LLRect()); LLUICtrlCallback callback = NULL; LLFlyoutButton* flyout_button = new LLFlyoutButton(name, rect, label, callback, NULL); std::string list_position; node->getAttributeString("list_position", list_position); if (list_position == "below") { flyout_button->mListPosition = BELOW; } else if (list_position == "above") { flyout_button->mListPosition = ABOVE; } flyout_button->initFromXML(node, parent); LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { if (child->hasName("flyout_button_item")) { std::string label = child->getTextContents(); std::string value = label; child->getAttributeString("value", value); flyout_button->add(label, LLSD(value) ); } } flyout_button->updateLayout(); return flyout_button; }
bool LLFontRegistry::parseFontInfo(const std::string& xml_filename) { bool success = false; // Succeed if we find at least one XUI file const string_vec_t& xml_paths = mXUIPaths; for (string_vec_t::const_iterator path_it = xml_paths.begin(); path_it != xml_paths.end(); ++path_it) { LLXMLNodePtr root; std::string full_filename = gDirUtilp->findSkinnedFilename(*path_it, xml_filename); bool parsed_file = LLXMLNode::parseFile(full_filename, root, NULL); if (!parsed_file) continue; if ( root.isNull() || ! root->hasName( "fonts" ) ) { llwarns << "Bad font info file: " << full_filename << llendl; continue; } std::string root_name; root->getAttributeString("name",root_name); if (root->hasName("fonts")) { // Expect a collection of children consisting of "font" or "font_size" entries bool init_succ = initFromXML(root); success = success || init_succ; } } //if (success) // dump(); return success; }
//static bool LLTrans::parseStrings(const std::string& xml_filename, const std::set<std::string>& default_args) { LLXMLNodePtr root; BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); if (!success || root.isNull() || !root->hasName( "strings" )) { LL_ERRS() << "Problem reading strings: " << xml_filename << LL_ENDL; return false; } sDefaultArgs.clear(); for (LLXMLNode* string = root->getFirstChild(); string != NULL; string = string->getNextSibling()) { if (!string->hasName("string")) { continue; } std::string string_name; if (! string->getAttributeString("name", string_name)) { LL_WARNS() << "Unable to parse string with no name" << LL_ENDL; continue; } std::string contents; //value is used for strings with preceeding spaces. If not present, fall back to getTextContents() if(!string->getAttributeString("value",contents)) contents=string->getTextContents(); LLTransTemplate xml_template(string_name, contents); sStringTemplates[xml_template.mName] = xml_template; std::set<std::string>::const_iterator iter = default_args.find(xml_template.mName); if (iter != default_args.end()) { std::string name = *iter; if (name[0] != '[') name = llformat("[%s]",name.c_str()); sDefaultArgs[name] = xml_template.mText; } } return true; }
//static LLView* LLFlyoutButton::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory) { std::string label(""); node->getAttributeString("label", label); LLRect rect; createRect(node, rect, parent, LLRect()); LLFlyoutButton* flyout_button = new LLFlyoutButton("flyout_button", rect, label); std::string list_position; node->getAttributeString("list_position", list_position); if (list_position == "below") { flyout_button->mListPosition = BELOW; } else if (list_position == "above") { flyout_button->mListPosition = ABOVE; } if (LLFontGL* font = selectFont(node)) flyout_button->mActionButton->setFont(font); flyout_button->initFromXML(node, parent); for (LLXMLNodePtr child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { if (child->hasName(LL_FLYOUT_BUTTON_ITEM_TAG)) { std::string label(child->getTextContents()); child->getAttributeString("label", label); std::string value(label); child->getAttributeString("value", value); flyout_button->add(label, LLSD(value)); } } flyout_button->updateLayout(); return flyout_button; }
//static bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& default_args) { std::string xml_filename = "(strings file)"; if (!root->hasName("strings")) { llerrs << "Invalid root node name in " << xml_filename << ": was " << root->getName() << ", expected \"strings\"" << llendl; } StringTable string_table; LLXUIParser parser; parser.readXUI(root, string_table, xml_filename); if (!string_table.validateBlock()) { llerrs << "Problem reading strings: " << xml_filename << llendl; return false; } sStringTemplates.clear(); sDefaultArgs.clear(); for(LLInitParam::ParamIterator<StringDef>::const_iterator it = string_table.strings.begin(); it != string_table.strings.end(); ++it) { LLTransTemplate xml_template(it->name, it->value); sStringTemplates[xml_template.mName] = xml_template; std::set<std::string>::const_iterator iter = default_args.find(xml_template.mName); if (iter != default_args.end()) { std::string name = *iter; if (name[0] != '[') name = llformat("[%s]",name.c_str()); sDefaultArgs[name] = xml_template.mText; } } return true; }
BOOL LLUICtrlFactory::buildPanelInternal(LLPanel* panelp, LLXMLNodePtr &root, const std::string &filename, const LLCallbackMap::map_t* factory_map) { BOOL didPost = FALSE; // root must be called panel if( !root->hasName("panel" ) ) { llwarns << "Root node should be named panel in : " << filename << llendl; return didPost; } if (factory_map) { mFactoryStack.push_front(factory_map); } // for local registry callbacks; define in constructor, referenced in XUI or postBuild panelp->getCommitCallbackRegistrar().pushScope(); panelp->getEnableCallbackRegistrar().pushScope(); didPost = panelp->initPanelXML(root, NULL, this); panelp->getCommitCallbackRegistrar().popScope(); panelp->getEnableCallbackRegistrar().popScope(); if (LLUI::sShowXUINames) { panelp->setToolTip(filename); } LLHandle<LLPanel> handle = panelp->getHandle(); mBuiltPanels[handle] = filename; if (factory_map) { mFactoryStack.pop_front(); } return didPost; }
bool LLToolBarView::loadToolbars(bool force_default) { LLToolBarView::ToolbarSet toolbar_set; bool err = false; // Load the toolbars.xml file std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml"); if (force_default) { toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); } else if (!gDirUtilp->fileExists(toolbar_file)) { llwarns << "User toolbars def not found -> use default" << llendl; toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml"); } LLXMLNodePtr root; if(!LLXMLNode::parseFile(toolbar_file, root, NULL)) { llwarns << "Unable to load toolbars from file: " << toolbar_file << llendl; err = true; } if (!err && !root->hasName("toolbars")) { llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl; err = true; } // Parse the toolbar settings LLXUIParser parser; if (!err) { parser.readXUI(root, toolbar_set, toolbar_file); } if (!err && !toolbar_set.validateBlock()) { llwarns << "Unable to validate toolbars from file: " << toolbar_file << llendl; err = true; } if (err) { if (force_default) { llerrs << "Unable to load toolbars from default file : " << toolbar_file << llendl; return false; } // Try to load the default toolbars return loadToolbars(true); } // Clear the toolbars now before adding the loaded commands and settings for (S32 i = TOOLBAR_FIRST; i <= TOOLBAR_LAST; i++) { if (mToolbars[i]) { mToolbars[i]->clearCommandsList(); } } // Add commands to each toolbar if (toolbar_set.left_toolbar.isProvided() && mToolbars[TOOLBAR_LEFT]) { if (toolbar_set.left_toolbar.button_display_mode.isProvided()) { LLToolBarEnums::ButtonType button_type = toolbar_set.left_toolbar.button_display_mode; mToolbars[TOOLBAR_LEFT]->setButtonType(button_type); } BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.left_toolbar.commands) { if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_LEFT])) { llwarns << "Error adding command '" << command_params.name() << "' to left toolbar." << llendl; } } } if (toolbar_set.right_toolbar.isProvided() && mToolbars[TOOLBAR_RIGHT]) { if (toolbar_set.right_toolbar.button_display_mode.isProvided()) { LLToolBarEnums::ButtonType button_type = toolbar_set.right_toolbar.button_display_mode; mToolbars[TOOLBAR_RIGHT]->setButtonType(button_type); } BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.right_toolbar.commands) { if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_RIGHT])) { llwarns << "Error adding command '" << command_params.name() << "' to right toolbar." << llendl; } } } if (toolbar_set.bottom_toolbar.isProvided() && mToolbars[TOOLBAR_BOTTOM]) { if (toolbar_set.bottom_toolbar.button_display_mode.isProvided()) { LLToolBarEnums::ButtonType button_type = toolbar_set.bottom_toolbar.button_display_mode; mToolbars[TOOLBAR_BOTTOM]->setButtonType(button_type); } BOOST_FOREACH(const LLCommandId::Params& command_params, toolbar_set.bottom_toolbar.commands) { if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_BOTTOM])) { llwarns << "Error adding command '" << command_params.name() << "' to bottom toolbar." << llendl; } } } mToolbarsLoaded = true; return true; }
// static bool LLMIMETypes::parseMIMETypes(const std::string& xml_filename) { LLXMLNodePtr root; bool success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); if (!success) { // If fails, check if we can read the file from the app_settings folder std::string settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, xml_filename); success = LLUICtrlFactory::getLayeredXMLNode(settings_filename, root); #if LL_WINDOWS // On the windows dev builds, unpackaged, the mime_types.xml file will be located in // indra/build-vc**/newview/<config>/app_settings. if (!success) { settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "app_settings", xml_filename); success = LLUICtrlFactory::getLayeredXMLNode(settings_filename, root); } #endif } if ( ! success || root.isNull() || ! root->hasName( "mimetypes" ) ) { llwarns << "Unable to read MIME type file: " << xml_filename << llendl; return false; } for (LLXMLNode* node = root->getFirstChild(); node != NULL; node = node->getNextSibling()) { if (node->hasName("defaultlabel")) { sDefaultLabel = node->getTextContents(); } else if (node->hasName("defaultwidget")) { sDefaultWidgetType = node->getTextContents(); } else if (node->hasName("defaultimpl")) { sDefaultImpl = node->getTextContents(); } else if (node->hasName("mimetype") || node->hasName("scheme")) { std::string mime_type; node->getAttributeString("name", mime_type); LLMIMEInfo info; for (LLXMLNode* child = node->getFirstChild(); child != NULL; child = child->getNextSibling()) { if (child->hasName("label")) { info.mLabel = child->getTextContents(); } else if (child->hasName("widgettype")) { info.mWidgetType = child->getTextContents(); } else if (child->hasName("impl")) { info.mImpl = child->getTextContents(); } } sMap[mime_type] = info; } else if (node->hasName("widgetset")) { std::string set_name; node->getAttributeString("name", set_name); LLMIMEWidgetSet info; for (LLXMLNode* child = node->getFirstChild(); child != NULL; child = child->getNextSibling()) { if (child->hasName("label")) { info.mLabel = child->getTextContents(); } if (child->hasName("icon")) { info.mIcon = child->getTextContents(); } if (child->hasName("default_type")) { info.mDefaultMimeType = child->getTextContents(); } if (child->hasName("tooltip")) { info.mToolTip = child->getTextContents(); } if (child->hasName("playtip")) { info.mPlayTip = child->getTextContents(); } if (child->hasName("allow_resize")) { BOOL allow_resize = FALSE; child->getBoolValue( 1, &allow_resize ); info.mAllowResize = (bool)allow_resize; } if (child->hasName("allow_looping")) { BOOL allow_looping = FALSE; child->getBoolValue( 1, &allow_looping ); info.mAllowLooping = (bool)allow_looping; } } sWidgetMap[set_name] = info; } } sXMLFilename = xml_filename; return true; }
// Checked: 2010-03-09 (RLVa-1.2.0a) | Added: RLVa-1.1.0h void RlvStrings::initClass() { static bool fInitialized = false; if (!fInitialized) { LLXMLNodePtr xmlRoot; if ( (!LLUICtrlFactory::getLayeredXMLNode("rlva_strings.xml", xmlRoot)) || (xmlRoot.isNull()) || (!xmlRoot->hasName("rlva_strings")) ) { RLV_ERRS << "Problem reading RLVa string XML file" << RLV_ENDL; return; } for (LLXMLNode* pNode = xmlRoot->getFirstChild(); pNode != NULL; pNode = pNode->getNextSibling()) { if (pNode->hasName("strings")) { std::string strName; for (LLXMLNode* pStringNode = pNode->getFirstChild(); pStringNode != NULL; pStringNode = pStringNode->getNextSibling()) { if ( (!pStringNode->hasName("string")) || (!pStringNode->getAttributeString("name", strName)) ) continue; m_StringMap[strName] = pStringNode->getTextContents(); } } else if (pNode->hasName("anonyms")) { for (LLXMLNode* pAnonymNode = pNode->getFirstChild(); pAnonymNode != NULL; pAnonymNode = pAnonymNode->getNextSibling()) { if (!pAnonymNode->hasName("anonym")) continue; m_Anonyms.push_back(pAnonymNode->getTextContents()); } } } if ( (m_StringMap.empty()) || (m_Anonyms.empty()) ) { RLV_ERRS << "Problem parsing RLVa string XML file" << RLV_ENDL; return; } fInitialized = true; } }