From: Enlightenment C. <no...@cv...> - 2006-07-09 18:01:38
|
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); |
From: Enlightenment C. <no...@cv...> - 2006-07-10 20:24:26
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_grid.c ewl_table.c ewl_calendar.c Log Message: *API BREAK* make the grid more c-ish the functions concerning the columns and rows are now estimates now values starting to count from 0 =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- ewl_grid.c 10 Jul 2006 03:07:07 -0000 1.19 +++ ewl_grid.c 11 Jul 2006 01:24:24 -0000 1.20 @@ -330,23 +330,23 @@ /* * check bounds */ - if (start_col < 1) { + if (start_col < 0) { DWARNING("start_col out of bounds. min is 1\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } - if (end_col > g->cols) - new_cols = end_col; + if (end_col >= g->cols) + new_cols = end_col + 1; else new_cols = g->cols; - if (start_row < 1) { + if (start_row < 0) { DWARNING("start_row out of bounds. min is 1\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } - if (end_row > g->rows) - new_rows = end_row; + if (end_row >= g->rows) + new_rows = end_row + 1; else new_rows = g->rows; @@ -401,17 +401,17 @@ /* * check bounds */ - if (col < 1) { + if (col < 0) { DWARNING("parameter 'col' is out of bounds\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } - else if (col > g->cols) { - ewl_grid_dimensions_set(g, col, g->rows); + else if (col >= g->cols) { + ewl_grid_dimensions_set(g, col + 1, g->rows); } - g->col_size[col - 1].override = 1; - g->col_size[col - 1].size = width; - g->col_size[col - 1].rel_size = relw; + g->col_size[col].override = 1; + g->col_size[col].size = width; + g->col_size[col].rel_size = relw; g->data_dirty = TRUE; ewl_widget_configure(EWL_WIDGET(g)); @@ -437,13 +437,13 @@ DCHECK_PARAM_PTR("width", width); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - if ((col > g->cols) || (col < 1)) { + if ((col >= g->cols) || (col < 0)) { 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; + if (width) *width = g->col_size[col].size; + if (relw) *relw = g->col_size[col].rel_size; } DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -465,16 +465,16 @@ DCHECK_TYPE("g", g, EWL_GRID_TYPE); /* check bounds */ - if (row < 1) { + if (row < 0) { DLEAVE_FUNCTION(DLEVEL_STABLE); } - else if (row > g->rows) { - ewl_grid_dimensions_set(g, g->cols, row); + else if (row >= g->rows) { + ewl_grid_dimensions_set(g, g->cols, row + 1); } - g->row_size[row - 1].override = 1; - g->row_size[row - 1].size = height; - g->row_size[row - 1].rel_size = relh; + g->row_size[row].override = 1; + g->row_size[row].size = height; + g->row_size[row].rel_size = relh; ewl_widget_configure(EWL_WIDGET(g)); @@ -499,13 +499,13 @@ DCHECK_PARAM_PTR("height", height); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - if ((row > g->rows) || (row < 1)) { + if ((row >= g->rows) || (row < 0)) { 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; + if (height) *height = g->row_size[row].size; + if (relh) *relh = g->row_size[row].rel_size; } DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -573,19 +573,19 @@ */ /* calculate child widgets width */ - for (i = (c->start_col - 1); i < c->end_col; i++) + for (i = c->start_col; 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++) + for (i = c->start_row; 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++) + for (i = 0; i < c->start_col; i++) c_x += g->col_size[i].current_size; /* calculate child widgets y coordinate */ - for (i = 0; i < (c->start_row - 1); i++) + for (i = 0; i < c->start_row; i++) c_y += g->row_size[i].current_size; } else { @@ -671,8 +671,9 @@ /* * 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++) + for (l = c->start_col; l <= c->end_col && l < g->cols; l++) + for (k = c->start_row; k <= c->end_row + && k < g->rows; k++) g->map[g->cols * k + l] = 1; } DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -746,10 +747,10 @@ * first calculate the current preferred size * of the cells */ - for (i = (c->start_col - 1); i < c->end_col; i++) + for (i = c->start_col; i <= c->end_col; i++) pref_w += g->col_size[i].preferred_size; - for (i = (c->start_row - 1); i < c->end_row; i++) + for (i = c->start_row; 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; @@ -757,13 +758,13 @@ if (pref_w > 0) { pref_w /= c->end_col - c->start_col + 1; - for (i = (c->start_col - 1); i < c->end_col; i++) + for (i = c->start_col; 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++) + for (i = c->start_row; i <= c->end_row; i++) g->row_size[i].preferred_size += pref_h; } } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_table.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- ewl_table.c 10 Jul 2006 09:14:08 -0000 1.18 +++ ewl_table.c 11 Jul 2006 01:24:24 -0000 1.19 @@ -119,7 +119,7 @@ * @param table: the table * @param w: the cell to add * @param start_col: the start column - * @param end_col: the end columnt + * @param end_col: the end column * @param start_row: the start row * @param end_row: the end row * @return Returns no value. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_calendar.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- ewl_calendar.c 10 Jul 2006 02:43:24 -0000 1.17 +++ ewl_calendar.c 11 Jul 2006 01:24:24 -0000 1.18 @@ -272,8 +272,9 @@ 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); + day_label, cur_col - 1, + cur_col - 1, cur_row - 1, + cur_row - 1); ewl_calendar_highlight_today(now, EWL_LABEL(day_label), cal); ewl_widget_show(day_label); @@ -420,43 +421,43 @@ day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "M"); 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_grid_child_position_set(EWL_GRID(ib->grid), day_label, 0, 0, 0, 0); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "T"); 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_grid_child_position_set(EWL_GRID(ib->grid), day_label, 1, 1, 0, 0); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "W"); 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_grid_child_position_set(EWL_GRID(ib->grid), day_label, 2, 2, 0, 0); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "T"); 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_grid_child_position_set(EWL_GRID(ib->grid), day_label, 3, 3, 0, 0); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "F"); 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_grid_child_position_set(EWL_GRID(ib->grid), day_label, 4, 4, 0, 0); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "S"); 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_grid_child_position_set(EWL_GRID(ib->grid), day_label, 5, 5, 0, 0); ewl_widget_show(day_label); day_label = ewl_label_new(); ewl_label_text_set(EWL_LABEL(day_label), "S"); 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_grid_child_position_set(EWL_GRID(ib->grid), day_label, 6, 6, 0, 0); ewl_widget_show(day_label); DLEAVE_FUNCTION(DLEVEL_STABLE); |
From: Enlightenment C. <no...@cv...> - 2006-07-11 22:44:24
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_grid.c ewl_enums.h ewl_grid.h ewl_colorpicker.c ewl_table.c Log Message: *API BREAK* again, - spilt ewl_grid_column/row_w/h_set/get into several functions - add ewl_grid_column/row_preferred_w/h_use - add ewl_grid_dimensions_get =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_grid.c 11 Jul 2006 20:42:42 -0000 1.21 +++ ewl_grid.c 12 Jul 2006 03:44:19 -0000 1.22 @@ -88,7 +88,7 @@ * @param cols: the new number of columns * @param rows: the new number of rows * @return Returns no value - * @brief Clears the grid and sets new geometry + * @brief sets the new dimensions */ void ewl_grid_dimensions_set(Ewl_Grid *g, int cols, int rows) @@ -152,6 +152,26 @@ } /** + * @param g: the grid + * @param cols: a pointer where the number of columns will be saved + * @param rows: a pointer where the number of rows will be saved + * @return Returns no value + * @brief get the number of columns and rows + */ +void +ewl_grid_dimensions_get(Ewl_Grid *g, int *cols, int *rows) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + if (cols) *cols = g->cols; + if (rows) *rows = g->rows; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** * @param g: the grid to change the fill orientation * @param orientation: the Ewl_Orientation value * @return Returns no value. @@ -331,7 +351,7 @@ * check bounds */ if (start_col < 0) { - DWARNING("start_col out of bounds. min is 1\n"); + DWARNING("start_col out of bounds. min is 0\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -341,7 +361,7 @@ new_cols = g->cols; if (start_row < 0) { - DWARNING("start_row out of bounds. min is 1\n"); + DWARNING("start_row out of bounds. min is 0\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -386,13 +406,33 @@ /** * @param g: the grid * @param col: the column - * @param relw: width relative to the grid width + * @return Returns the current width + * @brief Get the current width of a column + * + * This function returns current width of the column. + */ +int +ewl_grid_column_current_w_get(Ewl_Grid *g, int col) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("g", g, 0); + DCHECK_TYPE_RET("g", g, EWL_GRID_TYPE, 0); + + if ((col >= g->cols) || (col < 0)) + DRETURN_INT(0, DLEVEL_STABLE); + + DRETURN_INT(g->col_size[col].current_size, DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param col: the column * @param width: the new width * @return Returns no value. - * @brief Set the widget of a column + * @brief Set the fixed size of a column */ void -ewl_grid_column_w_set(Ewl_Grid *g, int col, float relw, int width) +ewl_grid_column_fixed_w_set(Ewl_Grid *g, int col, int width) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); @@ -409,9 +449,8 @@ ewl_grid_dimensions_set(g, col + 1, g->rows); } - g->col_size[col].override = 1; - g->col_size[col].size = width; - g->col_size[col].rel_size = relw; + g->col_size[col].resize_type = EWL_GRID_RESIZE_FIXED; + g->col_size[col].user.size = width; g->data_dirty = TRUE; ewl_widget_configure(EWL_WIDGET(g)); @@ -422,59 +461,194 @@ /** * @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. + * @return Returns the user set width * @brief Get the user set width of a column * * This function returns only the size set by the user. */ +int +ewl_grid_column_fixed_w_get(Ewl_Grid *g, int col) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("g", g, 0); + DCHECK_TYPE_RET("g", g, EWL_GRID_TYPE, 0); + + if ((col >= g->cols) || (col < 0)) + DRETURN_INT(0, DLEVEL_STABLE); + + DRETURN_INT(g->col_size[col].user.size, DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param col: the column + * @param width: the new relative width + * @return Returns no value. + * @brief Set the relative width of a column + */ void -ewl_grid_column_w_get(Ewl_Grid *g, int col, float *relw, int *width) +ewl_grid_column_relative_w_set(Ewl_Grid *g, int col, float relw) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); - DCHECK_PARAM_PTR("width", width); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - if ((col >= g->cols) || (col < 0)) { - if (width) *width = 0; - if (relw) *relw = 0.0; + /* + * check bounds + */ + if (col < 0) { + DWARNING("parameter 'col' is out of bounds\n"); + DLEAVE_FUNCTION(DLEVEL_STABLE); } - else { - if (width) *width = g->col_size[col].size; - if (relw) *relw = g->col_size[col].rel_size; + else if (col >= g->cols) { + ewl_grid_dimensions_set(g, col + 1, g->rows); } + g->col_size[col].resize_type = EWL_GRID_RESIZE_RELATIVE; + g->col_size[col].user.rel_size = relw; + g->data_dirty = TRUE; + + ewl_widget_configure(EWL_WIDGET(g)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param col: the column + * @return Returns the user set relative width + * @brief Get the user set relative width of a column + * + * This function returns only the relative size set by the user. + */ +float +ewl_grid_column_relative_w_get(Ewl_Grid *g, int col) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("g", g, 0.0); + DCHECK_TYPE_RET("g", g, EWL_GRID_TYPE, 0.0); + + if ((col >= g->cols) || (col < 0)) + DRETURN_FLOAT(0.0, DLEVEL_STABLE); + + DRETURN_FLOAT(g->col_size[col].user.rel_size, DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param col: the column + * @return Returns no value. + * @brief use the preferred size of the column + */ +void +ewl_grid_column_preferred_w_use(Ewl_Grid *g, int col) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + /* + * check bounds + */ + if (col < 0) { + DWARNING("parameter 'col' is out of bounds\n"); + DLEAVE_FUNCTION(DLEVEL_STABLE); + } + else if (col >= g->cols) { + ewl_grid_dimensions_set(g, col + 1, g->rows); + } + + g->col_size[col].resize_type = EWL_GRID_RESIZE_NONE; + g->col_size[col].user.size = 0; + g->data_dirty = TRUE; + + ewl_widget_configure(EWL_WIDGET(g)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param col: the column + * @return Returns no value. + * @brief remove the user set size + */ +void +ewl_grid_column_w_remove(Ewl_Grid *g, int col) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + /* + * check bounds + */ + if (col < 0) { + DWARNING("parameter 'col' is out of bounds\n"); + DLEAVE_FUNCTION(DLEVEL_STABLE); + } + else if (col >= g->cols) { + ewl_grid_dimensions_set(g, col + 1, g->rows); + } + + g->col_size[col].resize_type = EWL_GRID_RESIZE_NORMAL; + g->col_size[col].user.size = 0; + g->data_dirty = TRUE; + + ewl_widget_configure(EWL_WIDGET(g)); + DLEAVE_FUNCTION(DLEVEL_STABLE); } /** * @param g: the grid * @param row: the row - * @param relh: the height relative to the size of the grid + * @return Returns the current height + * @brief Get the current height of a column + * + * This function returns current width of the column. + */ +int +ewl_grid_row_current_h_get(Ewl_Grid *g, int row) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("g", g, 0); + DCHECK_TYPE_RET("g", g, EWL_GRID_TYPE, 0); + + if ((row >= g->rows) || (row < 0)) + DRETURN_INT(0, DLEVEL_STABLE); + + DRETURN_INT(g->row_size[row].current_size, DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param row: the row * @param height: the new height * @return Returns no value. - * @brief Set the user set height of a row + * @brief Set the fixed size of a column */ void -ewl_grid_row_h_set(Ewl_Grid *g, int row, float relh, int height) +ewl_grid_row_fixed_h_set(Ewl_Grid *g, int row, int height) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - /* check bounds */ + /* + * check bounds + */ if (row < 0) { + DWARNING("parameter 'row' is out of bounds\n"); DLEAVE_FUNCTION(DLEVEL_STABLE); } else if (row >= g->rows) { ewl_grid_dimensions_set(g, g->cols, row + 1); } - g->row_size[row].override = 1; - g->row_size[row].size = height; - g->row_size[row].rel_size = relh; + g->row_size[row].resize_type = EWL_GRID_RESIZE_FIXED; + g->row_size[row].user.size = height; + g->data_dirty = TRUE; ewl_widget_configure(EWL_WIDGET(g)); @@ -484,34 +658,149 @@ /** * @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. + * @return Returns the user set height * @brief Get the user set height of a row - * + * * This function returns only the size set by the user. */ +int +ewl_grid_row_fixed_h_get(Ewl_Grid *g, int row) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("g", g, 0); + DCHECK_TYPE_RET("g", g, EWL_GRID_TYPE, 0); + + if ((row >= g->rows) || (row < 0)) + DRETURN_INT(0, DLEVEL_STABLE); + + DRETURN_INT(g->row_size[row].user.size, DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param row: the row + * @param height: the new relative height + * @return Returns no value. + * @brief Set the relative height of a row + */ void -ewl_grid_row_h_get(Ewl_Grid *g, int row, float *relh, int *height) +ewl_grid_row_relative_h_set(Ewl_Grid *g, int row, float relh) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); - DCHECK_PARAM_PTR("height", height); DCHECK_TYPE("g", g, EWL_GRID_TYPE); - if ((row >= g->rows) || (row < 0)) { - if (height) *height = 0; - if (relh) *relh = 0.0; + /* + * check bounds + */ + if (row < 0) { + DWARNING("parameter 'row' is out of bounds\n"); + DLEAVE_FUNCTION(DLEVEL_STABLE); } - else { - if (height) *height = g->row_size[row].size; - if (relh) *relh = g->row_size[row].rel_size; + else if (row >= g->rows) { + ewl_grid_dimensions_set(g, g->cols, row + 1); } + g->row_size[row].resize_type = EWL_GRID_RESIZE_RELATIVE; + g->row_size[row].user.rel_size = relh; + g->data_dirty = TRUE; + + ewl_widget_configure(EWL_WIDGET(g)); + DLEAVE_FUNCTION(DLEVEL_STABLE); } /** + * @param g: the grid + * @param row: the row + * @return Returns the user set relative height + * @brief Get the user set relative height of a row + * + * This function returns only the relative size set by the user. + */ +float +ewl_grid_row_relative_h_get(Ewl_Grid *g, int row) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("g", g, 0.0); + DCHECK_TYPE_RET("g", g, EWL_GRID_TYPE, 0.0); + + if ((row >= g->rows) || (row < 0)) + DRETURN_FLOAT(0.0, DLEVEL_STABLE); + + DRETURN_FLOAT(g->row_size[row].user.rel_size, DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param row: the row + * @return Returns no value. + * @brief use the preferred size of the row + */ +void +ewl_grid_row_preferred_h_use(Ewl_Grid *g, int row) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + /* + * check bounds + */ + if (row < 0) { + DWARNING("parameter 'row' is out of bounds\n"); + DLEAVE_FUNCTION(DLEVEL_STABLE); + } + else if (row >= g->rows) { + ewl_grid_dimensions_set(g, g->cols, row + 1); + } + + g->row_size[row].resize_type = EWL_GRID_RESIZE_NONE; + g->row_size[row].user.size = 0; + g->data_dirty = TRUE; + + ewl_widget_configure(EWL_WIDGET(g)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param row: the row + * @return Returns no value. + * @brief remove the user set size + */ +void +ewl_grid_row_h_remove(Ewl_Grid *g, int row) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + + /* + * check bounds + */ + if (row < 0) { + DWARNING("parameter 'row' is out of bounds\n"); + DLEAVE_FUNCTION(DLEVEL_STABLE); + } + else if (row >= g->rows) { + ewl_grid_dimensions_set(g, g->cols, row + 1); + } + + g->row_size[row].resize_type = EWL_GRID_RESIZE_NORMAL; + g->row_size[row].user.size = 0; + g->data_dirty = TRUE; + + ewl_widget_configure(EWL_WIDGET(g)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + + + + +/** * @internal * @param w: The widget to work with * @param ev_data: UNUSED @@ -788,12 +1077,16 @@ 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; + switch (g->col_size[i].resize_type) { + case EWL_GRID_RESIZE_RELATIVE: + rel += g->col_size[i].user.rel_size; + break; + case EWL_GRID_RESIZE_FIXED: + fixed += g->col_size[i].user.size; + break; + default: + fixed += g->col_size[i].preferred_size; } - else - fixed += g->col_size[i].preferred_size; } ewl_object_preferred_inner_w_set(EWL_OBJECT(g), (int)(fixed / (1.0 - rel))); @@ -814,12 +1107,16 @@ 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; + switch (g->col_size[i].resize_type) { + case EWL_GRID_RESIZE_RELATIVE: + rel += g->row_size[i].user.rel_size; + break; + case EWL_GRID_RESIZE_FIXED: + fixed += g->row_size[i].user.size; + break; + default: + fixed += g->row_size[i].preferred_size; } - else - fixed += g->row_size[i].preferred_size; } ewl_object_preferred_inner_h_set(EWL_OBJECT(g), (int)(fixed / (1.0 - rel))); @@ -857,35 +1154,49 @@ g->col_size[i].current_size = new_w / g->cols; } else { - int pref_size, fixed_size; + int var; /* the variable size part */ + int fixed; /* the fixed size part */ double rel; - pref_size = fixed_size = 0; + var = fixed = 0; /* - * first we calculate the preferred size + * first we calculate the different parts of the size */ for (i = 0; i < g->cols; i++) { - 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; + switch (g->col_size[i].resize_type) { + case EWL_GRID_RESIZE_RELATIVE: + fixed += g->col_size[i].user.rel_size + * new_w; + g->col_size[i].current_size = + g->col_size[i].user.rel_size + * new_w; + break; + case EWL_GRID_RESIZE_FIXED: + fixed += g->col_size[i].user.size; + g->col_size[i].current_size = + g->col_size[i].user.size; + break; + case EWL_GRID_RESIZE_NONE: + fixed += g->col_size[i].preferred_size; + g->col_size[i].current_size = + g->col_size[i].preferred_size; + break; + default: + var += g->col_size[i].preferred_size; + + } } /* * we can only distribute the rest size to the * non-fixed ones */ - rel = (double)(new_w - fixed_size) / (double)pref_size; + rel = (double)(new_w - fixed) / (double)var; for (i = 0; i < g->cols; i++) - if (!g->col_size[i].override) + if (g->col_size[i].resize_type == EWL_GRID_RESIZE_NORMAL) g->col_size[i].current_size = - (int)g->col_size[i].current_size * rel; + (int)(g->col_size[i].preferred_size + * rel); } /* @@ -896,34 +1207,49 @@ g->row_size[i].current_size = new_h / g->rows; } else { - int pref_size, fixed_size; + int var; /* the variable size part */ + int fixed; /* the fixed size part */ double rel; - pref_size = fixed_size = 0; + var = fixed = 0; /* - * first we calculate the preferred size + * first we calculate the different parts of the size */ for (i = 0; i < g->rows; i++) { - 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; + switch (g->row_size[i].resize_type) { + case EWL_GRID_RESIZE_RELATIVE: + fixed += g->row_size[i].user.rel_size + * new_h; + g->row_size[i].current_size = + g->row_size[i].user.rel_size + * new_h; + break; + case EWL_GRID_RESIZE_FIXED: + fixed += g->row_size[i].user.size; + g->row_size[i].current_size = + g->row_size[i].user.size; + break; + case EWL_GRID_RESIZE_NONE: + fixed += g->row_size[i].preferred_size; + g->row_size[i].current_size = + g->row_size[i].preferred_size; + break; + default: + var += g->row_size[i].preferred_size; + + } } + /* - * we can only distribute the rest size - * to the non-fixed ones + * we can only distribute the rest size to the + * non-fixed ones */ - rel = (double)(new_h - fixed_size) / (double)pref_size; + rel = (double)(new_h - fixed) / (double)var; for (i = 0; i < g->rows; i++) - if (!g->row_size[i].override) + if (g->row_size[i].resize_type == EWL_GRID_RESIZE_NORMAL) g->row_size[i].current_size = - g->row_size[i].current_size * rel; + (int)(g->row_size[i].preferred_size + * rel); } /* =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_enums.h,v retrieving revision 1.49 retrieving revision 1.50 diff -u -3 -r1.49 -r1.50 --- ewl_enums.h 10 Jun 2006 00:35:06 -0000 1.49 +++ ewl_enums.h 12 Jul 2006 03:44:19 -0000 1.50 @@ -587,6 +587,23 @@ typedef enum Ewl_Filelist_Event_Type Ewl_Filelist_Event_Type; /** + * @enum Ewl_Grid_Resize_Type + * The different ways of resizing a column or a row + */ +enum Ewl_Grid_Resize_Type +{ + EWL_GRID_RESIZE_NORMAL, /**< use the standard resize methode */ + EWL_GRID_RESIZE_FIXED, /**< use the user set size */ + EWL_GRID_RESIZE_RELATIVE, /**< use the user set relative size */ + EWL_GRID_RESIZE_NONE /**< use the preferred size of the row */ +}; + +/** + * The Ewl_Grid_Resize_Type + */ +typedef enum Ewl_Grid_Resize_Type Ewl_Grid_Resize_Type; + +/** * @enum Ewl_Mouse_Cursor_Type * The possible mouse cursor settings */ =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- ewl_grid.h 10 Jul 2006 03:07:07 -0000 1.17 +++ ewl_grid.h 12 Jul 2006 03:44:19 -0000 1.18 @@ -25,15 +25,18 @@ typedef struct Ewl_Grid_Info Ewl_Grid_Info; /** - * Contains information about the Ewl_Grid + * Contains information about a row or column of Ewl_Grid */ struct Ewl_Grid_Info { - 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 */ + int current_size; /**< the current size */ + int preferred_size; /**< The greatest preferred size of a widget inside */ + union { + int size; /**< The size set by the user */ + float rel_size; /**< The relative size */ + } user; + + Ewl_Grid_Resize_Type resize_type; /**< Are there values set by the user */ }; /** @@ -95,12 +98,23 @@ int end_row); void ewl_grid_dimensions_set(Ewl_Grid *g, int col, int row); +void ewl_grid_dimensions_get(Ewl_Grid *g, int *col, int *row); -void ewl_grid_column_w_set(Ewl_Grid *g, int col, float relw, int width); -void ewl_grid_column_w_get(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_row_h_get(Ewl_Grid *g, int row, float *relh, int *height); +int ewl_grid_column_current_w_get(Ewl_Grid *g, int col); +void ewl_grid_column_fixed_w_set(Ewl_Grid *g, int col, int width); +int ewl_grid_column_fixed_w_get(Ewl_Grid *g, int col); +void ewl_grid_column_relative_w_set(Ewl_Grid *g, int col, float relw); +float ewl_grid_column_relative_w_get(Ewl_Grid *g, int col); +void ewl_grid_column_preferred_w_use(Ewl_Grid *g, int col); +void ewl_grid_column_w_remove(Ewl_Grid *g, int col); + +int ewl_grid_row_current_h_get(Ewl_Grid *g, int row); +void ewl_grid_row_fixed_h_set(Ewl_Grid *g, int row, int height); +int ewl_grid_row_fixed_h_get(Ewl_Grid *g, int row); +void ewl_grid_row_relative_h_set(Ewl_Grid *g, int col, float relh); +float ewl_grid_row_relative_h_get(Ewl_Grid *g, int col); +void ewl_grid_row_preferred_h_use(Ewl_Grid *g, int col); +void ewl_grid_row_h_remove(Ewl_Grid *g, int row); void ewl_grid_orientation_set(Ewl_Grid *g, Ewl_Orientation orientation); Ewl_Orientation ewl_grid_orientation_get(Ewl_Grid *g); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_colorpicker.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- ewl_colorpicker.c 10 Jul 2006 22:49:03 -0000 1.23 +++ ewl_colorpicker.c 12 Jul 2006 03:44:19 -0000 1.24 @@ -151,7 +151,8 @@ hbox = ewl_grid_new(); ewl_widget_internal_set(hbox, TRUE); ewl_grid_dimensions_set(EWL_GRID(hbox), 2, 2); - ewl_grid_homogeneous_set(EWL_GRID(hbox), TRUE); + ewl_grid_vhomogeneous_set(EWL_GRID(hbox), TRUE); + ewl_grid_column_preferred_w_use(EWL_GRID(hbox), 0); ewl_container_child_append(EWL_CONTAINER(vbox), hbox); ewl_object_fill_policy_set(EWL_OBJECT(hbox), EWL_FLAG_FILL_NONE | EWL_FLAG_FILL_HFILL); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_table.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- ewl_table.c 11 Jul 2006 01:24:24 -0000 1.19 +++ ewl_table.c 12 Jul 2006 03:44:19 -0000 1.20 @@ -274,7 +274,7 @@ DCHECK_PARAM_PTR("table", table); DCHECK_TYPE("table", table, EWL_TABLE_TYPE); - ewl_grid_column_w_set(table->grid, col, 0.0,width); + ewl_grid_column_fixed_w_set(table->grid, col, width); ewl_widget_configure(EWL_WIDGET(table)); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -294,7 +294,7 @@ DCHECK_PARAM_PTR("table", table); DCHECK_TYPE("table", table, EWL_TABLE_TYPE); - ewl_grid_column_w_get(table->grid, col, NULL, width); + if (width) *width = ewl_grid_column_fixed_w_get(table->grid, col); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -313,7 +313,8 @@ DCHECK_PARAM_PTR("table", table); DCHECK_TYPE("table", table, EWL_TABLE_TYPE); - ewl_grid_row_h_set(table->grid, row, 0.0, height); + ewl_grid_row_fixed_h_set(table->grid, row, height); + ewl_widget_configure(EWL_WIDGET(table)); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -333,7 +334,7 @@ DCHECK_PARAM_PTR("table", table); DCHECK_TYPE("table", table, EWL_TABLE_TYPE); - ewl_grid_row_h_get(table->grid, row, NULL, height); + if (height) *height = ewl_grid_row_fixed_h_get(table->grid, row); DLEAVE_FUNCTION(DLEVEL_STABLE); } |
From: Enlightenment C. <no...@cv...> - 2006-07-14 15:56:21
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/data/themes/e17/bits Modified Files: button-groups.edc Log Message: preventing button to be clipped =================================================================== RCS file: /cvs/e/e17/libs/ewl/data/themes/e17/bits/button-groups.edc,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- button-groups.edc 27 Jun 2006 03:04:26 -0000 1.12 +++ button-groups.edc 14 Jul 2006 20:56:20 -0000 1.13 @@ -13,7 +13,7 @@ mouse_events: 1; description { state: "default" 0.0; - min: 56 16; + min: 16 16; image { normal: "e17_button_sm.png"; border: 8 8 8 8; |
From: Enlightenment C. <no...@cv...> - 2006-07-24 00:50:23
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_grid.h ewl_grid.c Log Message: - fix ewl_grid_child_position_set - add ewl_grid_child_position_get =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- ewl_grid.h 16 Jul 2006 23:17:38 -0000 1.19 +++ ewl_grid.h 24 Jul 2006 05:50:19 -0000 1.20 @@ -96,6 +96,9 @@ 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_child_position_get(Ewl_Grid *g, Ewl_Widget *child, + int *start_col, int *end_col, int *start_row, + int *end_row); void ewl_grid_dimensions_set(Ewl_Grid *g, int col, int row); void ewl_grid_dimensions_get(Ewl_Grid *g, int *col, int *row); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- ewl_grid.c 16 Jul 2006 23:17:38 -0000 1.23 +++ ewl_grid.c 24 Jul 2006 05:50:19 -0000 1.24 @@ -373,10 +373,15 @@ /* * create a new child */ - child = NEW(Ewl_Grid_Child, 1); - if (!child) - DLEAVE_FUNCTION(DLEVEL_STABLE); - + if (!(child = ewl_widget_data_get(w,g))) { + child = NEW(Ewl_Grid_Child, 1); + if (!child) + DLEAVE_FUNCTION(DLEVEL_STABLE); + } + else { + g->space -= (child->end_col - child->start_col + 1) + * (child->end_row - child->start_row + 1) + 1; + } child->start_col = start_col; child->end_col = end_col; child->start_row = start_row; @@ -399,7 +404,84 @@ */ ewl_widget_data_set(w, (void *)g, child); ewl_grid_dimensions_set(g, new_cols, new_rows); + ewl_widget_configure(EWL_WIDGET(g)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param g: the grid + * @param w: the child widget + * @param start_col: the start column + * @param end_col: the end column + * @param start_row: the start row + * @param end_row: the end row + * @return Returns no value + * @brief get the position of a child widget + */ +void +ewl_grid_child_position_get(Ewl_Grid *g, Ewl_Widget *w, + int *start_col, int *end_col, + int *start_row, int *end_row) +{ + Ewl_Grid_Child *child; + int sc, ec, sr, er; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("g", g); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("g", g, EWL_GRID_TYPE); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); + + child = ewl_widget_data_get(w, g); + if (child) { + /* + * for a fixed-positioned widget we can + * just return the data + */ + sc = child->start_col; + ec = child->end_col; + sr = child->start_row; + er = child->end_row; + } + else { + Ewl_Widget *c; + int col, row; + void (*go_next)(Ewl_Grid *g, int *c, int *r); + /* + * for a floating widget we have to search + * for the current position + */ + if (!g->map) + ewl_grid_map_recalc(g); + /* + * 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; + + /* + * and now find the current position + */ + ecore_dlist_goto_first(EWL_CONTAINER(w)->children); + while ((c = ecore_dlist_next(EWL_CONTAINER(w)->children)) + && c != w) { + if (!ewl_widget_data_get(w, g)) + go_next(g, &col, &row); + } + sc = ec = col; + sr = er = row; + } + if (start_col) *start_col = sc; + if (end_col) *end_col = ec; + if (start_row) *start_row = sr; + if (end_row) *end_row = er; + DLEAVE_FUNCTION(DLEVEL_STABLE); } |
From: Enlightenment C. <no...@cv...> - 2006-07-27 23:21:23
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/data/images Modified Files: Makefile.am Added Files: e-logo-0.png e-logo-10.png e-logo-11.png e-logo-12.png e-logo-13.png e-logo-14.png e-logo-1.png e-logo-2.png e-logo-3.png e-logo-4.png e-logo-5.png e-logo-6.png e-logo-7.png e-logo-8.png e-logo-9.png Log Message: add the pics for the puzzle =================================================================== RCS file: /cvs/e/e17/libs/ewl/data/images/Makefile.am,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- Makefile.am 18 Oct 2005 16:20:25 -0000 1.12 +++ Makefile.am 28 Jul 2006 04:21:18 -0000 1.13 @@ -9,7 +9,10 @@ elicit3.png entice.png entice1.png entice2.png entice3.png \ entrance.png entrance1.png entrance2.png entrance3.png evidence.png \ evidence1.png evidence2.png evidence3.png evidence4.png \ - lilbottom.png lilgrad.png + lilbottom.png lilgrad.png e-logo-0.png e-logo-1.png e-logo-2.png \ + e-logo-3.png e-logo-4.png e-logo-5.png e-logo-6.png e-logo-7.png \ + e-logo-8.png e-logo-9.png e-logo-10.png e-logo-11.png e-logo-12.png \ + e-logo-13.png e-logo-14.png themedir = $(pkgdatadir)/images theme_DATA = $(IMAGES) $(EDJS) |
From: Enlightenment C. <no...@cv...> - 2006-07-27 23:24:03
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/bin/tests Modified Files: Makefile.am Added Files: puzzle.c Log Message: add a little puzzle game to ewl_test =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/Makefile.am,v retrieving revision 1.33 retrieving revision 1.34 diff -u -3 -r1.33 -r1.34 --- Makefile.am 14 Jul 2006 02:53:34 -0000 1.33 +++ Makefile.am 28 Jul 2006 04:23:57 -0000 1.34 @@ -27,7 +27,7 @@ ewl_scrollpane.la ewl_spinner.la ewl_progressbar.la \ ewl_theme.la ewl_media.la ewl_menu.la ewl_imenu.la \ ewl_widget.la fullscreen.la modal.la ewl_layer.la \ - ewl_list.la + ewl_list.la puzzle.la ewl_border_la_SOURCES = ewl_border.c ewl_border_la_LIBADD = $(top_builddir)/src/lib/libewl.la @@ -337,6 +337,13 @@ -L$(top_builddir)/src/lib/.libs ewl_list_la_DEPENDENCIES = +puzzle_la_SOURCES = puzzle.c +puzzle_la_LIBADD = $(top_builddir)/src/lib/libewl.la +puzzle_la_LDFLAGS = -module -avoid-version \ + -L$(top_builddir)/src/lib \ + -L$(top_builddir)/src/lib/.libs +puzzle_la_DEPENDENCIES = + FILES = $(ewl_border_la_SOURCES) $(ewl_box_la_SOURCES) \ $(ewl_button_la_SOURCES) $(ewl_colordialog_la_SOURCES) \ @@ -359,7 +366,8 @@ $(ewl_imenu_la_SOURCES) $(ewl_widget_la_SOURCES) \ $(ewl_image_thumbnail_la_SOURCES) $(fullscreen_la_SOURCES) \ $(modal_la_SOURCES) $(ewl_layer_la_SOURCES) \ - $(ewl_dnd_snoop_la_SOURCES) $(ewl_list_la_SOURCES) + $(ewl_dnd_snoop_la_SOURCES) $(ewl_list_la_SOURCES) \ + $(puzzle_la_SOURCES) EXTRA_DIST = $(FILES) |
From: Enlightenment C. <no...@cv...> - 2006-08-06 17:02:45
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_grid.c Log Message: fix position_get() and set the preferred size correct =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- ewl_grid.c 24 Jul 2006 05:50:19 -0000 1.24 +++ ewl_grid.c 6 Aug 2006 22:02:41 -0000 1.25 @@ -467,8 +467,8 @@ /* * and now find the current position */ - ecore_dlist_goto_first(EWL_CONTAINER(w)->children); - while ((c = ecore_dlist_next(EWL_CONTAINER(w)->children)) + ecore_dlist_goto_first(EWL_CONTAINER(g)->children); + while ((c = ecore_dlist_next(EWL_CONTAINER(g)->children)) && c != w) { if (!ewl_widget_data_get(w, g)) go_next(g, &col, &row); @@ -1189,7 +1189,7 @@ rel = 0.0; fixed = 0; for (i = 0; i < g->rows; i++) { - switch (g->col_size[i].resize_type) { + switch (g->row_size[i].resize_type) { case EWL_GRID_RESIZE_RELATIVE: rel += g->row_size[i].user.rel_size; break; |
From: Enlightenment C. <no...@cv...> - 2006-08-06 17:48:22
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/bin/tests Modified Files: Makefile.am Added Files: ewl_grid.c Log Message: add a grid test =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/Makefile.am,v retrieving revision 1.34 retrieving revision 1.35 diff -u -3 -r1.34 -r1.35 --- Makefile.am 28 Jul 2006 04:23:57 -0000 1.34 +++ Makefile.am 6 Aug 2006 22:47:49 -0000 1.35 @@ -27,7 +27,7 @@ ewl_scrollpane.la ewl_spinner.la ewl_progressbar.la \ ewl_theme.la ewl_media.la ewl_menu.la ewl_imenu.la \ ewl_widget.la fullscreen.la modal.la ewl_layer.la \ - ewl_list.la puzzle.la + ewl_list.la puzzle.la ewl_grid.la ewl_border_la_SOURCES = ewl_border.c ewl_border_la_LIBADD = $(top_builddir)/src/lib/libewl.la @@ -344,6 +344,13 @@ -L$(top_builddir)/src/lib/.libs puzzle_la_DEPENDENCIES = +ewl_grid_la_SOURCES = ewl_grid.c +ewl_grid_la_LIBADD = $(top_builddir)/src/lib/libewl.la +ewl_grid_la_LDFLAGS = -module -avoid-version \ + -L$(top_builddir)/src/lib \ + -L$(top_builddir)/src/lib/.libs +ewl_grid_la_DEPENDENCIES = + FILES = $(ewl_border_la_SOURCES) $(ewl_box_la_SOURCES) \ $(ewl_button_la_SOURCES) $(ewl_colordialog_la_SOURCES) \ @@ -367,7 +374,7 @@ $(ewl_image_thumbnail_la_SOURCES) $(fullscreen_la_SOURCES) \ $(modal_la_SOURCES) $(ewl_layer_la_SOURCES) \ $(ewl_dnd_snoop_la_SOURCES) $(ewl_list_la_SOURCES) \ - $(puzzle_la_SOURCES) + $(puzzle_la_SOURCES) $(ewl_grid_la_SOURCE) EXTRA_DIST = $(FILES) |
From: Enlightenment C. <no...@cv...> - 2006-08-07 14:15:51
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/bin/tests Modified Files: Makefile.am Log Message: oops, typo =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/Makefile.am,v retrieving revision 1.35 retrieving revision 1.36 diff -u -3 -r1.35 -r1.36 --- Makefile.am 6 Aug 2006 22:47:49 -0000 1.35 +++ Makefile.am 7 Aug 2006 19:15:44 -0000 1.36 @@ -374,7 +374,7 @@ $(ewl_image_thumbnail_la_SOURCES) $(fullscreen_la_SOURCES) \ $(modal_la_SOURCES) $(ewl_layer_la_SOURCES) \ $(ewl_dnd_snoop_la_SOURCES) $(ewl_list_la_SOURCES) \ - $(puzzle_la_SOURCES) $(ewl_grid_la_SOURCE) + $(puzzle_la_SOURCES) $(ewl_grid_la_SOURCES) EXTRA_DIST = $(FILES) |
From: Enlightenment C. <no...@cv...> - 2006-08-10 23:01:02
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: Ewl.h Makefile.am ewl_colorpicker.c ewl_progressbar.c ewl_progressbar.h ewl_scrollbar.c ewl_seeker.c ewl_seeker.h ewl_spinner.c ewl_spinner.h Log Message: **API-BREAK** - add ewl_range a new abstract widget to unify the api of seeker, spinner and progressbar - NOTE this breaks colorpicker hopefully for a short time =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/Ewl.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- Ewl.h 14 Jul 2006 02:53:34 -0000 1.6 +++ Ewl.h 11 Aug 2006 04:00:57 -0000 1.7 @@ -304,6 +304,7 @@ #include <ewl_colorpicker.h> #include <ewl_colordialog.h> #include <ewl_password.h> +#include <ewl_range.h> #include <ewl_seeker.h> #include <ewl_scrollbar.h> #include <ewl_spacer.h> =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/Makefile.am,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- Makefile.am 14 Jul 2006 02:53:34 -0000 1.29 +++ Makefile.am 11 Aug 2006 04:00:57 -0000 1.30 @@ -64,6 +64,7 @@ ewl_password.h \ ewl_progressbar.h \ ewl_radiobutton.h \ + ewl_range.h \ ewl_row.h \ ewl_scrollbar.h \ ewl_scrollpane.h \ @@ -133,6 +134,7 @@ ewl_password.c \ ewl_progressbar.c \ ewl_radiobutton.c \ + ewl_range.c \ ewl_row.c \ ewl_scrollbar.c \ ewl_scrollpane.c \ =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_colorpicker.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- ewl_colorpicker.c 12 Jul 2006 03:44:19 -0000 1.24 +++ ewl_colorpicker.c 11 Aug 2006 04:00:57 -0000 1.25 @@ -234,38 +234,38 @@ o = ewl_colorpicker_spinner_new(); ewl_widget_internal_set(o, TRUE); ewl_container_child_append(EWL_CONTAINER(hbox), o); - ewl_spinner_min_val_set(EWL_SPINNER(o), 0); - ewl_spinner_max_val_set(EWL_SPINNER(o), modes[i].max); + ewl_range_min_val_set(EWL_RANGE(o), 0); + ewl_range_max_val_set(EWL_RANGE(o), modes[i].max); switch(modes[i].mode) { case EWL_COLOR_MODE_HSV_HUE: - ewl_spinner_value_set(EWL_SPINNER(o), h); + ewl_range_value_set(EWL_RANGE(o), h); cp->spinners.hsv.h = o; break; case EWL_COLOR_MODE_HSV_SATURATION: - ewl_spinner_value_set(EWL_SPINNER(o), s * 100); + ewl_range_value_set(EWL_RANGE(o), s * 100); cp->spinners.hsv.s = o; break; case EWL_COLOR_MODE_HSV_VALUE: - ewl_spinner_value_set(EWL_SPINNER(o), v * 100); + ewl_range_value_set(EWL_RANGE(o), v * 100); cp->spinners.hsv.v = o; break; case EWL_COLOR_MODE_RGB_RED: - ewl_spinner_value_set(EWL_SPINNER(o), r); + ewl_range_value_set(EWL_RANGE(o), r); cp->spinners.rgb.r = o; break; case EWL_COLOR_MODE_RGB_GREEN: - ewl_spinner_value_set(EWL_SPINNER(o), g); + ewl_range_value_set(EWL_RANGE(o), g); cp->spinners.rgb.g = o; break; case EWL_COLOR_MODE_RGB_BLUE: - ewl_spinner_value_set(EWL_SPINNER(o), b); + ewl_range_value_set(EWL_RANGE(o), b); cp->spinners.rgb.b = o; break; } - ewl_spinner_step_set(EWL_SPINNER(o), 1); + ewl_range_step_set(EWL_RANGE(o), 1); ewl_spinner_digits_set(EWL_SPINNER(o), 0); ewl_colorpicker_spinner_mode_set(EWL_COLORPICKER_SPINNER(o), modes[i].mode); @@ -278,9 +278,9 @@ o = ewl_spinner_new(); ewl_widget_internal_set(o, TRUE); ewl_container_child_append(EWL_CONTAINER(vbox), o); - ewl_spinner_min_val_set(EWL_SPINNER(o), 0); - ewl_spinner_max_val_set(EWL_SPINNER(o), 255); - ewl_spinner_value_set(EWL_SPINNER(o), 0); + ewl_range_min_val_set(EWL_RANGE(o), 0); + ewl_range_max_val_set(EWL_RANGE(o), 255); + ewl_range_value_set(EWL_RANGE(o), 0); ewl_spinner_digits_set(EWL_SPINNER(o), 0); cp->spinners.alpha = o; @@ -335,7 +335,7 @@ DCHECK_TYPE("cp", cp, EWL_COLORPICKER_TYPE); if (alpha > 255) alpha = 255; - ewl_spinner_value_set(EWL_SPINNER(cp->spinners.alpha), alpha); + ewl_range_value_set(EWL_RANGE(cp->spinners.alpha), alpha); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -354,7 +354,7 @@ DCHECK_PARAM_PTR_RET("cp", cp, 255); DCHECK_TYPE_RET("cp", cp, EWL_COLORPICKER_TYPE, 255); - alpha = ewl_spinner_value_get(EWL_SPINNER(cp->spinners.alpha)); + alpha = ewl_range_value_get(EWL_RANGE(cp->spinners.alpha)); DRETURN_INT(alpha, DLEVEL_STABLE); } @@ -625,29 +625,29 @@ switch ((int)mode) { case EWL_COLOR_MODE_RGB_RED: - r = ewl_spinner_value_get(EWL_SPINNER(cp->spinners.rgb.r)); + r = ewl_range_value_get(EWL_RANGE(cp->spinners.rgb.r)); break; case EWL_COLOR_MODE_RGB_GREEN: - g = ewl_spinner_value_get(EWL_SPINNER(cp->spinners.rgb.g)); + g = ewl_range_value_get(EWL_RANGE(cp->spinners.rgb.g)); break; case EWL_COLOR_MODE_RGB_BLUE: - b = ewl_spinner_value_get(EWL_SPINNER(cp->spinners.rgb.b)); + b = ewl_range_value_get(EWL_RANGE(cp->spinners.rgb.b)); break; case EWL_COLOR_MODE_HSV_HUE: - h = ewl_spinner_value_get(EWL_SPINNER(cp->spinners.hsv.h)); + h = ewl_range_value_get(EWL_RANGE(cp->spinners.hsv.h)); set_hsv = TRUE; break; case EWL_COLOR_MODE_HSV_SATURATION: - s = ewl_spinner_value_get(EWL_SPINNER(cp->spinners.hsv.s)) / 100.0; + s = ewl_range_value_get(EWL_RANGE(cp->spinners.hsv.s)) / 100.0; set_hsv = TRUE; break; case EWL_COLOR_MODE_HSV_VALUE: - v = ewl_spinner_value_get(EWL_SPINNER(cp->spinners.hsv.v)) / 100.0; + v = ewl_range_value_get(EWL_RANGE(cp->spinners.hsv.v)) / 100.0; set_hsv = TRUE; break; @@ -734,13 +734,13 @@ DCHECK_PARAM_PTR("cp", cp); DCHECK_TYPE("cp", cp, EWL_COLORPICKER_TYPE); - ewl_spinner_value_set(EWL_SPINNER(cp->spinners.rgb.r), r); - ewl_spinner_value_set(EWL_SPINNER(cp->spinners.rgb.g), g); - ewl_spinner_value_set(EWL_SPINNER(cp->spinners.rgb.b), b); - - ewl_spinner_value_set(EWL_SPINNER(cp->spinners.hsv.h), h); - ewl_spinner_value_set(EWL_SPINNER(cp->spinners.hsv.s), s * 100); - ewl_spinner_value_set(EWL_SPINNER(cp->spinners.hsv.v), v * 100); + ewl_range_value_set(EWL_RANGE(cp->spinners.rgb.r), r); + ewl_range_value_set(EWL_RANGE(cp->spinners.rgb.g), g); + ewl_range_value_set(EWL_RANGE(cp->spinners.rgb.b), b); + + ewl_range_value_set(EWL_RANGE(cp->spinners.hsv.h), h); + ewl_range_value_set(EWL_RANGE(cp->spinners.hsv.s), s * 100); + ewl_range_value_set(EWL_RANGE(cp->spinners.hsv.v), v * 100); ewl_widget_color_set(cp->preview.current, r, g, b, 255); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_progressbar.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- ewl_progressbar.c 26 May 2006 18:17:19 -0000 1.9 +++ ewl_progressbar.c 11 Aug 2006 04:00:57 -0000 1.10 @@ -43,7 +43,7 @@ w = EWL_WIDGET(p); - if (!ewl_container_init(EWL_CONTAINER(w))) + if (!ewl_range_init(EWL_RANGE(w))) DRETURN_INT(FALSE, DLEVEL_STABLE); ewl_widget_appearance_set(w, EWL_PROGRESSBAR_TYPE); @@ -67,114 +67,21 @@ p->label = ewl_text_new(); ewl_text_text_set(EWL_TEXT(p->label), NULL); + ewl_widget_layer_priority_set(p->label, 1); ewl_object_alignment_set(EWL_OBJECT(p->label), EWL_FLAG_ALIGN_CENTER); ewl_container_child_append(EWL_CONTAINER(p), p->label); ewl_widget_show(p->label); - p->value = 0.0; - p->range = 100.0; p->auto_label = TRUE; ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_progressbar_configure_cb, NULL); + ewl_callback_append(w, EWL_CALLBACK_VALUE_CHANGED, + ewl_progressbar_value_changed_cb, NULL); DRETURN_INT(TRUE, DLEVEL_STABLE); } - -/** - * @param p: the progressbar whose value will be changed - * @param v: the new value of the statusbar - * @return Returns no value. - * @brief Set the value of the progressbars location - */ -void -ewl_progressbar_value_set(Ewl_Progressbar *p, double v) -{ - char c[10]; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("p", p); - DCHECK_TYPE("p", p, EWL_PROGRESSBAR_TYPE); - - if (v == p->value) - DRETURN(DLEVEL_STABLE); - - if (v < 0) v = 0; - - p->value = v; - if (p->auto_label) { - /* - * Do a precentage calculation as a default label. - */ - snprintf (c, sizeof (c), "%.0lf%%", (p->value / p->range) * 100); - ewl_text_text_set(EWL_TEXT(p->label), c); - } - - ewl_widget_configure(EWL_WIDGET(p)); - ewl_callback_call(EWL_WIDGET(p), EWL_CALLBACK_VALUE_CHANGED); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - - -/** - * @param p: the progressbars to retrieve the value - * @return Returns 0 on failure, the value of the progressbars location on success. - * @brief Retrieve the current value of the progressbars - */ -double -ewl_progressbar_value_get(Ewl_Progressbar *p) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("p", p, -1); - DCHECK_TYPE_RET("p", p, EWL_PROGRESSBAR_TYPE, -1); - - DRETURN_FLOAT(p->value, DLEVEL_STABLE); -} - -/** - * @param p: the progressbar whose range will be changed - * @param r: the new range of the statusbar - * @return Returns no value. - * @brief Set the range of the progressbar. Cannot be less then 1. - */ -void -ewl_progressbar_range_set(Ewl_Progressbar *p, double r) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("p", p); - DCHECK_TYPE("p", p, EWL_PROGRESSBAR_TYPE); - - if (r == p->range) - DRETURN(DLEVEL_STABLE); - - if (r < 1) - DRETURN(DLEVEL_STABLE); - - p->range = r; - - ewl_widget_configure(EWL_WIDGET(p)); - ewl_callback_call(EWL_WIDGET(p), EWL_CALLBACK_VALUE_CHANGED); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param p: the progressbars to retrieve the range - * @return Returns 0 on failure, the value of the progressbars location on success. - * @brief Retrieve the current range of the progressbars (default 100) - */ -double -ewl_progressbar_range_get(Ewl_Progressbar *p) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("p", p, -1); - DCHECK_TYPE_RET("p", p, EWL_PROGRESSBAR_TYPE, -1); - - DRETURN_FLOAT(p->range, DLEVEL_STABLE); -} - /** * @param p: the progressbars whose text will be changed * @param label: the new label @@ -205,6 +112,7 @@ void ewl_progressbar_custom_label_set(Ewl_Progressbar *p, char *format_string) { + Ewl_Range *r; char label[PATH_MAX]; DENTER_FUNCTION(DLEVEL_STABLE); @@ -212,9 +120,10 @@ DCHECK_TYPE("p", p, EWL_PROGRESSBAR_TYPE); p->auto_label = FALSE; + r = EWL_RANGE(p); if (format_string) { - snprintf (label, PATH_MAX, format_string, p->value, p->range); + snprintf (label, PATH_MAX, format_string, r->value, r->max_val); ewl_text_text_set(EWL_TEXT(p->label), label); } @@ -271,25 +180,67 @@ void *user_data __UNUSED__) { Ewl_Progressbar *p; + Ewl_Range *r; int dx, dy; - int dw, dh; + int dw; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); p = EWL_PROGRESSBAR(w); + r = EWL_RANGE(p); dx = CURRENT_X(p); dy = CURRENT_Y(p); dw = CURRENT_W(p); - dh = CURRENT_H(p); - - ewl_object_geometry_request(EWL_OBJECT(p->bar), dx, dy, - dw * (p->value / p->range), dh); + + dw = dw * (r->value - r->min_val) / (r->max_val - r->min_val); + + if (r->invert){ + dx += CURRENT_W(p) - dw; + } + + ewl_object_geometry_request(EWL_OBJECT(p->bar), dx, CURRENT_Y(p), + dw, CURRENT_H(p)); + ewl_object_place (EWL_OBJECT(p->label), CURRENT_X(p),CURRENT_Y(p), + CURRENT_W(p), CURRENT_H(p)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} - ewl_object_place (EWL_OBJECT(p->label), dx, dy, dw, dh); +/** + * @internal + * @param w: The widget to work with + * @param ev_data: UNUSED + * @param user_data: UNUSED + * @return Returns no value + * @brief the value changed callback + */ +void +ewl_progressbar_value_changed_cb(Ewl_Widget *w, void *ev_data __UNUSED__, + void *user_data __UNUSED__) +{ + Ewl_Progressbar *p; + Ewl_Range *r; + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); + + p = EWL_PROGRESSBAR(w); + r = EWL_RANGE(p); + + if (p->auto_label) { + char c[10]; + /* + * Do a precentage calculation as a default label. + */ + snprintf (c, sizeof (c), "%.0lf%%", (r->value / + (r->max_val - r->min_val)) * 100); + ewl_text_text_set(EWL_TEXT(p->label), c); + } + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -297,23 +248,24 @@ ewl_progressbar_child_handle(Ewl_Container *c, Ewl_Widget *w __UNUSED__) { - Ewl_Progressbar *p; + Ewl_Range *r; double value; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("c", c); DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE); - p = EWL_PROGRESSBAR(c); - value = p->value / p->range; + r = EWL_RANGE(c); + value = r->value / (r->max_val - r->min_val); if (value < 0.01) value = 0.01; - ewl_object_preferred_inner_w_set (EWL_OBJECT(p), - ewl_object_preferred_w_get (EWL_OBJECT(p->bar)) / value); + ewl_object_preferred_inner_w_set (EWL_OBJECT(c), + ewl_object_preferred_w_get( + EWL_OBJECT(EWL_PROGRESSBAR(c)->bar)) / value); - ewl_container_largest_prefer (EWL_CONTAINER (c), + ewl_container_largest_prefer(EWL_CONTAINER(c), EWL_ORIENTATION_VERTICAL); DLEAVE_FUNCTION(DLEVEL_STABLE); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_progressbar.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- ewl_progressbar.h 15 Mar 2006 04:03:48 -0000 1.9 +++ ewl_progressbar.h 11 Aug 2006 04:00:57 -0000 1.10 @@ -33,16 +33,14 @@ #define EWL_PROGRESSBAR(progressbar) ((Ewl_Progressbar *) progressbar) /** - * Inherits from Ewl_Container and creates an internal Ewl_Widget, the + * Inherits from Ewl_Range and creates an internal Ewl_Widget, the * statusbar itself. */ struct Ewl_Progressbar { - Ewl_Container container; /**< Inherit from Ewl_Container */ + Ewl_Range range; /**< Inherit from Ewl_Range */ Ewl_Widget *bar; /**< The moving bar on top */ Ewl_Widget *label; /**< text label on the bar */ - double value; /**< current value of the progressbar */ - double range; /**< the maximum range of the progressbar */ int auto_label; /**< flag if user is setting label or not */ }; @@ -50,12 +48,6 @@ Ewl_Widget *ewl_progressbar_new(void); int ewl_progressbar_init(Ewl_Progressbar *p); -void ewl_progressbar_value_set(Ewl_Progressbar *p, double v); -double ewl_progressbar_value_get(Ewl_Progressbar *p); - -void ewl_progressbar_range_set(Ewl_Progressbar *p, double r); -double ewl_progressbar_range_get(Ewl_Progressbar *p); - void ewl_progressbar_label_set(Ewl_Progressbar *p, char *label); void ewl_progressbar_custom_label_set(Ewl_Progressbar *p, char *format_string); @@ -67,6 +59,8 @@ * Internally used callbacks, override at your own risk. */ void ewl_progressbar_configure_cb(Ewl_Widget *w, void *ev_data, + void *user_data); +void ewl_progressbar_value_changed_cb(Ewl_Widget *w, void *ev_data, void *user_data); void ewl_progressbar_child_show_cb(Ewl_Container *c, Ewl_Widget *w); void ewl_progressbar_child_resize_cb(Ewl_Container *c, Ewl_Widget *w, int size, =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_scrollbar.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- ewl_scrollbar.c 26 May 2006 18:17:19 -0000 1.12 +++ ewl_scrollbar.c 11 Aug 2006 04:00:57 -0000 1.13 @@ -173,8 +173,8 @@ * Define the maximum value that the seeker can reach, and the * default increments it takes to get there. */ - ewl_seeker_range_set(EWL_SEEKER(s->seeker), 1.0); - ewl_seeker_step_set(EWL_SEEKER(s->seeker), 0.05); + ewl_range_max_val_set(EWL_RANGE(s->seeker), 1.0); + ewl_range_step_set(EWL_RANGE(s->seeker), 0.05); /* * Set the appearance strings for the parts of the scrollbar @@ -210,7 +210,7 @@ /* * Set the default value to the beginning of the seeker. */ - ewl_seeker_value_set(EWL_SEEKER(s->seeker), 0); + ewl_range_value_set(EWL_RANGE(s->seeker), 0.0); DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -402,7 +402,7 @@ DCHECK_PARAM_PTR_RET("s", s, -1); DCHECK_TYPE_RET("s", s, EWL_SCROLLBAR_TYPE, -1); - v = ewl_seeker_value_get(EWL_SEEKER(s->seeker)); + v = ewl_range_value_get(EWL_RANGE(s->seeker)); /* if (EWL_BOX(s)->orientation == EWL_ORIENTATION_VERTICAL) @@ -427,7 +427,7 @@ DCHECK_PARAM_PTR("s", s); DCHECK_TYPE("s", s, EWL_SCROLLBAR_TYPE); - ewl_seeker_value_set(EWL_SEEKER(s->seeker), v); + ewl_range_value_set(EWL_RANGE(s->seeker), v); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -444,7 +444,7 @@ DCHECK_PARAM_PTR_RET("s", s, 0); DCHECK_TYPE_RET("s", s, EWL_SCROLLBAR_TYPE, 0); - DRETURN_INT(ewl_seeker_step_get(EWL_SEEKER(s->seeker)), DLEVEL_STABLE); + DRETURN_INT(ewl_range_step_get(EWL_RANGE(s->seeker)), DLEVEL_STABLE); } /** @@ -462,7 +462,7 @@ DCHECK_PARAM_PTR("s", s); DCHECK_TYPE("s", s, EWL_SCROLLBAR_TYPE); - ewl_seeker_step_set(EWL_SEEKER(s->seeker), v); + ewl_range_step_set(EWL_RANGE(s->seeker), v); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -548,7 +548,7 @@ s = EWL_SCROLLBAR(data); dt = ecore_time_get() - s->start_time; - value = ewl_seeker_value_get(EWL_SEEKER(s->seeker)); + value = ewl_range_value_get(EWL_RANGE(s->seeker)); /* * Check the theme for a velocity setting and bring it within normal @@ -567,7 +567,7 @@ value += (double)(s->direction) * 10 * (1 - exp(-dt)) * ((double)(velocity) / 100.0); - ewl_seeker_value_set(EWL_SEEKER(s->seeker), value); + ewl_range_value_set(EWL_RANGE(s->seeker), value); DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_seeker.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- ewl_seeker.c 3 Jun 2006 16:18:11 -0000 1.18 +++ ewl_seeker.c 11 Aug 2006 04:00:57 -0000 1.19 @@ -87,7 +87,7 @@ w = EWL_WIDGET(s); - if (!ewl_container_init(EWL_CONTAINER(w))) + if (!ewl_range_init(EWL_RANGE(w))) DRETURN_INT(FALSE, DLEVEL_STABLE); /* @@ -111,12 +111,9 @@ ewl_widget_appearance_set(s->button, "hbutton"); /* - * Set the starting orientation, range and values + * Set the starting orientation */ s->orientation = EWL_ORIENTATION_HORIZONTAL; - s->range = 100.0; - s->value = 0.0; - s->step = 10.0; /* * Add necessary configuration callbacks @@ -201,130 +198,6 @@ } /** - * - * @param s: the seeker whose value will be changed - * @param v: the new value of the locator, checked against the valid range - * @return Returns no value. - * @brief Set the value of pointer of the seekers locator - */ -void -ewl_seeker_value_set(Ewl_Seeker *s, double v) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SEEKER_TYPE); - - if (v == s->value) - DRETURN(DLEVEL_STABLE); - - if (v < 0) v = 0; - if (v > s->range) v = s->range; - - s->value = v; - - ewl_widget_configure(EWL_WIDGET(s)); - ewl_callback_call(EWL_WIDGET(s), EWL_CALLBACK_VALUE_CHANGED); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - - -/** - * @param s: the seekers to retrieve the value - * @return Returns 0 on failure, the value of the seekers locator on success. - * @brief Retrieve the current value of the seekers locator - */ -double -ewl_seeker_value_get(Ewl_Seeker *s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("s", s, -1); - DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, -1); - - DRETURN_FLOAT(s->value, DLEVEL_STABLE); -} - -/** - * @param s: the seeker to change the range - * @param r: the largest bound on the range of the seekers value - * @return Returns no value. - * @brief specify the range of values represented by the seeker - */ -void -ewl_seeker_range_set(Ewl_Seeker *s, double r) -{ - int new_val; - - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SEEKER_TYPE); - - new_val = r * (s->value / s->range); - - s->range = r; - s->value = new_val; - - ewl_widget_configure(EWL_WIDGET(s)); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param s: the seeker to return the range of values - * @return Returns 0 on failure, or the upper bound on the seeker on success. - * @brief Retrieve the range of values represented by the seeker - */ -double -ewl_seeker_range_get(Ewl_Seeker *s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("s", s, -1); - DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, -1); - - DRETURN_FLOAT(s->range, DLEVEL_STABLE); -} - -/** - * @param s: the seeker to change step - * @param step: the new step value for the seeker - * @return Returns no value. - * @brief Set the steps between increments - * - * Changes the amount that each increment or decrement changes the value of the - * seeker @a s. - */ -void -ewl_seeker_step_set(Ewl_Seeker *s, double step) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SEEKER_TYPE); - - if (step > s->range) - step = s->range; - - s->step = step; - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param s: the seeker to retrieve step size - * @return Returns the step size of the seeker @a s. - * @brief Retrieve the step size of the seeker - */ -double -ewl_seeker_step_get(Ewl_Seeker *s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("s", s, -1); - DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, -1); - - DLEAVE_FUNCTION(DLEVEL_STABLE); - DRETURN_FLOAT(s->step, DLEVEL_STABLE); -} - -/** * @param s: the seeker to change autohide * @param v: the new boolean value for autohiding * @return Returns no value. @@ -371,99 +244,7 @@ DRETURN_INT(abs(s->autohide), DLEVEL_STABLE); } - -/** - * @param s: the seeker to set invert property - * @param invert: the new value for the seekers invert property - * @return Returns no value. - * @brief Changes the invert property on the seeker for inverting it's scale. - */ -void -ewl_seeker_invert_set(Ewl_Seeker *s, int invert) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SEEKER_TYPE); - - if (s->invert != invert) { - s->invert = invert; - ewl_widget_configure(EWL_WIDGET(s)); - } - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param s: the seeker to retrieve invert property value - * @return Returns the current value of the invert property in the seeker. - * @brief Retrieve the current invert value from a seeker. - */ -int -ewl_seeker_invert_get(Ewl_Seeker *s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("s", s, FALSE); - DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, FALSE); - - DRETURN_INT(s->invert, DLEVEL_STABLE); -} - -/** - * @param s: the seeker to increase - * @return Returns no value. - * @brief Increase the value of a seeker by it's step size - * - * Increases the value of the seeker @a s by one increment of it's step size. - */ -void -ewl_seeker_increase(Ewl_Seeker *s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SEEKER_TYPE); - - s->value += s->step; - - if (s->value > s->range) - s->value = s->range; - else if (s->value < 0.0) - s->value = 0.0; - - ewl_widget_configure(EWL_WIDGET(s)); - - ewl_callback_call(EWL_WIDGET(s), EWL_CALLBACK_VALUE_CHANGED); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param s: the seeker to decrease - * @return Returns no value. - * @brief Decrease the value of a seeker by it's step size - * - * Decreases the value of the seeker @a s by one increment of it's step size. - */ -void -ewl_seeker_decrease(Ewl_Seeker *s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SEEKER_TYPE); - - s->value -= s->step; - - if (s->value > s->range) - s->value = s->range; - else if (s->value < 0.0) - s->value = 0.0; - - ewl_widget_configure(EWL_WIDGET(s)); - - ewl_callback_call(EWL_WIDGET(s), EWL_CALLBACK_VALUE_CHANGED); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - + /** * @internal * @param w: The widget to work with @@ -479,7 +260,9 @@ void *user_data __UNUSED__) { Ewl_Seeker *s; + Ewl_Range *r; double s1, s2; + double range; int dx, dy; int dw, dh; int nw, nh; @@ -489,6 +272,8 @@ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); s = EWL_SEEKER(w); + r = EWL_RANGE(w); + if (!s->button) DRETURN(DLEVEL_STABLE); @@ -496,22 +281,23 @@ dy = CURRENT_Y(s); dw = CURRENT_W(s); dh = CURRENT_H(s); - + + range = r->max_val - r->min_val; /* * First determine the size based on the number of steps to span from * min to max values. Then reduce the total scale to keep the button on * the seeker, then position the button. */ - s1 = s->step / s->range; + s1 = r->step / range; if (s->autohide && s1 >= 1.0) { ewl_widget_hide(w); s->autohide = -abs(s->autohide); } - if (s->invert) - s2 = (s->range - s->value) / s->range; + if (r->invert) + s2 = (r->max_val - r->value) / range; else - s2 = s->value / s->range; + s2 = (r->value - r->min_val) / range; if (s->orientation == EWL_ORIENTATION_VERTICAL) { dh *= s1; @@ -609,6 +395,7 @@ { Ewl_Event_Mouse_Move *ev; Ewl_Seeker *s; + Ewl_Range *r; double scale; DENTER_FUNCTION(DLEVEL_STABLE); @@ -617,8 +404,9 @@ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); s = EWL_SEEKER(w); + r = EWL_RANGE(w); - if (s->step == s->range) + if (r->step == r->max_val - r->min_val) DRETURN(DLEVEL_STABLE); ev = ev_data; @@ -645,7 +433,7 @@ scale = ewl_seeker_mouse_value_map(s, ev->x, ev->y); - ewl_seeker_value_set(s, scale); + ewl_range_value_set(r, scale); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -664,6 +452,7 @@ void *user_data __UNUSED__) { Ewl_Seeker *s; + Ewl_Range *r; Ewl_Event_Mouse_Down *ev; double value, step = 0; int xx, yy, ww, hh; @@ -675,6 +464,7 @@ ev = ev_data; s = EWL_SEEKER(w); + r = EWL_RANGE(w); if (ewl_object_state_has(EWL_OBJECT(s->button), EWL_FLAG_STATE_PRESSED)) DRETURN(DLEVEL_STABLE); @@ -682,7 +472,7 @@ ewl_object_current_geometry_get(EWL_OBJECT(s->button), &xx, &yy, &ww, &hh); - value = s->value; + value = r->value; /* * Increment or decrement the value based on the position of the click @@ -691,25 +481,25 @@ if (s->orientation == EWL_ORIENTATION_HORIZONTAL) { s->dragstart = ev->x; if (ev->x < xx) { - step = -s->step; + step = -r->step; } else if (ev->x > xx + ww) { - step = s->step; + step = r->step; } } else { s->dragstart = ev->y; if (ev->y < yy) - step = -s->step; + step = -r->step; else if (ev->y > yy + hh) - step = s->step; + step = r->step; } - if (s->invert) + if (r->invert) step = -step; value += step; - ewl_seeker_value_set(s, value); + ewl_range_value_set(r, value); s->start_time = ecore_time_get(); s->timer = ecore_timer_add(0.5, ewl_seeker_timer, s); @@ -757,12 +547,12 @@ ewl_seeker_key_down_cb(Ewl_Widget *w, void *ev_data, void *user_data __UNUSED__) { - Ewl_Seeker *s; + Ewl_Range *r; Ewl_Event_Key_Down *ev; double start, end; - void (*increase)(Ewl_Seeker *s); - void (*decrease)(Ewl_Seeker *s); + void (*increase)(Ewl_Range *r); + void (*decrease)(Ewl_Range *r); DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); @@ -770,35 +560,35 @@ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); ev = ev_data; - s = EWL_SEEKER(w); + r = EWL_RANGE(w); - if (!s->invert) { - increase = ewl_seeker_increase; - decrease = ewl_seeker_decrease; - start = 0.0; - end = s->range; + if (!r->invert) { + increase = ewl_range_increase; + decrease = ewl_range_decrease; + start = r->min_val; + end = r->max_val; } else { - increase = ewl_seeker_decrease; - decrease = ewl_seeker_increase; - start = s->range; - end = 0.0; + increase = ewl_range_decrease; + decrease = ewl_range_increase; + start = r->max_val; + end = r->min_val; } if (!strcmp(ev->keyname, "Home")) - ewl_seeker_value_set(s, start); + ewl_range_value_set(r, start); else if (!strcmp(ev->keyname, "End")) - ewl_seeker_value_set(s, end); + ewl_range_value_set(r, end); else if (!strcmp(ev->keyname, "Left") || !strcmp(ev->keyname, "KP_Left") || !strcmp(ev->keyname, "Up") || !strcmp(ev->keyname, "KP_Up")) - decrease(s); + decrease(r); else if (!strcmp(ev->keyname, "Right") || !strcmp(ev->keyname, "KP_Right") || !strcmp(ev->keyname, "Down") || !strcmp(ev->keyname, "KP_Down")) - increase(s); + increase(r); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -814,7 +604,7 @@ ewl_seeker_child_show_cb(Ewl_Container *p, Ewl_Widget *w) { int pw, ph; - Ewl_Seeker *s; + Ewl_Range *r; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("p", p); @@ -822,15 +612,15 @@ DCHECK_TYPE("p", p, EWL_CONTAINER_TYPE); DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); - s = EWL_SEEKER(p); + r = EWL_RANGE(p); pw = ewl_object_preferred_w_get(EWL_OBJECT(w)); ph = ewl_object_preferred_h_get(EWL_OBJECT(w)); - if (s->orientation == EWL_ORIENTATION_HORIZONTAL) - pw *= s->range / s->step; + if (EWL_SEEKER(r)->orientation == EWL_ORIENTATION_HORIZONTAL) + pw *= (r->max_val - r->min_val) / r->step; else - ph *= s->range / s->step; + ph *= (r->max_val - r->min_val) / r->step; ewl_object_preferred_inner_size_set(EWL_OBJECT(p), pw, ph); @@ -840,6 +630,7 @@ static double ewl_seeker_mouse_value_map(Ewl_Seeker *s, int mx, int my) { + Ewl_Range *r; int m; int dc, dg; int adjust; @@ -849,6 +640,8 @@ DCHECK_PARAM_PTR_RET("s", s, 0.0); DCHECK_TYPE_RET("s", s, EWL_SEEKER_TYPE, 0.0); + r = EWL_RANGE(s); + if (s->orientation == EWL_ORIENTATION_HORIZONTAL) { m = mx; @@ -888,9 +681,12 @@ /* * Calculate the new value based on the range, sizes and new position. */ - scale = s->range * (double)(m - dc) / (double)dg; - if (s->invert) - scale = s->range - scale; + scale = (r->max_val - r->min_val) * (double)(m - dc) / (double)dg; + + if (!r->invert) + scale = r->min_val + scale; + else + scale = r->max_val - scale; DRETURN_FLOAT(scale, DLEVEL_STABLE); } @@ -899,41 +695,43 @@ ewl_seeker_timer(void *data) { Ewl_Seeker *s; - double value, posval; + double value, posval, step; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("data", data, FALSE); DCHECK_TYPE_RET("data", data, EWL_SEEKER_TYPE, FALSE); s = EWL_SEEKER(data); - value = ewl_seeker_value_get(s); + value = ewl_range_value_get(EWL_RANGE(s)); + step = ewl_range_step_get(EWL_RANGE(s)); /* * Find the value based on mouse position */ - posval = ewl_seeker_mouse_value_map(s, s->dragstart, s->dragstart); + posval = ewl_seeker_mouse_value_map(s, s->dragstart * 2, + s->dragstart * 2); /* * Limit the value to the intersection with the mouse. */ if (posval > value) { - if (value + s->step > posval) { + if (value + step > posval) { value = posval; } else { - value += s->step; + value += step; } } else { - if (value - s->step < posval) { + if (value - step < posval) { value = posval; } else { - value -= s->step; + value -= step; } } - ewl_seeker_value_set(EWL_SEEKER(s), value); + ewl_range_value_set(EWL_RANGE(s), value); DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_seeker.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- ewl_seeker.h 3 Jun 2006 16:18:11 -0000 1.12 +++ ewl_seeker.h 11 Aug 2006 04:00:57 -0000 1.13 @@ -40,13 +40,9 @@ */ struct Ewl_Seeker { - Ewl_Container container; /**< Inherit from Ewl_Container */ + Ewl_Range range; /**< Inherit from Ewl_Range */ Ewl_Orientation orientation; /**< Indicates layout direction */ Ewl_Widget *button; /**< Draggable widget for selecting value */ - double value; /**< Currently chosen value */ - double range; /**< Total selectable range */ - double step; /**< Size of increments in the range */ - int invert; /**< Invert the axis */ int dragstart; /**< The coordinate where the drag starts */ int autohide; /**< Indicator to hide when not scrollable */ Ecore_Timer *timer; /**< Timer for scroll repeating */ @@ -61,23 +57,8 @@ void ewl_seeker_orientation_set(Ewl_Seeker *s, Ewl_Orientation o); Ewl_Orientation ewl_seeker_orientation_get(Ewl_Seeker *s); -void ewl_seeker_value_set(Ewl_Seeker *s, double v); -double ewl_seeker_value_get(Ewl_Seeker *s); - -void ewl_seeker_range_set(Ewl_Seeker *s, double r); -double ewl_seeker_range_get(Ewl_Seeker *s); - -void ewl_seeker_step_set(Ewl_Seeker *s, double step); -double ewl_seeker_step_get(Ewl_Seeker *s); - void ewl_seeker_autohide_set(Ewl_Seeker *s, int v); int ewl_seeker_autohide_get(Ewl_Seeker *s); - -void ewl_seeker_invert_set(Ewl_Seeker *s, int invert); -int ewl_seeker_invert_get(Ewl_Seeker *s); - -void ewl_seeker_decrease(Ewl_Seeker *s); -void ewl_seeker_increase(Ewl_Seeker *s); /* * Internally used callbacks, override at your own risk. =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- ewl_spinner.c 10 Jul 2006 21:13:33 -0000 1.18 +++ ewl_spinner.c 11 Aug 2006 04:00:57 -0000 1.19 @@ -3,7 +3,7 @@ #include "ewl_debug.h" #include "ewl_macros.h" -static void ewl_spinner_calc_value(Ewl_Spinner *s, double val, unsigned int call); +static void ewl_spinner_entry_update(Ewl_Spinner *s); static int ewl_spinner_timer(void *data); /** @@ -39,19 +39,18 @@ int ewl_spinner_init(Ewl_Spinner *s) { - Ewl_Widget *w, *vbox; + Ewl_Widget *w; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("s", s, FALSE); w = EWL_WIDGET(s); - if (!ewl_box_init(EWL_BOX(w))) + if (!ewl_range_init(EWL_RANGE(w))) { DRETURN_INT(FALSE, DLEVEL_STABLE); } - ewl_box_orientation_set(EWL_BOX(w), EWL_ORIENTATION_HORIZONTAL); ewl_widget_appearance_set(w, EWL_SPINNER_TYPE); ewl_widget_inherit(w, EWL_SPINNER_TYPE); @@ -60,9 +59,17 @@ ewl_callback_append(w, EWL_CALLBACK_REALIZE, ewl_spinner_realize_cb, NULL); + ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, + ewl_spinner_configure_cb, NULL); + ewl_callback_append(w, EWL_CALLBACK_VALUE_CHANGED, + ewl_spinner_value_changed_cb, NULL); ewl_callback_prepend(w, EWL_CALLBACK_DESTROY, ewl_spinner_destroy_cb, NULL); - + ewl_container_show_notify_set(EWL_CONTAINER(w), + ewl_spinner_child_show_cb); + ewl_container_resize_notify_set(EWL_CONTAINER(w), + ewl_spinner_child_resize_cb); + s->entry = ewl_entry_new(); ewl_text_text_set(EWL_TEXT(s->entry), "0"); ewl_container_child_append(EWL_CONTAINER(s), s->entry); @@ -83,15 +90,15 @@ ewl_widget_show(s->entry); - vbox = ewl_vbox_new(); - ewl_container_child_append(EWL_CONTAINER(s), vbox); - ewl_widget_appearance_set(vbox, "controls"); - ewl_widget_internal_set(vbox, TRUE); - ewl_object_fill_policy_set(EWL_OBJECT(vbox), EWL_FLAG_FILL_NONE); - ewl_widget_show(vbox); + s->vbox = ewl_vbox_new(); + ewl_container_child_append(EWL_CONTAINER(s), s->vbox); + ewl_widget_appearance_set(s->vbox, "controls"); + ewl_widget_internal_set(s->vbox, TRUE); + ewl_object_fill_policy_set(EWL_OBJECT(s->vbox), EWL_FLAG_FILL_NONE); + ewl_widget_show(s->vbox); s->increment = ewl_button_new(); - ewl_container_child_append(EWL_CONTAINER(vbox), s->increment); + ewl_container_child_append(EWL_CONTAINER(s->vbox), s->increment); ewl_object_alignment_set(EWL_OBJECT(s->increment), EWL_FLAG_ALIGN_CENTER); ewl_widget_appearance_set(s->increment, "increment"); @@ -107,7 +114,7 @@ ewl_widget_show(s->increment); s->decrement = ewl_button_new(); - ewl_container_child_append(EWL_CONTAINER(vbox), s->decrement); + ewl_container_child_append(EWL_CONTAINER(s->vbox), s->decrement); ewl_object_alignment_set(EWL_OBJECT(s->decrement), EWL_FLAG_ALIGN_CENTER); ewl_widget_appearance_set(s->decrement, "decrement"); @@ -122,51 +129,12 @@ ewl_spinner_key_down_cb, s); ewl_widget_show(s->decrement); - s->min_val = INT_MIN; - s->max_val = INT_MAX; - s->value = 0.0; - s->step = 0.1; s->digits = 2; DRETURN_INT(TRUE, DLEVEL_STABLE); } /** - * @param s: the spinner widget to set the current value - * @param value: the value to set for the spinner @a s - * @return Returns no value. - * @brief Set the current value of a spinner widget - * - * Sets the current value of the spinner @a s to @a value. - */ -void -ewl_spinner_value_set(Ewl_Spinner *s, double value) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SPINNER_TYPE); - - ewl_spinner_calc_value(s, value, FALSE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param s: the spinner widget to retrieve the value - * @return Returns the current value in @a s on success, 0.0 on failure. - * @brief Get the current value of a spinner widget - */ -double -ewl_spinner_value_get(Ewl_Spinner *s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("s", s, 0.00); - DCHECK_TYPE_RET("s", s, EWL_SPINNER_TYPE, 0.00); - - DRETURN_FLOAT(s->value, DLEVEL_STABLE); -} - -/** * @param s: the widget to change the number of digits displayed * @param digits: the number of digits to display for the spinner @a s * @return Returns no value. @@ -182,100 +150,55 @@ DCHECK_TYPE("s", s, EWL_SPINNER_TYPE); s->digits = digits; - ewl_spinner_calc_value(s, s->value, FALSE); + ewl_spinner_entry_update(s); DLEAVE_FUNCTION(DLEVEL_STABLE); } /** - * @param s: the spinner to retrieve minimum value - * @brief Retrieves the minimum value for the spinner. - * @return Returns the currently set minimum value for the specified spinner. - */ -double -ewl_spinner_min_val_get(Ewl_Spinner *s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("s", s, 0.0); - DCHECK_TYPE_RET("s", s, EWL_SPINNER_TYPE, 0.0); - - DRETURN_FLOAT(s->min_val, DLEVEL_STABLE); -} - -/** - * @param s: the spinner to change the minimum possible value - * @param val: the new minimum possible value for @a s - * @return Returns no value. - * @brief Set the minimum value possible for a spinner - * - * Sets the smallest value that @a s can obtain to @a val. + * @internal + * @param w: The widget to work with + * @param ev_data: UNUSED + * @param user_data: UNUSED + * @return Returns no value + * @brief The realize callback */ void -ewl_spinner_min_val_set(Ewl_Spinner *s, double val) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SPINNER_TYPE); - - s->min_val = val; - ewl_spinner_calc_value(s, s->value, FALSE); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param s: the spinner to retrieve maximum value - * @brief Retrieves the maximum value for the spinner. - * @return Returns the currently set maximum value for the specified spinner. - */ -double -ewl_spinner_max_val_get(Ewl_Spinner *s) +ewl_spinner_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__, + void *user_data __UNUSED__) { - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("s", s, 100.0); - DCHECK_TYPE_RET("s", s, EWL_SPINNER_TYPE, 100.0); - - DRETURN_FLOAT(s->max_val, DLEVEL_STABLE); -} + Ewl_Spinner *s; -/** - * @param s: the spinner to change the maximum possible value - * @param val: the new maximum possible value for @a s - * @return Returns no value. - * @brief Set the maximum value possible for a spinner - * - * Sets the largest value that @a s can obtain to @a val. - */ -void -ewl_spinner_max_val_set(Ewl_Spinner *s, double val) -{ DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SPINNER_TYPE); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); - s->max_val = val; - ewl_spinner_calc_value(s, s->value, FALSE); + s = EWL_SPINNER(w); + ewl_spinner_entry_update(s); DLEAVE_FUNCTION(DLEVEL_STABLE); } /** - * @param s: the spinner to change increment step - * @param step: the new increment between clicks of the spinner @a s - * @brief Returns no value. - * @brief Set the increment between each click of the spinner - * - * Changes the increment that @a s changes by with each click of it's spinner - * buttons to @a step. + * @internal + * @param w: The widget to work with + * @param ev_data: UNUSED + * @param user_data: UNUSED + * @return Returns no value + * @brief The value changed callback */ void -ewl_spinner_step_set(Ewl_Spinner *s, double step) +ewl_spinner_value_changed_cb(Ewl_Widget *w, void *ev_data __UNUSED__, + void *user_data __UNUSED__) { + Ewl_Spinner *s; + DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - DCHECK_TYPE("s", s, EWL_SPINNER_TYPE); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); - s->step = step; + s = EWL_SPINNER(w); + ewl_spinner_entry_update(s); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -286,21 +209,34 @@ * @param ev_data: UNUSED * @param user_data: UNUSED * @return Returns no value - * @brief The realize callback + * @brief The configure callback */ void -ewl_spinner_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__, +ewl_spinner_configure_cb(Ewl_Widget *w, void *ev_data __UNUSED__, void *user_data __UNUSED__) { Ewl_Spinner *s; + int cx, cy, cw, ch; + int pvw; /* the preferred w of the vbox */ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); s = EWL_SPINNER(w); - ewl_spinner_calc_value(s, s->value, FALSE); + cx = CURRENT_X(w); + cy = CURRENT_Y(w); + cw = CURRENT_W(w); + ch = CURRENT_H(w); + + pvw = ewl_object_preferred_w_get(EWL_OBJECT(s->vbox)); + + ewl_object_place(EWL_OBJECT(s->vbox), cx + cw - pvw, cy, pvw, + ch); + ewl_object_place(EWL_OBJECT(s->entry), cx, cy, cw - pvw, + ch); + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -392,7 +328,7 @@ if (str && strlen(str)) { val = atof(str); - ewl_spinner_calc_value(s, (double) (val), TRUE); + ewl_range_value_set(EWL_RANGE(s), (double) (val)); } else if (str) FREE(str); @@ -411,7 +347,7 @@ ewl_spinner_wheel_cb(Ewl_Widget *w, void *ev_data, void *user_data __UNUSED__) { - Ewl_Spinner *s; + Ewl_Range *r; Ewl_Event_Mouse_Wheel *wheel; DENTER_FUNCTION(DLEVEL_STABLE); @@ -419,45 +355,32 @@ DCHECK_PARAM_PTR("ev_data", ev_data); DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); - s = EWL_SPINNER(w); + r = EWL_RANGE(w); wheel = (Ewl_Event_Mouse_Wheel *)ev_data; - ewl_spinner_calc_value(s, s->value - (wheel->z * s->step), TRUE); + ewl_range_value_set(r, r->value - (wheel->z * r->step)); DLEAVE_FUNCTION(DLEVEL_STABLE); } static void -ewl_spinner_calc_value(Ewl_Spinner *s, double value, unsigned int call) +ewl_spinner_entry_update(Ewl_Spinner *s) { + Ewl_Range *r; char format[64]; char str[64]; - double oval; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("s", s); DCHECK_TYPE("s", s, EWL_SPINNER_TYPE); - oval = s->value; - - if (value < s->min_val) - s->value = s->min_val; - else if (value > s->max_val) - s->value = s->max_val; - else - s->value = value; + r = EWL_RANGE(s); snprintf(format, 64, "%%.%df", s->digits); - snprintf(str, 64, format, s->value); + snprintf(str, 64, format, r->value); ewl_text_text_set(EWL_TEXT(s->entry), str); - if ((call == TRUE) && (oval != s->value)) { - oval = s->value; - ewl_callback_call_with_event_data(EWL_WIDGET(s), - EWL_CALLBACK_VALUE_CHANGED, &oval); - } - DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -474,6 +397,7 @@ void *user_data) { Ewl_Spinner *s; + Ewl_Range *r; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); @@ -481,12 +405,16 @@ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); s = EWL_SPINNER(user_data); + r = EWL_RANGE(s); ewl_spinner_focus_out_cb(EWL_WIDGET(s), NULL, NULL); - - ewl_spinner_calc_value(s, s->value + s->step, TRUE); + + if (!r->invert) + ewl_range_increase(r); + else + ewl_range_decrease(r); if (ev_data) { - s->direction = 1; + s->direction = (!r->invert) ? 1 : -1; s->start_time = ecore_time_get(); s->timer = ecore_timer_add(0.02, ewl_spinner_timer, s); } @@ -506,7 +434,6 @@ ewl_spinner_value_stop_cb(Ewl_Widget *w __UNUSED__, void *ev_data __UNUSED__, void *user_data) { - double oval; Ewl_Spinner *s; DENTER_FUNCTION(DLEVEL_STABLE); @@ -521,10 +448,6 @@ s->start_time = 0; } - oval = s->value; - ewl_callback_call_with_event_data(EWL_WIDGET(s), - EWL_CALLBACK_VALUE_CHANGED, &oval); - DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -541,6 +464,7 @@ void *user_data) { Ewl_Spinner *s; + Ewl_Range *r; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); @@ -548,11 +472,17 @@ DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); s = EWL_SPINNER(user_data); + r = EWL_RANGE(s); + ewl_spinner_focus_out_cb(EWL_WIDGET(s), NULL, NULL); - ewl_spinner_calc_value(s, s->value - s->step, TRUE); + if (!r->invert) + ewl_range_decrease(r); + else + ewl_range_increase(r); + if (ev_data) { - s->direction = -1; + s->direction = (!r->invert) ? -1 : 1; s->start_time = ecore_time_get(); s->timer = ecore_timer_add(0.02, ewl_spinner_timer, s); } @@ -591,6 +521,7 @@ ewl_spinner_timer(void *data) { Ewl_Spinner *s; + Ewl_Range *r; double dt; double value, range, tmpt; int velocity, delay; @@ -599,10 +530,11 @@ DCHECK_PARAM_PTR_RET("data", data, FALSE); s = EWL_SPINNER(data); + r = EWL_RANGE(s); dt = ecore_time_get() - s->start_time; - value = ewl_spinner_value_get(s); - range = s->max_val - s->min_val; + value = r->value; + range = r->max_val - r->min_val; /* * Check the theme for a velocity setting and bring it within normal @@ -632,8 +564,79 @@ tmpt = ((1 - exp(-tmpt)) * ((double)(velocity) / 100.0)) * range; value += (double)(s->direction) * ((1 - exp(-dt)) + tmpt); - ewl_spinner_value_set(s, value); + ewl_range_value_set(r, value); DRETURN_INT(TRUE, DLEVEL_STABLE); +} + +static void +ewl_spinner_child_handle(Ewl_Container *c, + Ewl_Widget *w __UNUSED__) +{ + Ewl_Spinner *s; + int pvw, pvh, pew, peh; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("c", c); + DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE); + + s = EWL_SPINNER(c); + + pvw = ewl_object_preferred_w_get(EWL_OBJECT(s->vbox)); + pvh = ewl_object_preferred_h_get(EWL_OBJECT(s->vbox)); + + pew = ewl_object_preferred_w_get(EWL_OBJECT(s->entry)); + peh = ewl_object_preferred_h_get(EWL_OBJECT(s->entry)); + + ewl_object_preferred_inner_size_set(EWL_OBJECT(c), pvw + pew, + MAX(peh, pvh)); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param c: The container to work with + * @param w: The widget to work with + * @return Returns no value + * @brief The child show callback + */ +void +ewl_spinner_child_show_cb(Ewl_Container *c, Ewl_Widget *w) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("c", c); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); + + ewl_spinner_child_handle(c, w); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @internal + * @param c: The container to work with + * @param w: The widget to work with + * @param size: UNUSED + * @param o: UNUSED + * @return Returns no value + * @brief The child resize callback + */ +void +ewl_spinner_child_resize_cb(Ewl_Container *c, Ewl_Widget *w, + int size __UNUSED__, + Ewl_Orientation o __UNUSED__) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("c", c); + DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("c", c, EWL_CONTAINER_TYPE); + DCHECK_TYPE("w", w, EWL_WIDGET_TYPE); + + ewl_spinner_child_handle(c, w); + + DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- ewl_spinner.h 15 Mar 2006 04:03:48 -0000 1.10 +++ ewl_spinner.h 11 Aug 2006 04:00:57 -0000 1.11 @@ -33,18 +33,15 @@ #define EWL_SPINNER(spinner) ((Ewl_Spinner *) spinner) /** - * Inherits from Ewl_Box and adds an entry box that can only contain + * Inherits from Ewl_Range and adds an entry box that can only contain * numerical values as well as buttons for manipulating that value. */ struct Ewl_Spinner { - Ewl_Box box; /**< Inherit from Ewl_Box */ - double min_val; /**< Minimum numerical value displayed */ - double max_val; /**< Maximum numerical value displayed */ - double value; /**< Current value displayed */ - double step; /**< Amount to add or subtract at a time */ + Ewl_Range range; /**< Inherit from Ewl_Range */ int digits; /**< Number of digits displayed after decimal */ Ewl_Widget *entry; /**< The Ewl_Entry displaying value */ + Ewl_Widget *vbox; /**< Ewl_Box to hold the buttons */ Ewl_Widget *increment; /**< Ewl_Button to add value */ Ewl_Widget *decrement; /**< Ewl_Button to subtract value */ double start_time; /**< Time the spinner was pressed */ @@ -54,20 +51,17 @@ Ewl_Widget *ewl_spinner_new(void); int ewl_spinner_init(Ewl_Spinner *s); -void ewl_spinner_value_set(Ewl_Spinner *s, double value); -double ewl_spinner_value_get(Ewl_Spinner *s); void ewl_spinner_digits_set(Ewl_Spinner *s, unsigned char digits); -double ewl_spinner_min_val_get(Ewl_Spinner *s); -void ewl_spinner_min_val_set(Ewl_Spinner *s, double val); -double ewl_spinner_max_val_get(Ewl_Spinner *s); -void ewl_spinner_max_val_set(Ewl_Spinner *s, double val); -void ewl_spinner_step_set(Ewl_Spinner *s, double step); /* * Internally used callbacks, override at your own risk. */ void ewl_spinner_realize_cb(Ewl_Widget *widget, void *ev_data, void *user_data); +void ewl_spinner_value_changed_cb(Ewl_Widget *widget, void *ev_data, + void *user_data); +void ewl_spinner_configure_cb(Ewl_Widget *widget, void *ev_data, + void *user_data); void ewl_spinner_key_down_cb(Ewl_Widget *widget, void *ev_data, void *user_data); void ewl_spinner_focus_out_cb(Ewl_Widget *w, void *ev_data, @@ -81,7 +75,9 @@ void *user_data); void ewl_spinner_value_stop_cb(Ewl_Widget *w, void *ev_data, void *user_data); void ewl_spinner_destroy_cb(Ewl_Widget *w, void *ev_data, void *user_data); - +void ewl_spinner_child_show_cb(Ewl_Container *c, Ewl_Widget *w); +void ewl_spinner_child_resize_cb(Ewl_Container *c, Ewl_Widget *w, int size, + Ewl_Orientation o); /** * @} */ |
From: Enlightenment C. <no...@cv...> - 2006-08-10 23:01:31
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/bin Modified Files: main.c Log Message: **API-BREAK** - add ewl_range a new abstract widget to unify the api of seeker, spinner and progressbar - NOTE this breaks colorpicker hopefully for a short time =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/main.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- main.c 12 Jul 2006 10:46:01 -0000 1.30 +++ main.c 11 Aug 2006 04:00:57 -0000 1.31 @@ -141,7 +141,7 @@ entries[2] = (val ? "" : buf); ewl_tree_text_row_add(EWL_TREE(tree), NULL, entries); - ewl_progressbar_value_set(EWL_PROGRESSBAR(progress), + ewl_range_value_set(EWL_RANGE(progress), (double)(++current_unit_test)); } else @@ -561,8 +561,8 @@ } progress = ewl_widget_name_find("unit_test_progress"); - ewl_progressbar_range_set(EWL_PROGRESSBAR(progress), (double)(i)); - ewl_progressbar_value_set(EWL_PROGRESSBAR(progress), 0.0); + ewl_range_max_val_set(EWL_RANGE(progress), (double)(i)); + ewl_range_value_set(EWL_RANGE(progress), 0.0); } @@ -585,8 +585,8 @@ ; progress = ewl_widget_name_find("unit_test_progress"); - ewl_progressbar_range_set(EWL_PROGRESSBAR(progress), (double)(i)); - ewl_progressbar_value_set(EWL_PROGRESSBAR(progress), 0.0); + ewl_range_max_val_set(EWL_RANGE(progress), (double)(i)); + ewl_range_value_set(EWL_RANGE(progress), 0.0); if (unit_test_timer) { |
From: Enlightenment C. <no...@cv...> - 2006-08-10 23:01:31
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/bin/tests Modified Files: ewl_media.c ewl_progressbar.c ewl_seeker.c ewl_spinner.c ewl_text_editor.c ewl_theme.c Log Message: **API-BREAK** - add ewl_range a new abstract widget to unify the api of seeker, spinner and progressbar - NOTE this breaks colorpicker hopefully for a short time =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/ewl_media.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_media.c 13 Jul 2006 19:43:24 -0000 1.6 +++ ewl_media.c 11 Aug 2006 04:00:57 -0000 1.7 @@ -160,7 +160,7 @@ t = data; pos = ewl_media_position_get(EWL_MEDIA(video)); - ewl_seeker_value_set(EWL_SEEKER(seeker), pos); + ewl_range_value_set(EWL_RANGE(seeker), pos); ewl_media_position_time_get(EWL_MEDIA(video), &h, &m, &s); snprintf(buf, sizeof(buf), "%02i:%02i:%02.0f", h, m, s); ewl_text_text_set(t, buf); @@ -172,7 +172,7 @@ { double val; - val = ewl_seeker_value_get(EWL_SEEKER(seeker)); + val = ewl_range_value_get(EWL_RANGE(seeker)); if (ewl_media_seekable_get(EWL_MEDIA(video))) ewl_media_position_set(EWL_MEDIA(video), val); } @@ -200,7 +200,7 @@ if (file) free(file); len = ewl_media_length_get(EWL_MEDIA(video)); - ewl_seeker_range_set(EWL_SEEKER(seeker), len); + ew_range_max_value_set(EWL_RANGE(seeker), len); } } @@ -308,9 +308,9 @@ ewl_container_child_append(EWL_CONTAINER(b), seeker); ewl_object_fill_policy_set(EWL_OBJECT(seeker), EWL_FLAG_FILL_VSHRINK | EWL_FLAG_FILL_HFILL); - ewl_seeker_value_set(EWL_SEEKER(seeker), 0.0); - ewl_seeker_range_set(EWL_SEEKER(seeker), 0.0); - ewl_seeker_step_set(EWL_SEEKER(seeker), 1.0); + ewl_range_value_set(EWL_RANGE(seeker), 0.0); + ewl_range_max_value_set(EWL_RANGE(seeker), 0.0); + ewl_range_step_set(EWL_RANGE(seeker), 1.0); ewl_callback_append(seeker, EWL_CALLBACK_VALUE_CHANGED, seeker_move_cb, video); ewl_widget_show(seeker); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/ewl_progressbar.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- ewl_progressbar.c 13 Jul 2006 19:43:24 -0000 1.4 +++ ewl_progressbar.c 11 Aug 2006 04:00:57 -0000 1.5 @@ -48,8 +48,10 @@ */ for (i = 0; i < 2; i++) { progressbar[i] = ewl_progressbar_new(); - ewl_progressbar_value_set (EWL_PROGRESSBAR(progressbar[i]), 0); - ewl_widget_show (progressbar[i]); + if (i == 0) + ewl_range_invert_set(EWL_RANGE(progressbar[0]), TRUE); + ewl_range_value_set(EWL_RANGE(progressbar[i]), 0); + ewl_widget_show(progressbar[i]); progress_timer[i] = ecore_timer_add(0.1, cb_increment_progress, (Ewl_Progressbar *) progressbar[i]); @@ -62,8 +64,8 @@ * Third big progressbar */ progressbar[2] = ewl_progressbar_new(); - ewl_progressbar_value_set (EWL_PROGRESSBAR(progressbar[2]), 0); - ewl_widget_show (progressbar[2]); + ewl_range_value_set(EWL_RANGE(progressbar[2]), 0); + ewl_widget_show(progressbar[2]); progress_timer[2] = ecore_timer_add(0.1, cb_increment_progress, (Ewl_Progressbar *) progressbar[2]); @@ -105,12 +107,12 @@ double val, value, range; char c[30]; int i; - Ewl_Progressbar *p; + Ewl_Range *r; - p = EWL_PROGRESSBAR(data); - val = ewl_progressbar_value_get(p); + r = EWL_RANGE(data); + val = ewl_range_value_get(r); - if (val >= p->range) { + if (val >= r->max_val) { for (i = 0; i < 3; i++) { if (progress_timer[i]) { ecore_timer_del(progress_timer[i]); @@ -121,27 +123,26 @@ } val += 1; - ewl_progressbar_value_set(p, val); - + ewl_range_value_set(r, val); if (val >= 20 && val < 35 ) { - ewl_progressbar_custom_label_set (p, + ewl_progressbar_custom_label_set(EWL_PROGRESSBAR(r), "%.0lf / %.0lf kbytes"); } if (val >= 35 && val < 60) { - value = ewl_progressbar_value_get (p); - range = ewl_progressbar_range_get (p); + value = ewl_range_value_get(r); + range = ewl_range_max_val_get(r); - snprintf (c, sizeof (c), "%.0lf of %.0lf beers", value, range); - ewl_progressbar_label_set (p, c); + snprintf(c, sizeof (c), "%.0lf of %.0lf beers", value, range); + ewl_progressbar_label_set(EWL_PROGRESSBAR(r), c); } if (val == 60) - ewl_progressbar_label_hide (p); + ewl_progressbar_label_hide(EWL_PROGRESSBAR(r)); if (val == 70) - ewl_progressbar_label_show (p); + ewl_progressbar_label_show(EWL_PROGRESSBAR(r)); return 1; } @@ -170,9 +171,9 @@ printf ("New random value: %d\n", j); for (i = 0; i < 3; i++) { - ewl_progressbar_range_set(EWL_PROGRESSBAR(progressbar[i]), j); + ewl_range_max_val_set(EWL_RANGE(progressbar[i]), j); - if (ewl_progressbar_value_get(EWL_PROGRESSBAR(progressbar[i])) >= j) + if (ewl_range_value_get(EWL_RANGE(progressbar[i])) >= j) cb_rerun_progressbars(EWL_WIDGET (progressbar[i]), NULL, NULL); } @@ -191,7 +192,7 @@ * (since the auto label is turned off when you label manually) */ ewl_progressbar_label_show (EWL_PROGRESSBAR (progressbar[i])); - ewl_progressbar_value_set (EWL_PROGRESSBAR (progressbar[i]), 0); + ewl_range_value_set(EWL_RANGE(progressbar[i]), 0); if (progress_timer[i]) { ecore_timer_del(progress_timer[i]); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/ewl_seeker.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- ewl_seeker.c 13 Jul 2006 19:43:24 -0000 1.4 +++ ewl_seeker.c 11 Aug 2006 04:00:57 -0000 1.5 @@ -40,10 +40,10 @@ static void cb_print_value(Ewl_Widget *w, void *ev __UNUSED__, void *data __UNUSED__) { - Ewl_Seeker *s; + Ewl_Range *r; - s = EWL_SEEKER(w); - printf("Seeker set to %g\n", ewl_seeker_value_get(s)); + r = EWL_RANGE(w); + printf("Seeker set to %g\n", ewl_range_value_get(r)); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/ewl_spinner.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- ewl_spinner.c 13 Jul 2006 19:43:24 -0000 1.4 +++ ewl_spinner.c 11 Aug 2006 04:00:57 -0000 1.5 @@ -37,10 +37,10 @@ spinner[0] = ewl_spinner_new(); ewl_spinner_digits_set(EWL_SPINNER(spinner[0]), 0); - ewl_spinner_min_val_set(EWL_SPINNER(spinner[0]), 0); - ewl_spinner_max_val_set(EWL_SPINNER(spinner[0]), 1280); - ewl_spinner_value_set(EWL_SPINNER(spinner[0]), 0.0); - ewl_spinner_step_set(EWL_SPINNER(spinner[0]), 1.0); + ewl_range_min_val_set(EWL_RANGE(spinner[0]), 0); + ewl_range_max_val_set(EWL_RANGE(spinner[0]), 1280); + ewl_range_value_set(EWL_RANGE(spinner[0]), 0.0); + ewl_range_step_set(EWL_RANGE(spinner[0]), 1.0); ewl_container_child_append(EWL_CONTAINER(spinner_row), spinner[0]); ewl_widget_show(spinner[0]); @@ -61,10 +61,10 @@ spinner[1] = ewl_spinner_new(); ewl_spinner_digits_set(EWL_SPINNER(spinner[1]), 0); - ewl_spinner_min_val_set(EWL_SPINNER(spinner[1]), 0); - ewl_spinner_max_val_set(EWL_SPINNER(spinner[1]), 1024); - ewl_spinner_value_set(EWL_SPINNER(spinner[1]), 0.0); - ewl_spinner_step_set(EWL_SPINNER(spinner[1]), 1.0); + ewl_range_min_val_set(EWL_RANGE(spinner[1]), 0); + ewl_range_max_val_set(EWL_RANGE(spinner[1]), 1024); + ewl_range_value_set(EWL_RANGE(spinner[1]), 0.0); + ewl_range_step_set(EWL_RANGE(spinner[1]), 1.0); ewl_container_child_append(EWL_CONTAINER(spinner_row), spinner[1]); ewl_widget_show(spinner[1]); @@ -85,10 +85,10 @@ spinner[2] = ewl_spinner_new(); ewl_spinner_digits_set(EWL_SPINNER(spinner[2]), 0); - ewl_spinner_min_val_set(EWL_SPINNER(spinner[2]), 0.0); - ewl_spinner_max_val_set(EWL_SPINNER(spinner[2]), 1280); - ewl_spinner_value_set(EWL_SPINNER(spinner[2]), 0.0); - ewl_spinner_step_set(EWL_SPINNER(spinner[2]), 1.0); + ewl_range_min_val_set(EWL_RANGE(spinner[2]), 0.0); + ewl_range_max_val_set(EWL_RANGE(spinner[2]), 1280); + ewl_range_value_set(EWL_RANGE(spinner[2]), 0.0); + ewl_range_step_set(EWL_RANGE(spinner[2]), 1.0); ewl_container_child_append(EWL_CONTAINER(spinner_row), spinner[2]); ewl_widget_show(spinner[2]); @@ -109,10 +109,10 @@ spinner[3] = ewl_spinner_new(); ewl_spinner_digits_set(EWL_SPINNER(spinner[3]), 0); - ewl_spinner_min_val_set(EWL_SPINNER(spinner[3]), 0.0); - ewl_spinner_max_val_set(EWL_SPINNER(spinner[3]), 1024); - ewl_spinner_value_set(EWL_SPINNER(spinner[3]), 0.0); - ewl_spinner_step_set(EWL_SPINNER(spinner[3]), 1.0); + ewl_range_min_val_set(EWL_RANGE(spinner[3]), 0.0); + ewl_range_max_val_set(EWL_RANGE(spinner[3]), 1024); + ewl_range_value_set(EWL_RANGE(spinner[3]), 0.0); + ewl_range_step_set(EWL_RANGE(spinner[3]), 1.0); ewl_container_child_append(EWL_CONTAINER(spinner_row), spinner[3]); ewl_widget_show(spinner[3]); @@ -131,10 +131,10 @@ void *data __UNUSED__) { printf("X %d, Y %d, W %d, H %d\n", - (int)ewl_spinner_value_get(EWL_SPINNER(spinner[0])), - (int)ewl_spinner_value_get(EWL_SPINNER(spinner[1])), - (int)ewl_spinner_value_get(EWL_SPINNER(spinner[2])), - (int)ewl_spinner_value_get(EWL_SPINNER(spinner[3]))); + (int)ewl_range_value_get(EWL_RANGE(spinner[0])), + (int)ewl_range_value_get(EWL_RANGE(spinner[1])), + (int)ewl_range_value_get(EWL_RANGE(spinner[2])), + (int)ewl_range_value_get(EWL_RANGE(spinner[3]))); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/ewl_text_editor.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ewl_text_editor.c 13 Jul 2006 19:43:24 -0000 1.5 +++ ewl_text_editor.c 11 Aug 2006 04:00:57 -0000 1.6 @@ -111,10 +111,10 @@ o = ewl_spinner_new(); ewl_container_child_append(EWL_CONTAINER(hbox), o); ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_NONE); - ewl_spinner_value_set(EWL_SPINNER(o), 12); - ewl_spinner_min_val_set(EWL_SPINNER(o), 8); - ewl_spinner_max_val_set(EWL_SPINNER(o), 72); - ewl_spinner_step_set(EWL_SPINNER(o), 1); + ewl_range_value_set(EWL_RANGE(o), 12); + ewl_range_min_val_set(EWL_RANGE(o), 8); + ewl_range_max_val_set(EWL_RANGE(o), 72); + ewl_range_step_set(EWL_RANGE(o), 1); ewl_spinner_digits_set(EWL_SPINNER(o), 0); ewl_callback_append(o, EWL_CALLBACK_VALUE_CHANGED, ete_cb_font_size, NULL); @@ -328,13 +328,13 @@ ewl_text_cursor_position_set(EWL_TEXT(entry), ewl_text_trigger_start_pos_get(selection)); ewl_text_font_size_apply(EWL_TEXT(entry), - ewl_spinner_value_get(EWL_SPINNER(w)), + ewl_range_value_get(EWL_RANGE(w)), ewl_text_trigger_length_get(selection)); ewl_text_cursor_position_set(EWL_TEXT(entry), cursor_pos); } else ewl_text_font_size_set(EWL_TEXT(entry), - ewl_spinner_value_get(EWL_SPINNER(w))); + ewl_range_value_get(EWL_RANGE(w))); } static void =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/bin/tests/ewl_theme.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- ewl_theme.c 13 Jul 2006 19:43:24 -0000 1.4 +++ ewl_theme.c 11 Aug 2006 04:00:57 -0000 1.5 @@ -164,10 +164,10 @@ misc = ewl_spinner_new(); ewl_spinner_digits_set(EWL_SPINNER(misc), 0); - ewl_spinner_min_val_set(EWL_SPINNER(misc), 0); - ewl_spinner_max_val_set(EWL_SPINNER(misc), 1024); - ewl_spinner_step_set(EWL_SPINNER(misc), 1.0); - ewl_spinner_value_set(EWL_SPINNER(misc), 15.0); + ewl_range_min_val_set(EWL_RANGE(misc), 0); + ewl_range_max_val_set(EWL_RANGE(misc), 1024); + ewl_range_step_set(EWL_RANGE(misc), 1.0); + ewl_range_value_set(EWL_RANGE(misc), 15.0); ewl_object_alignment_set(EWL_OBJECT(misc), EWL_FLAG_ALIGN_LEFT); ewl_container_child_append(EWL_CONTAINER(vbox), misc); ewl_widget_show(misc); @@ -177,9 +177,9 @@ ewl_widget_show(misc); misc = ewl_hseeker_new(); - ewl_seeker_range_set(EWL_SEEKER(misc), 10); - ewl_seeker_step_set(EWL_SEEKER(misc), 1.0); - ewl_seeker_value_set(EWL_SEEKER(misc), 15.0); + ewl_range_max_val_set(EWL_RANGE(misc), 10.0); + ewl_range_step_set(EWL_RANGE(misc), 1.0); + ewl_range_value_set(EWL_RANGE(misc), 15.0); ewl_object_alignment_set(EWL_OBJECT(misc), EWL_FLAG_ALIGN_LEFT); ewl_container_child_append(EWL_CONTAINER(vbox), misc); ewl_widget_show(misc); |
From: Enlightenment C. <no...@cv...> - 2006-08-10 23:02:42
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Added Files: ewl_range.c ewl_range.h Log Message: and here is the ewl_range |
From: Enlightenment C. <no...@cv...> - 2006-08-14 21:00:14
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_grid.c Log Message: fix grid_child_position_get() =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- ewl_grid.c 6 Aug 2006 22:02:41 -0000 1.25 +++ ewl_grid.c 14 Aug 2006 21:00:11 -0000 1.26 @@ -470,7 +470,7 @@ ecore_dlist_goto_first(EWL_CONTAINER(g)->children); while ((c = ecore_dlist_next(EWL_CONTAINER(g)->children)) && c != w) { - if (!ewl_widget_data_get(w, g)) + if (!ewl_widget_data_get(c, g)) go_next(g, &col, &row); } sc = ec = col; |
From: Enlightenment C. <no...@cv...> - 2006-08-16 16:00:38
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_spinner.c ewl_spinner.h Log Message: the spinner will now respect the user set steps =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- ewl_spinner.c 11 Aug 2006 04:00:57 -0000 1.19 +++ ewl_spinner.c 16 Aug 2006 16:00:31 -0000 1.20 @@ -416,6 +416,7 @@ if (ev_data) { s->direction = (!r->invert) ? 1 : -1; s->start_time = ecore_time_get(); + s->last_value = 0.0; s->timer = ecore_timer_add(0.02, ewl_spinner_timer, s); } @@ -484,6 +485,7 @@ if (ev_data) { s->direction = (!r->invert) ? -1 : 1; s->start_time = ecore_time_get(); + s->last_value = 0.0; s->timer = ecore_timer_add(0.02, ewl_spinner_timer, s); } @@ -522,9 +524,9 @@ { Ewl_Spinner *s; Ewl_Range *r; - double dt; - double value, range, tmpt; - int velocity, delay; + double dt, dv; + double step; + int velocity; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("data", data, FALSE); @@ -533,8 +535,7 @@ r = EWL_RANGE(s); dt = ecore_time_get() - s->start_time; - value = r->value; - range = r->max_val - r->min_val; + step = 0; /* * Check the theme for a velocity setting and bring it within normal @@ -545,27 +546,26 @@ velocity = 1; else if (velocity > 10) velocity = 10; - - /* - * Check the theme for a delay setting and bring it within normal - * useable bounds. - */ - delay = ewl_theme_data_int_get(EWL_WIDGET(s), "delay"); - if (delay < 1) - delay = 1; - else if (delay > 10) - delay = 10; + /* * Move the value of the spinner based on the direction of it's motion * and the velocity setting. */ - tmpt = (dt > (double)delay ? dt - (double)delay : 0.0); - tmpt = ((1 - exp(-tmpt)) * ((double)(velocity) / 100.0)) * range; - value += (double)(s->direction) * ((1 - exp(-dt)) + tmpt); - - ewl_range_value_set(r, value); + dv = velocity * s->direction + * (r->max_val - r->min_val) / r->step / 10 * dt * dt; + + while (r->step < abs(dv - s->last_value - step)) { + if (s->direction == 1) + step += r->step; + else + step -= r->step; + } + + ewl_range_value_set(r, r->value + step); + s->last_value += step; + DRETURN_INT(TRUE, DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- ewl_spinner.h 11 Aug 2006 04:00:57 -0000 1.11 +++ ewl_spinner.h 16 Aug 2006 16:00:31 -0000 1.12 @@ -45,6 +45,7 @@ Ewl_Widget *increment; /**< Ewl_Button to add value */ Ewl_Widget *decrement; /**< Ewl_Button to subtract value */ double start_time; /**< Time the spinner was pressed */ + double last_value; /**< The last value while spinning */ int direction; /**< Indicate increasing/decreasing value */ Ecore_Timer *timer; /**< Timer for tracking mouse button held down */ }; |
From: Enlightenment C. <no...@cv...> - 2006-08-16 18:57:44
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_grid.c ewl_grid.h Log Message: save some loops =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- ewl_grid.c 14 Aug 2006 21:00:11 -0000 1.26 +++ ewl_grid.c 16 Aug 2006 18:57:41 -0000 1.27 @@ -929,20 +929,12 @@ ecore_dlist_goto_first(EWL_CONTAINER(w)->children); while ((child = ecore_dlist_next(EWL_CONTAINER(w)->children))) { - /* - * 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; - c = (Ewl_Grid_Child *)ewl_widget_data_get(child, (void *) g); if (c) { + c_h = c_w = 0; /* * calculate the geometry of the fixed widgets */ - /* calculate child widgets width */ for (i = c->start_col; i <= c->end_col; i++) c_w += g->col_size[i].current_size; @@ -952,12 +944,10 @@ c_h += g->row_size[i].current_size; /* calculate child widgets x coordinate */ - for (i = 0; i < c->start_col; i++) - c_x += g->col_size[i].current_size; + c_x = g->col_size[c->start_col].current_pos; /* calculate child widgets y coordinate */ - for (i = 0; i < c->start_row; i++) - c_y += g->row_size[i].current_size; + c_y = g->row_size[c->start_row].current_pos; } else { /* @@ -965,14 +955,8 @@ */ 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; + c_x = g->col_size[col].current_pos; + c_y = g->row_size[row].current_pos; go_next(g, &col, &row); } @@ -1220,6 +1204,7 @@ { int i, new_w = 0, new_h = 0; int left_over, left_over2; + int pos; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("g", g); @@ -1373,6 +1358,21 @@ g->row_size[left_over2 % g->rows].current_size -= 1; left_over++; } + } + + /* + * calculate the positions + */ + pos = CURRENT_X(g); + for (i = 0; i < g->cols; i++) { + g->col_size[i].current_pos = pos; + pos += g->col_size[i].current_size; + } + + pos = CURRENT_Y(g); + for (i = 0; i < g->rows; i++) { + g->row_size[i].current_pos = pos; + pos += g->row_size[i].current_size; } DLEAVE_FUNCTION(DLEVEL_STABLE); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- ewl_grid.h 24 Jul 2006 05:50:19 -0000 1.20 +++ ewl_grid.h 16 Aug 2006 18:57:41 -0000 1.21 @@ -30,6 +30,7 @@ struct Ewl_Grid_Info { int current_size; /**< the current size */ + int current_pos; /**< the current position */ int preferred_size; /**< The greatest preferred size of a widget inside */ union { int size; /**< The size set by the user */ |
From: Enlightenment C. <no...@cv...> - 2006-08-17 10:40:39
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_spinner.c ewl_spinner.h Log Message: add ewl_spinner_digits_get() =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- ewl_spinner.c 16 Aug 2006 16:00:31 -0000 1.20 +++ ewl_spinner.c 17 Aug 2006 10:40:34 -0000 1.21 @@ -156,6 +156,21 @@ } /** + * @param s: The spinnner to get the number of digits displayed + * @return Returns the number of digits displayed by the spinner + * @brief This will retrieve the number of digits displayed by the spinner + */ +unsigned char +ewl_spinner_digits_get(Ewl_Spinner *s) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("s", s, 0); + DCHECK_TYPE_RET("s", s, EWL_SPINNER_TYPE, 0); + + DRETURN_INT(s->digits, DLEVEL_STABLE); +} + +/** * @internal * @param w: The widget to work with * @param ev_data: UNUSED =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- ewl_spinner.h 16 Aug 2006 16:00:31 -0000 1.12 +++ ewl_spinner.h 17 Aug 2006 10:40:34 -0000 1.13 @@ -39,7 +39,7 @@ struct Ewl_Spinner { Ewl_Range range; /**< Inherit from Ewl_Range */ - int digits; /**< Number of digits displayed after decimal */ + unsigned char digits; /**< Number of digits displayed after decimal */ Ewl_Widget *entry; /**< The Ewl_Entry displaying value */ Ewl_Widget *vbox; /**< Ewl_Box to hold the buttons */ Ewl_Widget *increment; /**< Ewl_Button to add value */ @@ -52,7 +52,9 @@ Ewl_Widget *ewl_spinner_new(void); int ewl_spinner_init(Ewl_Spinner *s); + void ewl_spinner_digits_set(Ewl_Spinner *s, unsigned char digits); +unsigned char ewl_spinner_digits_get(Ewl_Spinner *s); /* * Internally used callbacks, override at your own risk. |
From: Enlightenment C. <no...@cv...> - 2006-08-17 17:15:47
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl Modified Files: TODO Log Message: TODO-- =================================================================== RCS file: /cvs/e/e17/libs/ewl/TODO,v retrieving revision 1.106 retrieving revision 1.107 diff -u -3 -r1.106 -r1.107 --- TODO 16 Aug 2006 15:04:50 -0000 1.106 +++ TODO 17 Aug 2006 17:15:44 -0000 1.107 @@ -40,9 +40,6 @@ specific tab order it will be whiped out by the realize code. (In Ewl_Embed I believe). -- Resize the table multiple times vertically and the items are not placed in - the same place as original. - - the tree dosen't currently play well with the scrollbar. This can be seen in the tree test, if you shrink the window and scroll it will only scroll the first paned widget. (Need to make this and the paned work together). |
From: Enlightenment C. <no...@cv...> - 2006-08-17 18:33:06
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_grid.c Log Message: save some loops =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_grid.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- ewl_grid.c 16 Aug 2006 18:57:41 -0000 1.27 +++ ewl_grid.c 17 Aug 2006 18:33:04 -0000 1.28 @@ -900,7 +900,6 @@ 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 = 0; void (*go_next)(Ewl_Grid *g, int *c, int *r); DENTER_FUNCTION(DLEVEL_STABLE); @@ -931,17 +930,18 @@ while ((child = ecore_dlist_next(EWL_CONTAINER(w)->children))) { c = (Ewl_Grid_Child *)ewl_widget_data_get(child, (void *) g); if (c) { - c_h = c_w = 0; /* * calculate the geometry of the fixed widgets */ /* calculate child widgets width */ - for (i = c->start_col; i <= c->end_col; i++) - c_w += g->col_size[i].current_size; + c_w = g->col_size[c->end_col].current_pos + - g->col_size[c->start_col].current_pos + + g->col_size[c->end_col].current_size; /* calculate child widgets height */ - for (i = c->start_row; i <= c->end_row; i++) - c_h += g->row_size[i].current_size; + c_h = g->row_size[c->end_row].current_pos + - g->row_size[c->start_row].current_pos + + g->row_size[c->end_row].current_size; /* calculate child widgets x coordinate */ c_x = g->col_size[c->start_col].current_pos; |
From: Enlightenment C. <no...@cv...> - 2006-09-05 11:44:19
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_dnd.c Log Message: remove 2 unneeded semicolons; thanks to Pascal Brugier =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_dnd.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- ewl_dnd.c 5 Sep 2006 06:10:22 -0000 1.18 +++ ewl_dnd.c 5 Sep 2006 11:44:16 -0000 1.19 @@ -156,7 +156,7 @@ types = ecore_hash_get(ewl_dnd_provides_hash, w); - DRETURN_INT(ewl_dnd_types_encoded_contains(types, type);, DLEVEL_STABLE); + DRETURN_INT(ewl_dnd_types_encoded_contains(types, type), DLEVEL_STABLE); } @@ -220,7 +220,7 @@ types = ecore_hash_get(ewl_dnd_provides_hash, w); - DRETURN_INT(ewl_dnd_types_encoded_contains(types, type);, DLEVEL_STABLE); + DRETURN_INT(ewl_dnd_types_encoded_contains(types, type), DLEVEL_STABLE); } /** |
From: Enlightenment C. <no...@cv...> - 2006-09-08 21:49:48
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_text.c Log Message: make it compile again =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.c,v retrieving revision 1.117 retrieving revision 1.118 diff -u -3 -r1.117 -r1.118 --- ewl_text.c 8 Sep 2006 18:56:40 -0000 1.117 +++ ewl_text.c 8 Sep 2006 21:49:44 -0000 1.118 @@ -64,7 +64,7 @@ unsigned int *byte_idx, unsigned int *byte_len); static unsigned int ewl_text_char_length_get(const char *text); -static char *ewl_text_text_next_char(const char *text, unsigned int *idx;); +static char *ewl_text_text_next_char(const char *text, unsigned int *idx); /** @@ -2256,7 +2256,7 @@ /* This is stolen from evas_common_font_utf8_get_next() */ static char * -ewl_text_text_next_char(const char *text, int *idx) +ewl_text_text_next_char(const char *text, unsigned int *idx) { unsigned char d, d2, d3, d4; @@ -2330,7 +2330,7 @@ { Evas_Textblock_Cursor *cursor; char *tmp; - int idx; + unsigned int idx; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("tb", tb); |
From: Enlightenment C. <no...@cv...> - 2006-09-09 00:15:23
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_text.c Log Message: some work on utf8 support =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.c,v retrieving revision 1.118 retrieving revision 1.119 diff -u -3 -r1.118 -r1.119 --- ewl_text.c 8 Sep 2006 21:49:44 -0000 1.118 +++ ewl_text.c 9 Sep 2006 00:15:21 -0000 1.119 @@ -2566,8 +2566,14 @@ /* will this push us past the end? */ if ((cur_char_idx + 1) > char_idx) { + unsigned int byte_idx; + + ewl_text_char_to_byte(t, + char_idx - cur_char_idx, + 0, &byte_idx, + NULL); evas_textblock_cursor_pos_set(cursor, - char_idx - cur_char_idx); + byte_idx); break; } else @@ -2588,8 +2594,11 @@ * current index and set that */ if ((cur_char_idx + pos) > char_idx) { - evas_textblock_cursor_pos_set(cursor, - char_idx - cur_char_idx); + unsigned int byte_idx; + + ewl_text_char_to_byte(t, char_idx - cur_char_idx, + 0, &byte_idx, NULL); + evas_textblock_cursor_pos_set(cursor, byte_idx); break; } cur_char_idx += pos; |
From: Enlightenment C. <no...@cv...> - 2006-09-09 18:56:30
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_spinner.c Log Message: slow down the spinner =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_spinner.c 17 Aug 2006 10:40:34 -0000 1.21 +++ ewl_spinner.c 9 Sep 2006 18:56:27 -0000 1.22 @@ -561,16 +561,13 @@ velocity = 1; else if (velocity > 10) velocity = 10; - /* * Move the value of the spinner based on the direction of it's motion * and the velocity setting. */ + dv = velocity * s->direction * 10.0 * r->step * dt*dt; - dv = velocity * s->direction - * (r->max_val - r->min_val) / r->step / 10 * dt * dt; - while (r->step < abs(dv - s->last_value - step)) { if (s->direction == 1) step += r->step; |
From: Enlightenment C. <no...@cv...> - 2006-09-14 18:33:25
|
Enlightenment CVS committal Author : pfritz Project : e17 Module : libs/ewl Dir : e17/libs/ewl/src/lib Modified Files: ewl_progressbar.c Log Message: use a label instead of ewl_text =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_progressbar.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- ewl_progressbar.c 11 Aug 2006 04:00:57 -0000 1.10 +++ ewl_progressbar.c 14 Sep 2006 18:33:23 -0000 1.11 @@ -65,8 +65,8 @@ ewl_container_child_append(EWL_CONTAINER(p), p->bar); ewl_widget_show(p->bar); - p->label = ewl_text_new(); - ewl_text_text_set(EWL_TEXT(p->label), NULL); + p->label = ewl_label_new(); + ewl_label_text_set(EWL_LABEL(p->label), NULL); ewl_widget_layer_priority_set(p->label, 1); ewl_object_alignment_set(EWL_OBJECT(p->label), EWL_FLAG_ALIGN_CENTER); ewl_container_child_append(EWL_CONTAINER(p), p->label); @@ -98,7 +98,7 @@ p->auto_label = FALSE; if (label) - ewl_text_text_set(EWL_TEXT(p->label), label); + ewl_label_text_set(EWL_LABEL(p->label), label); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -124,7 +124,7 @@ if (format_string) { snprintf (label, PATH_MAX, format_string, r->value, r->max_val); - ewl_text_text_set(EWL_TEXT(p->label), label); + ewl_label_text_set(EWL_LABEL(p->label), label); } DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -143,7 +143,7 @@ DCHECK_TYPE("p", p, EWL_PROGRESSBAR_TYPE); p->auto_label = FALSE; - ewl_text_text_set(EWL_TEXT(p->label), ""); + ewl_label_text_set(EWL_LABEL(p->label), ""); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -238,7 +238,7 @@ */ snprintf (c, sizeof (c), "%.0lf%%", (r->value / (r->max_val - r->min_val)) * 100); - ewl_text_text_set(EWL_TEXT(p->label), c); + ewl_label_text_set(EWL_LABEL(p->label), c); } DLEAVE_FUNCTION(DLEVEL_STABLE); |