void create_widget(const dictionary_t& parameters, size_enum_t size, progress_bar_t*& widget) { name_t orientation(key_horizontal); int length(100); int width(14); GG::Clr color(GG::CLR_BLACK); GG::Clr bar_color(GG::CLR_BLUE); GG::Clr interior_color(GG::CLR_ZERO); dictionary_t::const_iterator it(parameters.find(key_format)); value_range_format_t format; if (it != parameters.end()) format.set(it->second.cast<dictionary_t>()); get_value(parameters, key_orientation, orientation); get_value(parameters, static_name_t("length"), length); get_value(parameters, static_name_t("width"), width); implementation::get_color(parameters, static_name_t("color"), color); implementation::get_color(parameters, static_name_t("bar_color"), bar_color); implementation::get_color(parameters, static_name_t("interior_color"), interior_color); widget = new progress_bar_t(orientation == key_vertical, format, length, width, color, bar_color, interior_color); }
void create_widget(const dictionary_t& parameters, size_enum_t size, progress_bar_t*& widget) { bool is_indeterminate(false); bool is_relevance(false); name_t orientation(key_horizontal); dictionary_t::const_iterator iter(parameters.find(key_format)); value_range_format_t format; if (iter != parameters.end()) format.set(iter->second.cast<dictionary_t>()); get_value(parameters, key_is_indeterminate, is_indeterminate); get_value(parameters, key_is_relevance, is_relevance); get_value(parameters, key_orientation, orientation); bool is_vertical(orientation == key_vertical); pb_style_t bar_theme(pb_style_progress_bar_s); if (is_relevance) bar_theme = pb_style_relevance_bar_s; else if (is_indeterminate) bar_theme = pb_style_indeterminate_bar_s; widget = new progress_bar_t(bar_theme, is_vertical, format, implementation::size_to_theme(size)); }
bool get_localized_string(const dictionary_t& parameters, name_t key, std::string& value) { dictionary_t::const_iterator i = parameters.find(key); if (i == parameters.end()) return false; bool retval = i->second.cast(value); if (retval) value = localization_invoke(value); return retval; }
void apply_layout_parameters( layout_attributes_t& data, const dictionary_t& parameters) { ADOBE_ONCE_INSTANCE(adobe_eve_evaluate); get_value(parameters, key_indent, data.indent_m); if (parameters.count(key_horizontal)) { (*alignment_table_g)( get_value(parameters, key_horizontal).cast<name_t>(), data.slice_m[extents_slices_t::horizontal].alignment_m); } if (parameters.count(key_vertical)) { (*alignment_table_g)( get_value(parameters, key_vertical).cast<name_t>(), data.slice_m[extents_slices_t::vertical].alignment_m); } // REVISIT (sparent) If we had named guides then named guide suppression would go here. if (parameters.count(key_guide_mask)) // an empty array would allow baselines out. { // Turn on all guides - then selectively suppress data.slice_m[extents_slices_t::vertical].suppress_m = false; data.slice_m[extents_slices_t::horizontal].suppress_m = false; array_t guide_mask(get_value(parameters, key_guide_mask).cast<array_t>()); for (array_t::const_iterator iter(guide_mask.begin()), last(guide_mask.end()); iter != last; ++iter) { if (iter->cast<name_t>() == key_guide_baseline) data.slice_m[extents_slices_t::vertical].suppress_m = true; if (iter->cast<name_t>() == key_guide_label) data.slice_m[extents_slices_t::horizontal].suppress_m = true; } } // REVISIT (sparent) : If we had named guides then named guide balancing would go here... /* Balanced guides must be supressed to avoid having them attach to outside guides which could overconstrain the system. */ if (parameters.count(key_guide_balance)) { data.slice_m[extents_slices_t::vertical].balance_m = false; data.slice_m[extents_slices_t::horizontal].balance_m = false; array_t guide_balance(get_value(parameters, key_guide_balance).cast<array_t>()); for (array_t::const_iterator iter(guide_balance.begin()), last(guide_balance.end()); iter != last; ++iter) { if (iter->cast<name_t>() == key_guide_baseline) { data.slice_m[extents_slices_t::vertical].balance_m = true; data.slice_m[extents_slices_t::vertical].suppress_m = true; } if (iter->cast<name_t>() == key_guide_label) { data.slice_m[extents_slices_t::horizontal].balance_m = true; data.slice_m[extents_slices_t::horizontal].suppress_m = true; } } } // REVISIT (sparent) : I'm seeing a pattern here - with three cases this could be factored { dictionary_t::const_iterator iter (parameters.find(key_placement)); if (iter != parameters.end()) { (*placement_table_g)(iter->second.cast<name_t>(), data.placement_m); } // Adjust defaults // Specifying a row from the parameters implies enabling baselines unless otherwise specified. if (iter != parameters.end() && data.placement_m == layout_attributes_placement_t::place_row && !parameters.count(key_guide_mask)) { data.slice_m[extents_slices_t::vertical].suppress_m = false; } } { dictionary_t::const_iterator iter (parameters.find(key_child_horizontal)); if (iter != parameters.end()) { (*alignment_table_g)( iter->second.cast<name_t>(), data.slice_m[extents_slices_t::horizontal].child_alignment_m); } } { dictionary_t::const_iterator iter (parameters.find(key_child_vertical)); if (iter != parameters.end()) { (*alignment_table_g)( iter->second.cast<name_t>(), data.slice_m[extents_slices_t::vertical].child_alignment_m); } } // spacing { dictionary_t::const_iterator iter (parameters.find(key_spacing)); if (iter != parameters.end()) { if (iter->second.type_info() == type_info<array_t>()) { const array_t& spacing_array = iter->second.cast<array_t>(); data.spacing_m.resize(spacing_array.size() + 1); layout_attributes_t::spacing_t::iterator dest_iter(data.spacing_m.begin() + 1); for (array_t::const_iterator iter(spacing_array.begin()); iter != spacing_array.end(); ++iter) { *dest_iter = iter->cast<long>(); ++dest_iter; } } else { double tmp(data.spacing_m[1]); iter->second.cast(tmp); // Try getting as number data.spacing_m[1] = long(tmp); } } } // margin { dictionary_t::const_iterator iter(parameters.find(key_margin)); if (iter != parameters.end()) { if (iter->second.type_info() == type_info<array_t>()) { const array_t& margin_array = iter->second.cast<array_t>(); data.vertical().margin_m.first = margin_array[0].cast<long>(); data.horizontal().margin_m.first = margin_array[1].cast<long>(); data.vertical().margin_m.second = margin_array[2].cast<long>(); data.horizontal().margin_m.second = margin_array[3].cast<long>(); } else { long margin = iter->second.cast<long>(); data.vertical().margin_m.first = margin; data.horizontal().margin_m.first = margin; data.vertical().margin_m.second = margin; data.horizontal().margin_m.second = margin; } } } }