Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_grid.c ewl_grid.h ewl_table.c ewl_calendar.c Log Message: *API BREAK* make the api more consistent with the rest of ewl That means: - ewl_grid_new(int cols, int rows) -> ewl_grid_new() Therefor there is now a ewl_grid_dimension_set(Ewl_Grid *g, int cols, int rows) - add widgets with ewl_container_child_prepend/../append() instead of ewl_grid_add. you can set the position of a child with ewl_grid_child_position_set(); widgets without set position will float around the widgets with position =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- ewl_grid.c 26 May 2006 17:25:59 -0000 1.16 +++ ewl_grid.c 9 Jul 2006 23:01:32 -0000 1.17 @@ -1,18 +1,24 @@ -#include <Ewl.h> +#include "Ewl.h" #include "ewl_debug.h" #include "ewl_macros.h" #include "ewl_private.h" static void ewl_grid_resize(Ewl_Grid *g); +static void ewl_grid_map_recalc(Ewl_Grid *g); +static void ewl_grid_child_data_collect(Ewl_Grid *g); +static void ewl_grid_hmap_position_next(Ewl_Grid *g, int *c, int *r); +static void ewl_grid_vmap_position_next(Ewl_Grid *g, int *c, int *r); +static void ewl_grid_map_start_position_get(Ewl_Grid *g, int *c, int *r); /** * @param cols: number of columns * @param rows: number of rows - * @return Returns a pointer to a newly allocated grid on success, NULL on failure. + * @return Returns a pointer to a newly allocated grid on success, + * NULL on failure. * @brief Create a new Ewl_Grid widget */ Ewl_Widget * -ewl_grid_new(int cols, int rows) +ewl_grid_new() { Ewl_Grid *g; @@ -22,7 +28,7 @@ if (!g) DRETURN_PTR(NULL, DLEVEL_STABLE); - if (!ewl_grid_init(g, cols, rows)) { + if (!ewl_grid_init(g)) { ewl_widget_destroy(EWL_WIDGET(g)); g = NULL; } @@ -40,7 +46,7 @@ * @brief Initializes an Ewl_Grid widget to default values */ int -ewl_grid_init(Ewl_Grid *g, int cols, int rows) +ewl_grid_init(Ewl_Grid *g) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("g", g, FALSE); @@ -54,32 +60,23 @@ ewl_widget_appearance_set(EWL_WIDGET(g), EWL_GRID_TYPE); ewl_widget_inherit(EWL_WIDGET(g), EWL_GRID_TYPE); - ewl_container_show_notify_set(EWL_CONTAINER(g), ewl_grid_child_show_cb); - ewl_container_resize_notify_set(EWL_CONTAINER(g), ewl_grid_child_resize_cb); + ewl_container_add_notify_set(EWL_CONTAINER(g), ewl_grid_child_add_cb); + ewl_container_remove_notify_set(EWL_CONTAINER(g), + ewl_grid_child_remove_cb); + ewl_container_show_notify_set(EWL_CONTAINER(g), + ewl_grid_child_show_cb); + ewl_container_resize_notify_set(EWL_CONTAINER(g), + ewl_grid_child_resize_cb); /* - * Initialize the lists that keep track of the - * horisontal and vertical size of cols/rows + * the smallest size where a grid make sense */ - g->col_size = NEW(Ewl_Grid_Info, cols); - if (!g->col_size) - DRETURN_INT(FALSE, DLEVEL_STABLE); - - g->row_size = NEW(Ewl_Grid_Info, rows); - if (!g->row_size) { - FREE(g->col_size); - DRETURN_INT(FALSE, DLEVEL_STABLE); - } - - /* - * Store the cols/rows in the grid - */ - g->cols = cols; - g->rows = rows; - + ewl_grid_dimension_set(g, 2, 2); + g->homogeneous_h = FALSE; g->homogeneous_v = FALSE; + g->orientation = EWL_ORIENTATION_HORIZONTAL; /* * Append callbacks */ @@ -103,9 +100,10 @@ * @brief Clears the grid and sets new geometry */ void -ewl_grid_reset(Ewl_Grid *g, int cols, int rows) +ewl_grid_dimension_set(Ewl_Grid *g, int cols, int rows) { Ewl_Widget *w; + Ewl_Grid_Info *col_new, *row_new; int i; DENTER_FUNCTION(DLEVEL_STABLE); @@ -114,42 +112,47 @@ w = EWL_WIDGET(g); - ewl_container_reset(EWL_CONTAINER(w)); - - IF_FREE(g->col_size); - IF_FREE(g->row_size); - - g->col_size = NEW(Ewl_Grid_Info, cols); - if (!g->col_size) + if (cols == g->cols && rows == g->rows) DRETURN(DLEVEL_STABLE); + + IF_FREE(g->map); + g->map = NULL; + g->data_dirty = TRUE; + + if (cols != g->cols) { + col_new = NEW(Ewl_Grid_Info, cols); + if (!col_new) + DRETURN(DLEVEL_STABLE); + + if (g->col_size) { + int num; + + num = MIN(cols, g->cols); + for (i = 0; i < num; i++) + col_new[i] = g->col_size[i]; - g->row_size = NEW(Ewl_Grid_Info, rows); - if (!g->row_size) { - FREE(g->col_size); - DRETURN(DLEVEL_STABLE); + FREE(g->col_size); + } + g->col_size = col_new; + g->cols = cols; } - g->cols = cols; - g->rows = rows; - - /* store the total size of the grid widget */ - g->grid_w = CURRENT_W(EWL_OBJECT(w)); - g->grid_h = CURRENT_H(EWL_OBJECT(w)); - - /* initialize the column width to default values */ - for (i = 0; i < g->cols; i++) { - if (g->homogeneous_h) - g->col_size[i].size = CURRENT_W(g) / g->cols; - else - g->col_size[i].size = 1; - } + if (rows != g->rows) { + row_new = NEW(Ewl_Grid_Info, rows); + if (!row_new) + DRETURN(DLEVEL_STABLE); + + if (g->row_size) { + int num; + + num = MIN(rows, g->rows); + for (i = 0; i < num; i++) + row_new[i] = g->row_size[i]; - /* initialize the row height to default values */ - for (i = 0; i < g->rows; i++) { - if (g->homogeneous_v) - g->row_size[i].size = CURRENT_H(g) / g->rows; - else - g->row_size[i].size = 1; + FREE(g->row_size); + } + g->row_size = row_new; + g->rows = rows; } ewl_widget_configure(w); @@ -158,6 +161,44 @@ } /** + * @param g: the grid to change the fill orientation + * @param h: the Ewl_Orientation value + * @return Returns no value. + * @brief Change the fill orientation + */ +void +ewl_grid_orientation_set(Ewl_Grid *g, Ewl_Orientation orientation) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + if (g->orientation != orientation) { + g->orientation = orientation; + g->data_dirty = TRUE; + + ewl_widget_configure(EWL_WIDGET(g)); + } + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param g: the grid to get the fill orientation + * @return The fill orientation flag + * @brief Retrieves the fill orientation flag + */ +Ewl_Orientation +ewl_grid_orientation_get(Ewl_Grid *g) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("g", g, 0); + DCHECK_TYPE_RET("g", g, EWL_GRID_TYPE, 0); + + DRETURN_INT(g->orientation, DLEVEL_STABLE); +} + +/** * @param g: the grid to change homogeneous layout * @param h: the boolean value to change the layout mode to * @return Returns no value. @@ -198,9 +239,12 @@ DCHECK_PARAM_PTR("g", g); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - if (g->homogeneous_h != h) + if (g->homogeneous_h != h) { g->homogeneous_h = h; - + g->data_dirty = TRUE; + ewl_widget_configure(EWL_WIDGET(g)); + } + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -221,8 +265,11 @@ DCHECK_PARAM_PTR("g", g); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - if (g->homogeneous_v != h) + if (g->homogeneous_v != h) { g->homogeneous_v = h; + g->data_dirty = TRUE; + ewl_widget_configure(EWL_WIDGET(g)); + } DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -265,13 +312,14 @@ * @param start_row: the start row * @param end_row: the end row * @return Returns no value - * @brief Add a child widget to the grid + * @brief Give a child widget a fixed-postion in the grid */ void -ewl_grid_add(Ewl_Grid *g, Ewl_Widget *w, +ewl_grid_child_position_set(Ewl_Grid *g, Ewl_Widget *w, int start_col, int end_col, int start_row, int end_row) { Ewl_Grid_Child *child; + int new_cols, new_rows; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); @@ -279,27 +327,34 @@ DCHECK_TYPE("g", g, EWL_GRID_TYPE); DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); + IF_FREE(g->map); + g->map = NULL; + g->data_dirty = TRUE; + /* * check bounds */ if (start_col < 1) { - printf("start_col out of bounds. min is 1\n"); - DLEAVE_FUNCTION(DLEVEL_STABLE); - } - if (end_col > g->cols) { - printf("end_col out of bounds. max is %d\n", g->cols); + DWARNING("start_col out of bounds. min is 1\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } + if (end_col > g->cols) + new_cols = end_col; + else + new_cols = g->cols; + if (start_row < 1) { - printf("start_row out of bounds. min is 1\n"); - DLEAVE_FUNCTION(DLEVEL_STABLE); - } - if (end_row > g->rows) { - printf("end_row out of bounds. max is %d\n", g->rows); + DWARNING("start_row out of bounds. min is 1\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } + if (end_row > g->rows) + new_rows = end_row; + else + new_rows = g->rows; - /* create a new child */ + /* + * create a new child + */ child = NEW(Ewl_Grid_Child, 1); if (!child) DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -309,11 +364,23 @@ child->start_row = start_row; child->end_row = end_row; - /* store the child info in the child widget */ + g->space += (end_col - start_col + 1) * (end_row - start_row + 1) - 1; + + /* + * if there is to less space resize the grid + */ + if (g->space > new_cols * new_rows) { + if (g->orientation == EWL_ORIENTATION_HORIZONTAL) + new_rows = g->space / new_cols + 1; + else + new_cols = g->space / new_rows + 1; + } + + /* + * store the child info in the child widget + */ ewl_widget_data_set(w, (void *) g, child); - ewl_container_child_append(EWL_CONTAINER(g), w); - ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_DESTROY, - ewl_grid_child_destroy_cb, g); + ewl_grid_dimension_set(g, new_cols, new_rows); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -321,12 +388,13 @@ /** * @param g: the grid * @param col: the column + * @param relw: width relative to the grid width * @param width: the new width * @return Returns no value. * @brief Set the widget of a column */ void -ewl_grid_col_w_set(Ewl_Grid *g, int col, int width) +ewl_grid_col_w_set(Ewl_Grid *g, int col, float relw, int width) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); @@ -335,19 +403,18 @@ /* * check bounds */ - if (col < 1 || col > g->cols) { - printf("parameter 'col' is out of bounds\n"); + if (col < 1) { + DWARNING("parameter 'col' is out of bounds\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } + else if (col > g->cols) { + ewl_grid_dimension_set(g, col, g->rows); + } g->col_size[col - 1].override = 1; - ewl_object_size_request(EWL_OBJECT(g), - ewl_object_current_w_get(EWL_OBJECT(g)) + - (width - g->col_size[col - 1].size), - ewl_object_current_h_get(EWL_OBJECT(g))); - - g->col_size[col - 1].size = width - /* this will be reverted in resize */ - ((ewl_object_current_w_get(EWL_OBJECT(g)) - g->grid_w) / g->cols); + g->col_size[col - 1].size = width; + g->col_size[col - 1].rel_size = relw; + g->data_dirty = TRUE; ewl_widget_configure(EWL_WIDGET(g)); @@ -357,19 +424,29 @@ /** * @param g: the grid * @param col: the column + * @param relw: the width relative to the grid width * @param width: integer pointer to store the width in * @return Returns no value. - * @brief Get the width of a column + * @brief Get the user set width of a column + * + * This function returns only the size set by the user. */ void -ewl_grid_col_w_get(Ewl_Grid *g, int col, int *width) +ewl_grid_col_w_get(Ewl_Grid *g, int col, float *relw, int *width) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); DCHECK_PARAM_PTR("width", width); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - *width = g->col_size[col].size; + if (col > g->cols || col < 1) { + if (width) *width = 0; + if (relw) *relw = 0.0; + } + else { + if (width) *width = g->col_size[col-1].size; + if (relw) *relw = g->col_size[col-1].rel_size; + } DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -377,30 +454,29 @@ /** * @param g: the grid * @param row: the row + * @param relh: the height relative to the size of the grid * @param height: the new height * @return Returns no value. - * @brief Set the height of a row + * @brief Set the user set height of a row */ void -ewl_grid_row_h_set(Ewl_Grid *g, int row, int height) +ewl_grid_row_h_set(Ewl_Grid *g, int row, float relh, int height) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); DCHECK_TYPE("g", g, EWL_GRID_TYPE); /* check bounds */ - if ((row < 1) || (row > g->rows)) { + if (row < 1) { DLEAVE_FUNCTION(DLEVEL_STABLE); } + else if (row > g->rows) { + ewl_grid_dimension_set(g, g->cols, row); + } g->row_size[row - 1].override = 1; - ewl_object_size_request(EWL_OBJECT(g), - ewl_object_current_w_get(EWL_OBJECT(g)), - ewl_object_current_h_get(EWL_OBJECT(g)) + - (height - g->row_size[row - 1].size)); - - g->row_size[row - 1].size = height - /* this will be reverted in resize */ - ((ewl_object_current_h_get(EWL_OBJECT(g)) - g->grid_h) / g->rows); + g->row_size[row - 1].size = height; + g->row_size[row - 1].rel_size = relh; ewl_widget_configure(EWL_WIDGET(g)); @@ -410,19 +486,29 @@ /** * @param g: the grid * @param row: the row + * @param relh: the height relative to the size of the grid * @param height: integer pointer to store the height in * @return Returns no value. - * @brief Get the height of a row + * @brief Get the user set height of a row + * + * This function returns only the size set by the user. */ void -ewl_grid_row_h_get(Ewl_Grid *g, int row, int *height) +ewl_grid_row_h_get(Ewl_Grid *g, int row, float *relh, int *height) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); DCHECK_PARAM_PTR("height", height); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - *height = g->row_size[row].size; + if (row > g->rows || row < 1) { + if (height) *height = 0; + if (relh) *relh = 0.0; + } + else { + if (height) *height = g->row_size[row - 1].size; + if (relh) *relh = g->row_size[row - 1].rel_size; + } DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -439,27 +525,10 @@ ewl_grid_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__, void *user_data __UNUSED__) { - Ewl_Grid *g; - int i; - DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); - g = EWL_GRID(w); - - /* store the total size of the grid widget */ - g->grid_w = CURRENT_W(EWL_OBJECT(w)); - g->grid_h = CURRENT_H(EWL_OBJECT(w)); - - /* initialize the column width to default values */ - for (i = 0; i < g->cols; i++) - g->col_size[i].size = g->grid_w / g->cols; - - /* initialize the row height to default values */ - for (i = 0; i < g->rows; i++) - g->row_size[i].size = g->grid_h / g->rows; - ewl_widget_configure(w); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -482,48 +551,87 @@ Ewl_Widget *child; int c_w = 0, c_h = 0; /* child width/height */ int c_x = 0, c_y = 0; /* child x/y coordinate */ + int col, row; int i; - + void (*go_next)(Ewl_Grid *g, int *c, int *r); + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); g = EWL_GRID(w); + if (!g->map) + ewl_grid_map_recalc(g); + if (g->data_dirty) + ewl_grid_child_data_collect(g); + ewl_grid_resize(g); - c_x = CURRENT_X(EWL_OBJECT(w)); - c_y = CURRENT_Y(EWL_OBJECT(w)); + i = 0; + /* + * setup the position stuff for the floating + * widgets + */ + ewl_grid_map_start_position_get(g, &col, &row); + if (g->orientation == EWL_ORIENTATION_HORIZONTAL) + go_next = ewl_grid_hmap_position_next; + else + go_next = ewl_grid_vmap_position_next; ecore_dlist_goto_first(EWL_CONTAINER(w)->children); while ((child = ecore_dlist_next(EWL_CONTAINER(w)->children)) != NULL) { - c = (Ewl_Grid_Child *) ewl_widget_data_get(child, (void *) g); + /* + * reset geometry values for the next child + */ + c_x = CURRENT_X(EWL_OBJECT(w)); + c_y = CURRENT_Y(EWL_OBJECT(w)); + c_w = 0; + c_h = 0; - /* calculate child widgets width */ - for (i = c->start_col - 1; i < c->end_col; i++) - c_w += g->col_size[i].size; - - /* calculate child widgets height */ - for (i = c->start_row - 1; i < c->end_row; i++) - c_h += g->row_size[i].size; - - /* calculate child widgets x coordinate */ - for (i = 0; i < (c->start_col - 1); i++) - c_x += g->col_size[i].size; - - /* calculate child widgets y coordinate */ - for (i = 0; i < (c->start_row - 1); i++) - c_y += g->row_size[i].size; + c = (Ewl_Grid_Child *) ewl_widget_data_get(child, (void *) g); + if (c) { + /* + * calculate the geometry of the fixed widgets + */ + + /* calculate child widgets width */ + for (i = c->start_col - 1; i < c->end_col; i++) + c_w += g->col_size[i].current_size; + + /* calculate child widgets height */ + for (i = c->start_row - 1; i < c->end_row; i++) + c_h += g->row_size[i].current_size; + + /* calculate child widgets x coordinate */ + for (i = 0; i < (c->start_col - 1); i++) + c_x += g->col_size[i].current_size; + + /* calculate child widgets y coordinate */ + for (i = 0; i < (c->start_row - 1); i++) + c_y += g->row_size[i].current_size; + } + else { + /* + * get the geometry of the non-fixed widgets + */ + c_w = g->col_size[col].current_size; + c_h = g->row_size[row].current_size; + + /* calculate child widgets x coordinate */ + for (i = 0; i < col; i++) + c_x += g->col_size[i].current_size; + + /* calculate child widgets y coordinate */ + for (i = 0; i < row; i++) + c_y += g->row_size[i].current_size; + + go_next(g, &col, &row); + } ewl_object_place(EWL_OBJECT(child), c_x, c_y, c_w, c_h); ewl_widget_configure(child); - - /* reset geometry values for the next child */ - c_x = CURRENT_X(EWL_OBJECT(w)); - c_y = CURRENT_Y(EWL_OBJECT(w)); - c_w = 0; - c_h = 0; } DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -549,81 +657,302 @@ g = EWL_GRID(w); + IF_FREE(g->map); IF_FREE(g->col_size) IF_FREE(g->row_size) g->col_size = NULL; g->row_size = NULL; + g->map = NULL; DLEAVE_FUNCTION(DLEVEL_STABLE); } /** * @internal - * @param w: The widget to work with - * @param ev_data: UNUSED - * @param user_data: User data + * @param g: The grid to work with * @return Returns no value - * @brief The child destroy callback + * @brief set up the map of the fixed postioned children */ -void -ewl_grid_child_destroy_cb(Ewl_Widget *w, void *ev_data __UNUSED__, - void *user_data) -{ +static void +ewl_grid_map_recalc(Ewl_Grid *g) +{ Ewl_Widget *child; - + Ewl_Grid_Child *c; + int l, k; + DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("w", w); - DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); + DCHECK_PARAM_PTR("g", g); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); - child = (Ewl_Widget *)ewl_widget_data_get(w, user_data); + IF_FREE(g->map); + g->map = NEW(char, g->cols * g->rows); + + ecore_dlist_goto_first(EWL_CONTAINER(g)->children); + while ((child = ecore_dlist_next(EWL_CONTAINER(g)->children)) != NULL) { + c = (Ewl_Grid_Child *) ewl_widget_data_get(child, (void *) g); - IF_FREE(child) + if (c) { + /* + * mark all positions that content a positioned widget + */ + for (l = c->start_col - 1; l < c->end_col && l < g->cols; l++) + for (k = c->start_row - 1; k < c->end_row + && k < g->rows; k++) + g->map[g->cols * k + l] = 1; + } + } DLEAVE_FUNCTION(DLEVEL_STABLE); } +/** + * @internal + * @param g: The grid to work with + * @return Returns no value + * @brief collect the preferred sizes of the columns and rows + */ static void -ewl_grid_resize(Ewl_Grid *g) +ewl_grid_child_data_collect(Ewl_Grid *g) { - int w_flag = 0, h_flag = 0; - int i, new_w = 0, new_h = 0; - int left_over, left_over2; - + int col, row; + Ewl_Grid_Child *c; + Ewl_Widget *child; + void (*go_next)(Ewl_Grid *g, int *c, int *r); + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - /* store the total size of the grid widget */ - if (ewl_object_current_w_get(EWL_OBJECT(g)) != g->grid_w) { - new_w = ewl_object_current_w_get(EWL_OBJECT(g)); - w_flag = 1; + /* + * setup the position stuff for the floating + * widgets + */ + ewl_grid_map_start_position_get(g, &col, &row); + if (g->orientation == EWL_ORIENTATION_HORIZONTAL) + go_next = ewl_grid_hmap_position_next; + else + go_next = ewl_grid_vmap_position_next; + + /* + * First collect the data of the non-fixed postion widgets + */ + ecore_dlist_goto_first(EWL_CONTAINER(g)->children); + while ((child = ecore_dlist_next(EWL_CONTAINER(g)->children)) != NULL) { + c = (Ewl_Grid_Child *) ewl_widget_data_get(child, (void *) g); + + if (!c) { + int pref_w, pref_h; + + /* + * go to the next free place + */ + pref_w = ewl_object_preferred_w_get(EWL_OBJECT(child)); + pref_h = ewl_object_preferred_h_get(EWL_OBJECT(child)); + g->col_size[col].preferred_size + = MAX(g->col_size[col].preferred_size, pref_w); + g->row_size[row].preferred_size + = MAX(g->row_size[row].preferred_size, pref_h); + + go_next(g, &col, &row); + } + } + + /* + * and now collect the data of the fixed postion widgets + */ + ecore_dlist_goto_first(EWL_CONTAINER(g)->children); + while ((child = ecore_dlist_next(EWL_CONTAINER(g)->children)) != NULL) { + c = (Ewl_Grid_Child *) ewl_widget_data_get(child, (void *) g); + + if (c) { + int pref_w, pref_h; + int i; + + pref_w = pref_h = 0; + /* + * first calculate the current preferred size + * of the cells + */ + for (i = c->start_col - 1; i < c->end_col; i++) + pref_w += g->col_size[i].preferred_size; + for (i = c->start_row - 1; i < c->end_row; i++) + pref_h += g->row_size[i].preferred_size; + + pref_w = ewl_object_preferred_w_get(EWL_OBJECT(child)) + - pref_w; + pref_h = ewl_object_preferred_h_get(EWL_OBJECT(child)) + - pref_h; + + if (pref_w > 0) { + pref_w /= c->end_col - c->start_col + 1; + for (i = c->start_col - 1; i < c->end_col; i++) + g->col_size[i].preferred_size += pref_w; + } + if (pref_h > 0) { + pref_h /= c->end_row - c->start_row + 1; + for (i = c->start_row - 1; i < c->end_row; i++) + g->row_size[i].preferred_size += pref_h; + } + } } - if (ewl_object_current_h_get(EWL_OBJECT(g)) != g->grid_h) { - new_h = ewl_object_current_h_get(EWL_OBJECT(g)); - h_flag = 1; + /* + * calculate the preferred size + */ + + if (g->homogeneous_h) { + int i, size; + + for (i = 0, size = 0; i < g->cols; i++) { + size = MAX(size, g->col_size[i].preferred_size); + } + ewl_object_preferred_inner_w_set(EWL_OBJECT(g), size * g->cols); + } + else { + float rel; + int i, fixed; + + rel = 0.0; + fixed = 0; + for (i = 0; i < g->cols; i++) { + if (g->col_size[i].override) { + rel += g->col_size[i].rel_size; + fixed += g->col_size[i].size; + } + else + fixed += g->col_size[i].preferred_size; + } + ewl_object_preferred_inner_w_set(EWL_OBJECT(g), + (int)(fixed / (1.0 - rel))); + } + + if (g->homogeneous_v) { + int i, size; + + for (i = 0, size = 0; i < g->rows; i++) { + size = MAX(size, g->row_size[i].preferred_size); + } + ewl_object_preferred_inner_h_set(EWL_OBJECT(g), size * g->rows); + } + else { + float rel; + int i, fixed; + + rel = 0.0; + fixed = 0; + for (i = 0; i < g->rows; i++) { + if (g->row_size[i].override) { + rel += g->row_size[i].rel_size; + fixed += g->row_size[i].size; + } + else + fixed += g->row_size[i].preferred_size; + } + ewl_object_preferred_inner_h_set(EWL_OBJECT(g), + (int)(fixed / (1.0 - rel))); } + + g->data_dirty = FALSE; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param g: The grid to work with + * @return Returns no value + * @brief recalculate the current size of the columns and rows + */ +static void +ewl_grid_resize(Ewl_Grid *g) +{ + int i, new_w = 0, new_h = 0; + int left_over, left_over2; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + new_w = CURRENT_W(g); + new_h = CURRENT_H(g); /* - * if grid with has changed we need to store the new column - * width + * calculated the new columns' widths */ - if (w_flag) { + if (g->homogeneous_h) { + for (i = 0; i < g->cols; i++) + g->col_size[i].current_size = new_w / g->cols; + } + else { + int pref_size, fixed_size; + double rel; + + pref_size = fixed_size = 0; + /* + * first we calculate the preferred size + */ for (i = 0; i < g->cols; i++) { - g->col_size[i].size += ((new_w - g->grid_w) / g->cols); + if (!g->col_size[i].override) + pref_size += + g->col_size[i].current_size + = g->col_size[i].preferred_size; + else + fixed_size += + g->col_size[i].current_size + = g->col_size[i].size + + g->col_size[i].rel_size + * new_w; } - g->grid_w = new_w; + + /* + * we can only distribute the rest size to the + * non-fixed ones + */ + rel = (double)(new_w - fixed_size) / (double)pref_size; + for (i = 0; i < g->cols; i++) + if (!g->col_size[i].override) + g->col_size[i].current_size = + (int)g->col_size[i].current_size + * rel; + } /* - * if grid height has changed we need to store the new row - * height + * calculated the new rows' heights */ - if (h_flag) { + if (g->homogeneous_v) { + for (i = 0; i < g->rows; i++) + g->row_size[i].current_size = new_h / g->rows; + } + else { + int pref_size, fixed_size; + double rel; + + pref_size = fixed_size = 0; + /* + * first we calculate the preferred size + */ for (i = 0; i < g->rows; i++) { - g->row_size[i].size += ((new_h - g->grid_h) / g->rows); + if (!g->row_size[i].override) + pref_size += + g->row_size[i].current_size + = g->row_size[i].preferred_size; + else + fixed_size += + g->row_size[i].current_size + = g->row_size[i].size + + g->row_size[i].rel_size + * new_h; } - g->grid_h = new_h; + /* + * we can only distribute the rest size + * to the non-fixed ones + */ + rel = (double)(new_h - fixed_size) / (double)pref_size; + for (i = 0; i < g->rows; i++) + if (!g->row_size[i].override) + g->row_size[i].current_size = + g->row_size[i].current_size + * rel; } /* @@ -631,34 +960,34 @@ * might be some more space to fill at the right and bottom. * this claims the left over space */ - left_over = g->grid_w; + left_over = new_w; for (i = 0; i < g->cols; i++) - left_over -= g->col_size[i].size; + left_over -= g->col_size[i].current_size; if (g->cols == 0) g->cols = 1; while (left_over != 0) { if (left_over > 0) { - g->col_size[left_over % g->cols].size += 1; + g->col_size[left_over % g->cols].current_size += 1; left_over--; } else if (left_over < 0) { left_over2 = 0 - left_over; - g->col_size[left_over2 % g->cols].size -= 1; + g->col_size[left_over2 % g->cols].current_size -= 1; left_over++; } } - left_over = g->grid_h; + left_over = new_h; for (i = 0; i < g->rows; i++) - left_over -= g->row_size[i].size; + left_over -= g->row_size[i].current_size; if (g->rows == 0) g->rows = 1; while (left_over != 0) { if (left_over > 0) { - g->row_size[left_over % g->rows].size += 1; + g->row_size[left_over % g->rows].current_size += 1; left_over--; } else if (left_over < 0) { left_over2 = 0 - left_over; - g->row_size[left_over2 % g->rows].size -= 1; + g->row_size[left_over2 % g->rows].current_size -= 1; left_over++; } } @@ -668,21 +997,122 @@ /** * @internal + * @param g: The grid to work with + * @param c: a pointer to the current column to get the next position + * @param r: a pointer to the current row to get the next position + * @return Returns no value + * @brief get the next free position for floating children + * + * Use this function in the horizontal fill orientation case. + */ +static void +ewl_grid_hmap_position_next(Ewl_Grid *g, int *c, int *r) +{ + int col, row; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_PARAM_PTR("c", c); + DCHECK_PARAM_PTR("r", r); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + col = *c; + row = *r; + + do { + col++; + if (col >= g->cols) { + col = 0; + row++; + } + } while (g->map[col + row * g->cols] != 0); + + *c = col; + *r = row; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param g: The grid to work with + * @param c: a pointer to the current column to get the next position + * @param r: a pointer to the current row to get the next position + * @return Returns no value + * @brief get the next free position for floating children + * + * Use this function in the vertical fill orientation case. + */ +static void +ewl_grid_vmap_position_next(Ewl_Grid *g, int *c, int *r) +{ + int col, row; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_PARAM_PTR("c", c); + DCHECK_PARAM_PTR("r", r); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + col = *c; + row = *r; + + do { + row++; + if (row >= g->rows) { + row = 0; + col++; + } + } while (g->map[col + row * g->cols] != 0); + + *c = col; + *r = row; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param g: The grid to work with + * @param c: a pointer to get the first free column position + * @param r: a pointer to get the first free row position + * @return Returns no value + * @brief get the first free position for floating children + */ +static void +ewl_grid_map_start_position_get(Ewl_Grid *g, int *c, int *r) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_PARAM_PTR("c", c); + DCHECK_PARAM_PTR("r", r); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + *c = 0; + *r = 0; + + if (*g->map != 0) { + if (g->orientation == EWL_ORIENTATION_HORIZONTAL) + ewl_grid_hmap_position_next(g, c, r); + else + ewl_grid_vmap_position_next(g, c, r); + } + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal * @param p: The container to work with * @param c: The widget to work with * @return Returns no value * @brief Notify the grid that a child has been added. */ -void -ewl_grid_child_show_cb(Ewl_Container *p, Ewl_Widget *c) +void +ewl_grid_child_add_cb(Ewl_Container *p, Ewl_Widget *c) { - int i; - int temp; - int max_w = 0, max_h = 0; - int g_w = 0, g_h = 0; Ewl_Grid *g; - Ewl_Grid_Child *cdata; - + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("p", p); DCHECK_PARAM_PTR("c", c); @@ -690,106 +1120,74 @@ DCHECK_TYPE("c", c, EWL_WIDGET_TYPE); g = EWL_GRID(p); - cdata = ewl_widget_data_get(c, (void *) g); - - /* - * If no data exists, we should add some defaults. - */ - if (!cdata) { - cdata = NEW(Ewl_Grid_Child, 1); - if (!cdata) - DRETURN(DLEVEL_STABLE); - cdata->start_col = cdata->end_col = 1; - cdata->start_row = cdata->end_row = 1; + g->data_dirty = TRUE; + g->space++; - ewl_widget_data_set(c, g, cdata); + if (g->space > g->cols * g->rows) { + if (g->orientation == EWL_ORIENTATION_HORIZONTAL) + ewl_grid_dimension_set(g, g->cols, + g->space / g->cols + 1); + else + ewl_grid_dimension_set(g, g->space / g->rows + 1, + g->rows); } - /* - * Add the widget to columns that it intersects. - */ - for (i = cdata->start_col; i <= cdata->end_col; i++) { - if (i < cdata->end_col) { - if (!g->col_size[i].cross) - g->col_size[i].cross = ecore_list_new(); - - ecore_list_append(g->col_size[i].cross, c); - } + DLEAVE_FUNCTION(DLEVEL_STABLE); +} - /* - * Calculate the amount of space the widget would - * need in this column. - */ - temp = ewl_object_preferred_w_get(EWL_OBJECT(c)) / - (cdata->end_col - cdata->start_col + 1); +/** + * @internal + * @param c: The Container + * @param p: The chil to be deleted + * @param idx: the index of the removed widget + * @return Returns no value + * @brief The child del callback + */ +void +ewl_grid_child_remove_cb(Ewl_Container *c, Ewl_Widget *w, int idx __UNUSED__) +{ + Ewl_Grid_Child *child; + Ewl_Grid *g; - /* - * Give the column a new preferred size based on - * the added widget. - */ - if (g->col_size[i-1].size < temp) { - if (!g->col_size[i-1].override) - g->col_size[i-1].size = temp; + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("c", c); + DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); - /* - * Save a pointer to the largest child. - */ - g->col_size[i-1].max = c; - } - max_w = MAX(max_w, temp) ; - max_w = MAX(max_w, g->col_size[i-1].size); + g = EWL_GRID(c); + child = (Ewl_Grid_Child *)ewl_widget_data_get(w, g); + + if (child) { + g->space -= (child->end_row - child->start_row + 1) + * (child->end_col - child->start_col + 1); + FREE(child); } + else + g->space--; + + IF_FREE(g->map); + g->map = NULL; + g->data_dirty = TRUE; - /* - * Add the widget to rows that it intersects. - */ - for (i = cdata->start_row; i <= cdata->end_row; i++) { - if (i < cdata->end_row) { - if (!g->row_size[i].cross) - g->row_size[i].cross = ecore_list_new(); - - ecore_list_append(g->row_size[i].cross, c); - } - - /* - * Calculate the amount of space the widget would - * need in this row. - */ - temp = ewl_object_preferred_h_get(EWL_OBJECT(c)) / - (cdata->end_row - cdata->start_row + 1); - - /* - * Give the row a new preferred size based on - * the added widget. - */ - if (g->row_size[i-1].size < temp) { - if (!g->row_size[i-1].override) - g->row_size[i-1].size = temp; + DLEAVE_FUNCTION(DLEVEL_STABLE); +} - /* - * Save a pointer to the largest child. - */ - g->row_size[i-1].max = c; - } - max_h = MAX(max_h, temp) ; - max_h = MAX(max_h, g->row_size[i-1].size); - } - - for (i = 0; i < g->cols; i++) { - if (g->homogeneous_h) { - g->col_size[i].size = max_w; - } - g_w += g->col_size[i].size; - } - for (i = 0; i < g->rows; i++) { - if (g->homogeneous_v) { - g->row_size[i].size = max_h; - } - g_h += g->row_size[i].size; - } - g->grid_w = g_w; - g->grid_h = g_h; - ewl_object_preferred_inner_size_set(EWL_OBJECT(g), g_w, g_h); +/** + * @internal + * @param p: The container to work with + * @param c: The widget to work with + * @return Returns no value + * @brief Notify the grid that a child has been added. + */ +void +ewl_grid_child_show_cb(Ewl_Container *p, Ewl_Widget *c) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("p", p); + DCHECK_PARAM_PTR("c", c); + DCHECK_TYPE("p", p, EWL_CONTAINER_TYPE); + DCHECK_TYPE("c", c, EWL_WIDGET_TYPE); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -807,103 +1205,14 @@ ewl_grid_child_resize_cb(Ewl_Container *p, Ewl_Widget *child, int size, Ewl_Orientation o) { - int give; - Ewl_Grid *g; - int used = 0; - int start_off, end_off; - Ewl_Grid_Info *info; - int i, num_spread = 1; - Ewl_Grid_Child *cdata; - int (*widget_size) (Ewl_Object * o); - DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("p", p); DCHECK_PARAM_PTR("child", child); DCHECK_TYPE("p", p, EWL_CONTAINER_TYPE); DCHECK_TYPE("child", child, EWL_WIDGET_TYPE); - g = EWL_GRID(p); - cdata = ewl_widget_data_get(child, (void *) g); - - /* - * Setup a couple orientation specific variables. - */ - if (o == EWL_ORIENTATION_HORIZONTAL) { - info = g->col_size; - start_off = cdata->start_col; - end_off = cdata->end_col; - widget_size = ewl_object_preferred_w_get; - } else { - info = g->row_size; - start_off = cdata->start_row; - end_off = cdata->end_row; - widget_size = ewl_object_preferred_h_get; - } - - /* - * Count the number of resizable columns to give the size change to. - */ - for (i = start_off; i < end_off; i++) { - if (!info[i].override) - num_spread++; - } - - /* - * No need to continue if none of the grid spaces will accept space. - */ - if (!num_spread) - DRETURN(DLEVEL_STABLE); - - /* - * Give out space to each of the grid spaces that will accept it. - */ - give = size / num_spread; - for (i = start_off; i < end_off && num_spread; i++) { - if (!info[i].override) { - - /* - * This case is simple, just add in the amount - * specified. - */ - if (child == info[i].max && give > 0) { - info[i].size += give; - used += give; - num_spread--; - } else { - int max = 0; - Ewl_Widget *temp; - - /* - * Otherwise we need to search for the largest - * widget in this space in the grid. - */ - ecore_list_goto_first(info[i].cross); - while ((temp = ecore_list_next(info[i].cross))) { - if (widget_size(EWL_OBJECT(temp)) > max) { - max = widget_size(EWL_OBJECT - (temp)); - info[i].max = temp; - } - } - } - } - } - - /* - * Hand out any remaining space available. - */ - info[i - 1].size += size % num_spread; - used += size % num_spread; - - /* - * Now resize the grid appropriately. - */ - if (o == EWL_ORIENTATION_HORIZONTAL) - ewl_object_w_request(EWL_OBJECT(g), CURRENT_W(g) - - (INSET_LEFT(g) + INSET_RIGHT(g)) + used); - else - ewl_object_h_request(EWL_OBJECT(g), CURRENT_H(g) - - (INSET_TOP(g) + INSET_BOTTOM(g)) + used); + EWL_GRID(p)->data_dirty = TRUE; + ewl_widget_configure(EWL_WIDGET(p)); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- ewl_grid.h 12 May 2006 01:24:39 -0000 1.14 +++ ewl_grid.h 9 Jul 2006 23:01:32 -0000 1.15 @@ -29,10 +29,11 @@ */ struct Ewl_Grid_Info { - int override; /**< Override the size of the column */ - int size; /**< The size */ - Ewl_Widget *max; /**< The largets child */ - Ecore_List *cross; /**< The row of widgets */ + int current_size; /**< the current size */ + int size; /**< The size set by the user */ + float rel_size; /**< The relative size */ + int preferred_size; /**< The greatest preferred size of a widget inside */ + char override; /**< Are there values set by the user */ }; /** @@ -55,17 +56,18 @@ Ewl_Grid_Info *col_size; /**< Horizontal/vertical size of the columns */ Ewl_Grid_Info *row_size; /**< Horizontal/vertical size of the rows */ + unsigned char data_dirty:1; /**< flag if the size of the columns and rows must + be recalculated */ + unsigned char homogeneous_h:1; /**< Horizontal homogeneous flag */ + unsigned char homogeneous_v:1; /**< Vertical homogeneous flag */ + + Ewl_Orientation orientation; int rows; /**< Row count */ int cols; /**< Column count */ + int space; /**< Space count */ - unsigned int homogeneous_h; /**< Horizontal homogeneous flag */ - unsigned int homogeneous_v; /**< Vertical homogeneous flag */ - - int grid_h; /**< Total height of the grid */ - int grid_w; /**< Total width of the grid */ - - Ecore_List *rchildren; /**< List of old children after a reset call */ + char *map; /**< Map of the child that have a postion */ }; /** @@ -85,20 +87,22 @@ int end_row; /**< The end row */ }; -Ewl_Widget *ewl_grid_new(int cols, int rows); -int ewl_grid_init(Ewl_Grid *g, int cols, int rows); +Ewl_Widget *ewl_grid_new(); +int ewl_grid_init(Ewl_Grid *g); -void ewl_grid_add(Ewl_Grid *g, Ewl_Widget *w, +void ewl_grid_child_position_set(Ewl_Grid *g, Ewl_Widget *child, int start_col, int end_col, int start_row, int end_row); -void ewl_grid_col_w_set(Ewl_Grid *g, int col, int width); -void ewl_grid_row_h_set(Ewl_Grid *g, int row, int height); +void ewl_grid_dimension_set(Ewl_Grid *g, int col, int row); +void ewl_grid_col_w_set(Ewl_Grid *g, int col, float relw, int width); +void ewl_grid_row_h_set(Ewl_Grid *g, int row, float relh, int height); -void ewl_grid_col_w_get(Ewl_Grid *g, int col, int *width); -void ewl_grid_row_h_get(Ewl_Grid *g, int row, int *height); +void ewl_grid_col_w_get(Ewl_Grid *g, int col, float *relw, int *width); +void ewl_grid_row_h_get(Ewl_Grid *g, int row, float *relh, int *height); -void ewl_grid_reset(Ewl_Grid *g, int rows, int cols); +void ewl_grid_orientation_set(Ewl_Grid *g, Ewl_Orientation orientation); +Ewl_Orientation ewl_grid_orientation_get(Ewl_Grid *g); void ewl_grid_homogeneous_set(Ewl_Grid *g, unsigned int h); void ewl_grid_hhomogeneous_set(Ewl_Grid *g, unsigned int h); @@ -112,6 +116,8 @@ void ewl_grid_realize_cb(Ewl_Widget *w, void *ev_data, void *user_data); void ewl_grid_configure_cb(Ewl_Widget *w, void *ev_data, void *user_data); void ewl_grid_destroy_cb(Ewl_Widget *w, void *ev_data , void *user_data); +void ewl_grid_child_add_cb(Ewl_Container *p, Ewl_Widget *c); +void ewl_grid_child_remove_cb(Ewl_Container *p, Ewl_Widget *c, int idx); void ewl_grid_child_show_cb(Ewl_Container *p, Ewl_Widget *c); void ewl_grid_child_resize_cb(Ewl_Container *p, Ewl_Widget *child, int size, Ewl_Orientation o); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_table.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- ewl_table.c 26 May 2006 19:01:56 -0000 1.15 +++ ewl_table.c 9 Jul 2006 23:01:32 -0000 1.16 @@ -65,10 +65,11 @@ /* * Create a new grid */ + t->grid = (Ewl_Grid *)ewl_grid_new(); if (col_headers) - t->grid = (Ewl_Grid *) ewl_grid_new(cols, rows + 1); + ewl_grid_dimension_set(t->grid, cols, rows + 1); else - t->grid = (Ewl_Grid *) ewl_grid_new(cols, rows); + ewl_grid_dimension_set(t->grid, cols, rows); ewl_container_child_append(EWL_CONTAINER(t), EWL_WIDGET(t->grid)); ewl_widget_show(EWL_WIDGET(t->grid)); @@ -85,7 +86,10 @@ ewl_container_child_append(EWL_CONTAINER(cell), button); ewl_object_fill_policy_set(EWL_OBJECT(cell), EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL); - ewl_grid_add(t->grid, EWL_WIDGET(cell), i, i, 1, 1); + ewl_container_child_append(EWL_CONTAINER(t->grid), + EWL_WIDGET(cell)); + ewl_grid_child_position_set(t->grid, EWL_WIDGET(cell), + i, i, 1, 1); ewl_widget_show(EWL_WIDGET(button)); ewl_widget_show(EWL_WIDGET(cell)); } @@ -140,11 +144,13 @@ * FIXME: one must verify that other functions that * ewl_table_add need this test */ + ewl_container_child_append(EWL_CONTAINER(table->grid), + EWL_WIDGET(cell)); if (table->col_headers) - ewl_grid_add(table->grid, EWL_WIDGET(cell), + ewl_grid_child_position_set(table->grid, EWL_WIDGET(cell), start_col, end_col, start_row + 1, end_row + 1); else - ewl_grid_add(table->grid, EWL_WIDGET(cell), + ewl_grid_child_position_set(table->grid, EWL_WIDGET(cell), start_col, end_col, start_row, end_row); ewl_callback_prepend(EWL_WIDGET(cell), EWL_CALLBACK_MOUSE_UP, @@ -272,7 +278,7 @@ DCHECK_PARAM_PTR("table", table); DCHECK_TYPE("table", table, EWL_TABLE_TYPE); - ewl_grid_col_w_set(table->grid, col, width); + ewl_grid_col_w_set(table->grid, col, 0.0,width); ewl_widget_configure(EWL_WIDGET(table)); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -292,7 +298,7 @@ DCHECK_PARAM_PTR("table", table); DCHECK_TYPE("table", table, EWL_TABLE_TYPE); - ewl_grid_col_w_get(table->grid, col, width); + ewl_grid_col_w_get(table->grid, col, NULL, width); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -311,7 +317,7 @@ DCHECK_PARAM_PTR("table", table); DCHECK_TYPE("table", table, EWL_TABLE_TYPE); - ewl_grid_row_h_set(table->grid, row, height); + ewl_grid_row_h_set(table->grid, row, 0.0, height); ewl_widget_configure(EWL_WIDGET(table)); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -331,7 +337,7 @@ DCHECK_PARAM_PTR("table", table); DCHECK_TYPE("table", table, EWL_TABLE_TYPE); - ewl_grid_row_h_get(table->grid, row, height); + ewl_grid_row_h_get(table->grid, row, NULL, height); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -355,10 +361,11 @@ DCHECK_PARAM_PTR("t", t); DCHECK_TYPE("t", t, EWL_TABLE_TYPE); + ewl_container_reset(EWL_CONTAINER(t->grid)); if (col_headers != NULL) - ewl_grid_reset(EWL_GRID(t->grid), cols, rows+1); + ewl_grid_dimension_set(EWL_GRID(t->grid), cols, rows+1); else - ewl_grid_reset(EWL_GRID(t->grid), cols, rows); + ewl_grid_dimension_set(EWL_GRID(t->grid), cols, rows); if (col_headers != NULL) { @@ -368,7 +375,10 @@ ewl_button_label_set(EWL_BUTTON(button), col_headers[i - 1]); ewl_widget_disable(button); ewl_container_child_append(EWL_CONTAINER(cell), button); - ewl_grid_add(t->grid, EWL_WIDGET(cell), i, i, 1, 1); + ewl_container_child_append(EWL_CONTAINER(t->grid), + EWL_WIDGET(cell)); + ewl_grid_child_position_set(t->grid, EWL_WIDGET(cell), + i, i, 1, 1); ewl_widget_show(button); ewl_widget_show(EWL_WIDGET(cell)); } @@ -514,7 +524,8 @@ DCHECK_TYPE("p", p, EWL_CONTAINER_TYPE); table = EWL_TABLE (p); - ewl_object_preferred_inner_size_get (EWL_OBJECT (table->grid), &width_g, &height_g); + ewl_object_preferred_inner_size_get (EWL_OBJECT (table->grid), + &width_g, &height_g); ewl_object_preferred_inner_size_set (EWL_OBJECT (table), width_g, height_g); DLEAVE_FUNCTION(DLEVEL_STABLE); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_calendar.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- ewl_calendar.c 15 Feb 2006 17:40:49 -0000 1.15 +++ ewl_calendar.c 9 Jul 2006 23:01:32 -0000 1.16 @@ -105,8 +105,9 @@ ewl_callback_append(next_button, EWL_CALLBACK_MOUSE_DOWN, ewl_calendar_next_month_cb, ib); ewl_widget_show(next_button); - ib->grid = ewl_grid_new(7, 7); - ewl_container_child_append(EWL_CONTAINER(vbox), ib->grid); + ib->grid = ewl_grid_new(); + ewl_grid_dimension_set(EWL_GRID(ib->grid), 7, 7); + ewl_container_child_append(EWL_CONTAINER(vbox), EWL_WIDGET(ib->grid)); ewl_object_fill_policy_set(EWL_OBJECT(ib->grid), EWL_FLAG_FILL_FILL); ewl_object_minimum_h_set(EWL_OBJECT(ib->grid), 100); ewl_widget_show(ib->grid); @@ -214,7 +215,7 @@ DCHECK_PARAM_PTR("cal", cal); DCHECK_TYPE("cal", cal, EWL_CALENDAR_TYPE); - ewl_grid_reset(EWL_GRID(cal->grid), 7, 7); + ewl_container_reset(EWL_CONTAINER(cal->grid)); ewl_calendar_add_day_labels(cal); /* Make the initial display.. */ @@ -268,9 +269,11 @@ ewl_callback_append(EWL_WIDGET(day_label), EWL_CALLBACK_CLICKED, ewl_calendar_day_pick, cal); - - ewl_grid_add(EWL_GRID(cal->grid), day_label, cur_col, cur_col, - cur_row, cur_row); + + ewl_container_child_append(EWL_CONTAINER(cal->grid), day_label); + ewl_grid_child_position_set(EWL_GRID(cal->grid), + day_label, cur_col, cur_col, + cur_row, cur_row); ewl_calendar_highlight_today(now, EWL_LABEL(day_label), cal); ewl_widget_show(day_label); @@ -416,37 +419,44 @@ /* Add the days*/ day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "M"); - ewl_grid_add(EWL_GRID(ib->grid), day_label, 1, 1, 1, 1); + ewl_container_child_append(EWL_CONTAINER(ib->grid), day_label); + ewl_grid_child_position_set(EWL_GRID(ib->grid), day_label, 1, 1, 1, 1); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "T"); - ewl_grid_add(EWL_GRID(ib->grid), day_label, 2, 2, 1, 1); + ewl_container_child_append(EWL_CONTAINER(ib->grid), day_label); + ewl_grid_child_position_set(EWL_GRID(ib->grid), day_label, 2, 2, 1, 1); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "W"); - ewl_grid_add(EWL_GRID(ib->grid), day_label, 3, 3, 1, 1); + ewl_container_child_append(EWL_CONTAINER(ib->grid), day_label); + ewl_grid_child_position_set(EWL_GRID(ib->grid), day_label, 3, 3, 1, 1); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "T"); - ewl_grid_add(EWL_GRID(ib->grid), day_label, 4, 4, 1, 1); + ewl_container_child_append(EWL_CONTAINER(ib->grid), day_label); + ewl_grid_child_position_set(EWL_GRID(ib->grid), day_label, 4, 4, 1, 1); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "F"); - ewl_grid_add(EWL_GRID(ib->grid), day_label, 5, 5, 1, 1); + ewl_container_child_append(EWL_CONTAINER(ib->grid), day_label); + ewl_grid_child_position_set(EWL_GRID(ib->grid), day_label, 5, 5, 1, 1); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "S"); - ewl_grid_add(EWL_GRID(ib->grid), day_label, 6, 6, 1, 1); + ewl_container_child_append(EWL_CONTAINER(ib->grid), day_label); + ewl_grid_child_position_set(EWL_GRID(ib->grid), day_label, 6, 6, 1, 1); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "S"); - ewl_grid_add(EWL_GRID(ib->grid), day_label, 7, 7, 1, 1); + ewl_container_child_append(EWL_CONTAINER(ib->grid), day_label); + ewl_grid_child_position_set(EWL_GRID(ib->grid), day_label, 7, 7, 1, 1); ewl_widget_show(day_label); DLEAVE_FUNCTION(DLEVEL_STABLE); ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs