Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src Modified Files: ewl_container.c ewl_entry.c ewl_object.c ewl_radiobutton.c ewl_row.c ewl_scrollbar.c ewl_textarea.c ewl_theme.c ewl_tree.c ewl_tree.h ewl_widget.c ewl_widget.h Log Message: Small cleanup of the theme key namespace. More work on the tree widget, now does the staggered layout as expected, currently using an indent value. That will no longer be needed once a bit is created for the nodes in the tree. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_container.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- ewl_container.c 6 Mar 2003 01:14:40 -0000 1.30 +++ ewl_container.c 25 Mar 2003 18:36:07 -0000 1.31 @@ -152,7 +152,7 @@ /* * Now call the add function for the container. */ - if (pc->child_add) + if (pc->child_add && VISIBLE(child)) pc->child_add(pc, child); DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -262,6 +262,8 @@ * Remove the child from the parent and set the childs parent to NULL */ ewd_list_remove(pc->children); + if (pc->child_remove && VISIBLE(child)) + pc->child_remove(pc, child); child->parent = NULL; /* @@ -292,7 +294,7 @@ * size just exit. Also exit if it has no function to be notified for * child resizes. */ - if (!w->parent || !EWL_CONTAINER(w->parent)->child_resize) + if (HIDDEN(w) || !w->parent || !EWL_CONTAINER(w->parent)->child_resize) DRETURN(DLEVEL_STABLE); /* @@ -466,7 +468,7 @@ ewd_list_goto_first(c->children); while ((child = ewd_list_next(c->children))) { curr_size = get_size(child); - if (curr_size > max_size) + if (VISIBLE(child) && curr_size > max_size) max_size = curr_size; } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -3 -r1.50 -r1.51 --- ewl_entry.c 6 Mar 2003 01:14:41 -0000 1.50 +++ ewl_entry.c 25 Mar 2003 18:36:08 -0000 1.51 @@ -579,17 +579,24 @@ } void -__ewl_entry_child_resize(Ewl_Container * entry, Ewl_Widget * text, int size, +__ewl_entry_child_resize(Ewl_Container * entry, Ewl_Widget * w, int size, Ewl_Orientation o) { + Ewl_Object *text; + DENTER_FUNCTION(DLEVEL_STABLE); + text = EWL_OBJECT(EWL_ENTRY(entry)->text); + + if (w != EWL_WIDGET(text)) + DRETURN(DLEVEL_STABLE); + if (o == EWL_ORIENTATION_HORIZONTAL) ewl_object_set_preferred_w(EWL_OBJECT(entry), - ewl_object_get_preferred_w(EWL_OBJECT(text))); + ewl_object_get_preferred_w(text)); else ewl_object_set_preferred_h(EWL_OBJECT(entry), - ewl_object_get_preferred_h(EWL_OBJECT(text))); + ewl_object_get_preferred_h(text)); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_object.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -3 -r1.32 -r1.33 --- ewl_object.c 21 Mar 2003 20:12:49 -0000 1.32 +++ ewl_object.c 25 Mar 2003 18:36:10 -0000 1.33 @@ -278,6 +278,7 @@ unsigned int ewl_object_get_preferred_w(Ewl_Object * o) { unsigned int add, temp; + DCHECK_PARAM_PTR_RET("o", o, 0); add = INSET_HORIZONTAL(o) + PADDING_HORIZONTAL(o); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_radiobutton.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- ewl_radiobutton.c 14 Aug 2002 02:05:36 -0000 1.22 +++ ewl_radiobutton.c 25 Mar 2003 18:36:14 -0000 1.23 @@ -93,8 +93,8 @@ w = EWL_WIDGET(rb); ewl_checkbutton_init(cb, label); - ewl_widget_set_appearance(w, "/button/radio"); - ewl_widget_set_appearance(cb->check, "/radio"); + ewl_widget_set_appearance(w, "radiobutton"); + ewl_widget_set_appearance(cb->check, "radio"); ewl_callback_del(w, EWL_CALLBACK_CLICKED, __ewl_checkbutton_clicked); ewl_callback_append(w, EWL_CALLBACK_CLICKED, =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_row.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- ewl_row.c 21 Mar 2003 20:12:49 -0000 1.7 +++ ewl_row.c 25 Mar 2003 18:36:15 -0000 1.8 @@ -45,6 +45,8 @@ ewl_container_init(EWL_CONTAINER(row), "row", __ewl_row_add, __ewl_row_resize, NULL); + ewl_object_set_fill_policy(EWL_OBJECT(row), EWL_FILL_POLICY_HFILL | + EWL_FILL_POLICY_HSHRINK); ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_CONFIGURE, __ewl_row_configure, NULL); @@ -94,7 +96,6 @@ Ewl_Container *c; Ewl_Object *child; int x; - int i = 0; DENTER_FUNCTION(DLEVEL_STABLE); @@ -102,22 +103,56 @@ c = EWL_CONTAINER(w); x = CURRENT_X(w); - ewd_list_goto_first(c->children); - while ((child = ewd_list_next(c->children))) { - ewl_object_request_position(child, x, CURRENT_Y(w)); + ewd_list_goto_first(c->children); - if (row->bounds && row->bounds[i]) { + /* + * This should be the common case, a row bounded by a set of fields, + * for forming a table. + */ + if (row->bounds) { + int i = 0; + while ((child = ewd_list_next(c->children))) { ewl_object_request_w(child, *row->base + *row->bounds[i] - x); + x = ewl_object_get_current_x(child) + + ewl_object_get_current_w(child); + i++; } - else { - ewl_object_request_w(child, - ewl_object_get_preferred_w(child)); + } + /* + * In the uncommon case, we simply try to give out a fair amount of + * space. + */ + else { + int remains, nodes; + + remains = CURRENT_W(w); + nodes = ewd_list_nodes(c->children); + while ((child = ewd_list_next(c->children))) { + int portion; + + /* + * Attempt to divvy up remaining space equally among + * remaining children. + */ + portion = remains / nodes; + ewl_object_request_position(child, x, CURRENT_Y(w)); + ewl_object_request_w(child, portion); + + ewl_object_request_h(child, + ewl_object_get_preferred_h(EWL_OBJECT(w))); + x = ewl_object_get_current_x(child) + + ewl_object_get_current_w(child); + + remains = CURRENT_X(w) + CURRENT_W(w) - x; + nodes--; } - ewl_object_request_h(child, - ewl_object_get_preferred_h(EWL_OBJECT(w))); - i++; + + if ((child = ewd_list_goto_last(c->children))) + ewl_object_request_w(child, + ewl_object_get_current_w(child) + + remains); } DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -152,7 +187,8 @@ row = EWL_ROW(c); if (o == EWL_ORIENTATION_VERTICAL) { if (EWL_OBJECT(w) == row->max && size > 0) - PREFERRED_H(c) += size; + ewl_object_set_preferred_h(EWL_OBJECT(c), + PREFERRED_H(c) + size); else { int h; int max_h = 0; @@ -174,6 +210,7 @@ } } else { - PREFERRED_W(c) += size; + ewl_object_set_preferred_w(EWL_OBJECT(c), + PREFERRED_W(c) + size); } } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollbar.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- ewl_scrollbar.c 13 Feb 2003 06:54:17 -0000 1.13 +++ ewl_scrollbar.c 25 Mar 2003 18:36:17 -0000 1.14 @@ -53,6 +53,7 @@ void ewl_scrollbar_init(Ewl_Scrollbar * s, Ewl_Orientation orientation) { Ewl_Widget *w; + char key[PATH_MAX]; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("s", s); @@ -60,6 +61,10 @@ w = EWL_WIDGET(s); ewl_box_init(EWL_BOX(w), orientation); + if (orientation == EWL_ORIENTATION_HORIZONTAL) + ewl_widget_set_appearance(w, "hscrollbar"); + else + ewl_widget_set_appearance(w, "vscrollbar"); /* * Create the basic widgets that are contained in the scrollbar. @@ -128,17 +133,17 @@ ewl_widget_set_appearance(s->button_increment, "button_decrement"); /* + * Set the alignment of the buttons to the seeker. + */ + snprintf(key, PATH_MAX, "%s/button_order", w->appearance); + s->buttons_alignment = ewl_theme_data_get_int(EWL_WIDGET(s), key); + + /* * Setup a few orientation specific variables, such as appearance and * packing order. */ if (orientation == EWL_ORIENTATION_HORIZONTAL) { - /* - * Set the alignment of the buttons to the seeker. - */ - s->buttons_alignment = ewl_theme_data_get_int(EWL_WIDGET(s), - "/hscrollbar/button_order"); - if (s->buttons_alignment & EWL_ALIGNMENT_LEFT) { /* @@ -176,12 +181,6 @@ */ ewl_seeker_set_value(EWL_SEEKER(s->seeker), 0); } else { - - /* - * Set the alignment of the buttons to the seeker. - */ - s->buttons_alignment = ewl_theme_data_get_int(EWL_WIDGET(s), - "/vscrollbar/button_order"); if (s->buttons_alignment & EWL_ALIGNMENT_TOP) { =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_textarea.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- ewl_textarea.c 14 Jan 2003 21:45:06 -0000 1.7 +++ ewl_textarea.c 25 Mar 2003 18:36:18 -0000 1.8 @@ -183,16 +183,25 @@ etox_context_free(ta->etox_context); ta->etox_context = NULL; } else { + char key[PATH_MAX]; /* * Get the default style and color based on the theme. */ - style = ewl_theme_data_get_str(w, - "/textarea/base/style"); - r = ewl_theme_data_get_int(w, "/textarea/base/r"); - g = ewl_theme_data_get_int(w, "/textarea/base/g"); - b = ewl_theme_data_get_int(w, "/textarea/base/b"); - a = ewl_theme_data_get_int(w, "/textarea/base/a"); + snprintf(key, PATH_MAX, "%s/style"); + style = ewl_theme_data_get_str(w, key); + + snprintf(key, PATH_MAX, "%s/r"); + r = ewl_theme_data_get_int(w, key); + + snprintf(key, PATH_MAX, "%s/g"); + g = ewl_theme_data_get_int(w, key); + + snprintf(key, PATH_MAX, "%s/b"); + b = ewl_theme_data_get_int(w, key); + + snprintf(key, PATH_MAX, "%s/a"); + a = ewl_theme_data_get_int(w, key); /* * Set the default style =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_theme.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -3 -r1.37 -r1.38 --- ewl_theme.c 14 Jan 2003 21:45:06 -0000 1.37 +++ ewl_theme.c 25 Mar 2003 18:36:19 -0000 1.38 @@ -241,6 +241,8 @@ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("k", k, NULL); + printf("%s\n", k); + for (temp = k; temp && !ret; temp = strchr(temp, '/')) { if (w->theme) ret = ewd_hash_get(w->theme, temp); @@ -286,6 +288,8 @@ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("k", k, FALSE); + + printf("%s\n", k); for (temp = k; temp && !ret; temp = strchr(temp, '/')) { if (w->theme) =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_tree.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- ewl_tree.c 21 Mar 2003 20:12:50 -0000 1.4 +++ ewl_tree.c 25 Mar 2003 18:36:20 -0000 1.5 @@ -101,8 +101,7 @@ w = EWL_WIDGET(prow); - if (prow && w->parent && - (EWL_TREE_NODE(w->parent)->tree != tree)) + if (prow && w->parent && (EWL_TREE_NODE(w->parent)->tree != tree)) DRETURN_PTR(NULL, DLEVEL_STABLE); /* @@ -119,6 +118,8 @@ DRETURN_PTR(NULL, DLEVEL_STABLE); } + ewl_widget_show(row); + EWL_TREE_NODE(node)->tree = tree; ewl_container_append_child(EWL_CONTAINER(node), row); @@ -135,19 +136,22 @@ break; } - ewl_container_append_child(EWL_CONTAINER(row), cell); + ewl_widget_show(cell); ewl_container_append_child(EWL_CONTAINER(cell), children[i]); + ewl_container_append_child(EWL_CONTAINER(row), cell); } /* * Place the new row in the tree. */ - if (row) { - if (prow && w->parent) - ewl_container_append_child(EWL_CONTAINER(w->parent), - node); - else - ewl_container_append_child(EWL_CONTAINER(tree), node); + if (prow && w->parent) { + if (EWL_TREE_NODE(w->parent)->expanded) + ewl_widget_show(node); + ewl_container_append_child(EWL_CONTAINER(w->parent), node); + } + else { + ewl_container_append_child(EWL_CONTAINER(tree), node); + ewl_widget_show(node); } DRETURN_PTR(row, DLEVEL_STABLE); @@ -196,6 +200,34 @@ } /** + * ewl_tree_set_row_expanded - set the expanded state of a specific row + * @row: the row to change the expanded state + * @expanded: the new expanded state for the row + * + * Returns no value. Changes the expanded state of @row to @expanded, which + * should be TRUE or FALSE. + */ +void ewl_tree_set_row_expanded(Ewl_Row *row, int expanded) +{ + Ewl_Tree_Node *node; + + DENTER_FUNCTION(DLEVEL_STABLE); + + DCHECK_PARAM_PTR("row", row); + + node = EWL_TREE_NODE(EWL_WIDGET(row)->parent); + + if (node && node->expanded != expanded) { + if (!expanded) + ewl_tree_node_collapse(EWL_TREE_NODE(node)); + else + ewl_tree_node_expand(EWL_TREE_NODE(node)); + } + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** * ewl_tree_node_new - allocate and initialize a new node * * Returns a newly allocated node on success, NULL on failure. @@ -241,6 +273,68 @@ DRETURN_INT(TRUE, DLEVEL_STABLE); } +/** + * ewl_tree_node_collapse - collapse a node in the tree + * @node: the node in the tree to collapse + * + * Returns no value. Hides the rows below a node @node. + */ +void ewl_tree_node_collapse(Ewl_Tree_Node *node) +{ + Ewl_Widget *w; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("node", node); + + if (!node->expanded) + DRETURN(DLEVEL_STABLE); + + node->expanded = FALSE; + + ewd_list_goto_first(EWL_CONTAINER(node)->children); + ewd_list_next(EWL_CONTAINER(node)->children); + + while ((w = ewd_list_next(EWL_CONTAINER(node)->children))) { + ewl_widget_hide(w); + ewl_object_set_preferred_h(EWL_OBJECT(node), + PREFERRED_H(node) - + ewl_object_get_preferred_h(EWL_OBJECT(w))); + } + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * ewl_tree_node_expand - expand a node in the tree + * @node: the node in the tree to expand + * + * Returns no value. Hides the rows below a node @node. + */ +void ewl_tree_node_expand(Ewl_Tree_Node *node) +{ + Ewl_Widget *w; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("node", node); + + if (node->expanded) + DRETURN(DLEVEL_STABLE); + + node->expanded = TRUE; + + ewd_list_goto_first(EWL_CONTAINER(node)->children); + ewd_list_next(EWL_CONTAINER(node)->children); + + while ((w = ewd_list_next(EWL_CONTAINER(node)->children))) { + ewl_widget_show(w); + ewl_object_set_preferred_h(EWL_OBJECT(node), + PREFERRED_H(node) + + ewl_object_get_preferred_h(EWL_OBJECT(w))); + } + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + static void __ewl_tree_add(Ewl_Container *c, Ewl_Widget *w) { @@ -306,7 +400,7 @@ Ewl_Tree_Node *node; Ewl_Container *c; Ewl_Object *child; - int x; + int x, y, width; DENTER_FUNCTION(DLEVEL_STABLE); @@ -323,17 +417,19 @@ * The first child is the current level row * are lower nodes and rows. */ - x = CURRENT_X(w); - ewl_object_request_geometry(child, x, CURRENT_Y(w), - CURRENT_W(w), CURRENT_H(w)); - x += node->tree->indent; + ewl_object_request_geometry(child, CURRENT_X(w), CURRENT_Y(w), + CURRENT_W(w), ewl_object_get_preferred_h(child)); + x = CURRENT_X(w) + node->tree->indent; + y = CURRENT_Y(w) + ewl_object_get_current_h(child); + width = CURRENT_W(w) - x + CURRENT_X(w); /* * All subsequent children are lower nodes and rows. */ while ((child = ewd_list_next(c->children))) { - ewl_object_request_geometry(child, x, CURRENT_Y(w), - CURRENT_W(w), CURRENT_H(w)); + ewl_object_request_geometry(child, x, y, width, + ewl_object_get_preferred_h(child)); + y += ewl_object_get_current_h(child); } DLEAVE_FUNCTION(DLEVEL_STABLE); @@ -349,14 +445,14 @@ node = EWL_TREE_NODE(c); - if (!ewd_list_nodes(c->children) || node->expanded) { + if (node->expanded || !ewd_list_nodes(c->children)) { ewl_object_set_preferred_h(EWL_OBJECT(c), - ewl_object_get_preferred_h(EWL_OBJECT(c)) + + PREFERRED_H(c) + ewl_object_get_preferred_h(EWL_OBJECT(w))); } width = ewl_object_get_preferred_w(EWL_OBJECT(w)); - if (ewl_object_get_preferred_w(EWL_OBJECT(c)) < width) + if (PREFERRED_W(c) < width) ewl_object_set_preferred_w(EWL_OBJECT(c), width); DLEAVE_FUNCTION(DLEVEL_STABLE); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_tree.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- ewl_tree.h 21 Feb 2003 23:04:20 -0000 1.3 +++ ewl_tree.h 25 Mar 2003 18:36:21 -0000 1.4 @@ -41,10 +41,14 @@ Ewl_Widget *ewl_tree_node_new(); int ewl_tree_node_init(Ewl_Tree_Node *tree_node); +void ewl_tree_node_collapse(Ewl_Tree_Node *tree); +void ewl_tree_node_expand(Ewl_Tree_Node *tree); Ewl_Widget *ewl_tree_new(unsigned short columns); int ewl_tree_init(Ewl_Tree *tree, unsigned short columns); void ewl_tree_set_columns(Ewl_Tree *tree, unsigned short columns); Ewl_Widget *ewl_tree_add(Ewl_Tree *tree, Ewl_Row *prow, Ewl_Widget **children); +void ewl_tree_set_row_expanded(Ewl_Row *row, int expanded); +Ewl_Row *ewl_tree_find_row(Ewl_Tree *tree, int row); #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -3 -r1.47 -r1.48 --- ewl_widget.c 6 Mar 2003 01:14:41 -0000 1.47 +++ ewl_widget.c 25 Mar 2003 18:36:21 -0000 1.48 @@ -150,6 +150,10 @@ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); + if (HIDDEN(w) && w->parent && EWL_CONTAINER(w->parent)->child_add) + EWL_CONTAINER(w->parent)->child_add(EWL_CONTAINER(w->parent), + w); + w->visible |= EWL_VISIBILITY_SHOWN; if (w->parent && (REALIZED(w->parent) && !REALIZED(w))) @@ -173,8 +177,9 @@ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); - if (!VISIBLE(w)) - DRETURN(DLEVEL_STABLE); + if (VISIBLE(w) && w->parent && EWL_CONTAINER(w->parent)->child_remove) + EWL_CONTAINER(w->parent)->child_remove(EWL_CONTAINER(w->parent), + w); w->visible = EWL_VISIBILITY_HIDDEN; =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.h,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- ewl_widget.h 14 Jan 2003 21:45:06 -0000 1.24 +++ ewl_widget.h 25 Mar 2003 18:36:22 -0000 1.25 @@ -154,7 +154,7 @@ #define REALIZED(w) (EWL_WIDGET(w)->visible & EWL_VISIBILITY_REALIZED) #define VISIBLE(w) (EWL_WIDGET(w)->visible & EWL_VISIBILITY_SHOWN) -#define HIDDEN(w) (EWL_WIDGET(w)->visible & EWL_VISIBILITY_HIDDEN) +#define HIDDEN(w) (!(EWL_WIDGET(w)->visible & EWL_VISIBILITY_SHOWN)) #define LAYER(w) EWL_WIDGET(w)->layer #endif /* __EWL_WIDGET_H__ */ ------------------------------------------------------- This SF.net email is sponsored by: The Definitive IT and Networking Event. Be There! NetWorld+Interop Las Vegas 2003 -- Register today! http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs