Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_debug.h ewl_overlay.c ewl_tooltip.c ewl_tooltip.h 
        ewl_widget.c ewl_widget.h 


Log Message:
Added a field to track inheritance for widgets. Cleaned up some warnings in
the overlay container. Fixed up the tooltips to behave more as expected.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_debug.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- ewl_debug.h 25 Nov 2003 07:47:29 -0000      1.18
+++ ewl_debug.h 21 Feb 2004 04:50:45 -0000      1.19
@@ -41,9 +41,9 @@
        if (ewl_config.debug.enable && ewl_config.debug.level >= lvl) \
          { \
                fprintf(stderr, "<--  %s:%i\tReturning %p in %s();\n", \
-                       __FILE__, __LINE__, ptr, __FUNCTION__); \
+                       __FILE__, __LINE__, (void *)ptr, __FUNCTION__); \
          } \
-       return ptr; \
+       return (void *)ptr; \
 }
 
 #define DRETURN_FLOAT(num, lvl) \
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_overlay.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ewl_overlay.c       12 Feb 2004 06:34:12 -0000      1.1
+++ ewl_overlay.c       21 Feb 2004 04:50:45 -0000      1.2
@@ -116,26 +116,26 @@
                               int size, Ewl_Orientation o)
 {
        int            maxw = 0, maxh = 0;
-       Ewl_Embed     *o;
+       Ewl_Overlay   *overlay;
        Ewl_Object    *child;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
 
        child = EWL_OBJECT(w);
-       o = EWL_EMBED(c);
+       overlay = EWL_OVERLAY(c);
 
-       ewd_list_goto_first(EWL_CONTAINER(o)->children);
-       while ((child = ewd_list_next(EWL_CONTAINER(o)->children))) {
+       ewd_list_goto_first(EWL_CONTAINER(overlay)->children);
+       while ((child = ewd_list_next(EWL_CONTAINER(overlay)->children))) {
                int             cs;
 
                /*
                 * FIXME: Do we really want to do this?
                 * Move children within the bounds of the viewable area
                 */
-               if (ewl_object_get_current_x(child) < CURRENT_X(o))
-                       ewl_object_request_x(child, CURRENT_X(o));
-               if (ewl_object_get_current_y(child) < CURRENT_Y(o))
-                       ewl_object_request_y(child, CURRENT_Y(o));
+               if (ewl_object_get_current_x(child) < CURRENT_X(overlay))
+                       ewl_object_request_x(child, CURRENT_X(overlay));
+               if (ewl_object_get_current_y(child) < CURRENT_Y(overlay))
+                       ewl_object_request_y(child, CURRENT_Y(overlay));
 
                cs = ewl_object_get_current_x(child) +
                        ewl_object_get_preferred_w(child);
@@ -157,7 +157,7 @@
 
        }
 
-       ewl_object_set_preferred_size(EWL_OBJECT(o), maxw, maxh);
+       ewl_object_set_preferred_size(EWL_OBJECT(overlay), maxw, maxh);
        ewl_object_request_size(EWL_OBJECT(c),
                                ewl_object_get_current_w(EWL_OBJECT(c)),
                                ewl_object_get_current_h(EWL_OBJECT(c)));
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_tooltip.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_tooltip.c       16 Jan 2004 16:49:06 -0000      1.4
+++ ewl_tooltip.c       21 Feb 2004 04:50:45 -0000      1.5
@@ -1,6 +1,11 @@
 #include <Ewl.h>
 
 
+/**
+ * @parent: the widget this tooltip relates
+ * @return Returns a new tooltip widget on success, NULL on failure.
+ * @brief Creates a new tooltip widget for a specific parent.
+ */
 Ewl_Widget *ewl_tooltip_new (Ewl_Widget *parent)
 {
        Ewl_Tooltip *t;
@@ -11,23 +16,32 @@
        if (!t)
                DRETURN_PTR(NULL, DLEVEL_STABLE);
 
-       ewl_tooltip_init (t, parent);
+       if (!ewl_tooltip_init (t, parent)) {
+               FREE(t);
+       }
 
        DRETURN_PTR(EWL_WIDGET(t), DLEVEL_STABLE);
 }
 
-
-void ewl_tooltip_init (Ewl_Tooltip *t, Ewl_Widget *parent)
+/**
+ * @t: the tooltip widget to initialize to default values
+ * @parent: the parent widget the tooltip is associated with
+ * @return Returns TRUE on success, FALSE otherwise.
+ * @brief Initialize the default values of the tooltip fields.
+ */
+int ewl_tooltip_init (Ewl_Tooltip *t, Ewl_Widget *parent)
 {
        Ewl_Widget *w;
        
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("t", t);
+       DCHECK_PARAM_PTR_RET("t", t, FALSE);
 
        w = EWL_WIDGET (t);
 
-       ewl_floater_init (EWL_FLOATER(w), parent);
+       ewl_box_init(EWL_BOX(w), EWL_ORIENTATION_VERTICAL);
        ewl_widget_set_appearance (EWL_WIDGET (w), "tooltip");
+       ewl_object_set_fill_policy(EWL_OBJECT(w), EWL_FLAG_FILL_NONE);
+       ewl_widget_set_layer(w, 2000);
 
        t->text = ewl_text_new ("test tooltip");
        ewl_object_set_alignment (EWL_OBJECT(t->text),
@@ -40,22 +54,28 @@
        t->hide = FALSE;
 
        if (parent) {
-               ewl_callback_append (parent, EWL_CALLBACK_FOCUS_IN, 
-                               ewl_tooltip_parent_focus_in, t);
+               ewl_callback_append (parent, EWL_CALLBACK_MOUSE_MOVE, 
+                               ewl_tooltip_parent_mouse_move_cb, t);
                ewl_callback_append (parent, EWL_CALLBACK_FOCUS_OUT,
-                               ewl_tooltip_parent_focus_out, t);
+                               ewl_tooltip_parent_focus_out_cb, t);
 
                /* 
                 * If the parent is clicked we don't want to display 
                 * the tooltip.
                 */
                ewl_callback_append (parent, EWL_CALLBACK_MOUSE_DOWN,
-                               ewl_tooltip_parent_mouse_down, t);
+                               ewl_tooltip_parent_mouse_down_cb, t);
        }
        
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
+       DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
 
+/**
+ * @param t: the tooltip to change displayed text
+ * @param text: the new text to display in the tooltip
+ * @return Returns no value.
+ * @brief Change the text displayed in the tooltip.
+ */
 void ewl_tooltip_set_text (Ewl_Tooltip *t, char *text)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -66,6 +86,12 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/**
+ * @param t: the tooltip to change the display delay
+ * @param delay: the delay in fractions of seconds before displaying tooltip
+ * @return Returns no value.
+ * @brief Changes the delay value on the tooltip.
+ */
 void ewl_tooltip_set_delay (Ewl_Tooltip *t, double delay)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -84,7 +110,7 @@
        if (t->hide)
                return FALSE;
 
-       ewl_object_request_position (EWL_WIDGET (t), t->x, t->y);
+       ewl_object_request_position (EWL_OBJECT(t), t->x, t->y);
        ewl_widget_show (EWL_WIDGET (t));
 
        printf ("Opening tooltip after %lf secs\n", t->delay);
@@ -94,7 +120,8 @@
        return FALSE;
 }
 
-void ewl_tooltip_parent_mouse_down(Ewl_Widget * w, void *ev_data, void *user_data)
+void
+ewl_tooltip_parent_mouse_down_cb(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ewl_Tooltip *t = user_data;
 
@@ -114,7 +141,8 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void ewl_tooltip_parent_focus_in(Ewl_Widget * w, void *ev_data, void *user_data)
+void
+ewl_tooltip_parent_mouse_move_cb(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ewl_Tooltip *t = user_data;
        Ecore_X_Event_Mouse_Move *e = ev_data;
@@ -131,14 +159,18 @@
        printf ("X: %d Y: %d\n", e->x, e->y);
        
 
-       if (!t->timer) {
-               t->timer = ecore_timer_add (t->delay, ewl_tooltip_focus_timer, t);
+       if (t->timer) {
+               ecore_timer_del (t->timer);
+               t->timer = NULL;
        }
-       
+
+       t->timer = ecore_timer_add(t->delay, ewl_tooltip_focus_timer, t);
+
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
-void ewl_tooltip_parent_focus_out(Ewl_Widget * w, void *ev_data, void *user_data)
+void
+ewl_tooltip_parent_focus_out_cb(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ewl_Tooltip *t = user_data;
        
@@ -157,4 +189,3 @@
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
-       
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_tooltip.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_tooltip.h       16 Jan 2004 16:49:06 -0000      1.6
+++ ewl_tooltip.h       21 Feb 2004 04:50:45 -0000      1.7
@@ -11,21 +11,21 @@
 #define EWL_TOOLTIP(tt) ((Ewl_Tooltip *) tt)
 
 struct _ewl_tooltip {
-       Ewl_Floater box;    /**< the floating box container */
+       Ewl_Box      box;    /**< the floating box container */
 
        Ewl_Widget  *text;  /**< the text displaying in the tooltip */
 
-       double      delay;  /**< how long before tooltip will display in secs */
-       int         hide;   /**< flag to enable/disable tooltip */
+       double       delay;  /**< time before tooltip will display in secs */
+       int          hide;   /**< flag to enable/disable tooltip */
 
-       int         x;
-       int         y;
+       int          x;
+       int          y;
 
        Ecore_Timer *timer; /**< pointer to the focus timer */
 };
 
 Ewl_Widget *ewl_tooltip_new (Ewl_Widget *parent);
-void ewl_tooltip_init (Ewl_Tooltip *t, Ewl_Widget *parent);
+int ewl_tooltip_init (Ewl_Tooltip *t, Ewl_Widget *parent);
 void ewl_tooltip_set_text (Ewl_Tooltip *t, char *text);
 void ewl_tooltip_set_delay (Ewl_Tooltip *t, double delay);
 
@@ -33,11 +33,11 @@
  * Internally used callbacks, override at your own risk.
  */
 int  ewl_tooltip_focus_timer (void *data);
-void ewl_tooltip_parent_mouse_down (Ewl_Widget * w, void *ev_data, 
+void ewl_tooltip_parent_mouse_down_cb (Ewl_Widget * w, void *ev_data, 
                void *user_data);
-void ewl_tooltip_parent_focus_in (Ewl_Widget * w, void *ev_data, 
+void ewl_tooltip_parent_mouse_move_cb (Ewl_Widget * w, void *ev_data, 
                void *user_data);
-void ewl_tooltip_parent_focus_out (Ewl_Widget * w, void *ev_data, 
+void ewl_tooltip_parent_focus_out_cb (Ewl_Widget * w, void *ev_data, 
                void *user_data);
 
 #endif        /* __EWL_TOOLTIP_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -3 -r1.100 -r1.101
--- ewl_widget.c        19 Feb 2004 21:45:02 -0000      1.100
+++ ewl_widget.c        21 Feb 2004 04:50:45 -0000      1.101
@@ -73,6 +73,7 @@
        ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE,
                            ewl_widget_mouse_move_cb, NULL);
 
+       w->inheritance = strdup("/widget");
        ewl_widget_set_appearance(w, appearance);
 
        DRETURN_INT(TRUE, DLEVEL_STABLE);
@@ -384,10 +385,12 @@
  */
 void ewl_widget_set_appearance(Ewl_Widget * w, char *appearance)
 {
+       int il = 0, al;
        char *current;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
+       DCHECK_PARAM_PTR("appearance", appearance);
 
        /*
         * Only continue if the appearance has changed.
@@ -403,12 +406,42 @@
                FREE(w->appearance);
        }
 
+       al = strlen(appearance) + 1;
+
        /*
         * The base appearance is used for determining the theme key of the
-        * widget
+        * widget.
+        */
+       w->appearance = (char *)malloc(al);
+       if (!w->appearance)
+               DRETURN(DLEVEL_STABLE);
+
+       strcpy(w->appearance, appearance);
+
+       /*
+        * We don't throw away any inheritance info, so we can just allocate
+        * the memory we need and place the new info on the end.
         */
-       w->appearance = strdup(appearance);
+       if (w->inheritance)
+               il = strlen(w->inheritance);
 
+       il += al;
+       current = (char *)malloc(il);
+       if (current) {
+               /*
+                * NOTE: This strcat should be safe, the strings lengths have
+                * already been computed to determine the size of the
+                * allocation.
+                */
+               strcat(current, appearance);
+               IF_FREE(w->inheritance);
+               w->inheritance = current;
+       }
+
+       /*
+        * Regenerate the entire path of widgets in the heirarchy, and
+        * recreate the visible components of the widget if necessary.
+        */
        ewl_widget_rebuild_appearance(w);
        if (REALIZED(w)) {
                ewl_widget_unrealize(w);
@@ -629,13 +662,10 @@
 int ewl_widget_get_layer_sum(Ewl_Widget *w)
 {
        int sum = 0;
-       Ewl_Widget *emb = NULL;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("w", w, 0);
 
-       emb = ewl_embed_find_by_widget(w);
-
        while (!REALIZED(w) && w->parent) {
                sum += LAYER(w);
                w = w->parent;
@@ -737,6 +767,28 @@
 }
 
 /**
+ * @param widget: the widget to determine if a type is inherited
+ * @param type: the type to check for inheritance in the widget
+ * @return Returns TRUE if @w inherited the type @t, otherwise FALSE.
+ * @brief Determine if the widget @w has inherited from the type @t.
+ */
+unsigned int ewl_widget_is_type(Ewl_Widget *widget, char *type)
+{
+       int found = FALSE;
+       char tmp[PATH_MAX];
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("widget", widget, FALSE);
+       DCHECK_PARAM_PTR_RET("type", type, FALSE);
+
+       snprintf(tmp, PATH_MAX, "/%s/", type);
+       if (widget->inheritance && strstr(widget->inheritance, tmp))
+               found = TRUE;
+
+       DRETURN_INT(found, DLEVEL_STABLE);
+}
+
+/**
  * @param w: the widget to query the state of the internal flag
  * @return Returns TRUE if the widget is marked internal, otherwise FALSE.
  * @brief Checks the widget for the internal flag.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_widget.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -3 -r1.41 -r1.42
--- ewl_widget.h        17 Feb 2004 05:18:38 -0000      1.41
+++ ewl_widget.h        21 Feb 2004 04:50:45 -0000      1.42
@@ -42,6 +42,7 @@
        Evas_Object    *theme_object; /**< Appearance shown on canvas */
        char           *bit_state; /**< State of the appaarance */
        char           *appearance; /**< Key to lookup appearance in theme */
+       char           *inheritance; /**< Key to lookup inhertiance of widget */
        int             layer; /**< Current layer of widget on canvas */
 
        Ewd_Hash       *theme; /**< Overriding theme settings of this widget */
@@ -122,6 +123,7 @@
  * Retrieve the appearance string of a widget.
  */
 char           *ewl_widget_get_appearance(Ewl_Widget * w);
+unsigned int    ewl_widget_is_type(Ewl_Widget *widget, char *type);
 
 /*
  * Change the parent of a widget.




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to