inline widget_node_t create_and_hookup_widget<control_button_t, poly_placeable_t>(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, bool is_container, const layout_attributes_t& layout_attributes) { size_enum_t size(parameters.count(key_size) ? implementation::enumerate_size(get_value(parameters, key_size).cast<name_t>()) : parent.size_m); std::string name; std::string alt_text; std::string expression_string; get_value(parameters, key_name, name); get_value(parameters, key_alt_text, alt_text); get_value(parameters, static_name_t("expression"), expression_string); control_button_t* widget(NULL); widget = new control_button_t(name, alt_text, boost::bind(&sheet_t::inspect, boost::ref(token.sheet_m), _1), parse_adam_expression(expression_string), implementation::size_to_theme(size)); assemblage_cleanup_ptr(token.client_holder_m.assemblage_m, widget); // // Call display_insertion to embed the new widget within the view heirarchy // platform_display_type display_token(insert(get_main_display(), parent.display_token_m, *widget)); eve_t::iterator eve_token; eve_token = attach_placeable<poly_placeable_t>(parent.eve_token_m, *widget, parameters, token, is_container, layout_attributes); attach_view_and_controller(*widget, parameters, token); // // Return the widget_node_t that comprises the tokens created for this widget by the various components // return widget_node_t(size, eve_token, display_token, parent.keyboard_token_m); }
widget_node_t make_optional_panel(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory) { size_enum_t size(parameters.count(key_size) ? implementation::enumerate_size(get_value(parameters, key_size).cast<name_t>()) : parent.size_m); optional_panel_t* widget(NULL); create_widget(parameters, size, widget); token.client_holder_m.assemblage_m.cleanup(boost::bind(delete_ptr<optional_panel_t*>(), widget)); // // Call display_insertion to embed the new widget within the view heirarchy // platform_display_type display_token(insert(get_main_display(), parent.display_token_m, *widget)); // // As per SF.net bug 1428833, we want to attach the poly_placeable_t // to Eve before we attach the controller and view to the model // eve_t::iterator eve_token; eve_token = attach_placeable<poly_placeable_t>(parent.eve_token_m, *widget, parameters, token, factory.is_container(static_name_t("optional")), factory.layout_attributes(static_name_t("optional"))); widget->set_optional_display_procs(boost::bind(&optional_display_show, boost::ref(token.client_holder_m.visible_change_queue_m), boost::ref(token.client_holder_m.eve_m), eve_token, _1), boost::bind(&optional_display_hide, boost::ref(token.client_holder_m.visible_change_queue_m), boost::ref(token.client_holder_m.eve_m), eve_token, _1)); attach_view_and_controller(*widget, parameters, token); // // Return the widget_node_t that comprises the tokens created for this widget by the various components // return widget_node_t(size, eve_token, display_token, parent.keyboard_token_m); }
widget_node_t make_edit_number(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory) { bool is_container(factory.is_container(static_name_t("edit_number"))); const layout_attributes_t& layout_attributes( factory.layout_attributes(static_name_t("edit_number"))); size_enum_t size(parameters.count(key_size) ? implementation::enumerate_size(get_value(parameters, key_size).cast<name_t>()) : parent.size_m); edit_number_t* widget(NULL); create_widget(parameters, size, widget); assemblage_cleanup_ptr(token.client_holder_m.assemblage_m, widget); // // Call display_insertion to embed the new widget within the view heirarchy // platform_display_type display_token(insert(get_main_display(), parent.display_token_m, *widget)); // // As per SF.net bug 1428833, we want to attach the poly_placeable_t // to Eve before we attach the controller and view to the model // eve_t::iterator eve_token; eve_token = attach_placeable<poly_placeable_t>(parent.eve_token_m, *widget, parameters, token, is_container, layout_attributes); attach_edit_num_view_and_controller(*widget, parameters, token); keyboard_t::iterator keyboard_token = keyboard_t::get().insert(parent.keyboard_token_m, poly_key_handler_t(boost::ref(*widget))); // // Return the widget_node_t that comprises the tokens created for this widget by the various components // return widget_node_t(size, eve_token, display_token, keyboard_token); }
std::unique_ptr<eve_client_holder> make_view(name_t file_path, const line_position_t::getline_proc_t& getline_proc, std::istream& stream, sheet_t& sheet, behavior_t& root_behavior, const button_notifier_t& notifier, size_enum_t dialog_size, const widget_factory_proc_t& proc, platform_display_type display_root) { std::unique_ptr<eve_client_holder> result{new eve_client_holder(root_behavior)}; factory_token_t token{sheet, *(result.get()), notifier}; vm_lookup_t lookup; lookup.attach_to(result->layout_sheet_m.machine_m); /* We set the initial parent to be the root of the main display, an empty eve iterator and the given dialog size. */ get_main_display().set_root(display_root); result->layout_sheet_m.machine_m.set_variable_lookup(boost::bind(&adobe::layout_variables, boost::ref(result->layout_sheet_m), _1)); parse(stream, line_position_t(file_path, getline_proc), widget_node_t(dialog_size, eve_t::iterator(), get_main_display().root(), keyboard_t::iterator()), bind_layout(boost::bind(&client_assembler, boost::ref(token), _1, _2, _3, boost::cref(proc)), result->layout_sheet_m, result->layout_sheet_m.machine_m)); result->contributing_m = sheet.contributing(); return result; }
widget_node_t make_button(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory) { size_enum_t size(parameters.count(key_size) ? implementation::enumerate_size(get_value(parameters, key_size).cast<name_t>()) : parent.size_m); button_t* widget = implementation::create_button_widget(parameters, token, size); token.client_holder_m.assemblage_m.cleanup(boost::bind(delete_ptr(),widget)); // // Call display_insertion to embed the new widget within the view heirarchy // platform_display_type display_token(insert(get_main_display(), parent.display_token_m, *widget)); // set up key handler code. We do this all the time because we want the button to be updated // when modifier keys are pressed during execution of the dialog. keyboard_t::iterator keyboard_token(keyboard_t::get().insert(parent.keyboard_token_m, poly_key_handler_t(boost::ref(*widget)))); // // As per SF.net bug 1428833, we want to attach the poly_placeable_t // to Eve before we attach the controller and view to the model // eve_t::iterator eve_token; eve_token = attach_placeable<poly_placeable_t>(parent.eve_token_m, *widget, parameters, token, factory.is_container("button"_name), factory.layout_attributes("button"_name)); // // Return the widget_node_t that comprises the tokens created for this widget by the various components // return widget_node_t(size, eve_token, display_token, keyboard_token); }