Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_cursor.c ewl_cursor.h ewl_entry.c ewl_entry.h ewl_row.h 
        ewl_text.c ewl_text.h ewl_window.c 


Log Message:
Removing the selection widget dependancy in the entry widget, expanding cursor
functionality, and flushing out the row code a bit more.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_cursor.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ewl_cursor.c        21 Feb 2003 23:04:18 -0000      1.10
+++ ewl_cursor.c        26 Feb 2003 01:15:23 -0000      1.11
@@ -38,7 +38,8 @@
 
        ewl_widget_init(w, "cursor");
 
-       c->position = 1;
+       c->position.start = 1;
+       c->position.end = 1;
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -51,20 +52,23 @@
  * Returns no value. Changes the position of the cursor so that the entry
  * widget can update it appropriately.
  */
-void ewl_cursor_set_position(Ewl_Widget * w, unsigned int p)
+void
+ewl_cursor_set_position(Ewl_Cursor * c, unsigned int start, unsigned int end)
 {
-       Ewl_Cursor     *c;
-
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
-
-       c = EWL_CURSOR(w);
+       DCHECK_PARAM_PTR("c", c);
 
-       if (p == 0)
-               p = 1;
-       c->position = p;
+       if (start == 0)
+               start = 1;
+       c->position.start = start;
+
+       if (end == 0)
+               end = 1;
+       if (end < start)
+               end = start;
+       c->position.end = end;
 
-       ewl_callback_call(w, EWL_CALLBACK_VALUE_CHANGED);
+       ewl_callback_call(EWL_WIDGET(c), EWL_CALLBACK_VALUE_CHANGED);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -73,16 +77,26 @@
  * ewl_cursor_get_position - retrieve the position of the cursor
  * @w: the entry cursor to retrieve the current position
  *
- * Returns the current position of the entry widget @w.
+ * Returns the current start position of the cursor widget @w.
  */
-int ewl_cursor_get_position(Ewl_Widget * w)
+unsigned int ewl_cursor_get_start_position(Ewl_Cursor * c)
 {
-       Ewl_Cursor     *c;
-
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR_RET("w", w, 0);
+       DCHECK_PARAM_PTR_RET("c", c, 0);
 
-       c = EWL_CURSOR(w);
+       DRETURN_INT(c->position.start, DLEVEL_STABLE);
+}
+
+/**
+ * ewl_cursor_get_position - retrieve the position of the cursor
+ * @w: the entry cursor to retrieve the current position
+ *
+ * Returns the current end position of the cursor widget @w.
+ */
+unsigned int ewl_cursor_get_end_position(Ewl_Cursor * c)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("c", c, 0);
 
-       DRETURN_INT(c->position, DLEVEL_STABLE);
+       DRETURN_INT(c->position.end, DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_cursor.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_cursor.h        21 Feb 2003 23:04:19 -0000      1.7
+++ ewl_cursor.h        26 Feb 2003 01:15:23 -0000      1.8
@@ -9,13 +9,18 @@
 struct _ewl_cursor {
        Ewl_Widget      widget;
 
-       unsigned int    position;
+       struct {
+               unsigned int start;
+               unsigned int end;
+       } position;
 };
 
 Ewl_Widget     *ewl_cursor_new(void);
 void            ewl_cursor_init(Ewl_Cursor * c);
-void            ewl_cursor_set_position(Ewl_Widget * w, unsigned int p);
-int             ewl_cursor_get_position(Ewl_Widget * w);
+void            ewl_cursor_set_position(Ewl_Cursor * w, unsigned int start,
+                                       unsigned int end);
+unsigned int    ewl_cursor_get_start_position(Ewl_Cursor * w);
+unsigned int    ewl_cursor_get_end_position(Ewl_Cursor * w);
 
 
 #endif                         /* __EWL_CURSOR_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -3 -r1.44 -r1.45
--- ewl_entry.c 22 Feb 2003 17:23:28 -0000      1.44
+++ ewl_entry.c 26 Feb 2003 01:15:23 -0000      1.45
@@ -1,7 +1,6 @@
 
 #include <Ewl.h>
 
-void            ewl_entry_init(Ewl_Entry * e, char *text);
 void            __ewl_entry_configure(Ewl_Widget * w, void *ev_data,
                                      void *user_data);
 void            __ewl_entry_key_down(Ewl_Widget * w, void *ev_data,
@@ -25,12 +24,14 @@
 void            __ewl_entry_update_selected_region(Ewl_Widget * w,
                                                   void *user_data,
                                                   void *ev_data);
+void            __ewl_entry_child_add(Ewl_Container * c, Ewl_Widget * w);
 void            __ewl_entry_child_resize(Ewl_Container * entry,
                                         Ewl_Widget * text, int size,
                                         Ewl_Orientation o);
 
 /**
  * ewl_entry_new - allocate and initialize a new entry widget
+ * @text: the initial text to display in the widget
  *
  * Returns a newly allocated and initialized entry widget on success, NULL on
  * failure.
@@ -55,6 +56,7 @@
 /**
  * ewl_entry_init - initialize an entry widget to default values
  * @e: the entry widget to initialize
+ * @text: the initial text to display in the widget
  *
  * Returns no value. Initializes the entry widget @e to it's default values
  * and callbacks.
@@ -62,13 +64,14 @@
 void ewl_entry_init(Ewl_Entry * e, char *text)
 {
        Ewl_Widget     *w;
+       int             pos;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("e", e);
 
        w = EWL_WIDGET(e);
 
-       ewl_container_init(EWL_CONTAINER(w), "entry", NULL,
+       ewl_container_init(EWL_CONTAINER(w), "entry", __ewl_entry_child_add,
                        __ewl_entry_child_resize, NULL);
        ewl_object_set_fill_policy(EWL_OBJECT(w), EWL_FILL_POLICY_HSHRINK |
                        EWL_FILL_POLICY_HFILL);
@@ -79,14 +82,13 @@
        ewl_container_append_child(EWL_CONTAINER(e), e->text);
        ewl_widget_show(e->text);
 
-       e->selection = ewl_selection_new();
-       ewl_container_append_child(EWL_CONTAINER(e), e->selection);
-       ewl_widget_show(e->selection);
-       
        e->cursor = ewl_cursor_new();
        ewl_container_append_child(EWL_CONTAINER(e), e->cursor);
        ewl_widget_show(e->cursor);
 
+       pos = ewl_text_get_length(EWL_TEXT(e->text)) + 1;
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), pos, pos);
+
        /*
         * Attach necessary callback mechanisms 
         */
@@ -114,11 +116,16 @@
  */
 void ewl_entry_set_text(Ewl_Entry * e, char *t)
 {
+       int pos;
+
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("e", e);
 
        ewl_text_set_text(EWL_TEXT(e->text), t);
 
+       pos = ewl_text_get_length(EWL_TEXT(e->text)) + 1;
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), pos, pos);
+
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -141,14 +148,15 @@
        DRETURN_PTR(ewl_text_get_text(EWL_TEXT(e->text)), DLEVEL_STABLE);
 }
 
+/*
+ * Layout the text and cursor within the entry widget.
+ */
 void __ewl_entry_configure(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ewl_Entry      *e;
        int             xx, yy, ww, hh;
-       int             xx2, yy2, ww2, hh2;
-       int             c_pos, l;
-       int             ss, ee;
-       int             sx, sy, sw, sh, ex, ey, ew, eh;
+       int             c_spos, c_epos, l;
+       int             sx = 0, sy = 0, ex = 0, ey = 0, ew = 0, eh = 0;
        char           *str;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -156,67 +164,43 @@
 
        e = EWL_ENTRY(w);
 
-       /******************************************************************/
-
+       /*
+        * The contents are clipped starting at these positions
+        */
        xx = CURRENT_X(w);
-
        yy = CURRENT_Y(w);
 
+       /*
+        * First position the text.
+        * FIXME: This needs to be scrollable
+        */
        ewl_object_request_position(EWL_OBJECT(e->text), xx, yy);
 
-       /******************************************************************/
-
-       c_pos = ewl_cursor_get_position(e->cursor);
-
-       ewl_text_get_letter_geometry(EWL_TEXT(e->text), --c_pos, &xx2,
-                                    &yy2, &ww2, &hh2);
+       /*
+        * Now position the cursor based on the current position in the text.
+        */
+       c_spos = ewl_cursor_get_start_position(EWL_CURSOR(e->cursor));
+       ewl_text_get_letter_geometry(EWL_TEXT(e->text), --c_spos, &sx,
+                                    &sy, NULL, NULL);
+
+       c_epos = ewl_cursor_get_start_position(EWL_CURSOR(e->cursor));
+       ewl_text_get_letter_geometry(EWL_TEXT(e->text), --c_epos, &ex,
+                                    &ey, &ew, &eh);
 
        str = EWL_TEXT(e->text)->text;
 
-       if (str && (l = strlen(str)) && c_pos >= l) {
-               xx += CURRENT_W(e->text);
+       if (str && (l = strlen(str)) && c_spos >= l) {
+               xx += ewl_object_get_current_w(EWL_OBJECT(e->text));
                ww = 5;
-               hh = CURRENT_H(e->text);
        } else {
-               xx = xx2;
-               yy = yy2;
-               ww = ww2;
-               hh = hh2;
-       }
-
-       ewl_object_request_geometry(EWL_OBJECT(e->cursor), xx, yy, ww, hh);
-
-       /******************************************************************/
-
-       ewl_selection_get_covered(e->selection, &ss, &ee);
-
-       if (ss >= 0) {
-               xx = CURRENT_X(e->text);
-               yy = CURRENT_Y(e->text);
-               ww = 0;
-
-               ewl_text_get_letter_geometry(EWL_TEXT(e->text), ss, &sx,
-                                            &sy, &sw, &sh);
-               ewl_text_get_letter_geometry(EWL_TEXT(e->text), ss + ee,
-                                            &ex, &ey, &ew, &eh);
-
                xx += sx;
-               ww += sw;
-
-               if (ee > 0) {
-                       ww -= sw;
-                       ww += ex - sx;
-                       ww += ew;
-               } else if (ee < 0) {
-                       xx -= sx;
-                       xx += ex;
-                       ww += (int) (sx - ex);
+               ww = (ex + ew) - sx;
+       }
 
-               }
+       yy += ey;
+       hh = ewl_object_get_current_h(EWL_OBJECT(e->text));
 
-               ewl_object_request_geometry(EWL_OBJECT(e->selection), xx, yy,
-                                           ww, hh);
-       }
+       ewl_object_request_geometry(EWL_OBJECT(e->cursor), xx, yy, ww, hh);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -251,6 +235,9 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/*
+ * Place the cursor appropriately on a mouse down event.
+ */
 void __ewl_entry_mouse_down(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ecore_Event_Mouse_Down *ev;
@@ -277,22 +264,16 @@
                                              CURRENT_Y(e->text) +
                                              (CURRENT_H(e->text) / 2));
 
-       ewl_cursor_set_position(e->cursor, index + 1);
-
-       ewl_widget_hide(e->selection);
-
-       if (index == 0)
-               ewl_selection_set_covered(e->selection, index, 0);
-       else if (len > 0)
-               ewl_selection_set_covered(e->selection, len - 1, 0);
-       else
-               ewl_selection_set_covered(e->selection, index, 0);
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), index + 1, index + 1);
 
        ewl_widget_configure(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/*
+ * Hilight text when the mouse moves when the button is pressed
+ */
 void __ewl_entry_mouse_move(Ewl_Widget * w, void *ev_data, void *user_data)
 {
        Ecore_Event_Mouse_Move *ev;
@@ -304,41 +285,34 @@
        ev = ev_data;
        e = EWL_ENTRY(w);
 
+       /*
+        * Check for the button pressed state, otherwise, do nothing.
+        */
        if (w->state & EWL_STATE_PRESSED) {
                int             ss, ee;
                int             index = 0;
 
-               ewl_widget_show(e->selection);
+               ss = ewl_cursor_get_start_position(EWL_CURSOR(e->cursor));
+               ee = ewl_cursor_get_end_position(EWL_CURSOR(e->cursor));
 
-               ewl_selection_get_covered(e->selection, &ss, &ee);
-               if (ev->x > CURRENT_X(e->text) &&
-                   ev->x < CURRENT_X(e->text) + CURRENT_W(e->text)) {
-                       index = ewl_text_get_index_at(EWL_TEXT(e->text),
-                                                     (ev->x),
-                                                     (CURRENT_Y(e->text) +
-                                                      (CURRENT_H(e->text) /
-                                                       2)));
+               /*
+                * FIXME: the correct behavior here is to scroll to the left
+                * or right when selecting text.
+                */
+               if (ev->x < CURRENT_X(e->text))
+                       ss = 1;
+               else if (ev->x > CURRENT_X(e->text) + CURRENT_W(e->text))
+                       ee = ewl_text_get_length(EWL_TEXT(e->text)) + 1;
+               else {
+                       index = ewl_text_get_index_at(EWL_TEXT(e->text), ev->x,
+                                             (CURRENT_Y(e->text) +
+                                              (CURRENT_H(e->text) / 2)));
 
                        ee = index - ss;
-
-                       ewl_selection_set_covered(e->selection, ss, ee);
-
-                       ewl_cursor_set_position(e->cursor, index + 1);
-
-               } else if (ev->x < CURRENT_X(e->text)) {
-               } else if (ev->x > CURRENT_X(e->text) + CURRENT_W(e->text)) {
-                       char           *str;
-
-                       str = ewl_entry_get_text(EWL_ENTRY(w));
-
-                       if (str)
-                               index = strlen(str);
-
-                       ewl_cursor_set_position(e->cursor, index + 1);
-                       ewl_selection_set_covered(e->selection, ss,
-                                                 index - ss - 1);
                }
 
+               ewl_cursor_set_position(EWL_CURSOR(e->cursor), ss, ee);
+
                ewl_widget_configure(w);
        }
 
@@ -382,12 +356,12 @@
        DCHECK_PARAM_PTR("w", w);
 
        e = EWL_ENTRY(w);
-       pos = ewl_cursor_get_position(e->cursor);
+       pos = ewl_cursor_get_start_position(EWL_CURSOR(e->cursor));
 
        if (pos > 1)
                --pos;
 
-       ewl_cursor_set_position(e->cursor, pos);
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), pos, pos);
        ewl_widget_configure(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -404,38 +378,44 @@
        DCHECK_PARAM_PTR("w", w);
 
        e = EWL_ENTRY(w);
-       pos = ewl_cursor_get_position(e->cursor);
+       pos = ewl_cursor_get_end_position(EWL_CURSOR(e->cursor));
        str = ewl_entry_get_text(EWL_ENTRY(w));
 
-       if (str)
-               len = strlen(str);
+       len = strlen(str);
 
        FREE(str);
 
        if (pos <= len)
                ++pos;
 
-       ewl_cursor_set_position(e->cursor, pos);
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), pos, pos);
        ewl_widget_configure(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/*
+ * Position the cursor at the beginning of the widget. This is internal, so the
+ * parameter is not checked.
+ */
 void __ewl_entry_move_cursor_to_home(Ewl_Widget * w)
 {
        Ewl_Entry      *e;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
 
        e = EWL_ENTRY(w);
 
-       ewl_cursor_set_position(e->cursor, 1);
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), 1, 1);
        ewl_widget_configure(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/*
+ * Position the cursor at the end of the widget. This is internal, so the
+ * parameter is not checked.
+ */
 void __ewl_entry_move_cursor_to_end(Ewl_Widget * w)
 {
        Ewl_Entry      *e;
@@ -443,7 +423,6 @@
        int             l = 0;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("w", w);
 
        e = EWL_ENTRY(w);
        s = ewl_entry_get_text(EWL_ENTRY(w));
@@ -453,7 +432,7 @@
                FREE(s);
        }
 
-       ewl_cursor_set_position(e->cursor, ++l);
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), l + 1, l + 1);
        ewl_widget_configure(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -474,13 +453,15 @@
        l = strlen(s);
        l2 = strlen(s2);
 
-       p = ewl_cursor_get_position(e->cursor);
+       p = ewl_cursor_get_start_position(EWL_CURSOR(e->cursor));
 
        s3 = NEW(char, l + 1 + l2);
 
        s3[0] = 0;
        strncat(s3, s2, p - 1);
        strcat(s3, s);
+
+       p = ewl_cursor_get_end_position(EWL_CURSOR(e->cursor));
        strcat(s3, &(s2[p - 1]));
 
        ewl_entry_set_text(EWL_ENTRY(w), s3);
@@ -489,7 +470,7 @@
        FREE(s3);
 
        p += l;
-       ewl_cursor_set_position(e->cursor, p);
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), p, p);
        ewl_widget_configure(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -505,7 +486,7 @@
        DCHECK_PARAM_PTR("w", w);
 
        e = EWL_ENTRY(w);
-       p = ewl_cursor_get_position(e->cursor);
+       p = ewl_cursor_get_start_position(EWL_CURSOR(e->cursor));
 
        if (p <= 1)
                DRETURN(DLEVEL_STABLE);
@@ -523,7 +504,7 @@
        FREE(s);
        FREE(s2);
 
-       ewl_cursor_set_position(e->cursor, p);
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), p, p);
        ewl_widget_configure(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -539,7 +520,7 @@
        DCHECK_PARAM_PTR("w", w);
 
        e = EWL_ENTRY(w);
-       p = ewl_cursor_get_position(e->cursor);
+       p = ewl_cursor_get_end_position(EWL_CURSOR(e->cursor));
 
        s2 = ewl_entry_get_text(EWL_ENTRY(w));
 
@@ -553,20 +534,42 @@
 
        FREE(s);
 
-       ewl_cursor_set_position(e->cursor, p);
+       ewl_cursor_set_position(EWL_CURSOR(e->cursor), p, p);
        ewl_widget_configure(w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 void
+__ewl_entry_child_add(Ewl_Container * c, Ewl_Widget * w)
+{
+       Ewl_Entry *e;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
+       e = EWL_ENTRY(c);
+
+       if (e->text == w) {
+               ewl_object_set_preferred_size(EWL_OBJECT(c),
+                          ewl_object_get_preferred_w(EWL_OBJECT(w)),
+                          ewl_object_get_preferred_h(EWL_OBJECT(w)));
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+void
 __ewl_entry_child_resize(Ewl_Container * entry, Ewl_Widget * text, int size,
                         Ewl_Orientation o)
 {
+       DENTER_FUNCTION(DLEVEL_STABLE);
+
        if (o == EWL_ORIENTATION_HORIZONTAL)
                ewl_object_set_preferred_w(EWL_OBJECT(entry),
                           ewl_object_get_preferred_w(EWL_OBJECT(text)));
        else
                ewl_object_set_preferred_h(EWL_OBJECT(entry),
                           ewl_object_get_preferred_h(EWL_OBJECT(text)));
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_entry.h 14 Aug 2002 02:05:36 -0000      1.16
+++ ewl_entry.h 26 Feb 2003 01:15:23 -0000      1.17
@@ -11,10 +11,10 @@
 
        Ewl_Widget     *text;
        Ewl_Widget     *cursor;
-       Ewl_Widget     *selection;
 };
 
 Ewl_Widget     *ewl_entry_new(char *text);
+void            ewl_entry_init(Ewl_Entry * e, char *text);
 void            ewl_entry_set_text(Ewl_Entry * e, char *t);
 char           *ewl_entry_get_text(Ewl_Entry * e);
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_row.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_row.h   20 Feb 2003 05:17:40 -0000      1.5
+++ ewl_row.h   26 Feb 2003 01:15:24 -0000      1.6
@@ -18,6 +18,7 @@
 
 Ewl_Widget *ewl_row_new();
 int ewl_row_init(Ewl_Row *row);
-void ewl_row_set_column_table(Ewl_Row *row, int n, unsigned int **colw);
+void ewl_row_set_column_bounds(Ewl_Row *row, int n, unsigned int *base,
+               unsigned int **bounds);
 
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_text.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -3 -r1.44 -r1.45
--- ewl_text.c  19 Feb 2003 02:18:06 -0000      1.44
+++ ewl_text.c  26 Feb 2003 01:15:24 -0000      1.45
@@ -60,6 +60,7 @@
 
        t->text = (text ? strdup(text) : strdup(""));
        t->align = EWL_ALIGNMENT_TOP | EWL_ALIGNMENT_LEFT;
+       t->length = strlen(text);
 
        /*
         * Set up appropriate callbacks for specific events
@@ -115,7 +116,10 @@
        if (t->estyle) {
                estyle_set_text(t->estyle, t->text);
                __ewl_text_update_size(t);
+               t->length = estyle_length(t->estyle);
        }
+       else
+               t->length = strlen(t->text);
 
 
        ewl_widget_configure(w);
@@ -395,6 +399,20 @@
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * ewl_text_get_length - retrieve the length of the text in the widget
+ * @t: the text widget to retrieve text length
+ *
+ * Returns the length of the text enclosed in the widget @t.
+ */
+inline int ewl_text_get_length(Ewl_Text *t)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("t", t, 0);
+
+       DRETURN_INT(t->length, DLEVEL_STABLE);
 }
 
 /**
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_text.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- ewl_text.h  14 Jan 2003 21:45:06 -0000      1.20
+++ ewl_text.h  26 Feb 2003 01:15:24 -0000      1.21
@@ -41,6 +41,7 @@
                                   int *a);
 void            ewl_text_get_text_geometry(Ewl_Text * t, int *xx, int *yy,
                                           int *ww, int *hh);
+inline int      ewl_text_get_length(Ewl_Text *t);
 void            ewl_text_set_style(Ewl_Text * t, char *s);
 void            ewl_text_get_letter_geometry(Ewl_Text * t, int index, int *xx,
                                             int *yy, int *ww, int *hh);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_window.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- ewl_window.c        19 Feb 2003 02:18:06 -0000      1.42
+++ ewl_window.c        26 Feb 2003 01:15:24 -0000      1.43
@@ -5,6 +5,8 @@
 
 void            __ewl_window_realize(Ewl_Widget * w, void *ev_data,
                                     void *user_data);
+void            __ewl_window_unrealize(Ewl_Widget * w, void *ev_data,
+                                    void *user_data);
 void            __ewl_window_show(Ewl_Widget * w, void *ev_data,
                                  void *user_data);
 void            __ewl_window_hide(Ewl_Widget * w, void *ev_data,
@@ -393,6 +395,8 @@
 
        ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_REALIZE,
                             __ewl_window_realize, NULL);
+       ewl_callback_prepend(EWL_WIDGET(w), EWL_CALLBACK_UNREALIZE,
+                            __ewl_window_unrealize, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_SHOW,
                            __ewl_window_show, NULL);
        ewl_callback_append(EWL_WIDGET(w), EWL_CALLBACK_HIDE,
@@ -479,15 +483,27 @@
                                XEV_IN_OUT | XEV_EXPOSE | XEV_VISIBILITY |
                                XEV_MOUSE_MOVE | XEV_FOCUS);
 
-       /*
-       window->bg_rect = evas_add_rectangle(window->evas);
-       evas_set_color(window->evas, window->bg_rect, 0, 0, 0, 255);
-       evas_set_layer(window->evas, window->bg_rect, LAYER(w) - 1000);
-       evas_show(window->evas, window->bg_rect);
-       */
-
        if (window->flags & EWL_WINDOW_BORDERLESS)
                ecore_window_hint_set_borderless(window->window);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+void __ewl_window_unrealize(Ewl_Widget * w, void *ev_data, void *user_data)
+{
+       Ewl_Object     *o;
+       Ewl_Window     *window;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
+
+       window = EWL_WINDOW(w);
+       o = EWL_OBJECT(w);
+
+       evas_free(window->evas);
+       window->evas = NULL;
+
+       ecore_window_destroy(window->window);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }




-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to