Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_menu_base.c ewl_menu_base.h ewl_tree.c 


Log Message:
Some menu progress and a minor change in how tree rows are generated.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_menu_base.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- ewl_menu_base.c     12 Nov 2003 20:07:17 -0000      1.18
+++ ewl_menu_base.c     18 Nov 2003 21:15:46 -0000      1.19
@@ -1,13 +1,16 @@
 #include <Ewl.h>
 
-void           __ewl_menu_base_expand(Ewl_Widget *w, void *ev_data,
+static void    __ewl_menu_base_expand(Ewl_Widget *w, void *ev_data,
                                        void *user_data);
-void            __ewl_menu_base_collapse(Ewl_Widget * w, void *ev_data,
+static void     __ewl_menu_base_collapse(Ewl_Widget * w, void *ev_data,
                                         void *user_data);
-void            __ewl_menu_base_destroy(Ewl_Widget * w, void *ev_data,
+static void     __ewl_menu_base_destroy(Ewl_Widget * w, void *ev_data,
                                         void *user_data);
-void            __ewl_menu_add(Ewl_Container * parent, Ewl_Widget * child);
-void            __item_clicked(Ewl_Widget * w, void *ev_data, void *user_data);
+
+static void     __ewl_menu_add(Ewl_Container * parent, Ewl_Widget * child);
+static void     __ewl_menu_item_add(Ewl_Container *parent, Ewl_Widget *child);
+static void     __ewl_menu_item_resize(Ewl_Container *parent, Ewl_Widget *child,
+               int size, Ewl_Orientation o);
 
 /**
  * @param menu: the menu item to initialize
@@ -74,6 +77,7 @@
                DRETURN_PTR(NULL, DLEVEL_STABLE);
 
        ewl_menu_item_init(item, image, text);
+       ewl_container_add_notify(EWL_CONTAINER(item), __ewl_menu_add);
 
        DRETURN_PTR(EWL_WIDGET(item), DLEVEL_STABLE);
 }
@@ -99,8 +103,8 @@
         * and the recursive setting. This will cause clicks to stop at this
         * level.
         */
-       ewl_box_init(EWL_BOX(item), EWL_ORIENTATION_HORIZONTAL);
-       ewl_widget_set_appearance(EWL_WIDGET(item), "menuitem");
+       ewl_container_init(EWL_CONTAINER(item), "menuitem", __ewl_menu_item_add,
+                          __ewl_menu_item_resize, NULL);
        ewl_object_set_fill_policy(EWL_OBJECT(item), EWL_FLAG_FILL_HFILL);
 
        ewl_container_intercept_callback(EWL_CONTAINER(item),
@@ -199,23 +203,58 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void __ewl_menu_add(Ewl_Container * parent, Ewl_Widget * child)
+static void __ewl_menu_item_add(Ewl_Container *parent, Ewl_Widget *child)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       ewl_container_prefer_largest(parent, EWL_ORIENTATION_VERTICAL);
+       ewl_object_set_preferred_w(EWL_OBJECT(parent), PREFERRED_W(parent) +
+                       ewl_object_get_preferred_w(EWL_OBJECT(child)));
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
+__ewl_menu_item_resize(Ewl_Container *parent, Ewl_Widget *child, int size,
+               Ewl_Orientation o)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       if (o == EWL_ORIENTATION_VERTICAL)
+               ewl_container_prefer_largest(parent, o);
+       else
+               ewl_object_set_preferred_w(EWL_OBJECT(parent),
+                               PREFERRED_W(parent) + size);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void __ewl_menu_add(Ewl_Container * parent, Ewl_Widget * child)
 {
        Ewl_IMenu      *menu;
+       Ewl_Menu_Item  *item;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
 
+       menu = EWL_IMENU(parent);
+       item = EWL_MENU_ITEM(parent);
+
        /*
         * Place the newly added child in the popup menu.
         */
-       menu = EWL_IMENU(parent);
-       ewl_container_append_child(EWL_CONTAINER(menu->base.popbox), child);
+       if (child != item->icon && child != item->text)
+               ewl_container_append_child(EWL_CONTAINER(menu->base.popbox),
+                               child);
+       else
+               __ewl_menu_item_add(parent, child);
+
        EWL_MENU_ITEM(child)->submenu = TRUE;
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void __ewl_menu_base_expand(Ewl_Widget *w, void *ev_data, void *user_data)
+static void
+__ewl_menu_base_expand(Ewl_Widget *w, void *ev_data, void *user_data)
 {
        Ewl_Menu_Base *menu = EWL_MENU_BASE(w);
 
@@ -230,7 +269,8 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void __ewl_menu_base_collapse(Ewl_Widget * w, void *ev_data, void *user_data)
+static void
+__ewl_menu_base_collapse(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ewl_Menu_Base      *menu;
 
@@ -243,7 +283,8 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void __ewl_menu_base_destroy(Ewl_Widget * w, void *ev_data, void *user_data)
+static void
+__ewl_menu_base_destroy(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ewl_Menu_Base      *menu;
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_menu_base.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_menu_base.h     16 Oct 2003 20:54:25 -0000      1.7
+++ ewl_menu_base.h     18 Nov 2003 21:15:46 -0000      1.8
@@ -28,8 +28,7 @@
  */
 struct Ewl_Menu_Item
 {
-       
-       Ewl_Box         box; /**< Inherit from Ewl_Box for layout  */
+       Ewl_Container   container; /**< Inherit from Ewl_Container */
        Ewl_Widget     *icon; /**< The image in this menu item.  */
        Ewl_Widget     *text; /**< The text label for this menu item.  */
        int             submenu; /**< Indicates if this is inside a menu.  */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_tree.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- ewl_tree.c  14 Nov 2003 21:25:26 -0000      1.26
+++ ewl_tree.c  18 Nov 2003 21:15:46 -0000      1.27
@@ -151,7 +151,6 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
 
        DCHECK_PARAM_PTR_RET("tree", tree, NULL);
-       DCHECK_PARAM_PTR_RET("children", children, NULL);
 
        w = EWL_WIDGET(prow);
 
@@ -181,7 +180,7 @@
        /*
         * Pretty basic here, build up the rows and add the widgets to them.
         */
-       for (i = 0; i < tree->ncols; i++) {
+       for (i = 0; i < tree->ncols && children; i++) {
                Ewl_Widget *cell;
 
                cell = ewl_cell_new();
@@ -191,14 +190,15 @@
                        break;
                }
 
+               ewl_container_append_child(EWL_CONTAINER(row), cell);
                ewl_object_set_fill_policy(EWL_OBJECT(cell),
-                               EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_HSHRINK);
+                               EWL_FLAG_FILL_HFILL |
+                               EWL_FLAG_FILL_HSHRINK);
                ewl_widget_show(cell);
 
                if (children[i]) {
                        ewl_container_append_child(EWL_CONTAINER(cell),
-                                       children[i]);
-                       ewl_container_append_child(EWL_CONTAINER(row), cell);
+                                                  children[i]);
                }
        }
 
@@ -235,17 +235,17 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
 
        DCHECK_PARAM_PTR_RET("tree", tree, NULL);
-       DCHECK_PARAM_PTR_RET("text", text, NULL);
 
        entries = NEW(Ewl_Widget *, tree->ncols);
        if (!entries)
                DRETURN_PTR(NULL, DLEVEL_STABLE);
 
        for (i = 0; i < tree->ncols; i++) {
-               if (text[i]) {
+               if (text)
                        entries[i] = ewl_entry_new(text[i]);
-                       ewl_widget_show(entries[i]);
-               }
+               else
+                       entries[i] = ewl_entry_new(NULL);
+               ewl_widget_show(entries[i]);
        }
 
        row = ewl_tree_add_row(tree, prow, entries);




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to