summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJihoon Kim <imfine98@gmail.com>2014-02-05 10:16:13 +0000
committerTom Hacohen <tom@stosb.com>2014-02-05 10:16:13 +0000
commit35fdd7b817c822285a47b3a5338cd905398e5fd8 (patch)
treee4802b1a23a901d7c17162efee72a4b9d3636eed
parent81214f3770e8933cd2f72150f4f1610c817a6101 (diff)
entry: Add elm_entry_select_region_set API
Summary: in case of GTK, it provides API to select a region of text (gtk_editable_select_region). However, there are only API to select all or none in EFL. This API will provide the way to select a region of text. Test Plan: elementary_test > entry3 > press 'Region' button Reviewers: woohyun, tasn, id213sin Reviewed By: tasn Differential Revision: https://phab.enlightenment.org/D520
-rw-r--r--src/bin/test_entry.c17
-rw-r--r--src/lib/elm_entry.c32
-rw-r--r--src/lib/elm_entry_eo.h16
-rw-r--r--src/lib/elm_entry_legacy.h11
4 files changed, 76 insertions, 0 deletions
diff --git a/src/bin/test_entry.c b/src/bin/test_entry.c
index c6483d88f..937169227 100644
--- a/src/bin/test_entry.c
+++ b/src/bin/test_entry.c
@@ -658,6 +658,13 @@ my_ent_bt_non(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
658} 658}
659 659
660static void 660static void
661my_ent_bt_region(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
662{
663 Evas_Object *en = data;
664 elm_entry_select_region_set(en, 10, 16);
665}
666
667static void
661my_ent_bt_ins(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 668my_ent_bt_ins(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
662{ 669{
663 Evas_Object *en = data; 670 Evas_Object *en = data;
@@ -935,6 +942,16 @@ test_entry3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
935 evas_object_show(bt); 942 evas_object_show(bt);
936 943
937 bt = elm_button_add(win); 944 bt = elm_button_add(win);
945 elm_object_text_set(bt, "Region");
946 evas_object_smart_callback_add(bt, "clicked", my_ent_bt_region, en);
947 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
948 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
949 elm_box_pack_end(bx2, bt);
950 evas_object_propagate_events_set(bt, EINA_FALSE);
951 elm_object_focus_allow_set(bt, EINA_FALSE);
952 evas_object_show(bt);
953
954 bt = elm_button_add(win);
938 elm_object_text_set(bt, "Ins"); 955 elm_object_text_set(bt, "Ins");
939 evas_object_smart_callback_add(bt, "clicked", my_ent_bt_ins, en); 956 evas_object_smart_callback_add(bt, "clicked", my_ent_bt_ins, en);
940 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); 957 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c
index 01b3e80cb..078ad9b51 100644
--- a/src/lib/elm_entry.c
+++ b/src/lib/elm_entry.c
@@ -4018,6 +4018,36 @@ _select_all(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
4018 edje_object_part_text_select_all(sd->entry_edje, "elm.text"); 4018 edje_object_part_text_select_all(sd->entry_edje, "elm.text");
4019} 4019}
4020 4020
4021EAPI void
4022elm_entry_select_region_set(Evas_Object *obj, int start, int end)
4023{
4024 ELM_ENTRY_CHECK(obj);
4025 eo_do(obj, elm_obj_entry_select_region_set(start, end));
4026}
4027
4028static void
4029_select_region_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4030{
4031 Elm_Entry_Smart_Data *sd = _pd;
4032 int start = va_arg(*list, int);
4033 int end = va_arg(*list, int);
4034
4035 if ((sd->password)) return;
4036 if (sd->sel_mode)
4037 {
4038 sd->sel_mode = EINA_FALSE;
4039 if (!_elm_config->desktop_entry)
4040 edje_object_part_text_select_allow_set
4041 (sd->entry_edje, "elm.text", EINA_FALSE);
4042 edje_object_signal_emit(sd->entry_edje, "elm,state,select,off", "elm");
4043 }
4044
4045 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, start);
4046 edje_object_part_text_select_begin(sd->entry_edje, "elm.text");
4047 edje_object_part_text_cursor_pos_set(sd->entry_edje, "elm.text", EDJE_CURSOR_MAIN, end);
4048 edje_object_part_text_select_extend(sd->entry_edje, "elm.text");
4049}
4050
4021EAPI Eina_Bool 4051EAPI Eina_Bool
4022elm_entry_cursor_geometry_get(const Evas_Object *obj, 4052elm_entry_cursor_geometry_get(const Evas_Object *obj,
4023 Evas_Coord *x, 4053 Evas_Coord *x,
@@ -5880,6 +5910,7 @@ _class_constructor(Eo_Class *klass)
5880 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_EDITABLE_GET), _editable_get), 5910 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_EDITABLE_GET), _editable_get),
5881 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_SELECT_NONE), _select_none), 5911 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_SELECT_NONE), _select_none),
5882 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_SELECT_ALL), _select_all), 5912 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_SELECT_ALL), _select_all),
5913 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_SELECT_REGION_SET), _select_region_set),
5883 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_CURSOR_GEOMETRY_GET), _cursor_geometry_get), 5914 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_CURSOR_GEOMETRY_GET), _cursor_geometry_get),
5884 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_CURSOR_NEXT), _cursor_next), 5915 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_CURSOR_NEXT), _cursor_next),
5885 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_CURSOR_PREV), _cursor_prev), 5916 EO_OP_FUNC(ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_CURSOR_PREV), _cursor_prev),
@@ -5979,6 +6010,7 @@ static const Eo_Op_Description op_desc[] = {
5979 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_EDITABLE_GET, "Get whether the entry is editable or not."), 6010 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_EDITABLE_GET, "Get whether the entry is editable or not."),
5980 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_SELECT_NONE, "This drops any existing text selection within the entry."), 6011 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_SELECT_NONE, "This drops any existing text selection within the entry."),
5981 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_SELECT_ALL, "This selects all text within the entry."), 6012 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_SELECT_ALL, "This selects all text within the entry."),
6013 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_SELECT_REGION_SET, "This selects a region of text within the entry."),
5982 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_CURSOR_GEOMETRY_GET, "This function returns the geometry of the cursor."), 6014 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_CURSOR_GEOMETRY_GET, "This function returns the geometry of the cursor."),
5983 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_CURSOR_NEXT, "This moves the cursor one place to the right within the entry."), 6015 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_CURSOR_NEXT, "This moves the cursor one place to the right within the entry."),
5984 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_CURSOR_PREV, "This moves the cursor one place to the left within the entry."), 6016 EO_OP_DESCRIPTION(ELM_OBJ_ENTRY_SUB_ID_CURSOR_PREV, "This moves the cursor one place to the left within the entry."),
diff --git a/src/lib/elm_entry_eo.h b/src/lib/elm_entry_eo.h
index e168ce5b5..d9d78862a 100644
--- a/src/lib/elm_entry_eo.h
+++ b/src/lib/elm_entry_eo.h
@@ -27,6 +27,7 @@ enum
27 ELM_OBJ_ENTRY_SUB_ID_EDITABLE_GET, 27 ELM_OBJ_ENTRY_SUB_ID_EDITABLE_GET,
28 ELM_OBJ_ENTRY_SUB_ID_SELECT_NONE, 28 ELM_OBJ_ENTRY_SUB_ID_SELECT_NONE,
29 ELM_OBJ_ENTRY_SUB_ID_SELECT_ALL, 29 ELM_OBJ_ENTRY_SUB_ID_SELECT_ALL,
30 ELM_OBJ_ENTRY_SUB_ID_SELECT_REGION_SET,
30 ELM_OBJ_ENTRY_SUB_ID_CURSOR_GEOMETRY_GET, 31 ELM_OBJ_ENTRY_SUB_ID_CURSOR_GEOMETRY_GET,
31 ELM_OBJ_ENTRY_SUB_ID_CURSOR_NEXT, 32 ELM_OBJ_ENTRY_SUB_ID_CURSOR_NEXT,
32 ELM_OBJ_ENTRY_SUB_ID_CURSOR_PREV, 33 ELM_OBJ_ENTRY_SUB_ID_CURSOR_PREV,
@@ -395,6 +396,21 @@ enum
395#define elm_obj_entry_select_all() ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_SELECT_ALL) 396#define elm_obj_entry_select_all() ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_SELECT_ALL)
396 397
397/** 398/**
399 * @def elm_obj_entry_select_region_set
400 * @since 1.9
401 *
402 * This selects a region of text within the entry.
403 *
404 * @param[in] start
405 * @param[in] end
406 *
407 * @see elm_entry_select_region_set
408 *
409 * @ingroup Entry
410 */
411#define elm_obj_entry_select_region_set(start, end) ELM_OBJ_ENTRY_ID(ELM_OBJ_ENTRY_SUB_ID_SELECT_REGION_SET), EO_TYPECHECK(int, start), EO_TYPECHECK(int, end)
412
413/**
398 * @def elm_obj_entry_cursor_geometry_get 414 * @def elm_obj_entry_cursor_geometry_get
399 * @since 1.8 415 * @since 1.8
400 * 416 *
diff --git a/src/lib/elm_entry_legacy.h b/src/lib/elm_entry_legacy.h
index b3f5506b1..26141d22b 100644
--- a/src/lib/elm_entry_legacy.h
+++ b/src/lib/elm_entry_legacy.h
@@ -348,6 +348,17 @@ EAPI void elm_entry_select_none(Evas_Object *obj);
348EAPI void elm_entry_select_all(Evas_Object *obj); 348EAPI void elm_entry_select_all(Evas_Object *obj);
349 349
350/** 350/**
351 * This selects a region of text within the entry.
352 *
353 * @param obj The entry object
354 * @param start The starting position
355 * @param end The end position
356 *
357 * @ingroup Entry
358 */
359EAPI void elm_entry_select_region_set(Evas_Object *obj, int start, int end);
360
361/**
351 * This function returns the geometry of the cursor. 362 * This function returns the geometry of the cursor.
352 * 363 *
353 * It's useful if you want to draw something on the cursor (or where it is), 364 * It's useful if you want to draw something on the cursor (or where it is),