/* Removes the child from the box */ static void _etk_box_child_remove(Etk_Container *container, Etk_Widget *widget) { Etk_Box *box; Etk_Box_Cell *cell; if (!(box = ETK_BOX(container)) || !widget) return; if ((cell = _etk_box_cell_get(widget))) { if (cell->prev) cell->prev->next = cell->next; if (cell->next) cell->next->prev = cell->prev; if (cell == box->first_cell[cell->group]) box->first_cell[cell->group] = cell->next; if (cell == box->last_cell[cell->group]) box->last_cell[cell->group] = cell->prev; box->cells_count[cell->group]--; ETK_WIDGET(box)->focus_order = eina_list_remove_list(ETK_WIDGET(box)->focus_order, cell->focus_node); etk_object_data_set(ETK_OBJECT(widget), "_Etk_Box::Cell", NULL); free(cell); etk_widget_size_recalc_queue(ETK_WIDGET(box)); etk_signal_emit(ETK_CONTAINER_CHILD_REMOVED_SIGNAL, ETK_OBJECT(box), widget); } }
/** * @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)); }
/** * @brief Sets the submenu of the menu-item: the submenu will be popped up when the menu-item is selected * @param menu_item a menu-item * @param submenu the submenu to attach to the menu-item */ void etk_menu_item_submenu_set(Etk_Menu_Item *menu_item, Etk_Menu *submenu) { if (!menu_item || menu_item->submenu == submenu) return; if (menu_item->submenu) { menu_item->submenu->parent_item = NULL; etk_object_notify(ETK_OBJECT(menu_item->submenu), "parent-item"); } menu_item->submenu = submenu; if (menu_item->submenu) { menu_item->submenu->parent_item = menu_item; etk_object_notify(ETK_OBJECT(menu_item->submenu), "parent-item"); } if (menu_item->submenu) etk_widget_theme_signal_emit(ETK_WIDGET(menu_item), "etk,action,show,arrow", ETK_TRUE); else etk_widget_theme_signal_emit(ETK_WIDGET(menu_item), "etk,action,hide,arrow", ETK_TRUE); etk_widget_size_recalc_queue(ETK_WIDGET(menu_item)); etk_object_notify(ETK_OBJECT(menu_item), "submenu"); }
/** * @brief Sets whether or not all the cells of the box should have the same size * @param box a box * @param homogeneous if @a homogeneous is ETK_TRUE, all the cells will have the same size */ void etk_box_homogeneous_set(Etk_Box *box, Etk_Bool homogeneous) { if (!box) return; box->homogeneous = homogeneous; etk_widget_size_recalc_queue(ETK_WIDGET(box)); etk_object_notify(ETK_OBJECT(box), "homogeneous"); }
/** * @brief Sets the amount of free space between two cells * @param box a box * @param spacing the new amount of free space between two cells, in pixels */ void etk_box_spacing_set(Etk_Box *box, int spacing) { if (!box) return; box->spacing = spacing; etk_widget_size_recalc_queue(ETK_WIDGET(box)); etk_object_notify(ETK_OBJECT(box), "spacing"); }
/** * @brief Changes the homogenous property of the table * @param table a table * @param homogeneous a flag describing whether the table should be homogenous horizontally, vertically, * in both directions or not at all */ void etk_table_homogeneous_set(Etk_Table *table, Etk_Table_Homogeneous homogeneous) { if (!table) return; table->homogeneous = homogeneous; etk_widget_size_recalc_queue(ETK_WIDGET(table)); etk_object_notify(ETK_OBJECT(table), "homogeneous"); }
/** * @brief Changes the packing settings of a child of the box * @param box a box * @param child a child of the box. If @a child is not packed in the box, this function has no effect * @param fill_policy the new fill-policy of the child * @param padding the new amount of free space on the two sides of the child, in pixels */ void etk_box_child_packing_set(Etk_Box *box, Etk_Widget *child, Etk_Box_Fill_Policy fill_policy, int padding) { Etk_Box_Cell *cell; if (!box || !child) return; if ((cell = _etk_box_cell_get(child))) { cell->fill_policy = fill_policy; cell->padding = padding; etk_widget_size_recalc_queue(ETK_WIDGET(box)); } }
/** * @brief Resizes the table. The children that are attached to a row or a column that is removed will be unparented * @param table a table * @param num_rows the new number of rows * @param num_cols the new number of cols */ void etk_table_resize(Etk_Table *table, int num_cols, int num_rows) { Eina_List *l, *next; Etk_Table_Cell **new_cells; Etk_Table_Cell *cell; Etk_Table_Col_Row *new_cols, *new_rows; Etk_Widget *child; int i, j; if (!table) return; if (num_cols < 0) num_cols = 0; if (num_rows < 0) num_rows = 0; if (num_cols == 0 && num_rows == 0) { new_cells = NULL; new_cols = NULL; new_rows = NULL; } else { new_cells = calloc(num_cols * num_rows, sizeof(Etk_Table_Cell *)); new_cols = malloc(num_cols * sizeof(Etk_Table_Col_Row)); new_rows = malloc(num_rows * sizeof(Etk_Table_Col_Row)); } for (l = table->cells_list; l; l = next) { next = l->next; cell = l->data; child = cell->child; /* The child is in the old table but not in the new one: we remove it */ if (cell->left_attach >= num_cols || cell->top_attach >= num_rows) etk_table_cell_clear(table, cell->left_attach, cell->top_attach); /* The child is in the new table: we copy it to the new table */ else { cell->right_attach = ETK_MIN(num_cols - 1, cell->right_attach); cell->bottom_attach = ETK_MIN(num_rows - 1, cell->bottom_attach); for (i = cell->left_attach; i <= cell->right_attach; i++) { for (j = cell->top_attach; j <= cell->bottom_attach; j++) new_cells[j * num_cols + i] = cell; } } } free(table->cells); free(table->cols); free(table->rows); table->cells = new_cells; table->cols = new_cols; table->rows = new_rows; table->num_cols = num_cols; table->num_rows = num_rows; etk_widget_size_recalc_queue(ETK_WIDGET(table)); etk_object_notify(ETK_OBJECT(table), "num-cols"); etk_object_notify(ETK_OBJECT(table), "num-rows"); }