/* This function is called when the radio-button is turned on: it deactivates all * the other radio-buttons of the group, and activate the given radio-button */ static void _etk_radio_button_active_set(Etk_Toggle_Button *toggle_button, Etk_Bool active) { Etk_Radio_Button *radio_button; Etk_Toggle_Button *tb; Eina_List *l; if (!(radio_button = ETK_RADIO_BUTTON(toggle_button)) || toggle_button->active == active) return; if (!toggle_button->active || (toggle_button->active && radio_button->can_uncheck)) { toggle_button->active = active; etk_signal_emit(ETK_TOGGLE_BUTTON_TOGGLED_SIGNAL, ETK_OBJECT(toggle_button)); etk_object_notify(ETK_OBJECT(toggle_button), "active"); if (toggle_button->active) { /* Deactivate the current active button of the group */ for (l = *radio_button->group; l; l = l->next) { tb = ETK_TOGGLE_BUTTON(l->data); if (tb != toggle_button && tb->active) { ETK_RADIO_BUTTON(tb)->can_uncheck = ETK_TRUE; etk_toggle_button_active_set(tb, ETK_FALSE); } } } radio_button->can_uncheck = ETK_FALSE; } }
/* 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); } }
static Etk_Bool _etk_cairo_size_requested_cb(Etk_Object *object, Etk_Size *size, void *data) { Etk_Cairo *cairo; unsigned char *pixels = NULL; int static old_w = -1, old_h = -1; int w, h; if (!(cairo = ETK_CAIRO(object))) return ETK_TRUE; etk_widget_geometry_get(ETK_WIDGET(cairo), NULL, NULL, &w, &h); if (old_w == w && old_h == h) return ETK_TRUE; old_w = w; old_h = h; _etk_cairo_rebuild(cairo); cairo_rectangle(cairo->cairo.cr, 0, 0, w, h); etk_signal_emit(ETK_CAIRO_REDRAW_REQUIRED_SIGNAL, object, NULL); pixels = cairo_image_surface_get_data(cairo->cairo.surface); if (pixels) etk_image_set_from_data(ETK_IMAGE(cairo->image), w, h, pixels, ETK_FALSE); return ETK_TRUE; }
/* Behavior of the "active_set" function for a radio menu item */ static void _etk_menu_item_radio_active_set(Etk_Menu_Item_Check *check_item, Etk_Bool active) { Etk_Menu_Item_Radio *radio_item; Etk_Menu_Item_Check *ci; Eina_List *l; if (!(radio_item = ETK_MENU_ITEM_RADIO(check_item)) || check_item->active == active) return; if (!check_item->active || (check_item->active && radio_item->can_uncheck)) { check_item->active = active; etk_signal_emit(ETK_MENU_ITEM_CHECK_TOGGLED_SIGNAL, ETK_OBJECT(check_item)); etk_object_notify(ETK_OBJECT(check_item), "active"); if (check_item->active) { /* Uncheck the previously checked item of the group */ for (l = *radio_item->group; l; l = l->next) { ci = ETK_MENU_ITEM_CHECK(l->data); if (ci != check_item && ci->active) { ETK_MENU_ITEM_RADIO(ci)->can_uncheck = ETK_TRUE; etk_menu_item_check_active_set(ci, ETK_FALSE); } } } radio_item->can_uncheck = ETK_FALSE; } }
/** * @brief Unselects the menu-item * @param menu_item a menu-item */ void etk_menu_item_unselect(Etk_Menu_Item *menu_item) { if (!menu_item || !menu_item->is_selected) return; menu_item->is_selected = ETK_FALSE; etk_signal_emit(ETK_MENU_ITEM_UNSELECTED_SIGNAL, ETK_OBJECT(menu_item)); }
/* Behavior of the "active_set" function for a check menu item */ static void _etk_menu_item_check_active_set(Etk_Menu_Item_Check *check_item, Etk_Bool active) { if (!check_item || check_item->active == active) return; check_item->active = active; etk_signal_emit(ETK_MENU_ITEM_CHECK_TOGGLED_SIGNAL, ETK_OBJECT(check_item)); etk_object_notify(ETK_OBJECT(check_item), "active"); }
/* Called when a button of the action-area of the dialog is clicked */ static Etk_Bool _etk_dialog_button_clicked_cb(Etk_Object *object, void *data) { int response_id; if ((response_id = etk_dialog_button_response_id_get(ETK_BUTTON(object))) == ETK_RESPONSE_NONE) return ETK_TRUE; etk_signal_emit(ETK_DIALOG_RESPONSE_SIGNAL, ETK_OBJECT(data), response_id); return ETK_TRUE; }
/* Called when a widget is removed from the toolbar's box */ static Etk_Bool _etk_toolbar_child_removed_cb(Etk_Object *object, Etk_Widget *child, void *data) { Etk_Toolbar *toolbar; if (!(toolbar = ETK_TOOLBAR(data)) || !child) return ETK_TRUE; if (etk_widget_theme_parent_get(child) == ETK_WIDGET(toolbar)) etk_widget_theme_parent_set(child, NULL); etk_signal_emit(ETK_CONTAINER_CHILD_REMOVED_SIGNAL, ETK_OBJECT(toolbar), child); return ETK_TRUE; }
/** * @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 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); }
/* 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); }
/** * @brief Activates the menu-item * @param menu_item a menu-item */ void etk_menu_item_activate(Etk_Menu_Item *menu_item) { if (!menu_item) return; etk_signal_emit(ETK_MENU_ITEM_ACTIVATED_SIGNAL, ETK_OBJECT(menu_item)); }