Edje entry: added edje_object_part_text_user_insert.

SVN revision: 68556
This commit is contained in:
Tom Hacohen 2012-02-29 15:57:53 +00:00
parent db7f5d6c5f
commit 97c02b6656
5 changed files with 61 additions and 5 deletions

View File

@ -364,3 +364,9 @@
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.

View File

@ -2664,6 +2664,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.

View 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);
@ -2523,6 +2521,35 @@ _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *
if (ch) *ch = hh;
}
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)
{
@ -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 */

View 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);

View File

@ -1471,6 +1471,20 @@ edje_object_part_text_cursor_geometry_get(const Evas_Object *obj, const char *pa
return;
}
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)
{