Edje entry: added edje_object_part_text_user_insert.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 29 Feb 2012 15:57:53 +0000 (15:57 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 29 Feb 2012 15:57:53 +0000 (15:57 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@68556 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/lib/Edje.h
src/lib/edje_entry.c
src/lib/edje_private.h
src/lib/edje_util.c

index 25e9e80..4f4299a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 2012-02-24  Jihoon Kim
 
        * add edje_object_part_text_imf_context_get for getting Ecore_IMF_Context handle in edje text object
+
+2012-02-29  Tom Hacohen (TAsn)
+
+       * Entry: Added edje_object_part_text_user_insert.
+       This function inserts text as if the user has inserted it.
+       This means it actually registers as a change and etc.
index 03e439f..075daf8 100644 (file)
@@ -2665,6 +2665,15 @@ EAPI Eina_Bool        edje_object_part_text_item_geometry_get       (const Evas_
 EAPI void             edje_object_part_text_cursor_geometry_get     (const Evas_Object *obj, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
 
 /**
+ * @brief Deletes the selection and emits a change event.
+ *
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @since 1.2.0
+ */
+EAPI void             edje_object_part_text_user_insert        (const Evas_Object *obj, const char *part, const char *text);
+
+/**
  * @brief Enables selection if the entry is an EXPLICIT selection mode
  * type.
  *
index a39d8e1..6b94f75 100644 (file)
@@ -1062,12 +1062,14 @@ _range_del_emit(Edje *ed, Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __
    _edje_emit(ed, "entry,changed", en->rp->part->name);
    _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info,
                    _free_entry_change_info);
+   _sel_clear(en->cursor, en->rp->object, en);
 }
 
 static void
 _range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
 {
    evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
+   _sel_clear(en->cursor, en->rp->object, en);
 }
 
 static void
@@ -1441,7 +1443,6 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
                        _range_del_emit(ed, en->cursor, rp->object, en);
                        info->merge = EINA_TRUE;
                     }
-                  _sel_clear(en->cursor, rp->object, en);
                   info->change.insert.pos =
                      evas_textblock_cursor_pos_get(en->cursor);
                   info->change.insert.content = eina_stringshare_add("<tab/>");
@@ -1506,7 +1507,6 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
                   _range_del_emit(ed, en->cursor, rp->object, en);
                   info->merge = EINA_TRUE;
                }
-             _sel_clear(en->cursor, rp->object, en);
 
              info->change.insert.pos =
                 evas_textblock_cursor_pos_get(en->cursor);
@@ -1549,7 +1549,6 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v
                   _range_del_emit(ed, en->cursor, rp->object, en);
                   info->merge = EINA_TRUE;
                }
-             _sel_clear(en->cursor, rp->object, en);
 
              info->change.insert.pos =
                 evas_textblock_cursor_pos_get(en->cursor);
@@ -2320,7 +2319,6 @@ _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
    // prepend markup @ cursor pos
    if (en->have_selection)
      _range_del(en->cursor, rp->object, en);
-   _sel_clear(en->cursor, rp->object, en);
    //xx
 //   evas_object_textblock_text_markup_prepend(en->cursor, text);
    _text_filter_markup_prepend(en, en->cursor, text);
@@ -2524,6 +2522,35 @@ _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *
 }
 
 void
+_edje_entry_user_insert(Edje_Real_Part *rp, const char *text)
+{
+   Entry *en = rp->entry_data;
+   Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
+   info->insert = EINA_TRUE;
+   info->change.insert.plain_length = 1;
+   info->change.insert.content = eina_stringshare_add(text);
+     {
+        char *tmp;
+        tmp = evas_textblock_text_markup_to_utf8(rp->object,
+                                                 info->change.insert.content);
+        info->change.insert.plain_length = eina_unicode_utf8_get_len(tmp);
+        free(tmp);
+     }
+
+   if (en->have_selection)
+     {
+        _range_del_emit(rp->edje, en->cursor, rp->object, en);
+        info->merge = EINA_TRUE;
+     }
+   info->change.insert.pos = evas_textblock_cursor_pos_get(en->cursor);
+   _text_filter_text_prepend(en, en->cursor, text);
+   _edje_emit(rp->edje, "entry,changed", rp->part->name);
+   _edje_emit_full(rp->edje, "entry,changed,user", rp->part->name,
+                   info, _free_entry_change_info);
+   _edje_emit(rp->edje, "cursor,changed", rp->part->name);
+}
+
+void
 _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow)
 {
    Entry *en = rp->entry_data;
@@ -3247,7 +3274,6 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx __UN
      {
         /* delete selected characters */
         _range_del_emit(ed, en->cursor, rp->object, en);
-        _sel_clear(en->cursor, rp->object, en);
      }
 
    /* delete preedit characters */
index 30bb242..9636129 100644 (file)
@@ -1937,6 +1937,7 @@ const Eina_List *_edje_entry_anchors_list(Edje_Real_Part *rp);
 Eina_Bool _edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch);
 const Eina_List *_edje_entry_items_list(Edje_Real_Part *rp);
 void _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch);
+void _edje_entry_user_insert(Edje_Real_Part *rp, const char *text);
 void _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow);
 Eina_Bool _edje_entry_select_allow_get(const Edje_Real_Part *rp);
 void _edje_entry_select_abort(Edje_Real_Part *rp);
index 8c72fd8..f844e78 100644 (file)
@@ -1472,6 +1472,20 @@ edje_object_part_text_cursor_geometry_get(const Evas_Object *obj, const char *pa
 }
 
 EAPI void
+edje_object_part_text_user_insert(const Evas_Object *obj, const char *part, const char *text)
+{
+   Edje *ed;
+   Edje_Real_Part *rp;
+
+   ed = _edje_fetch(obj);
+   if ((!ed) || (!part)) return;
+   rp = _edje_real_part_recursive_get(ed, part);
+   if (!rp) return;
+   if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
+     _edje_entry_user_insert(rp, text);
+}
+
+EAPI void
 edje_object_part_text_select_allow_set(const Evas_Object *obj, const char *part, Eina_Bool allow)
 {
    Edje *ed;