Example #1
0
void attach_view_and_controller(popup_t&               control,
                                const dictionary_t&    parameters,
                                const factory_token_t& token,
                                adobe::name_t,
                                adobe::name_t,
                                adobe::name_t)
{
    sheet_t&      layout_sheet(token.client_holder_m.layout_sheet_m);
    assemblage_t& assemblage(token.client_holder_m.assemblage_m);

    if (parameters.count(key_bind) != 0)
    {
        name_t cell(get_value(parameters, key_bind).cast<name_t>());

        attach_view_and_controller_direct(control, parameters, token, cell);
    }

    if (parameters.count(key_items) && 
            get_value(parameters, key_items).type_info() == typeid(name_t))
    {
        // dynamically bind to the cell instead of getting a static list of popup items

        name_t cell(get_value(parameters, key_items).cast<name_t>());

        if (layout_sheet.count_interface(cell))
            attach_popup_menu_item_set(control, cell, layout_sheet, assemblage, token.client_holder_m);
        else
            attach_popup_menu_item_set(control, cell, token.sheet_m, assemblage, token.client_holder_m);
    }
}
void attach_view_and_controller(slider_t&              control,
                                const dictionary_t&    parameters,
                                const factory_token_t& token,
                                adobe::name_t,
                                adobe::name_t,
                                adobe::name_t)
{
    sheet_t& layout_sheet(token.client_holder_m.layout_sheet_m);

    if (parameters.count(key_bind) != 0)
    {
        name_t cell(get_value(parameters, key_bind).cast<name_t>());
    
        attach_view_direct(control, parameters, token, cell);

        // is the cell in the layout sheet or the Adam sheet?
        if (layout_sheet.count_interface(cell) != 0)
            couple_controller_to_cell(control, cell, layout_sheet, token, parameters);
        else
            couple_controller_to_cell(control, cell, token.sheet_m, token, parameters);
    }
}
Example #3
0
    void attach_view_and_controller(listbox_t&             control,
                                    const dictionary_t&    parameters,
                                    const factory_token_t& token,
                                    adobe::name_t,
                                    adobe::name_t,
                                    adobe::name_t)
    {
        basic_sheet_t& layout_sheet(token.client_holder_m.layout_sheet_m);
        assemblage_t&  assemblage(token.client_holder_m.assemblage_m);

        if (parameters.count(key_bind) != 0) {
            name_t cell(get_value(parameters, key_bind).cast<name_t>());
            attach_view_and_controller_direct(control, parameters, token, cell);
        }

        control.row_factory_m = token.row_factory_m;

        if (parameters.count(key_items) &&
            get_value(parameters, key_items).type_info() == type_info<name_t>()) {
            name_t cell(get_value(parameters, key_items).cast<name_t>());
            listbox_t::item_set_view_controller_t& tmp = control.item_set_view_controller_m;
            if (layout_sheet.count_interface(cell)) {
                attach_view(assemblage, cell, tmp, layout_sheet);
                attach_controller_direct(tmp, parameters, token, cell);
            } else {
                attach_view(assemblage, cell, tmp, token.sheet_m);
                attach_controller_direct(tmp, parameters, token, cell);
            }
        }

        {
            any_regular_t selection_changed_binding;
            name_t cell;
            array_t expression;
            if (get_value(parameters, static_name_t("bind_selection_changed_signal"), selection_changed_binding))
                implementation::cell_and_expression(selection_changed_binding, cell, expression);
            control.selection_changed_proc_m =
                boost::bind(&handle_selection_changed_signal,
                            _1,
                            token.signal_notifier_m,
                            static_name_t("selection_changed"),
                            control.signal_id_m,
                            boost::ref(token.sheet_m),
                            cell,
                            expression,
                            _2);
        }

        {
            any_regular_t dropped_binding;
            name_t cell;
            array_t expression;
            if (get_value(parameters, static_name_t("bind_dropped_signal"), dropped_binding))
                implementation::cell_and_expression(dropped_binding, cell, expression);
            control.dropped_proc_m =
                boost::bind(&handle_row_signal,
                            _1,
                            token.signal_notifier_m,
                            static_name_t("dropped"),
                            control.signal_id_m,
                            boost::ref(token.sheet_m),
                            cell,
                            expression,
                            _2);
        }

        {
            any_regular_t drop_acceptable_binding;
            name_t cell;
            array_t expression;
            if (get_value(parameters, static_name_t("bind_drop_acceptable_signal"), drop_acceptable_binding))
                implementation::cell_and_expression(drop_acceptable_binding, cell, expression);
            control.drop_acceptable_proc_m =
                boost::bind(&handle_drop_acceptable_signal,
                            _1,
                            token.signal_notifier_m,
                            static_name_t("drop_acceptable"),
                            control.signal_id_m,
                            boost::ref(token.sheet_m),
                            cell,
                            expression,
                            _2,
                            _3);
        }

        {
            any_regular_t left_clicked_binding;
            name_t cell;
            array_t expression;
            if (get_value(parameters, static_name_t("bind_left_clicked_signal"), left_clicked_binding))
                implementation::cell_and_expression(left_clicked_binding, cell, expression);
            control.left_clicked_proc_m =
                boost::bind(&handle_row_click_signal,
                            _1,
                            token.signal_notifier_m,
                            static_name_t("left_clicked"),
                            control.signal_id_m,
                            boost::ref(token.sheet_m),
                            cell,
                            expression,
                            _2,
                            _3);
        }

        {
            any_regular_t right_clicked_binding;
            name_t cell;
            array_t expression;
            if (get_value(parameters, static_name_t("bind_right_clicked_signal"), right_clicked_binding))
                implementation::cell_and_expression(right_clicked_binding, cell, expression);
            control.right_clicked_proc_m =
                boost::bind(&handle_row_click_signal,
                            _1,
                            token.signal_notifier_m,
                            static_name_t("right_clicked"),
                            control.signal_id_m,
                            boost::ref(token.sheet_m),
                            cell,
                            expression,
                            _2,
                            _3);
        }

        {
            any_regular_t double_clicked_binding;
            name_t cell;
            array_t expression;
            if (get_value(parameters, static_name_t("bind_double_clicked_signal"), double_clicked_binding))
                implementation::cell_and_expression(double_clicked_binding, cell, expression);
            control.double_clicked_proc_m =
                boost::bind(&handle_row_signal,
                            _1,
                            token.signal_notifier_m,
                            static_name_t("double_clicked"),
                            control.signal_id_m,
                            boost::ref(token.sheet_m),
                            cell,
                            expression,
                            _2);
        }

        {
            any_regular_t erased_binding;
            name_t cell;
            array_t expression;
            if (get_value(parameters, static_name_t("bind_erased_signal"), erased_binding))
                implementation::cell_and_expression(erased_binding, cell, expression);
            control.erased_proc_m =
                boost::bind(&handle_row_signal,
                            _1,
                            token.signal_notifier_m,
                            static_name_t("erased"),
                            control.signal_id_m,
                            boost::ref(token.sheet_m),
                            cell,
                            expression,
                            _2);
        }

        {
            any_regular_t browsed_binding;
            name_t cell;
            array_t expression;
            if (get_value(parameters, static_name_t("bind_browsed_signal"), browsed_binding))
                implementation::cell_and_expression(browsed_binding, cell, expression);
            control.browsed_proc_m =
                boost::bind(&handle_row_signal,
                            _1,
                            token.signal_notifier_m,
                            static_name_t("browsed"),
                            control.signal_id_m,
                            boost::ref(token.sheet_m),
                            cell,
                            expression,
                            _2);
        }

        adobe::attach_view(control.name_m.color_proxy_m, parameters, token, adobe::static_name_t("bind_label_color"));
#define BIND_COLOR(name)                                                \
        adobe::attach_view(control.name##_proxy_m, parameters, token, adobe::static_name_t("bind_" #name))
        BIND_COLOR(color);
        BIND_COLOR(interior_color);
        BIND_COLOR(hilite_color);
        BIND_COLOR(item_text_color);
#undef BIND_COLOR
    }