/** * @brief Sets the image of the menu-item. The image will be displayed on the left of the label * @param image_item an image menu-item * @param image the image to set (NULL to remove the image) */ void etk_menu_item_image_set(Etk_Menu_Item_Image *image_item, Etk_Image *image) { Etk_Menu_Item *menu_item; Etk_Widget *image_widget; if (!(menu_item = ETK_MENU_ITEM(image_item))) return; if (menu_item->left_widget) { etk_widget_parent_set(menu_item->left_widget, NULL); menu_item->left_widget = NULL; } if ((image_widget = ETK_WIDGET(image))) { menu_item->left_widget = image_widget; etk_widget_parent_set(menu_item->left_widget, ETK_WIDGET(menu_item)); etk_widget_pass_mouse_events_set(menu_item->left_widget, ETK_TRUE); etk_widget_swallow_widget(ETK_WIDGET(menu_item), "etk.swallow.left_widget", image_widget); etk_widget_theme_signal_emit(ETK_WIDGET(menu_item), "etk,action,show,left_widget", ETK_TRUE); } else etk_widget_theme_signal_emit(ETK_WIDGET(menu_item), "etk,action,hide,left_widget", ETK_TRUE); etk_widget_size_recalc_queue(ETK_WIDGET(menu_item)); }
/* Menu_Item_Ckeck: Initializes the check menu item */ static void _etk_menu_item_check_constructor(Etk_Menu_Item_Check *check_item) { Etk_Menu_Item *menu_item; if (!(menu_item = ETK_MENU_ITEM(check_item))) return; check_item->active = ETK_FALSE; check_item->toggled_handler = _etk_menu_item_check_toggled_handler; check_item->active_set = _etk_menu_item_check_active_set; menu_item->left_widget = etk_widget_new(ETK_WIDGET_TYPE, "theme-group", ETK_IS_MENU_ITEM_RADIO(check_item) ? "radiobox" : "checkbox", "theme-parent", check_item, "pass-mouse-events", ETK_TRUE, "visible", ETK_TRUE, NULL); etk_widget_parent_set(menu_item->left_widget, ETK_WIDGET(menu_item)); etk_widget_swallow_widget(ETK_WIDGET(menu_item), "etk.swallow.left_widget", menu_item->left_widget); etk_widget_theme_signal_emit(ETK_WIDGET(menu_item), "etk,action,show,left_widget", ETK_TRUE); if (check_item->active) etk_widget_theme_signal_emit(menu_item->left_widget, "etk,state,on", ETK_FALSE); else etk_widget_theme_signal_emit(menu_item->left_widget, "etk,state,off", ETK_FALSE); etk_signal_connect_by_code(ETK_WIDGET_REALIZED_SIGNAL, ETK_OBJECT(menu_item->left_widget), ETK_CALLBACK(_etk_menu_item_check_box_realized_cb), menu_item); etk_signal_connect_by_code(ETK_MENU_ITEM_ACTIVATED_SIGNAL, ETK_OBJECT(menu_item), ETK_CALLBACK(_etk_menu_item_check_activated_cb), menu_item); }
/** * @brief Changes the position of a child of the box * @param box a box * @param child the child you want to change the position of * @param group the group in which the child will be repacked * @param pos the position where to repack @a child (starting from 0). If @a pos <= 0, @a child will be packed at the * start of the child-group, and if @a pos is greater than the number of children in the group, it will be packed * at the end */ void etk_box_child_position_set(Etk_Box *box, Etk_Widget *child, Etk_Box_Group group, int pos) { Etk_Box_Cell *cell; Etk_Box_Fill_Policy fill_policy; int padding; if (!box || !child || !(cell = _etk_box_cell_get(child))) return; padding = cell->padding; fill_policy = cell->fill_policy; etk_widget_parent_set(child, NULL); etk_box_insert_at(box, child, group, pos, fill_policy, padding); }
/* Initialized the cairo widget */ static void _etk_cairo_constructor(Etk_Cairo *cairo) { Etk_Widget *widget; if (!(widget = ETK_WIDGET(cairo))) return; cairo->cairo.cr = NULL; cairo->cairo.surface = NULL; cairo->min_size.w = 0; cairo->min_size.h = 0; cairo->image = etk_image_new(); etk_widget_internal_set(cairo->image, ETK_TRUE); etk_widget_parent_set(cairo->image, widget); etk_widget_show(cairo->image); widget->size_allocate = _etk_cairo_size_allocate; cairo->redraw_required_handler = _etk_cairo_redraw_required_handler; etk_signal_connect("size-requested", ETK_OBJECT(cairo), ETK_CALLBACK(_etk_cairo_size_requested_cb), NULL); }
/** * @brief Attachs a widget to the table * @param table a table * @param child the widget to attach * @param left_attach the column where the left side of the child will be attached (starting from 0) * @param right_attach the column where the right side of the child will be attached (starting from 0) * @param top_attach the row where the top side of the child will be attached (starting from 0) * @param bottom_attach the row where the bottom side of the child will be attached (starting from 0) * @param fill_policy The fill policy of the child * @param x_padding the amount of free space on the left and on the right sides of the child widget * @param y_padding the amount of free space on the top and on the bottom sides of the child widget */ void etk_table_attach(Etk_Table *table, Etk_Widget *child, int left_attach, int right_attach, int top_attach, int bottom_attach, Etk_Table_Fill_Policy fill_policy, int x_padding, int y_padding) { Etk_Table_Cell *cell; int i, j; if (!table || !table->cells || !child) return; left_attach = ETK_CLAMP(left_attach, 0, table->num_cols - 1); right_attach = ETK_CLAMP(right_attach, left_attach, table->num_cols - 1); top_attach = ETK_CLAMP(top_attach, 0, table->num_rows - 1); bottom_attach = ETK_CLAMP(bottom_attach, top_attach, table->num_rows - 1); cell = malloc(sizeof(Etk_Table_Cell)); cell->left_attach = left_attach; cell->right_attach = right_attach; cell->top_attach = top_attach; cell->bottom_attach = bottom_attach; cell->x_padding = x_padding; cell->y_padding = y_padding; cell->fill_policy = fill_policy; cell->child = child; for (i = left_attach; i <= right_attach; i++) { for (j = top_attach; j <= bottom_attach; j++) { etk_table_cell_clear(table, i, j); table->cells[CELL_INDEX(table, i, j)] = cell; } } table->cells_list = eina_list_append(table->cells_list, cell); cell->node = eina_list_last(table->cells_list); etk_object_data_set(ETK_OBJECT(child), "_Etk_Table::Cell", cell); etk_widget_parent_set(child, ETK_WIDGET(table)); etk_signal_emit(ETK_CONTAINER_CHILD_ADDED_SIGNAL, ETK_OBJECT(table), child); }
/** * @brief Sets the toolbar's orientation (horizontal or vertical) * @param toolbar a toolbar * @param orientation the orientation to set */ void etk_toolbar_orientation_set(Etk_Toolbar *toolbar, Etk_Toolbar_Orientation orientation) { Eina_List *children, *l; Etk_Widget *prev_box; if (!toolbar || toolbar->orientation == orientation) return; toolbar->reorientating = ETK_TRUE; prev_box = toolbar->box; toolbar->orientation = orientation; if (toolbar->orientation == ETK_TOOLBAR_VERT) toolbar->box = etk_vbox_new(ETK_FALSE, 0); else toolbar->box = etk_hbox_new(ETK_FALSE, 0); etk_widget_internal_set(toolbar->box, ETK_TRUE); etk_widget_show(toolbar->box); etk_signal_connect_by_code(ETK_CONTAINER_CHILD_ADDED_SIGNAL, ETK_OBJECT(toolbar->box), ETK_CALLBACK(_etk_toolbar_child_added_cb), toolbar); etk_signal_connect_by_code(ETK_CONTAINER_CHILD_REMOVED_SIGNAL, ETK_OBJECT(toolbar->box), ETK_CALLBACK(_etk_toolbar_child_removed_cb), NULL); children = etk_container_children_get(ETK_CONTAINER(prev_box)); for (l = children; l; l = l->next) etk_toolbar_append(toolbar, ETK_WIDGET(l->data), ETK_BOX_START); eina_list_free(children); etk_object_destroy(ETK_OBJECT(prev_box)); if (toolbar->orientation == ETK_TOOLBAR_VERT) etk_widget_theme_group_set(ETK_WIDGET(toolbar), "vtoolbar"); else etk_widget_theme_group_set(ETK_WIDGET(toolbar), "htoolbar"); etk_widget_parent_set(toolbar->box, ETK_WIDGET(toolbar)); toolbar->reorientating = ETK_FALSE; etk_object_notify(ETK_OBJECT(toolbar), "orientation"); }
/** * @brief Clears the cell ( @a col, @a row ): it removes from the table the widget that is in this cell * @param table a table * @param col the column in which the widget to remove is (starting from 0) * @param row the row in which the widget to remove is (starting from 0) */ void etk_table_cell_clear(Etk_Table *table, int col, int row) { Etk_Table_Cell *cell; Etk_Widget *child; int i, j; if (!table || !table->cells || col < 0 || col > table->num_cols - 1 || row < 0 || row > table->num_rows - 1) return; if (!(cell = table->cells[CELL_INDEX(table, col, row)]) || !(child = cell->child)) return; for (i = cell->left_attach; i <= cell->right_attach; i++) { for (j = cell->top_attach; j <= cell->bottom_attach; j++) table->cells[CELL_INDEX(table, i, j)] = NULL; } table->cells_list = eina_list_remove_list(table->cells_list, cell->node); free(cell); etk_object_data_set(ETK_OBJECT(child), "_Etk_Table::Cell", NULL); etk_widget_parent_set(child, NULL); etk_signal_emit(ETK_CONTAINER_CHILD_REMOVED_SIGNAL, ETK_OBJECT(table), child); }
/* Initializes the members and build the toolbar */ static void _etk_toolbar_constructor(Etk_Toolbar *toolbar) { if (!toolbar) return; toolbar->style = ETK_TOOLBAR_BOTH_VERT; toolbar->orientation = ETK_TOOLBAR_HORIZ; toolbar->stock_size = ETK_STOCK_MEDIUM; toolbar->reorientating = ETK_FALSE; ETK_WIDGET(toolbar)->size_request = _etk_toolbar_size_request; ETK_WIDGET(toolbar)->size_allocate = _etk_toolbar_size_allocate; ETK_CONTAINER(toolbar)->child_add = _etk_toolbar_child_add; ETK_CONTAINER(toolbar)->child_remove = _etk_toolbar_child_remove; ETK_CONTAINER(toolbar)->children_get = _etk_toolbar_children_get; toolbar->box = etk_hbox_new(ETK_FALSE, 0); etk_widget_parent_set(toolbar->box, ETK_WIDGET(toolbar)); etk_widget_internal_set(ETK_WIDGET(toolbar->box), ETK_TRUE); etk_widget_show(toolbar->box); etk_signal_connect_by_code(ETK_CONTAINER_CHILD_ADDED_SIGNAL, ETK_OBJECT(toolbar->box), ETK_CALLBACK(_etk_toolbar_child_added_cb), toolbar); etk_signal_connect_by_code(ETK_CONTAINER_CHILD_REMOVED_SIGNAL, ETK_OBJECT(toolbar->box), ETK_CALLBACK(_etk_toolbar_child_removed_cb), NULL); }
/* Adds a new widget to the box, after the cell "after" */ static void _etk_box_insert_after_cell(Etk_Box *box, Etk_Widget *child, Etk_Box_Group group, Etk_Box_Cell *after, Etk_Box_Fill_Policy fill_policy, int padding) { Etk_Box_Cell *cell; Etk_Widget *box_widget; if (!(box_widget = ETK_WIDGET(box)) || !child) return; if (after && after->group != group) { ETK_WARNING("The child to pack and the widget after which the child should be packed " "do not belong to the same child-group"); return; } cell = malloc(sizeof(Etk_Box_Cell)); cell->prev = NULL; cell->next = NULL; cell->child = child; cell->focus_node = NULL; cell->group = group; cell->fill_policy = fill_policy; cell->padding = padding; if (after) { cell->prev = after; cell->next = after->next; if (after->next) after->next->prev = cell; else box->last_cell[group] = cell; after->next = cell; box_widget->focus_order = eina_list_append_relative_list(box_widget->focus_order, child, after->focus_node); cell->focus_node = eina_list_next(after->focus_node); } else { cell->next = box->first_cell[group]; if (box->first_cell[group]) box->first_cell[group]->prev = cell; else box->last_cell[group] = cell; box->first_cell[group] = cell; if (group == ETK_BOX_START || !box->last_cell[ETK_BOX_START]) { box_widget->focus_order = eina_list_prepend(box_widget->focus_order, child); cell->focus_node = box_widget->focus_order; } else { box_widget->focus_order = eina_list_append_relative_list(box_widget->focus_order, child, box->last_cell[ETK_BOX_START]->focus_node); cell->focus_node = eina_list_next(box->last_cell[ETK_BOX_START]->focus_node); } } box->cells_count[group]++; etk_widget_parent_set(child, ETK_WIDGET(box)); etk_object_data_set(ETK_OBJECT(child), "_Etk_Box::Cell", cell); etk_signal_emit(ETK_CONTAINER_CHILD_ADDED_SIGNAL, ETK_OBJECT(box), child); }