Exemplo n.º 1
0
GG::ListBox::Row* item_to_row(const dictionary_t& item,
                              const row_factory_t* row_factory,
                              const GG::Clr& default_item_color)
{
    const bool contains_color = item.count(static_name_t("color"));
    dictionary_t colorful_dictionary;
    if (!contains_color) {
        colorful_dictionary = item;
        colorful_dictionary[static_name_t("color")] = any_regular_t(default_item_color);
    }
    const dictionary_t& dictionary = contains_color ? item : colorful_dictionary;
    name_t type;
    get_value(dictionary, static_name_t("type"), type);
    row_factory_t::const_iterator it;
    GG::ListBox::Row* retval = 0;
    if (row_factory && (it = row_factory->find(type)) != row_factory->end())
        retval = it->second(dictionary);
    else
        retval = GG::DefaultRowFactoryFunction(dictionary);
    retval->SetItem(item);
    return retval;
}