Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_paned.c ewl_paned.h 


Log Message:
- make the grabber a widget in its own right

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_paned.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- ewl_paned.c 31 Jan 2006 05:11:59 -0000      1.17
+++ ewl_paned.c 8 Feb 2006 04:18:43 -0000       1.18
@@ -106,13 +106,14 @@
                                        ewl_paned_cb_child_show);
        ewl_container_hide_notify_set(EWL_CONTAINER(p),
                                        ewl_paned_cb_child_hide);
+       ewl_container_resize_notify_set(EWL_CONTAINER(p),
+                                       ewl_paned_cb_child_resize);
 
        ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
                                ewl_paned_cb_configure, NULL);
 
        ewl_object_fill_policy_set(EWL_OBJECT(w), EWL_FLAG_FILL_FILL);
 
-       /* XXX should this be focusable? */
        ewl_widget_focusable_set(w, FALSE);
 
        DRETURN_INT(TRUE, DLEVEL_STABLE);
@@ -128,7 +129,6 @@
 {
        Ewl_Widget *child;
        Ewl_Orientation sep;
-       char *buf;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("p", p);
@@ -138,15 +138,9 @@
                DRETURN(DLEVEL_STABLE);
 
        if (o == EWL_ORIENTATION_HORIZONTAL)
-       {
-               buf = "grabber/vertical";
                sep = EWL_ORIENTATION_VERTICAL;
-       }
        else
-       {
-               buf = "grabber/horizontal";
                sep = EWL_ORIENTATION_HORIZONTAL;
-       }
 
        ecore_list_goto_first(EWL_CONTAINER(p)->children);
        while ((child = ecore_list_next(EWL_CONTAINER(p)->children)))
@@ -155,10 +149,8 @@
                 * appearance/orientation. XXX This assumes that all 
                 * internal widgets will be grabbers ... */
                if (ewl_widget_internal_is(child))
-               {
-                       ewl_widget_appearance_set(child, buf);
-                       ewl_separator_orientation_set(EWL_SEPARATOR(child), 
sep);
-               }
+                       ewl_paned_grabber_orientation_set(
+                                       EWL_PANED_GRABBER(child), sep);
        }
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -198,20 +190,12 @@
 
        /* create the required grabber */
        if (EWL_PANED(c)->orientation == EWL_ORIENTATION_HORIZONTAL)
-       {
-               o = ewl_vseparator_new();
-               ewl_widget_appearance_set(o, "grabber/vertical");
-               ewl_attach_mouse_cursor_set(o, 
-                               EWL_MOUSE_CURSOR_SB_H_DOUBLE_ARROW);
-       }
+               idx = EWL_ORIENTATION_VERTICAL;
        else
-       {
-               o = ewl_hseparator_new();
-               ewl_widget_appearance_set(o, "grabber/horizontal");
-               ewl_attach_mouse_cursor_set(o,
-                               EWL_MOUSE_CURSOR_SB_V_DOUBLE_ARROW);
-       }
-       ewl_widget_internal_set(o, TRUE);
+               idx = EWL_ORIENTATION_HORIZONTAL;
+
+       o = ewl_paned_grabber_new();
+       ewl_paned_grabber_orientation_set(EWL_PANED_GRABBER(o), idx);
 
        ewl_callback_append(o, EWL_CALLBACK_MOUSE_DOWN,
                        ewl_paned_grabber_cb_mouse_down, c);
@@ -289,6 +273,19 @@
 }
 
 void
+ewl_paned_cb_child_resize(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);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+void
 ewl_paned_cb_child_show(Ewl_Container *c, Ewl_Widget *w)
 {
        int cw, ch, ww, wh;
@@ -969,4 +966,136 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/*
+ * Ewl_Paned_Grabber stuff
+ */
+
+/**
+ * @return Returns a new Ewl_Paned_Grabber widget or NULL on failure
+ */
+Ewl_Widget *
+ewl_paned_grabber_new(void)
+{
+       Ewl_Widget *w;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       w = NEW(Ewl_Paned_Grabber, 1);
+       if (!w)
+               DRETURN_PTR(NULL, DLEVEL_STABLE);
+
+       if (!ewl_paned_grabber_init(EWL_PANED_GRABBER(w)))
+       {
+               ewl_widget_destroy(w);
+               DRETURN_PTR(NULL, DLEVEL_STABLE);
+       }
+
+       DRETURN_PTR(w, DLEVEL_STABLE);
+}
+
+/**
+ * @param g: The Ewl_Paned_Grabber to initialize
+ * @return Returns TRUE on success or FALSE on failure
+ */
+int
+ewl_paned_grabber_init(Ewl_Paned_Grabber *g)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("g", g, FALSE);
+
+       if (!ewl_separator_init(EWL_SEPARATOR(g)))
+               DRETURN_INT(FALSE, DLEVEL_STABLE);
+
+       ewl_widget_inherit(EWL_WIDGET(g), EWL_PANED_GRABBER_TYPE);
+       ewl_paned_grabber_orientation_set(g, EWL_ORIENTATION_HORIZONTAL);
+
+       /* grabber is always internal to the paned */
+       ewl_widget_internal_set(EWL_WIDGET(g), TRUE);
+
+       DRETURN_INT(TRUE, DLEVEL_STABLE);
+}
+
+/**
+ * @param g: The Ewl_Paned_Grabber to set the orientation on
+ * @param o: The Ewl_Orientation to set on the grabber
+ * @return Returns no value.
+ */
+void
+ewl_paned_grabber_orientation_set(Ewl_Paned_Grabber *g, Ewl_Orientation o)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("g", g);
+       DCHECK_TYPE("g", g, EWL_PANED_GRABBER_TYPE);
+
+       if (o == EWL_ORIENTATION_VERTICAL)
+       {
+               ewl_separator_orientation_set(EWL_SEPARATOR(g), 
+                                               EWL_ORIENTATION_VERTICAL);
+               ewl_widget_appearance_set(EWL_WIDGET(g), "grabber/vertical");
+               ewl_paned_grabber_show_cursor_for(g, 
+                                       EWL_POSITION_LEFT | EWL_POSITION_RIGHT);
+       }
+       else
+       {
+               ewl_separator_orientation_set(EWL_SEPARATOR(g),
+                                               EWL_ORIENTATION_HORIZONTAL);
+               ewl_widget_appearance_set(EWL_WIDGET(g), "grabber/horizontal");
+               ewl_paned_grabber_show_cursor_for(g,
+                                       EWL_POSITION_TOP | EWL_POSITION_BOTTOM);
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param g: The Ewl_Paned_Grabber to get the orientation from
+ * @return Returns the Ewl_Orientation set on the grabber
+ */
+Ewl_Orientation 
+ewl_paned_grabber_orientation_get(Ewl_Paned_Grabber *g)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("g", g, EWL_ORIENTATION_HORIZONTAL);
+       DCHECK_TYPE_RET("g", g, EWL_PANED_GRABBER_TYPE, 
+                                       EWL_ORIENTATION_HORIZONTAL);
+
+       DRETURN_INT(ewl_separator_orientation_get(EWL_SEPARATOR(g)), 
+                                               DLEVEL_STABLE);
+}
+
+/**
+ * @param g: The Ewl_Paned_Grabber to set the cursor for
+ * @param dir: The diretions to show arrows for
+ * @return Returns no value.
+ *
+ * @brief This will show the arrows to allow the grabber to move in the
+ * directions specified by @a dir.
+ */
+void
+ewl_paned_grabber_show_cursor_for(Ewl_Paned_Grabber *g, unsigned int dir)
+{
+       int pos = 0;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("g", g);
+       DCHECK_TYPE("g", g, EWL_PANED_GRABBER_TYPE);
+
+       if ((dir & EWL_POSITION_LEFT) && (dir & EWL_POSITION_RIGHT))
+               pos = EWL_MOUSE_CURSOR_SB_H_DOUBLE_ARROW;
+       else if ((dir & EWL_POSITION_TOP) && (dir & EWL_POSITION_BOTTOM))
+               pos = EWL_MOUSE_CURSOR_SB_V_DOUBLE_ARROW;
+       else if (dir & EWL_POSITION_LEFT)
+               pos = EWL_MOUSE_CURSOR_SB_LEFT_ARROW;
+       else if (dir & EWL_POSITION_RIGHT)
+               pos = EWL_MOUSE_CURSOR_SB_RIGHT_ARROW;
+       else if (dir & EWL_POSITION_TOP)
+               pos = EWL_MOUSE_CURSOR_SB_UP_ARROW;
+       else
+               pos = EWL_MOUSE_CURSOR_SB_DOWN_ARROW;
+
+       ewl_attach_mouse_cursor_set(EWL_WIDGET(g), pos);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_paned.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_paned.h 12 Jan 2006 18:21:19 -0000      1.9
+++ ewl_paned.h 8 Feb 2006 04:18:43 -0000       1.10
@@ -60,6 +60,32 @@
 
 void ewl_paned_cb_configure(Ewl_Widget *w, void *ev, void *data);
 
+/*
+ * Ewl_Paned_Grabber stuff
+ */
+
+#define EWL_PANED_GRABBER_TYPE "paned_grabber"
+
+typedef struct Ewl_Paned_Grabber Ewl_Paned_Grabber;
+
+#define EWL_PANED_GRABBER(g) ((Ewl_Paned_Grabber *)g)
+
+struct Ewl_Paned_Grabber
+{
+       Ewl_Separator separator;
+       unsigned int placed:1;
+};
+
+Ewl_Widget     *ewl_paned_grabber_new(void);
+int             ewl_paned_grabber_init(Ewl_Paned_Grabber *g);
+
+void            ewl_paned_grabber_orientation_set(Ewl_Paned_Grabber *g, 
+                                                       Ewl_Orientation o);
+Ewl_Orientation  ewl_paned_grabber_orientation_get(Ewl_Paned_Grabber *g);
+
+void            ewl_paned_grabber_show_cursor_for(Ewl_Paned_Grabber *g, 
+                                                       unsigned int dir);
+
 /**
  * @}
  */




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to