2016-06-08 08:37:35 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-03 04:27:30 -07:00
|
|
|
#define EFL_ACCESS_OBJECT_PROTECTED
|
2017-09-25 01:15:44 -07:00
|
|
|
#define EFL_ACCESS_TEXT_PROTECTED
|
|
|
|
#define EFL_ACCESS_EDITABLE_TEXT_PROTECTED
|
2016-06-08 08:37:35 -07:00
|
|
|
#define ELM_LAYOUT_PROTECTED
|
2018-11-12 08:57:24 -08:00
|
|
|
#define EFL_PART_PROTECTED
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
#include <Elementary.h>
|
|
|
|
#include <Elementary_Cursor.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
|
|
|
#include "elm_entry_common.h"
|
|
|
|
#include "elm_widget_entry.h"
|
|
|
|
#include "efl_ui_text.eo.h"
|
2016-10-18 03:34:12 -07:00
|
|
|
#include "elm_hoversel.eo.h"
|
2018-11-12 08:57:24 -08:00
|
|
|
#include "efl_ui_text_part.eo.h"
|
|
|
|
#include "elm_part_helper.h"
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
typedef struct _Efl_Ui_Text_Data Efl_Ui_Text_Data;
|
|
|
|
typedef struct _Efl_Ui_Text_Rectangle Efl_Ui_Text_Rectangle;
|
2016-06-22 05:12:15 -07:00
|
|
|
typedef struct _Anchor Anchor;
|
2018-09-13 02:45:29 -07:00
|
|
|
typedef struct _Selection_Loss_Data Selection_Loss_Data;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base widget smart data extended with entry instance data.
|
|
|
|
*/
|
|
|
|
struct _Efl_Ui_Text_Data
|
|
|
|
{
|
|
|
|
Evas_Object *hit_rect, *entry_edje, *scr_edje;
|
|
|
|
|
|
|
|
Evas_Object *hoversel;
|
|
|
|
Evas_Object *mgf_bg;
|
|
|
|
Evas_Object *mgf_clip;
|
|
|
|
Evas_Object *mgf_proxy;
|
2017-01-12 08:01:52 -08:00
|
|
|
Eo *text_obj;
|
2018-11-12 05:09:56 -08:00
|
|
|
Eo *text_guide_obj;
|
|
|
|
Eo *text_table;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *pan;
|
|
|
|
Eo *scroller;
|
|
|
|
Eo *manager;
|
2016-06-08 08:37:35 -07:00
|
|
|
Eo *cursor;
|
|
|
|
Eo *cursor_bidi;
|
|
|
|
Evas_Object *start_handler;
|
|
|
|
Evas_Object *end_handler;
|
2016-06-22 10:02:32 -07:00
|
|
|
Ecore_Job *deferred_decoration_job;
|
2016-06-08 08:37:35 -07:00
|
|
|
Ecore_Timer *longpress_timer;
|
|
|
|
Ecore_Timer *delay_write;
|
|
|
|
/* for deferred appending */
|
|
|
|
Ecore_Idler *append_text_idler;
|
|
|
|
char *append_text_left;
|
|
|
|
int append_text_position;
|
|
|
|
int append_text_len;
|
|
|
|
/* Only for clipboard */
|
|
|
|
const char *cut_sel;
|
|
|
|
const char *text;
|
|
|
|
const char *file;
|
|
|
|
Elm_Text_Format format;
|
2017-05-23 06:04:04 -07:00
|
|
|
Evas_Coord ent_w, ent_h;
|
2016-06-08 08:37:35 -07:00
|
|
|
Evas_Coord downx, downy;
|
|
|
|
Evas_Coord ox, oy;
|
2016-06-22 05:12:15 -07:00
|
|
|
Eina_List *anchors;
|
2018-09-13 02:45:29 -07:00
|
|
|
int gen;
|
2016-10-05 07:10:20 -07:00
|
|
|
Eina_List *sel;
|
2016-06-08 08:37:35 -07:00
|
|
|
Eina_List *items; /** context menu item list */
|
2017-11-09 07:53:20 -08:00
|
|
|
Efl_Canvas_Text_Factory *item_factory;
|
|
|
|
Efl_Canvas_Text_Factory *item_fallback_factory;
|
2016-06-08 08:37:35 -07:00
|
|
|
Eina_List *markup_filters;
|
|
|
|
Ecore_Job *hov_deljob;
|
|
|
|
Mod_Api *api; // module api if supplied
|
|
|
|
int cursor_pos;
|
|
|
|
Elm_Scroller_Policy policy_h, policy_v;
|
|
|
|
Elm_Wrap_Type line_wrap;
|
|
|
|
Elm_Input_Panel_Layout input_panel_layout;
|
|
|
|
Elm_Autocapital_Type autocapital_type;
|
|
|
|
Elm_Input_Panel_Lang input_panel_lang;
|
|
|
|
Elm_Input_Panel_Return_Key_Type input_panel_return_key_type;
|
|
|
|
Elm_Input_Hints input_hints;
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *sel_handler_cursor;
|
2016-06-08 08:37:35 -07:00
|
|
|
void *input_panel_imdata;
|
|
|
|
int input_panel_imdata_len;
|
|
|
|
int input_panel_layout_variation;
|
|
|
|
int validators;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
Evas_Object *hover_parent; /**< hover parent object. entry is a hover parent object by default */
|
|
|
|
Evas_Object *pop; /**< hidden icon for hover target */
|
|
|
|
Evas_Object *hover; /**< hover object */
|
|
|
|
const char *hover_style; /**< style of a hover object */
|
|
|
|
} anchor_hover;
|
|
|
|
|
2019-02-07 03:41:51 -08:00
|
|
|
Efl_Ui_Selection_Format cnp_mode;
|
2016-06-08 08:37:35 -07:00
|
|
|
Elm_Sel_Format drop_format;
|
|
|
|
|
2017-09-11 22:38:51 -07:00
|
|
|
struct {
|
|
|
|
char *text;
|
|
|
|
Eina_Bool enabled;
|
|
|
|
} async;
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
struct {
|
|
|
|
Eina_Size2D scroll;
|
|
|
|
Eina_Size2D layout;
|
|
|
|
} last;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
Eina_Future *primary;
|
|
|
|
Eina_Future *clipboard;
|
|
|
|
} sel_future;
|
2016-06-08 08:37:35 -07:00
|
|
|
Eina_Bool input_panel_return_key_disabled : 1;
|
|
|
|
Eina_Bool drag_selection_asked : 1;
|
|
|
|
Eina_Bool sel_handler_disabled : 1;
|
|
|
|
Eina_Bool start_handler_down : 1;
|
|
|
|
Eina_Bool start_handler_shown : 1;
|
|
|
|
Eina_Bool end_handler_down : 1;
|
|
|
|
Eina_Bool end_handler_shown : 1;
|
|
|
|
Eina_Bool input_panel_enable : 1;
|
|
|
|
Eina_Bool prediction_allow : 1;
|
|
|
|
Eina_Bool selection_asked : 1;
|
|
|
|
Eina_Bool auto_return_key : 1;
|
|
|
|
Eina_Bool have_selection : 1;
|
2016-06-22 10:02:32 -07:00
|
|
|
Eina_Bool deferred_decoration_selection : 1;
|
|
|
|
Eina_Bool deferred_decoration_cursor : 1;
|
|
|
|
Eina_Bool deferred_decoration_anchor : 1;
|
2016-06-08 08:37:35 -07:00
|
|
|
Eina_Bool context_menu : 1;
|
|
|
|
Eina_Bool long_pressed : 1;
|
|
|
|
Eina_Bool cur_changed : 1;
|
|
|
|
Eina_Bool single_line : 1;
|
|
|
|
Eina_Bool can_write : 1;
|
|
|
|
Eina_Bool auto_save : 1;
|
|
|
|
Eina_Bool password : 1;
|
2016-06-22 06:22:27 -07:00
|
|
|
Eina_Bool editable : 1; // FIXME: This is redundant because of text interactive and should be removed
|
2016-06-08 08:37:35 -07:00
|
|
|
Eina_Bool disabled : 1;
|
|
|
|
Eina_Bool h_bounce : 1;
|
|
|
|
Eina_Bool v_bounce : 1;
|
|
|
|
Eina_Bool has_text : 1;
|
|
|
|
Eina_Bool use_down : 1;
|
|
|
|
Eina_Bool sel_mode : 1;
|
|
|
|
Eina_Bool sel_allow : 1;
|
|
|
|
Eina_Bool changed : 1;
|
|
|
|
Eina_Bool scroll : 1;
|
|
|
|
Eina_Bool input_panel_show_on_demand : 1;
|
2016-06-22 05:12:15 -07:00
|
|
|
Eina_Bool anchors_updated : 1;
|
2017-11-09 07:53:20 -08:00
|
|
|
Eina_Bool fallback_item_provider_disabled : 1;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Bool text_changed : 1;
|
|
|
|
Eina_Bool text_resized : 1;
|
|
|
|
Eina_Bool calc_force : 1;
|
|
|
|
Eina_Bool cursor_update : 1;
|
2016-06-22 05:12:15 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _Anchor
|
|
|
|
{
|
|
|
|
Eo *obj;
|
|
|
|
char *name;
|
2017-07-17 07:38:28 -07:00
|
|
|
Efl_Text_Annotate_Annotation *annotation;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_List *rects;
|
|
|
|
int gen;
|
2016-06-22 05:12:15 -07:00
|
|
|
Eina_Bool item : 1;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Bool updated : 1;
|
2016-06-08 08:37:35 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define EFL_UI_TEXT_DATA_GET(o, sd) \
|
2016-08-15 06:44:41 -07:00
|
|
|
Efl_Ui_Text_Data * sd = efl_data_scope_get(o, EFL_UI_TEXT_CLASS)
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
#define EFL_UI_TEXT_DATA_GET_OR_RETURN(o, ptr) \
|
|
|
|
EFL_UI_TEXT_DATA_GET(o, ptr); \
|
|
|
|
if (EINA_UNLIKELY(!ptr)) \
|
|
|
|
{ \
|
2018-01-31 19:16:28 -08:00
|
|
|
ERR("No widget data for object %p (%s)", \
|
2016-06-08 08:37:35 -07:00
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EFL_UI_TEXT_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
|
|
|
|
EFL_UI_TEXT_DATA_GET(o, ptr); \
|
|
|
|
if (EINA_UNLIKELY(!ptr)) \
|
|
|
|
{ \
|
2018-01-31 19:16:28 -08:00
|
|
|
ERR("No widget data for object %p (%s)", \
|
2016-06-08 08:37:35 -07:00
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
return val; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EFL_UI_TEXT_CHECK(obj) \
|
2016-08-15 06:44:41 -07:00
|
|
|
if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_TEXT_CLASS))) \
|
2016-06-08 08:37:35 -07:00
|
|
|
return
|
|
|
|
|
|
|
|
struct _Efl_Ui_Text_Rectangle
|
|
|
|
{
|
2016-10-05 07:10:20 -07:00
|
|
|
Evas_Object *obj_bg, *obj_fg, *obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
};
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
struct _Selection_Loss_Data
|
|
|
|
{
|
|
|
|
Eo *obj;
|
2018-12-21 13:46:06 -08:00
|
|
|
Efl_Ui_Selection_Type stype;
|
2018-09-13 02:45:29 -07:00
|
|
|
};
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
#define MY_CLASS EFL_UI_TEXT_CLASS
|
2017-07-27 23:35:10 -07:00
|
|
|
#define MY_CLASS_PFX efl_ui_text
|
2016-07-12 02:03:54 -07:00
|
|
|
#define MY_CLASS_NAME "Efl.Ui.Text"
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_entry"
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
#include "efl_ui_internal_text_interactive.h"
|
2018-11-05 13:55:20 -08:00
|
|
|
#include "efl_ui_internal_text_scroller.h"
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
/* Maximum chunk size to be inserted to the entry at once
|
|
|
|
* FIXME: This size is arbitrary, should probably choose a better size.
|
|
|
|
* Possibly also find a way to set it to a low value for weak computers,
|
|
|
|
* and to a big value for better computers. */
|
|
|
|
#define EFL_UI_TEXT_CHUNK_SIZE 10000
|
|
|
|
#define EFL_UI_TEXT_DELAY_WRITE_TIME 2.0
|
|
|
|
|
|
|
|
#define ENTRY_PASSWORD_MASK_CHARACTER 0x002A
|
|
|
|
|
|
|
|
static Eina_List *entries = NULL;
|
|
|
|
|
|
|
|
struct _Mod_Api
|
|
|
|
{
|
|
|
|
void (*obj_hook)(Evas_Object *obj);
|
|
|
|
void (*obj_unhook)(Evas_Object *obj);
|
|
|
|
void (*obj_longpress)(Evas_Object *obj);
|
|
|
|
};
|
|
|
|
|
2017-11-14 03:38:49 -08:00
|
|
|
static const char PART_NAME_HANDLER_START[] = "handler/start";
|
|
|
|
static const char PART_NAME_HANDLER_END[] = "handler/end";
|
|
|
|
static const char PART_NAME_CURSOR[] = "cursor";
|
|
|
|
static const char PART_NAME_SELECTION[] = "selection";
|
|
|
|
static const char PART_NAME_ANCHOR[] = "anchor";
|
|
|
|
|
|
|
|
static void _create_selection_handlers(Evas_Object *obj, Efl_Ui_Text_Data *sd);
|
2016-06-08 08:37:35 -07:00
|
|
|
static void _update_decorations(Eo *obj);
|
2016-12-01 03:25:11 -08:00
|
|
|
static void _create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd);
|
2017-12-12 22:05:15 -08:00
|
|
|
static void _efl_ui_text_changed_cb(void *data, const Efl_Event *event);
|
|
|
|
static void _efl_ui_text_changed_user_cb(void *data, const Efl_Event *event);
|
|
|
|
static void _efl_ui_text_selection_changed_cb(void *data, const Efl_Event *event);
|
|
|
|
static void _efl_ui_text_cursor_changed_cb(void *data, const Efl_Event *event);
|
2018-09-13 02:45:29 -07:00
|
|
|
static void _text_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED);
|
|
|
|
static void _scroller_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED);
|
|
|
|
static void _text_position_changed_cb(void *data, const Efl_Event *event EINA_UNUSED);
|
2017-12-12 22:05:15 -08:00
|
|
|
static void _efl_ui_text_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
static void _efl_ui_text_select_none(Eo *obj, Efl_Ui_Text_Data *sd);
|
2018-04-17 11:09:44 -07:00
|
|
|
static const char* _efl_ui_text_selection_get(const Eo *obj, Efl_Ui_Text_Data *sd);
|
2016-06-28 05:24:35 -07:00
|
|
|
static void _edje_signal_emit(Efl_Ui_Text_Data *obj, const char *sig, const char *src);
|
2016-07-10 07:30:51 -07:00
|
|
|
static void _decoration_defer_all(Eo *obj);
|
2017-11-14 03:38:49 -08:00
|
|
|
static inline Eo * _decoration_create(Eo *obj, Efl_Ui_Text_Data *sd, const char *source, Eina_Bool above);
|
2016-10-05 07:10:20 -07:00
|
|
|
static void _decoration_defer(Eo *obj);
|
2017-06-07 22:50:14 -07:00
|
|
|
static void _clear_text_selection(Efl_Ui_Text_Data *sd);
|
2018-09-13 02:45:29 -07:00
|
|
|
static void _anchors_free(Efl_Ui_Text_Data *sd);
|
|
|
|
static void _selection_defer(Eo *obj, Efl_Ui_Text_Data *sd);
|
|
|
|
static Eina_Position2D _decoration_calc_offset(Efl_Ui_Text_Data *sd);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
static char *
|
|
|
|
_file_load(const char *file)
|
|
|
|
{
|
|
|
|
Eina_File *f;
|
|
|
|
char *text = NULL;
|
|
|
|
void *tmp = NULL;
|
|
|
|
|
|
|
|
f = eina_file_open(file, EINA_FALSE);
|
|
|
|
if (!f) return NULL;
|
|
|
|
|
|
|
|
tmp = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
|
|
|
if (!tmp) goto on_error;
|
|
|
|
|
|
|
|
text = malloc(eina_file_size_get(f) + 1);
|
|
|
|
if (!text) goto on_error;
|
|
|
|
|
|
|
|
memcpy(text, tmp, eina_file_size_get(f));
|
|
|
|
text[eina_file_size_get(f)] = 0;
|
|
|
|
|
|
|
|
if (eina_file_map_faulted(f, tmp))
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(text, free);
|
|
|
|
}
|
|
|
|
|
|
|
|
on_error:
|
|
|
|
if (tmp) eina_file_map_free(f, tmp);
|
|
|
|
eina_file_close(f);
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_plain_load(const char *file)
|
|
|
|
{
|
2016-07-10 04:44:22 -07:00
|
|
|
return _file_load(file);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_load_do(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
char *text;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (!sd->file)
|
|
|
|
{
|
|
|
|
elm_object_text_set(obj, "");
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (sd->format)
|
|
|
|
{
|
2016-07-10 04:44:22 -07:00
|
|
|
/* Only available format */
|
2016-06-08 08:37:35 -07:00
|
|
|
case ELM_TEXT_FORMAT_PLAIN_UTF8:
|
2016-07-10 04:44:22 -07:00
|
|
|
text = _plain_load(sd->file);
|
|
|
|
break;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
default:
|
2016-07-10 04:44:22 -07:00
|
|
|
text = NULL;
|
|
|
|
break;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (text)
|
|
|
|
{
|
2016-07-10 04:44:22 -07:00
|
|
|
efl_text_set(obj, text);
|
2016-06-08 08:37:35 -07:00
|
|
|
free(text);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-10 04:44:22 -07:00
|
|
|
efl_text_set(obj, "");
|
2016-06-08 08:37:35 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-07-10 04:44:22 -07:00
|
|
|
_text_save(const char *file,
|
|
|
|
const char *text)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
if (!text)
|
|
|
|
{
|
|
|
|
ecore_file_unlink(file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
f = fopen(file, "wb");
|
|
|
|
if (!f)
|
|
|
|
{
|
|
|
|
ERR("Failed to open %s for writing", file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fputs(text, f) == EOF)
|
|
|
|
ERR("Failed to write text to file %s", file);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_save_do(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (!sd->file) return;
|
|
|
|
switch (sd->format)
|
|
|
|
{
|
2016-07-10 04:44:22 -07:00
|
|
|
/* Only supported format */
|
2016-06-08 08:37:35 -07:00
|
|
|
case ELM_TEXT_FORMAT_PLAIN_UTF8:
|
2016-07-10 04:44:22 -07:00
|
|
|
_text_save(sd->file, efl_text_get(obj));
|
2016-06-08 08:37:35 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_TEXT_FORMAT_MARKUP_UTF8:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_text_guide_update(Evas_Object *obj,
|
|
|
|
Eina_Bool has_text)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if ((has_text) && (!sd->has_text))
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,guide,disabled", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
else if ((!has_text) && (sd->has_text))
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,guide,enabled", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
sd->has_text = has_text;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_validate(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
Eina_Bool res;
|
|
|
|
Elm_Validate_Content vc;
|
|
|
|
Eina_Strbuf *buf;
|
|
|
|
|
|
|
|
if (sd->validators == 0) return;
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
vc.text = edje_object_part_text_get(sd->entry_edje, "efl.text");
|
2017-12-12 22:19:43 -08:00
|
|
|
res = efl_event_callback_call(obj, EFL_UI_TEXT_EVENT_VALIDATE, (void *)&vc);
|
2016-06-08 08:37:35 -07:00
|
|
|
buf = eina_strbuf_new();
|
2016-06-20 07:31:31 -07:00
|
|
|
eina_strbuf_append_printf(buf, "validation,%s,%s", vc.signal, res == EINA_FALSE ? "fail" : "pass");
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->scr_edje, eina_strbuf_string_get(buf), "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
eina_tmpstr_del(vc.signal);
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_filter_free(Elm_Entry_Markup_Filter *tf)
|
|
|
|
{
|
|
|
|
if (tf->func == elm_entry_filter_limit_size)
|
|
|
|
{
|
|
|
|
Elm_Entry_Filter_Limit_Size *lim = tf->data;
|
|
|
|
|
|
|
|
free(lim);
|
|
|
|
}
|
|
|
|
else if (tf->func == elm_entry_filter_accept_set)
|
|
|
|
{
|
|
|
|
Elm_Entry_Filter_Accept_Set *as = tf->data;
|
|
|
|
|
|
|
|
if (as)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(as->accepted);
|
|
|
|
eina_stringshare_del(as->rejected);
|
|
|
|
|
|
|
|
free(as);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(tf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mirrored_set(Evas_Object *obj,
|
|
|
|
Eina_Bool rtl)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
edje_object_mirrored_set(sd->entry_edje, rtl);
|
|
|
|
|
|
|
|
if (sd->anchor_hover.hover)
|
2017-06-13 03:41:15 -07:00
|
|
|
efl_ui_mirrored_set(sd->anchor_hover.hover, rtl);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hide_selection_handler(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (!sd->start_handler) return;
|
|
|
|
|
|
|
|
if (sd->start_handler_shown)
|
|
|
|
{
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->start_handler, "efl,handler,hide", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->start_handler_shown = EINA_FALSE;
|
|
|
|
}
|
|
|
|
if (sd->end_handler_shown)
|
|
|
|
{
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->end_handler, "efl,handler,hide", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->end_handler_shown = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
static Eina_Rect
|
2016-06-08 08:37:35 -07:00
|
|
|
_viewport_region_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Rect rect;
|
2016-06-08 08:37:35 -07:00
|
|
|
Evas_Object *parent;
|
|
|
|
|
|
|
|
if (sd->scroll)
|
2018-09-13 02:45:29 -07:00
|
|
|
{
|
|
|
|
rect = efl_ui_scrollable_viewport_geometry_get(sd->scroller);
|
|
|
|
}
|
2016-06-08 08:37:35 -07:00
|
|
|
else
|
2018-09-13 02:45:29 -07:00
|
|
|
{
|
|
|
|
rect = efl_gfx_entity_geometry_get(sd->text_obj);
|
|
|
|
}
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
parent = elm_widget_parent_get(obj);
|
|
|
|
while (parent)
|
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
if (efl_isa(parent, ELM_INTERFACE_SCROLLABLE_MIXIN))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Eina_Rectangle r;
|
|
|
|
EINA_RECTANGLE_SET(&r, 0, 0, 0, 0);
|
|
|
|
evas_object_geometry_get(parent, &r.x, &r.y, &r.w, &r.h);
|
2018-09-13 02:45:29 -07:00
|
|
|
if (!eina_rectangle_intersection(&rect.rect, &r))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
rect = EINA_RECT_EMPTY();
|
2016-06-08 08:37:35 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parent = elm_widget_parent_get(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-07-10 09:52:14 -07:00
|
|
|
_update_selection_handler(Eo *obj)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
Evas_Coord sx, sy, sh;
|
|
|
|
Evas_Coord ex, ey, eh;
|
|
|
|
|
2016-11-28 23:30:36 -08:00
|
|
|
if (!sd->have_selection)
|
|
|
|
{
|
|
|
|
_hide_selection_handler(obj);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!sd->sel_handler_disabled)
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Rect rect;
|
|
|
|
Eina_Position2D off;
|
2016-06-08 08:37:35 -07:00
|
|
|
Evas_Coord hx, hy;
|
|
|
|
Eina_Bool hidden = EINA_FALSE;
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *sel_start, *sel_end;
|
2016-07-10 09:52:14 -07:00
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(obj, &sel_start, &sel_end);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (!sd->start_handler)
|
2017-11-14 03:38:49 -08:00
|
|
|
_create_selection_handlers(obj, sd);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
//evas_object_geometry_get(sd->entry_edje, &ent_x, &ent_y, NULL, NULL);
|
2016-07-10 09:52:14 -07:00
|
|
|
|
2017-06-08 03:07:12 -07:00
|
|
|
efl_text_cursor_geometry_get(obj, sel_start,
|
|
|
|
EFL_TEXT_CURSOR_TYPE_BEFORE,
|
2016-07-10 09:52:14 -07:00
|
|
|
&sx, &sy, NULL, &sh,
|
|
|
|
NULL, NULL, NULL, NULL);
|
2018-09-13 02:45:29 -07:00
|
|
|
off = _decoration_calc_offset(sd);
|
|
|
|
hx = off.x + sx;
|
|
|
|
hy = off.y + sy + sh;
|
2016-07-10 09:52:14 -07:00
|
|
|
evas_object_move(sd->start_handler, hx, hy);
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
rect = _viewport_region_get(obj);
|
|
|
|
|
|
|
|
if (!eina_rectangle_xcoord_inside(&rect.rect, hx) ||
|
|
|
|
!eina_rectangle_ycoord_inside(&rect.rect, hy))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
hidden = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (!sd->start_handler_shown && !hidden)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->start_handler,
|
2018-04-26 04:24:09 -07:00
|
|
|
"efl,handler,show", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->start_handler_shown = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (sd->start_handler_shown && hidden)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->start_handler,
|
2018-04-26 04:24:09 -07:00
|
|
|
"efl,handler,hide", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->start_handler_shown = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
hidden = EINA_FALSE;
|
2017-06-08 03:07:12 -07:00
|
|
|
efl_text_cursor_geometry_get(obj, sel_end,
|
|
|
|
EFL_TEXT_CURSOR_TYPE_BEFORE,
|
2016-07-10 09:52:14 -07:00
|
|
|
&ex, &ey, NULL, &eh,
|
|
|
|
NULL, NULL, NULL, NULL);
|
2018-09-13 02:45:29 -07:00
|
|
|
hx = off.x + ex;
|
|
|
|
hy = off.y + ey + eh;
|
2016-07-10 09:52:14 -07:00
|
|
|
evas_object_move(sd->end_handler, hx, hy);
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
if (!eina_rectangle_xcoord_inside(&rect.rect, hx) ||
|
|
|
|
!eina_rectangle_ycoord_inside(&rect.rect, hy))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
hidden = EINA_TRUE;
|
|
|
|
}
|
|
|
|
if (!sd->end_handler_shown && !hidden)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->end_handler,
|
2018-04-26 04:24:09 -07:00
|
|
|
"efl,handler,show", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->end_handler_shown = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (sd->end_handler_shown && hidden)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->end_handler,
|
2018-04-26 04:24:09 -07:00
|
|
|
"efl,handler,hide", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->end_handler_shown = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sd->start_handler_shown)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->start_handler,
|
2018-04-26 04:24:09 -07:00
|
|
|
"efl,handler,hide", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->start_handler_shown = EINA_FALSE;
|
|
|
|
}
|
|
|
|
if (sd->end_handler_shown)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->end_handler,
|
2018-04-26 04:24:09 -07:00
|
|
|
"efl,handler,hide", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->end_handler_shown = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-09-13 02:45:29 -07:00
|
|
|
_selection_data_cb(void *data EINA_UNUSED, Eo *obj,
|
2018-12-21 13:46:06 -08:00
|
|
|
Efl_Ui_Selection_Data *sel_data)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Efl_Text_Cursor_Cursor *cur, *start, *end;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
char *buf = eina_slice_strdup(sel_data->content);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(obj, &start, &end);
|
|
|
|
if (!efl_text_cursor_equal(obj, start, end))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_canvas_text_range_delete(obj, start, end);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
cur = efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN);
|
2018-12-21 13:46:06 -08:00
|
|
|
if (sel_data->format == EFL_UI_SELECTION_FORMAT_MARKUP)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2019-01-28 08:10:40 -08:00
|
|
|
efl_text_markup_interactive_cursor_markup_insert(obj, cur, buf);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
else // TEXT
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-06-08 03:07:12 -07:00
|
|
|
efl_text_cursor_text_insert(obj, cur, buf);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
free(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dnd_enter_cb(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj)
|
|
|
|
{
|
|
|
|
elm_object_focus_set(obj, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dnd_leave_cb(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj)
|
|
|
|
{
|
|
|
|
if (_elm_config->desktop_entry)
|
|
|
|
elm_object_focus_set(obj, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dnd_pos_cb(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj,
|
|
|
|
Evas_Coord x,
|
|
|
|
Evas_Coord y,
|
|
|
|
Elm_Xdnd_Action action EINA_UNUSED)
|
|
|
|
{
|
|
|
|
int pos;
|
|
|
|
Evas_Coord ox, oy, ex, ey;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
|
|
|
|
evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL);
|
|
|
|
x = x + ox - ex;
|
|
|
|
y = y + oy - ey;
|
|
|
|
|
|
|
|
edje_object_part_text_cursor_coord_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EDJE_CURSOR_USER, x, y);
|
2016-06-08 08:37:35 -07:00
|
|
|
pos = edje_object_part_text_cursor_pos_get
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EDJE_CURSOR_USER);
|
|
|
|
edje_object_part_text_cursor_pos_set(sd->entry_edje, "efl.text",
|
2016-06-08 08:37:35 -07:00
|
|
|
EDJE_CURSOR_MAIN, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_dnd_drop_cb(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj,
|
|
|
|
Elm_Selection_Data *drop)
|
|
|
|
{
|
|
|
|
Eina_Bool rv;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
rv = edje_object_part_text_cursor_coord_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EDJE_CURSOR_MAIN, drop->x, drop->y);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (!rv) WRN("Warning: Failed to position cursor: paste anyway");
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
//rv = _selection_data_cb(NULL, obj, drop);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Elm_Sel_Format
|
|
|
|
_get_drop_format(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if ((sd->editable) && (!sd->single_line) && (!sd->password) && (!sd->disabled))
|
2018-12-21 13:46:06 -08:00
|
|
|
return EFL_UI_SELECTION_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
|
|
|
|
return EFL_UI_SELECTION_FORMAT_MARKUP;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* we can't reuse layout's here, because it's on entry_edje only */
|
|
|
|
EOLIAN static Eina_Bool
|
2018-01-07 20:55:35 -08:00
|
|
|
_efl_ui_text_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool disabled)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-08-23 22:06:32 -07:00
|
|
|
const char *emission ;
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_drop_target_del(obj, sd->drop_format,
|
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
2017-08-23 22:06:32 -07:00
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
emission = disabled ? "efl,state,disabled" : "efl,state,enabled";
|
|
|
|
edje_object_signal_emit(sd->entry_edje, emission, "efl");
|
2017-08-23 22:06:32 -07:00
|
|
|
if (sd->scroll)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->scr_edje, emission, "efl");
|
2018-09-13 02:45:29 -07:00
|
|
|
//elm_interface_scrollable_freeze_set(obj, disabled);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
2017-08-23 22:06:32 -07:00
|
|
|
sd->disabled = disabled;
|
|
|
|
|
|
|
|
if (!disabled)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
sd->drop_format = _get_drop_format(obj);
|
|
|
|
elm_drop_target_add(obj, sd->drop_format,
|
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we can't issue the layout's theming code here, cause it assumes an
|
|
|
|
* unique edje object, always */
|
2018-11-19 20:56:37 -08:00
|
|
|
EOLIAN static Efl_Ui_Theme_Apply_Result
|
2018-01-07 20:55:35 -08:00
|
|
|
_efl_ui_text_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-11-19 20:56:37 -08:00
|
|
|
Efl_Ui_Theme_Apply_Result theme_apply;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
|
|
|
|
2017-08-02 05:15:50 -07:00
|
|
|
// Note: We are skipping elm_layout here! This is by design.
|
|
|
|
// This assumes the following inheritance: my_class -> layout -> widget ...
|
2018-01-07 20:55:35 -08:00
|
|
|
theme_apply = efl_ui_widget_theme_apply(efl_cast(obj, EFL_UI_WIDGET_CLASS));
|
2018-11-19 20:56:37 -08:00
|
|
|
if (!theme_apply) return EFL_UI_THEME_APPLY_RESULT_FAIL;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-09-11 22:38:51 -07:00
|
|
|
efl_event_freeze(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
edje_object_mirrored_set
|
2017-06-13 03:41:15 -07:00
|
|
|
(wd->resize_obj, efl_ui_mirrored_get(obj));
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
edje_object_scale_set
|
|
|
|
(wd->resize_obj,
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_scale_get(obj) * elm_config_scale_get());
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-06-13 03:41:15 -07:00
|
|
|
_mirrored_set(obj, efl_ui_mirrored_get(obj));
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-11-14 03:38:49 -08:00
|
|
|
elm_widget_element_update(obj, sd->entry_edje,
|
2017-12-06 00:33:03 -08:00
|
|
|
elm_widget_theme_element_get(obj));
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (elm_widget_disabled_get(obj))
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,state,disabled", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
edje_object_part_text_input_panel_layout_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Input_Panel_Layout)sd->input_panel_layout);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_part_text_input_panel_layout_variation_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", sd->input_panel_layout_variation);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_part_text_autocapital_type_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Text_Autocapital_Type)sd->autocapital_type);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_part_text_prediction_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", sd->prediction_allow);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_part_text_input_hint_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Input_Hints)sd->input_hints);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_part_text_input_panel_enabled_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", sd->input_panel_enable);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_part_text_input_panel_imdata_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", sd->input_panel_imdata,
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->input_panel_imdata_len);
|
|
|
|
edje_object_part_text_input_panel_return_key_type_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Input_Panel_Return_Key_Type)sd->input_panel_return_key_type);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_part_text_input_panel_return_key_disabled_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", sd->input_panel_return_key_disabled);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_part_text_input_panel_show_on_demand_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", sd->input_panel_show_on_demand);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
// elm_entry_cursor_pos_set -> cursor,changed -> widget_show_region_set
|
|
|
|
// -> smart_objects_calculate will call all smart calculate functions,
|
|
|
|
// and one of them can delete elm_entry.
|
|
|
|
evas_object_ref(obj);
|
|
|
|
|
2017-11-29 00:39:42 -08:00
|
|
|
if (efl_ui_focus_object_focus_get(obj))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,action,focus", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
if (sd->scroll)
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->scr_edje, "efl,action,focus", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
edje_object_message_signal_process(sd->entry_edje);
|
|
|
|
|
|
|
|
Evas_Object* clip = evas_object_clip_get(sd->entry_edje);
|
|
|
|
evas_object_clip_set(sd->hit_rect, clip);
|
|
|
|
|
|
|
|
if (sd->start_handler)
|
|
|
|
{
|
2017-11-14 03:38:49 -08:00
|
|
|
elm_widget_element_update(obj, sd->start_handler, PART_NAME_HANDLER_START);
|
|
|
|
elm_widget_element_update(obj, sd->end_handler, PART_NAME_HANDLER_END);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
sd->has_text = !sd->has_text;
|
|
|
|
_efl_ui_text_guide_update(obj, !sd->has_text);
|
2017-09-11 22:38:51 -07:00
|
|
|
efl_event_thaw(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-11-16 01:45:05 -08:00
|
|
|
efl_event_callback_call(obj, EFL_UI_LAYOUT_EVENT_THEME_CHANGED, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
evas_object_unref(obj);
|
|
|
|
|
2017-08-02 05:15:50 -07:00
|
|
|
return theme_apply;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cursor_geometry_recalc(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
2016-07-10 07:30:51 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
Evas_Coord x2, y2, w2, h2;
|
|
|
|
Evas_Coord cx, cy, cw, ch;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-09-11 22:38:51 -07:00
|
|
|
if (!sd->editable) return;
|
|
|
|
|
2017-06-07 22:10:19 -07:00
|
|
|
cx = cy = cw = ch = 0;
|
|
|
|
x2 = y2 = w2 = h2 = 0;
|
|
|
|
x = y = w = h = 0;
|
|
|
|
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *main_cur =
|
2017-06-08 06:46:42 -07:00
|
|
|
efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-06-08 03:07:12 -07:00
|
|
|
efl_text_cursor_geometry_get(obj, main_cur,
|
|
|
|
EFL_TEXT_CURSOR_TYPE_BEFORE,
|
2016-07-10 07:30:51 -07:00
|
|
|
&cx, &cy, &cw, &ch, NULL, NULL, NULL, NULL);
|
|
|
|
edje_object_size_min_restricted_calc(sd->cursor, &cw, NULL, cw, 0);
|
|
|
|
if (cw < 1) cw = 1;
|
|
|
|
if (ch < 1) ch = 1;
|
|
|
|
edje_object_size_min_restricted_calc(sd->cursor, &cw, NULL, cw, 0);
|
|
|
|
evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h);
|
|
|
|
evas_object_geometry_get(
|
2018-11-12 05:09:56 -08:00
|
|
|
sd->text_obj,
|
2016-07-10 07:30:51 -07:00
|
|
|
&x2, &y2, &w2, &h2);
|
2018-11-12 05:09:56 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_ui_scrollable_scroll(sd->scroller, EINA_RECT(cx, cy, cw, ch), EINA_FALSE);
|
|
|
|
|
2016-07-03 09:38:03 -07:00
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
#define SIZE2D_EQ(X, Y) (((X).w == (Y).w) && ((X).h == (Y).h))
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Size2D min = EINA_SIZE2D(0, 0);
|
|
|
|
Eina_Size2D edmin = EINA_SIZE2D(0, 0);
|
|
|
|
Eina_Size2D sz = EINA_SIZE2D(0, 0);
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2016-11-28 03:22:40 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
sz = efl_gfx_entity_size_get(obj);
|
|
|
|
if (!sd->calc_force && SIZE2D_EQ(sd->last.layout, sz) &&
|
|
|
|
!sd->text_changed)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-11-28 03:22:40 -08:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->single_line = !efl_text_multiline_get(sd->text_obj);
|
|
|
|
|
|
|
|
sd->calc_force = EINA_FALSE;
|
|
|
|
sd->last.layout.w = sz.w;
|
|
|
|
sd->last.layout.h = sz.h;
|
|
|
|
sd->text_changed = EINA_FALSE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-11-28 03:22:40 -08:00
|
|
|
if (sd->scroll)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
if (sd->single_line)
|
2016-11-28 03:22:40 -08:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_ui_internal_text_scroller_mode_set(sd->scroller,
|
|
|
|
EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
|
2016-11-28 03:22:40 -08:00
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
else
|
2017-05-23 06:04:04 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_ui_internal_text_scroller_mode_set(sd->scroller,
|
|
|
|
EFL_UI_TEXT_SCROLLER_MODE_MULTILINE);
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
}
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
elm_layout_sizing_eval(sd->scroller);
|
|
|
|
min = efl_gfx_size_hint_min_get(sd->scroller);
|
|
|
|
if (sd->single_line)
|
|
|
|
{
|
|
|
|
efl_ui_internal_text_scroller_mode_set(sd->scroller,
|
|
|
|
EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
|
|
|
|
edje_object_size_min_calc(wd->resize_obj, &edmin.w, &edmin.h);
|
|
|
|
min.w = edmin.w;
|
|
|
|
min.h = edmin.h;
|
|
|
|
efl_gfx_size_hint_restricted_min_set(obj, min);
|
|
|
|
}
|
2017-05-23 06:04:04 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->cursor_update = EINA_TRUE;
|
|
|
|
_decoration_defer_all(obj);
|
2017-09-11 22:38:51 -07:00
|
|
|
}
|
|
|
|
else
|
2017-09-09 03:21:06 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
edje_object_size_min_calc(wd->resize_obj, &edmin.w, &edmin.h);
|
|
|
|
efl_canvas_text_size_formatted_get(sd->text_obj, &min.w, &min.h);
|
|
|
|
min.w += edmin.w;
|
|
|
|
min.h += edmin.h;
|
|
|
|
efl_gfx_size_hint_restricted_min_set(obj, min);
|
2017-09-09 03:21:06 -07:00
|
|
|
}
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_return_key_enabled_check(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Eina_Bool return_key_disabled = EINA_FALSE;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (!sd->auto_return_key) return;
|
|
|
|
|
|
|
|
if (efl_canvas_text_is_empty_get(obj) == EINA_TRUE)
|
|
|
|
return_key_disabled = EINA_TRUE;
|
|
|
|
|
|
|
|
efl_ui_text_input_panel_return_key_disabled_set(obj, return_key_disabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-01-19 00:25:47 -08:00
|
|
|
_efl_ui_text_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Object *top;
|
|
|
|
Eina_Bool top_is_win = EINA_FALSE;
|
|
|
|
|
|
|
|
if (!sd->editable) return EINA_FALSE;
|
|
|
|
|
|
|
|
top = elm_widget_top_get(obj);
|
2016-08-15 06:44:41 -07:00
|
|
|
if (top && efl_isa(top, EFL_UI_WIN_CLASS))
|
2016-06-08 08:37:35 -07:00
|
|
|
top_is_win = EINA_TRUE;
|
|
|
|
|
2017-11-29 00:39:42 -08:00
|
|
|
if (efl_ui_focus_object_focus_get(obj))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
evas_object_focus_set(sd->text_obj, EINA_TRUE);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
_edje_signal_emit(sd, "efl,action,focus", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
if (sd->scroll)
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->scr_edje, "efl,action,focus", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-12-12 01:21:01 -08:00
|
|
|
if (top && top_is_win && sd->input_panel_enable && !sd->input_panel_show_on_demand)
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
|
|
|
|
if (_elm_config->atspi_mode)
|
2017-10-18 18:13:54 -07:00
|
|
|
efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_FOCUSED, EINA_TRUE);
|
2016-06-08 08:37:35 -07:00
|
|
|
_return_key_enabled_check(obj);
|
|
|
|
_validate(obj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-12 05:09:56 -08:00
|
|
|
Eo *sw = sd->text_obj;
|
2016-07-10 07:30:51 -07:00
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
_edje_signal_emit(sd, "efl,action,unfocus", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
if (sd->scroll)
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->scr_edje, "efl,action,unfocus", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_object_focus_set(sw, EINA_FALSE);
|
2016-07-10 07:30:51 -07:00
|
|
|
|
2016-12-12 01:21:01 -08:00
|
|
|
if (top && top_is_win && sd->input_panel_enable)
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
|
|
|
|
if (_elm_config->atspi_mode)
|
2017-10-18 18:13:54 -07:00
|
|
|
efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_FOCUSED, EINA_FALSE);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (_elm_config->selection_clear_enable)
|
|
|
|
{
|
|
|
|
if ((sd->have_selection) && (!sd->hoversel))
|
|
|
|
{
|
|
|
|
sd->sel_mode = EINA_FALSE;
|
|
|
|
elm_widget_scroll_hold_pop(obj);
|
2018-04-26 03:27:43 -07:00
|
|
|
edje_object_part_text_select_allow_set(sd->entry_edje, "efl.text", EINA_FALSE);
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,state,select,off", "efl");
|
2018-04-26 03:27:43 -07:00
|
|
|
edje_object_part_text_select_none(sd->entry_edje, "efl.text");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
}
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->scr_edje, "validation,default", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2017-09-13 19:59:44 -07:00
|
|
|
EOLIAN static Eina_Rect
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_ui_widget_interest_region_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Coord edje_x, edje_y, elm_x, elm_y;
|
2017-09-13 19:59:44 -07:00
|
|
|
Eina_Rect r = {};
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-06-20 05:31:08 -07:00
|
|
|
efl_text_cursor_geometry_get(obj,
|
|
|
|
efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN),
|
|
|
|
EFL_TEXT_CURSOR_TYPE_BEFORE,
|
2017-08-29 19:29:08 -07:00
|
|
|
&r.x, &r.y, &r.w, &r.h,
|
2017-06-20 05:31:08 -07:00
|
|
|
NULL, NULL, NULL, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (sd->single_line)
|
|
|
|
{
|
2017-08-29 19:29:08 -07:00
|
|
|
evas_object_geometry_get(sd->entry_edje, NULL, NULL, NULL, &r.h);
|
|
|
|
r.y = 0;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
evas_object_geometry_get(sd->entry_edje, &edje_x, &edje_y, NULL, NULL);
|
|
|
|
evas_object_geometry_get(obj, &elm_x, &elm_y, NULL, NULL);
|
|
|
|
|
2017-08-29 19:29:08 -07:00
|
|
|
r.x += edje_x - elm_x;
|
|
|
|
r.y += edje_y - elm_y;
|
|
|
|
if (r.w < 1) r.w = 1;
|
|
|
|
if (r.h < 1) r.h = 1;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-08-29 19:29:08 -07:00
|
|
|
return r;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hoversel_position(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Coord cx, cy, cw, ch, x, y, mw, mh, w, h;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
cx = cy = 0;
|
|
|
|
cw = ch = 1;
|
|
|
|
evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h);
|
|
|
|
if (sd->use_down)
|
|
|
|
{
|
|
|
|
cx = sd->downx - x;
|
|
|
|
cy = sd->downy - y;
|
|
|
|
cw = 1;
|
|
|
|
ch = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
edje_object_part_text_cursor_geometry_get
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", &cx, &cy, &cw, &ch);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
evas_object_size_hint_min_get(sd->hoversel, &mw, &mh);
|
|
|
|
if (cx + mw > w)
|
|
|
|
cx = w - mw;
|
|
|
|
if (cy + mh > h)
|
|
|
|
cy = h - mh;
|
2018-11-21 07:38:24 -08:00
|
|
|
evas_object_geometry_set(sd->hoversel, x + cx, y + cy, mw, mh);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hover_del_job(void *data)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
ELM_SAFE_FREE(sd->hoversel, evas_object_del);
|
|
|
|
sd->hov_deljob = NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_hover_dismissed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->use_down = 0;
|
|
|
|
if (sd->hoversel) evas_object_hide(sd->hoversel);
|
|
|
|
if (sd->sel_mode)
|
|
|
|
{
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
{
|
|
|
|
if (!sd->password)
|
|
|
|
edje_object_part_text_select_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EINA_TRUE);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
elm_widget_scroll_freeze_pop(data);
|
|
|
|
ecore_job_del(sd->hov_deljob);
|
|
|
|
sd->hov_deljob = ecore_job_add(_hover_del_job, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hover_selected_cb(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (!sd->sel_allow) return;
|
|
|
|
|
|
|
|
sd->sel_mode = EINA_TRUE;
|
2018-04-26 03:27:43 -07:00
|
|
|
edje_object_part_text_select_none(sd->entry_edje, "efl.text");
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
{
|
|
|
|
if (!sd->password)
|
|
|
|
edje_object_part_text_select_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EINA_TRUE);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,state,select,on", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
elm_widget_scroll_hold_push(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_paste_cb(Eo *obj)
|
|
|
|
{
|
2018-12-21 13:46:06 -08:00
|
|
|
Efl_Ui_Selection_Format formats = EFL_UI_SELECTION_FORMAT_TEXT |
|
|
|
|
EFL_UI_SELECTION_FORMAT_MARKUP;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-12-21 13:46:06 -08:00
|
|
|
efl_ui_selection_get(obj, EFL_UI_SELECTION_TYPE_CLIPBOARD, formats,
|
2018-09-13 02:45:29 -07:00
|
|
|
NULL, _selection_data_cb, NULL, 1);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hoversel_item_paste_cb(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_paste_cb(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_selection_clear(void *data, Elm_Sel_Type selection)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (!sd->have_selection) return;
|
2018-12-21 13:46:06 -08:00
|
|
|
if ((selection == EFL_UI_SELECTION_TYPE_CLIPBOARD) ||
|
|
|
|
(selection == EFL_UI_SELECTION_TYPE_PRIMARY))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
_efl_ui_text_select_none(data, sd);
|
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
_selection_defer(data, sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Value
|
|
|
|
_selection_lost_cb(void *data, const Eina_Value value)
|
|
|
|
{
|
|
|
|
Selection_Loss_Data *sdata = data;
|
|
|
|
_selection_clear(sdata->obj, sdata->stype);
|
|
|
|
EFL_UI_TEXT_DATA_GET(sdata->obj, sd);
|
|
|
|
switch (sdata->stype)
|
|
|
|
{
|
2018-12-21 13:46:06 -08:00
|
|
|
case EFL_UI_SELECTION_TYPE_CLIPBOARD:
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->sel_future.clipboard = NULL;
|
|
|
|
break;
|
2018-12-21 13:46:06 -08:00
|
|
|
case EFL_UI_SELECTION_TYPE_PRIMARY:
|
2018-09-13 02:45:29 -07:00
|
|
|
default:
|
|
|
|
sd->sel_future.primary = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-12-21 13:46:06 -08:00
|
|
|
_selection_store(Efl_Ui_Selection_Type seltype,
|
2016-06-08 08:37:35 -07:00
|
|
|
Evas_Object *obj)
|
|
|
|
{
|
|
|
|
char *sel;
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *start, *end;
|
2018-12-21 13:46:06 -08:00
|
|
|
Efl_Ui_Selection_Format selformat = EFL_UI_SELECTION_FORMAT_MARKUP;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Slice slice;
|
|
|
|
Selection_Loss_Data *ldata;
|
|
|
|
Eina_Future *f;
|
|
|
|
|
|
|
|
ldata = calloc(1, sizeof(Selection_Loss_Data));
|
|
|
|
if (!ldata) return;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(obj, &start, &end);
|
2019-01-28 08:10:40 -08:00
|
|
|
sel = efl_text_markup_interactive_markup_range_get(obj, start, end);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if ((!sel) || (!sel[0])) return; /* avoid deleting our own selection */
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
slice.len = strlen(sel);
|
|
|
|
slice.mem = sel;
|
|
|
|
|
|
|
|
|
|
|
|
switch (seltype)
|
|
|
|
{
|
2018-12-21 13:46:06 -08:00
|
|
|
case EFL_UI_SELECTION_TYPE_CLIPBOARD:
|
2018-09-13 02:45:29 -07:00
|
|
|
if (sd->sel_future.clipboard)
|
|
|
|
{
|
|
|
|
eina_future_cancel(sd->sel_future.clipboard);
|
|
|
|
}
|
|
|
|
|
2018-12-21 13:46:06 -08:00
|
|
|
f = sd->sel_future.clipboard = efl_ui_selection_set(obj, seltype,
|
2018-09-13 02:45:29 -07:00
|
|
|
selformat, slice, 1);
|
|
|
|
break;
|
|
|
|
|
2018-12-21 13:46:06 -08:00
|
|
|
case EFL_UI_SELECTION_TYPE_PRIMARY:
|
2018-09-13 02:45:29 -07:00
|
|
|
default:
|
|
|
|
if (sd->sel_future.primary)
|
|
|
|
{
|
|
|
|
eina_future_cancel(sd->sel_future.primary);
|
|
|
|
}
|
|
|
|
|
2018-12-21 13:46:06 -08:00
|
|
|
f = sd->sel_future.primary = efl_ui_selection_set(obj, seltype,
|
2018-09-13 02:45:29 -07:00
|
|
|
selformat, slice, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ldata->obj = obj;
|
|
|
|
eina_future_then_easy(f, _selection_lost_cb, NULL, NULL, EINA_VALUE_TYPE_UINT, ldata);
|
|
|
|
|
2018-12-21 13:46:06 -08:00
|
|
|
//if (seltype == EFL_UI_SELECTION_TYPE_CLIPBOARD)
|
2018-09-13 02:45:29 -07:00
|
|
|
// eina_stringshare_replace(&sd->cut_sel, sel);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
free(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cut_cb(Eo *obj)
|
|
|
|
{
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *start, *end;
|
2016-06-08 08:37:35 -07:00
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
2017-12-12 22:19:43 -08:00
|
|
|
efl_event_callback_call(obj, EFL_UI_EVENT_SELECTION_CUT, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
/* Store it */
|
|
|
|
sd->sel_mode = EINA_FALSE;
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
edje_object_part_text_select_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EINA_FALSE);
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,state,select,off", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
elm_widget_scroll_hold_pop(obj);
|
|
|
|
|
2018-12-21 13:46:06 -08:00
|
|
|
_selection_store(EFL_UI_SELECTION_TYPE_CLIPBOARD, obj);
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(obj, &start, &end);
|
2016-06-08 08:37:35 -07:00
|
|
|
efl_canvas_text_range_delete(obj, start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hoversel_item_cut_cb(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_cut_cb(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_copy_cb(Eo *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
2017-12-12 22:19:43 -08:00
|
|
|
efl_event_callback_call(obj, EFL_UI_EVENT_SELECTION_COPY, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->sel_mode = EINA_FALSE;
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
{
|
|
|
|
edje_object_part_text_select_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EINA_FALSE);
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,state,select,off", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_widget_scroll_hold_pop(obj);
|
|
|
|
}
|
2018-12-21 13:46:06 -08:00
|
|
|
_selection_store(EFL_UI_SELECTION_TYPE_CLIPBOARD, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hoversel_item_copy_cb(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_copy_cb(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hover_cancel_cb(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->sel_mode = EINA_FALSE;
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
edje_object_part_text_select_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EINA_FALSE);
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,state,select,off", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
elm_widget_scroll_hold_pop(data);
|
2018-04-26 03:27:43 -07:00
|
|
|
edje_object_part_text_select_none(sd->entry_edje, "efl.text");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_hover_item_clicked_cb(void *data,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Elm_Entry_Context_Menu_Item *it = data;
|
|
|
|
if (!it) return;
|
|
|
|
|
|
|
|
if (it->func) it->func(it->data, it->obj, it);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_menu_call(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *top;
|
|
|
|
const Eina_List *l;
|
|
|
|
const Elm_Entry_Context_Menu_Item *it;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (sd->anchor_hover.hover) return;
|
|
|
|
|
2017-12-12 22:19:43 -08:00
|
|
|
efl_event_callback_call(obj, EFL_UI_TEXT_EVENT_CONTEXT_OPEN, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if ((sd->api) && (sd->api->obj_longpress))
|
|
|
|
{
|
|
|
|
sd->api->obj_longpress(obj);
|
|
|
|
}
|
|
|
|
else if (sd->context_menu)
|
|
|
|
{
|
|
|
|
const char *context_menu_orientation;
|
|
|
|
Eina_Bool ownersel;
|
|
|
|
|
|
|
|
ownersel = elm_selection_selection_has_owner(obj);
|
|
|
|
if (!sd->items)
|
|
|
|
{
|
|
|
|
/* prevent stupid blank hoversel */
|
|
|
|
if (sd->have_selection && sd->password) return;
|
|
|
|
if (_elm_config->desktop_entry && (!sd->have_selection) && ((!sd->editable) || (!ownersel)))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (sd->hoversel) evas_object_del(sd->hoversel);
|
|
|
|
else elm_widget_scroll_freeze_push(obj);
|
|
|
|
|
|
|
|
sd->hoversel = elm_hoversel_add(obj);
|
|
|
|
context_menu_orientation = edje_object_data_get
|
|
|
|
(sd->entry_edje, "context_menu_orientation");
|
|
|
|
|
|
|
|
if ((context_menu_orientation) &&
|
|
|
|
(!strcmp(context_menu_orientation, "horizontal")))
|
|
|
|
elm_hoversel_horizontal_set(sd->hoversel, EINA_TRUE);
|
|
|
|
|
|
|
|
elm_object_style_set(sd->hoversel, "entry");
|
|
|
|
elm_widget_sub_object_add(obj, sd->hoversel);
|
|
|
|
elm_object_text_set(sd->hoversel, "Text");
|
|
|
|
top = elm_widget_top_get(obj);
|
|
|
|
|
|
|
|
if (top) elm_hoversel_hover_parent_set(sd->hoversel, top);
|
|
|
|
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_add
|
2016-06-08 08:37:35 -07:00
|
|
|
(sd->hoversel, ELM_HOVERSEL_EVENT_DISMISSED, _hover_dismissed_cb, obj);
|
|
|
|
if (sd->have_selection)
|
|
|
|
{
|
|
|
|
if (!sd->password)
|
|
|
|
{
|
2016-09-17 15:58:55 -07:00
|
|
|
if (sd->editable)
|
|
|
|
elm_hoversel_item_add
|
|
|
|
(sd->hoversel, E_("Cut"), NULL, ELM_ICON_NONE,
|
|
|
|
_hoversel_item_cut_cb, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_hoversel_item_add
|
|
|
|
(sd->hoversel, E_("Copy"), NULL, ELM_ICON_NONE,
|
|
|
|
_hoversel_item_copy_cb, obj);
|
2016-09-17 15:58:55 -07:00
|
|
|
if (sd->editable && ownersel)
|
|
|
|
elm_hoversel_item_add
|
|
|
|
(sd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
|
|
|
|
_hoversel_item_paste_cb, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_hoversel_item_add
|
|
|
|
(sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
|
|
|
|
_hover_cancel_cb, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!sd->sel_mode)
|
|
|
|
{
|
|
|
|
if (sd->sel_allow && !_elm_config->desktop_entry)
|
|
|
|
{
|
|
|
|
if (!sd->password)
|
|
|
|
elm_hoversel_item_add
|
|
|
|
(sd->hoversel, E_("Select"), NULL, ELM_ICON_NONE,
|
|
|
|
_hover_selected_cb, obj);
|
|
|
|
}
|
|
|
|
if (ownersel)
|
|
|
|
{
|
|
|
|
if (sd->editable)
|
|
|
|
elm_hoversel_item_add
|
|
|
|
(sd->hoversel, E_("Paste"), NULL, ELM_ICON_NONE,
|
|
|
|
_hoversel_item_paste_cb, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_hoversel_item_add
|
|
|
|
(sd->hoversel, E_("Cancel"), NULL, ELM_ICON_NONE,
|
|
|
|
_hover_cancel_cb, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->items, l, it)
|
|
|
|
{
|
|
|
|
elm_hoversel_item_add(sd->hoversel, it->label, it->icon_file,
|
|
|
|
it->icon_type, _hover_item_clicked_cb, it);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sd->hoversel)
|
|
|
|
{
|
|
|
|
_hoversel_position(obj);
|
|
|
|
evas_object_show(sd->hoversel);
|
|
|
|
elm_hoversel_hover_begin(sd->hoversel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
{
|
|
|
|
edje_object_part_text_select_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EINA_FALSE);
|
|
|
|
edje_object_part_text_select_abort(sd->entry_edje, "efl.text");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_long_press_cb(void *data)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
/* Context menu will not appear if context menu disabled is set
|
|
|
|
* as false on a long press callback */
|
|
|
|
if (!_elm_config->context_menu_disabled &&
|
|
|
|
(!_elm_config->desktop_entry))
|
|
|
|
_menu_call(data);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->long_pressed = EINA_TRUE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->longpress_timer = NULL;
|
|
|
|
efl_event_callback_call(data, EFL_UI_EVENT_LONGPRESSED, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-09-13 02:45:29 -07:00
|
|
|
_key_down_cb(void *data,
|
|
|
|
Evas *evas EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Evas_Event_Key_Down *ev = event_info;
|
|
|
|
Eina_Bool on_hold = EINA_FALSE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
/* First check if context menu disabled is false or not, and
|
|
|
|
* then check for key id */
|
|
|
|
if ((!_elm_config->context_menu_disabled) && !strcmp(ev->key, "Menu"))
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
_menu_call(data);
|
|
|
|
on_hold = EINA_TRUE;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
#if defined(__APPLE__) && defined(__MACH__)
|
|
|
|
Eina_Bool control = evas_key_modifier_is_set(ev->modifiers, "Super");
|
|
|
|
#else
|
|
|
|
Eina_Bool control = evas_key_modifier_is_set(ev->modifiers, "Control");
|
|
|
|
#endif
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
/* Ctrl operations */
|
|
|
|
if (control)
|
|
|
|
{
|
|
|
|
if (!strncmp(ev->key, "c", 1))
|
|
|
|
{
|
|
|
|
_copy_cb(data);
|
|
|
|
on_hold = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strncmp(ev->key, "x", 1))
|
|
|
|
{
|
|
|
|
_cut_cb(data);
|
|
|
|
on_hold = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strncmp(ev->key, "v", 1))
|
|
|
|
{
|
|
|
|
_paste_cb(data);
|
|
|
|
on_hold = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (on_hold) ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_down_cb(void *data,
|
|
|
|
Evas *evas EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (sd->disabled) return;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
|
|
|
sd->downx = ev->canvas.x;
|
|
|
|
sd->downy = ev->canvas.y;
|
|
|
|
sd->long_pressed = EINA_FALSE;
|
|
|
|
|
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
|
|
|
sd->longpress_timer = ecore_timer_add
|
|
|
|
(_elm_config->longpress_timeout, _long_press_cb, data);
|
|
|
|
}
|
|
|
|
/* If right button is pressed and context menu disabled is true,
|
|
|
|
* then only context menu will appear */
|
|
|
|
else if (ev->button == 3 && (!_elm_config->context_menu_disabled))
|
|
|
|
{
|
|
|
|
if (_elm_config->desktop_entry)
|
|
|
|
{
|
|
|
|
sd->use_down = 1;
|
|
|
|
_menu_call(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_up_cb(void *data,
|
|
|
|
Evas *evas EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
|
|
|
Eina_Bool top_is_win = EINA_FALSE;
|
|
|
|
Evas_Object *top;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (sd->disabled) return;
|
|
|
|
if (ev->button == 1)
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
|
|
|
/* Since context menu disabled flag was checked at long press start while mouse
|
|
|
|
* down, hence the same should be checked at mouse up from a long press
|
|
|
|
* as well */
|
2018-09-13 02:45:29 -07:00
|
|
|
if (sd->long_pressed)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
if (!_elm_config->context_menu_disabled)
|
|
|
|
{
|
|
|
|
_menu_call(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
top = elm_widget_top_get(data);
|
|
|
|
if (top)
|
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
if (efl_isa(top, EFL_UI_WIN_CLASS))
|
2016-06-08 08:37:35 -07:00
|
|
|
top_is_win = EINA_TRUE;
|
|
|
|
|
2016-12-12 01:21:01 -08:00
|
|
|
if (top_is_win && sd->input_panel_enable && sd->input_panel_show_on_demand)
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Since context menu disabled flag was checked at mouse right key down,
|
|
|
|
* hence the same should be stopped at mouse up of right key as well */
|
|
|
|
else if ((ev->button == 3) && (!_elm_config->context_menu_disabled) &&
|
|
|
|
(!_elm_config->desktop_entry))
|
|
|
|
{
|
|
|
|
sd->use_down = 1;
|
|
|
|
_menu_call(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_move_cb(void *data,
|
|
|
|
Evas *evas EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Move *ev = event_info;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (sd->disabled) return;
|
|
|
|
if (ev->buttons == 1)
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
if (sd->long_pressed)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Coord x, y;
|
|
|
|
Eina_Bool rv;
|
|
|
|
|
|
|
|
evas_object_geometry_get(sd->entry_edje, &x, &y, NULL, NULL);
|
|
|
|
rv = edje_object_part_text_cursor_coord_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EDJE_CURSOR_USER,
|
2016-06-08 08:37:35 -07:00
|
|
|
ev->cur.canvas.x - x, ev->cur.canvas.y - y);
|
|
|
|
if (rv)
|
|
|
|
{
|
|
|
|
edje_object_part_text_cursor_copy
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EDJE_CURSOR_USER, EDJE_CURSOR_MAIN);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
WRN("Warning: Cannot move cursor");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!sd->sel_mode)
|
|
|
|
{
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
|
|
|
}
|
|
|
|
else if (sd->longpress_timer)
|
|
|
|
{
|
|
|
|
Evas_Coord dx, dy;
|
|
|
|
|
|
|
|
dx = sd->downx - ev->cur.canvas.x;
|
|
|
|
dx *= dx;
|
|
|
|
dy = sd->downy - ev->cur.canvas.y;
|
|
|
|
dy *= dy;
|
|
|
|
if ((dx + dy) >
|
|
|
|
((_elm_config->finger_size / 2) *
|
|
|
|
(_elm_config->finger_size / 2)))
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sd->longpress_timer)
|
|
|
|
{
|
|
|
|
Evas_Coord dx, dy;
|
|
|
|
|
|
|
|
dx = sd->downx - ev->cur.canvas.x;
|
|
|
|
dx *= dx;
|
|
|
|
dy = sd->downy - ev->cur.canvas.y;
|
|
|
|
dy *= dy;
|
|
|
|
if ((dx + dy) >
|
|
|
|
((_elm_config->finger_size / 2) *
|
|
|
|
(_elm_config->finger_size / 2)))
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2016-06-22 05:12:15 -07:00
|
|
|
_item_get(void *data, const char *item)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-11-09 07:53:20 -08:00
|
|
|
Evas_Object *o = NULL;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
2017-11-09 07:53:20 -08:00
|
|
|
if (item)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-11-09 07:53:20 -08:00
|
|
|
if (sd->item_factory)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-11-09 07:53:20 -08:00
|
|
|
o = efl_canvas_text_factory_create(sd->item_factory, data, item);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
2017-11-09 07:53:20 -08:00
|
|
|
else if (sd->item_fallback_factory)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-11-09 07:53:20 -08:00
|
|
|
o = efl_canvas_text_factory_create(sd->item_fallback_factory,
|
|
|
|
data, item);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-04 21:39:20 -08:00
|
|
|
_efl_ui_text_efl_layout_signal_signal_emit(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, const char *emission, const char *source)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
/* always pass to both edje objs */
|
2017-12-04 21:39:20 -08:00
|
|
|
efl_layout_signal_emit(sd->entry_edje, emission, source);
|
2017-08-03 01:24:50 -07:00
|
|
|
|
|
|
|
// FIXME: This should not be here!
|
2017-12-04 21:39:20 -08:00
|
|
|
efl_layout_signal_process(sd->entry_edje, EINA_TRUE);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (sd->scr_edje)
|
|
|
|
{
|
2017-12-04 21:39:20 -08:00
|
|
|
efl_layout_signal_emit(sd->scr_edje, emission, source);
|
|
|
|
efl_layout_signal_process(sd->scr_edje, EINA_TRUE); // FIXME
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-06 10:48:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_efl_ui_text_efl_layout_signal_signal_callback_add(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *pd, const char *emission, const char *source, void *func_data, EflLayoutSignalCb func, Eina_Free_Cb func_free_cb)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-08-03 01:24:50 -07:00
|
|
|
Eina_Bool ok;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2019-02-06 10:48:43 -08:00
|
|
|
ok = efl_layout_signal_callback_add(pd->entry_edje, emission, source, func_data, func, func_free_cb);
|
|
|
|
if (pd->scr_edje)
|
|
|
|
ok = efl_layout_signal_callback_add(pd->scr_edje, emission, source, func_data, func, func_free_cb);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-08-03 01:24:50 -07:00
|
|
|
return ok;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2019-02-06 10:48:43 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_efl_ui_text_efl_layout_signal_signal_callback_del(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *pd, const char *emission, const char *source, void *func_data, EflLayoutSignalCb func, Eina_Free_Cb func_free_cb)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-08-03 01:24:50 -07:00
|
|
|
Eina_Bool ok;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2019-02-06 10:48:43 -08:00
|
|
|
ok = efl_layout_signal_callback_del(pd->entry_edje, emission, source, func_data, func, func_free_cb);
|
|
|
|
if (pd->scr_edje)
|
|
|
|
ok = efl_layout_signal_callback_del(pd->scr_edje, emission, source, func_data, func, func_free_cb);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-08-03 01:24:50 -07:00
|
|
|
return ok;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-09-13 02:45:29 -07:00
|
|
|
_selection_handlers_offset_calc(Evas_Object *obj, Evas_Object *handler)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Coord cx, cy, cw, ch;
|
|
|
|
Evas_Coord hh;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Position2D pos;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
pos = efl_gfx_entity_position_get(sd->text_obj);
|
2017-09-26 16:03:59 -07:00
|
|
|
efl_text_cursor_geometry_get(obj,
|
2017-06-08 06:46:42 -07:00
|
|
|
efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN),
|
2017-06-08 03:07:12 -07:00
|
|
|
EFL_TEXT_CURSOR_TYPE_BEFORE,
|
2016-07-10 09:52:14 -07:00
|
|
|
&cx, &cy, &cw, &ch,
|
|
|
|
NULL, NULL, NULL, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_size_min_calc(handler, NULL, &hh);
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->ox = pos.x + cx + (cw / 2);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (ch > hh)
|
2018-09-13 02:45:29 -07:00
|
|
|
{
|
|
|
|
sd->oy = pos.y + cy + ch;
|
|
|
|
}
|
2016-06-08 08:37:35 -07:00
|
|
|
else
|
2018-09-13 02:45:29 -07:00
|
|
|
{
|
|
|
|
sd->oy = pos.y + cy + (ch / 2);
|
|
|
|
}
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
|
|
|
sd->long_pressed = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_start_handler_mouse_down_cb(void *data,
|
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2018-09-13 02:45:29 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
int start_pos, end_pos, pos;
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *sel_start, *sel_end;
|
|
|
|
Efl_Text_Cursor_Cursor *main_cur;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = sd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
sd->start_handler_down = EINA_TRUE;
|
|
|
|
|
|
|
|
/* Get the cursors */
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end);
|
2017-06-08 06:46:42 -07:00
|
|
|
main_cur = efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
start_pos = efl_text_cursor_position_get(text_obj, sel_start);
|
|
|
|
end_pos = efl_text_cursor_position_get(text_obj, sel_end);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (start_pos <= end_pos)
|
|
|
|
{
|
|
|
|
pos = start_pos;
|
|
|
|
sd->sel_handler_cursor = sel_start;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos = end_pos;
|
|
|
|
sd->sel_handler_cursor = sel_end;
|
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_cursor_position_set(text_obj, main_cur, pos);
|
|
|
|
_selection_handlers_offset_calc(data, sd->start_handler);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_start_handler_mouse_up_cb(void *data,
|
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->start_handler_down = EINA_FALSE;
|
|
|
|
/* Context menu should not appear, even in case of selector mode, if the
|
|
|
|
* flag is false (disabled) */
|
|
|
|
if ((!_elm_config->context_menu_disabled) &&
|
|
|
|
(!_elm_config->desktop_entry) && (sd->long_pressed))
|
|
|
|
_menu_call(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_start_handler_mouse_move_cb(void *data,
|
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (!sd->start_handler_down) return;
|
|
|
|
Evas_Event_Mouse_Move *ev = event_info;
|
|
|
|
Evas_Coord ex, ey;
|
|
|
|
Evas_Coord cx, cy;
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL);
|
|
|
|
cx = ev->cur.canvas.x - sd->ox - ex;
|
|
|
|
cy = ev->cur.canvas.y - sd->oy - ey;
|
|
|
|
if (cx <= 0) cx = 1;
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_cursor_coord_set(sd->text_obj, sd->sel_handler_cursor, cx, cy);
|
|
|
|
pos = efl_text_cursor_position_get(sd->text_obj, sd->sel_handler_cursor);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
/* Set the main cursor. */
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_cursor_position_set(sd->text_obj,
|
|
|
|
efl_text_cursor_get(sd->text_obj, EFL_TEXT_CURSOR_GET_MAIN), pos);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
|
|
|
sd->long_pressed = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_end_handler_mouse_down_cb(void *data,
|
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2018-09-13 02:45:29 -07:00
|
|
|
void *event_info EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *sel_start, *sel_end;
|
|
|
|
Efl_Text_Cursor_Cursor *main_cur;
|
2016-06-08 08:37:35 -07:00
|
|
|
int pos, start_pos, end_pos;
|
|
|
|
|
|
|
|
sd->end_handler_down = EINA_TRUE;
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = sd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end);
|
2017-06-08 06:46:42 -07:00
|
|
|
main_cur = efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
start_pos = efl_text_cursor_position_get(text_obj, sel_start);
|
|
|
|
end_pos = efl_text_cursor_position_get(text_obj, sel_end);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (start_pos < end_pos)
|
|
|
|
{
|
|
|
|
pos = end_pos;
|
2016-07-10 09:52:14 -07:00
|
|
|
sd->sel_handler_cursor = sel_end;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pos = start_pos;
|
2016-07-10 09:52:14 -07:00
|
|
|
sd->sel_handler_cursor = sel_start;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_cursor_position_set(text_obj, main_cur, pos);
|
|
|
|
_selection_handlers_offset_calc(data, sd->end_handler);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_end_handler_mouse_up_cb(void *data,
|
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->end_handler_down = EINA_FALSE;
|
|
|
|
/* Context menu appear was checked in case of selector start, and hence
|
|
|
|
* the same should be checked at selector end as well */
|
|
|
|
if ((!_elm_config->context_menu_disabled) &&
|
|
|
|
(!_elm_config->desktop_entry) && (sd->long_pressed))
|
|
|
|
_menu_call(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_end_handler_mouse_move_cb(void *data,
|
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
if (!sd->end_handler_down) return;
|
|
|
|
Evas_Event_Mouse_Move *ev = event_info;
|
|
|
|
Evas_Coord ex, ey;
|
|
|
|
Evas_Coord cx, cy;
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
evas_object_geometry_get(sd->entry_edje, &ex, &ey, NULL, NULL);
|
|
|
|
cx = ev->cur.canvas.x - sd->ox - ex;
|
|
|
|
cy = ev->cur.canvas.y - sd->oy - ey;
|
|
|
|
if (cx <= 0) cx = 1;
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_cursor_coord_set(sd->text_obj, sd->sel_handler_cursor, cx, cy);
|
|
|
|
pos = efl_text_cursor_position_get(sd->text_obj, sd->sel_handler_cursor);
|
2016-06-08 08:37:35 -07:00
|
|
|
/* Set the main cursor. */
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_text_cursor_position_set(sd->text_obj, efl_text_cursor_get(data, EFL_TEXT_CURSOR_GET_MAIN), pos);
|
2016-06-08 08:37:35 -07:00
|
|
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
|
|
|
sd->long_pressed = EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
static void
|
|
|
|
_create_selection_handlers(Evas_Object *obj, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
Evas_Object *handle;
|
|
|
|
|
|
|
|
handle = _decoration_create(obj, sd, PART_NAME_HANDLER_START, EINA_TRUE);
|
|
|
|
evas_object_pass_events_set(handle, EINA_FALSE);
|
|
|
|
sd->start_handler = handle;
|
|
|
|
evas_object_event_callback_add(handle, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_start_handler_mouse_down_cb, obj);
|
|
|
|
evas_object_event_callback_add(handle, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_start_handler_mouse_move_cb, obj);
|
|
|
|
evas_object_event_callback_add(handle, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_start_handler_mouse_up_cb, obj);
|
|
|
|
evas_object_show(handle);
|
|
|
|
|
|
|
|
handle = _decoration_create(obj, sd, PART_NAME_HANDLER_END, EINA_TRUE);
|
|
|
|
evas_object_pass_events_set(handle, EINA_FALSE);
|
|
|
|
sd->end_handler = handle;
|
|
|
|
evas_object_event_callback_add(handle, EVAS_CALLBACK_MOUSE_DOWN,
|
|
|
|
_end_handler_mouse_down_cb, obj);
|
|
|
|
evas_object_event_callback_add(handle, EVAS_CALLBACK_MOUSE_MOVE,
|
|
|
|
_end_handler_mouse_move_cb, obj);
|
|
|
|
evas_object_event_callback_add(handle, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_end_handler_mouse_up_cb, obj);
|
|
|
|
evas_object_show(handle);
|
|
|
|
}
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
EOLIAN static void
|
2018-04-05 01:47:26 -07:00
|
|
|
_efl_ui_text_efl_gfx_entity_position_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Position2D pos)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-12-06 00:33:03 -08:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
|
|
|
|
return;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos);
|
|
|
|
efl_gfx_entity_position_set(sd->hit_rect, pos);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
if (sd->hoversel) _hoversel_position(obj);
|
|
|
|
}
|
2016-07-10 04:43:43 -07:00
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
EOLIAN static void
|
2018-04-05 01:47:26 -07:00
|
|
|
_efl_ui_text_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Size2D sz)
|
2017-12-06 00:33:03 -08:00
|
|
|
{
|
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
|
|
|
|
return;
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(sd->hit_rect, sz);
|
2017-12-06 00:33:03 -08:00
|
|
|
_update_selection_handler(obj);
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), sz);
|
2017-12-06 00:33:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-04-05 01:47:26 -07:00
|
|
|
_efl_ui_text_efl_gfx_entity_visible_set(Eo *obj, Efl_Ui_Text_Data *sd EINA_UNUSED, Eina_Bool vis)
|
2017-12-06 00:33:03 -08:00
|
|
|
{
|
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
|
|
|
|
return;
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), vis);
|
2017-12-06 00:33:03 -08:00
|
|
|
if (vis) _update_selection_handler(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_efl_canvas_group_group_member_add(Eo *obj, Efl_Ui_Text_Data *sd, Evas_Object *member)
|
|
|
|
{
|
|
|
|
efl_canvas_group_member_add(efl_super(obj, MY_CLASS), member);
|
|
|
|
|
|
|
|
if (sd->hit_rect)
|
|
|
|
evas_object_raise(sd->hit_rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cb_added(void *data EINA_UNUSED, const Efl_Event *ev)
|
|
|
|
{
|
2018-02-27 04:19:17 -08:00
|
|
|
const Efl_Callback_Array_Item_Full *event = ev->info;
|
2017-12-06 00:33:03 -08:00
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(ev->object, sd);
|
2018-02-27 04:19:17 -08:00
|
|
|
// XXX: BUG - not walking the array until a NULL entry
|
2017-12-06 00:33:03 -08:00
|
|
|
if (event->desc == EFL_UI_TEXT_EVENT_VALIDATE)
|
|
|
|
sd->validators++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cb_deleted(void *data EINA_UNUSED, const Efl_Event *ev)
|
|
|
|
{
|
2018-02-27 04:19:17 -08:00
|
|
|
const Efl_Callback_Array_Item_Full *event = ev->info;
|
2017-12-06 00:33:03 -08:00
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(ev->object, sd);
|
2018-02-27 04:19:17 -08:00
|
|
|
// XXX: BUG - not walking the array until a NULL entry
|
2017-12-06 00:33:03 -08:00
|
|
|
if (event->desc == EFL_UI_TEXT_EVENT_VALIDATE)
|
|
|
|
sd->validators--;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-12 05:09:56 -08:00
|
|
|
static void
|
|
|
|
_update_guide_text(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
const char *txt;
|
|
|
|
Eina_Bool show_guide;
|
|
|
|
|
|
|
|
txt = efl_text_get(sd->text_obj);
|
|
|
|
|
|
|
|
show_guide = (!txt || (txt[0] == '\0'));
|
|
|
|
|
|
|
|
efl_gfx_entity_visible_set(sd->text_guide_obj, show_guide);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-12 05:14:11 -08:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* Returns the numeric value of HEX chars for example for ch = 'A'
|
|
|
|
* the function will return 10.
|
|
|
|
*
|
|
|
|
* @param ch The HEX char.
|
|
|
|
* @return numeric value of HEX.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
_hex_string_get(char ch, Eina_Bool *ok)
|
|
|
|
{
|
|
|
|
if ((ch >= '0') && (ch <= '9')) return (ch - '0');
|
|
|
|
else if ((ch >= 'A') && (ch <= 'F')) return (ch - 'A' + 10);
|
|
|
|
else if ((ch >= 'a') && (ch <= 'f')) return (ch - 'a' + 10);
|
|
|
|
*ok = EINA_FALSE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
_format_color_parse(const char *str, int slen,
|
|
|
|
unsigned char *r, unsigned char *g,
|
|
|
|
unsigned char *b, unsigned char *a)
|
|
|
|
{
|
|
|
|
Eina_Bool v = EINA_TRUE;
|
|
|
|
|
|
|
|
*r = *g = *b = *a = 0;
|
|
|
|
|
|
|
|
if (slen == 7) /* #RRGGBB */
|
|
|
|
{
|
|
|
|
*r = (_hex_string_get(str[1], &v) << 4) | (_hex_string_get(str[2], &v));
|
|
|
|
*g = (_hex_string_get(str[3], &v) << 4) | (_hex_string_get(str[4], &v));
|
|
|
|
*b = (_hex_string_get(str[5], &v) << 4) | (_hex_string_get(str[6], &v));
|
|
|
|
*a = 0xff;
|
|
|
|
}
|
|
|
|
else if (slen == 9) /* #RRGGBBAA */
|
|
|
|
{
|
|
|
|
*r = (_hex_string_get(str[1], &v) << 4) | (_hex_string_get(str[2], &v));
|
|
|
|
*g = (_hex_string_get(str[3], &v) << 4) | (_hex_string_get(str[4], &v));
|
|
|
|
*b = (_hex_string_get(str[5], &v) << 4) | (_hex_string_get(str[6], &v));
|
|
|
|
*a = (_hex_string_get(str[7], &v) << 4) | (_hex_string_get(str[8], &v));
|
|
|
|
}
|
|
|
|
else if (slen == 4) /* #RGB */
|
|
|
|
{
|
|
|
|
*r = _hex_string_get(str[1], &v);
|
|
|
|
*r = (*r << 4) | *r;
|
|
|
|
*g = _hex_string_get(str[2], &v);
|
|
|
|
*g = (*g << 4) | *g;
|
|
|
|
*b = _hex_string_get(str[3], &v);
|
|
|
|
*b = (*b << 4) | *b;
|
|
|
|
*a = 0xff;
|
|
|
|
}
|
|
|
|
else if (slen == 5) /* #RGBA */
|
|
|
|
{
|
|
|
|
*r = _hex_string_get(str[1], &v);
|
|
|
|
*r = (*r << 4) | *r;
|
|
|
|
*g = _hex_string_get(str[2], &v);
|
|
|
|
*g = (*g << 4) | *g;
|
|
|
|
*b = _hex_string_get(str[3], &v);
|
|
|
|
*b = (*b << 4) | *b;
|
|
|
|
*a = _hex_string_get(str[4], &v);
|
|
|
|
*a = (*a << 4) | *a;
|
|
|
|
}
|
|
|
|
else v = EINA_FALSE;
|
|
|
|
|
|
|
|
*r = (*r * *a) / 255;
|
|
|
|
*g = (*g * *a) / 255;
|
|
|
|
*b = (*b * *a) / 255;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* Updates the text properties of the object from the theme.
|
|
|
|
*
|
|
|
|
* This update functions skips any property that was already set,
|
|
|
|
* to allow users to override the theme during the construction of the widget.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_update_text_theme(Eo *obj, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
const char *font_name;
|
|
|
|
const char *font_size;
|
|
|
|
const char *colorcode;
|
|
|
|
|
|
|
|
int font_size_n;
|
|
|
|
unsigned char r, g, b, a;
|
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
// Main Text
|
|
|
|
// font_set
|
|
|
|
font_name = edje_object_data_get(wd->resize_obj, "font.name");
|
|
|
|
font_size = edje_object_data_get(wd->resize_obj, "font.size");
|
|
|
|
font_size_n = font_size ? atoi(font_size) : 0;
|
|
|
|
efl_text_font_set(sd->text_obj, font_name, font_size_n);
|
|
|
|
|
|
|
|
// color
|
|
|
|
colorcode = edje_object_data_get(wd->resize_obj, "style.color");
|
|
|
|
if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, &b, &a))
|
|
|
|
{
|
|
|
|
efl_text_normal_color_set(sd->text_obj, r, g, b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Guide Text
|
|
|
|
font_name = edje_object_data_get(wd->resize_obj, "guide.font.name");
|
|
|
|
font_size = edje_object_data_get(wd->resize_obj, "guide.font.size");
|
|
|
|
font_size_n = font_size ? atoi(font_size) : 0;
|
|
|
|
efl_text_font_set(sd->text_guide_obj, font_name, font_size_n);
|
|
|
|
|
|
|
|
// color
|
|
|
|
colorcode = edje_object_data_get(wd->resize_obj, "guide.style.color");
|
2018-11-28 04:39:45 -08:00
|
|
|
if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, &b, &a))
|
2018-11-12 05:14:11 -08:00
|
|
|
{
|
|
|
|
efl_text_normal_color_set(sd->text_guide_obj, r, g, b, a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
EOLIAN static Eo *
|
|
|
|
_efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
Eo *text_obj;
|
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
|
|
|
|
|
|
|
if (!elm_widget_theme_klass_get(obj))
|
|
|
|
elm_widget_theme_klass_set(obj, "text");
|
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2017-05-31 00:50:55 -07:00
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_widget_sub_object_parent_add(obj);
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
text_obj = efl_add(EFL_UI_INTERNAL_TEXT_INTERACTIVE_CLASS, obj);
|
2019-02-07 03:41:54 -08:00
|
|
|
efl_event_callback_forwarder_add(text_obj, EFL_UI_TEXT_EVENT_CHANGED_USER, obj);
|
2019-02-07 03:41:52 -08:00
|
|
|
efl_event_callback_forwarder_add(text_obj, EFL_UI_TEXT_EVENT_CHANGED, obj);
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->text_obj = text_obj;
|
2018-11-12 05:09:56 -08:00
|
|
|
sd->text_guide_obj = efl_add(EFL_CANVAS_TEXT_CLASS, obj);
|
|
|
|
sd->text_table = efl_add(EFL_UI_TABLE_CLASS, obj);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_composite_attach(obj, text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
sd->entry_edje = wd->resize_obj;
|
2018-12-21 13:46:06 -08:00
|
|
|
sd->cnp_mode = EFL_UI_SELECTION_FORMAT_TEXT;
|
2017-12-06 00:33:03 -08:00
|
|
|
sd->line_wrap = ELM_WRAP_WORD;
|
|
|
|
sd->context_menu = EINA_TRUE;
|
|
|
|
sd->auto_save = EINA_TRUE;
|
|
|
|
sd->editable = EINA_TRUE;
|
|
|
|
sd->sel_allow = EINA_TRUE;
|
2018-12-21 13:46:06 -08:00
|
|
|
sd->drop_format = EFL_UI_SELECTION_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE;
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->last.scroll = EINA_SIZE2D(0, 0);
|
|
|
|
sd->sel_handler_disabled = EINA_TRUE;
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eo *
|
|
|
|
_efl_ui_text_efl_object_finalize(Eo *obj,
|
|
|
|
Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
obj = efl_finalize(efl_super(obj, MY_CLASS));
|
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
2017-05-23 06:04:04 -07:00
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
elm_drop_target_add(obj, sd->drop_format,
|
2016-06-08 08:37:35 -07:00
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
|
|
|
|
2017-11-17 00:24:39 -08:00
|
|
|
if (!elm_widget_theme_object_set(obj, wd->resize_obj,
|
2017-11-14 03:38:49 -08:00
|
|
|
elm_widget_theme_klass_get(obj),
|
2017-12-06 00:33:03 -08:00
|
|
|
elm_widget_theme_element_get(obj),
|
2017-11-14 03:38:49 -08:00
|
|
|
elm_widget_theme_style_get(obj)))
|
2017-12-06 00:33:03 -08:00
|
|
|
CRI("Failed tp set layout!");
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_ENTRY);
|
|
|
|
efl_event_callback_add(obj, EFL_EVENT_CALLBACK_ADD, _cb_added, NULL);
|
|
|
|
efl_event_callback_add(obj, EFL_EVENT_CALLBACK_DEL, _cb_deleted, NULL);
|
2017-12-06 00:33:03 -08:00
|
|
|
|
2018-11-12 05:14:11 -08:00
|
|
|
//TODO: complete the usage of the text theme
|
|
|
|
_update_text_theme(obj, sd);
|
|
|
|
//efl_text_font_set(sd->text_obj, "Sans", 12);
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->single_line = !efl_text_multiline_get(sd->text_obj);
|
2017-12-06 00:33:03 -08:00
|
|
|
|
2018-11-12 05:09:56 -08:00
|
|
|
efl_pack_table(sd->text_table, sd->text_obj, 0, 0, 1, 1);
|
|
|
|
efl_pack_table(sd->text_table, sd->text_guide_obj, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
//edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
|
|
|
|
//edje_object_part_swallow(sd->entry_edje, "efl.text_guide", sd->text_guide_obj);
|
|
|
|
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_table);
|
|
|
|
|
|
|
|
_update_guide_text(obj, sd);
|
2018-09-13 02:45:29 -07:00
|
|
|
|
2018-11-12 05:09:56 -08:00
|
|
|
sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj);
|
2017-12-06 00:33:03 -08:00
|
|
|
|
2016-07-10 07:30:51 -07:00
|
|
|
evas_object_size_hint_weight_set
|
2017-12-06 00:33:03 -08:00
|
|
|
(sd->entry_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2016-07-10 07:30:51 -07:00
|
|
|
evas_object_size_hint_align_set
|
2017-12-06 00:33:03 -08:00
|
|
|
(sd->entry_edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_event_callback_add(sd->text_obj, EFL_UI_TEXT_EVENT_CHANGED_USER,
|
2017-12-12 22:05:15 -08:00
|
|
|
_efl_ui_text_changed_user_cb, obj);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_event_callback_add(sd->text_obj, EFL_CANVAS_TEXT_EVENT_CHANGED,
|
2016-07-11 04:20:28 -07:00
|
|
|
_efl_ui_text_changed_cb, obj);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_event_callback_add(sd->text_obj, EFL_TEXT_INTERACTIVE_EVENT_SELECTION_CHANGED,
|
2016-06-08 08:37:35 -07:00
|
|
|
_efl_ui_text_selection_changed_cb, obj);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_event_callback_add(sd->text_obj, EFL_CANVAS_TEXT_EVENT_CURSOR_CHANGED,
|
2016-06-08 08:37:35 -07:00
|
|
|
_efl_ui_text_cursor_changed_cb, obj);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_event_callback_add(sd->text_obj, EFL_GFX_ENTITY_EVENT_MOVE,
|
|
|
|
_text_position_changed_cb, obj);
|
2017-12-06 00:33:03 -08:00
|
|
|
evas_object_event_callback_add(sd->entry_edje, EVAS_CALLBACK_MOVE,
|
2016-06-08 08:37:35 -07:00
|
|
|
_efl_ui_text_move_cb, obj);
|
|
|
|
|
|
|
|
evas_object_event_callback_add
|
2017-12-06 00:33:03 -08:00
|
|
|
(sd->entry_edje, EVAS_CALLBACK_KEY_DOWN, _key_down_cb, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_object_event_callback_add
|
2017-12-06 00:33:03 -08:00
|
|
|
(sd->entry_edje, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_object_event_callback_add
|
2017-12-06 00:33:03 -08:00
|
|
|
(sd->entry_edje, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_object_event_callback_add
|
2017-12-06 00:33:03 -08:00
|
|
|
(sd->entry_edje, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_event_callback_add(obj, EFL_GFX_ENTITY_EVENT_RESIZE,
|
|
|
|
_text_size_changed_cb, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
|
|
|
|
|
|
|
efl_ui_text_input_panel_layout_set(obj, ELM_INPUT_PANEL_LAYOUT_NORMAL);
|
|
|
|
efl_ui_text_input_panel_enabled_set(obj, EINA_TRUE);
|
|
|
|
efl_ui_text_prediction_allow_set(obj, EINA_TRUE);
|
|
|
|
efl_ui_text_input_hint_set(obj, ELM_INPUT_HINT_AUTO_COMPLETE);
|
|
|
|
|
2017-06-13 03:41:15 -07:00
|
|
|
_mirrored_set(obj, efl_ui_mirrored_get(obj));
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
_create_text_cursors(obj, sd);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-11-18 02:20:10 -08:00
|
|
|
sd->calc_force = EINA_TRUE;
|
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
return obj;
|
2018-09-13 02:45:29 -07:00
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-06 00:33:03 -08:00
|
|
|
_efl_ui_text_efl_object_destructor(Eo *obj, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Elm_Entry_Context_Menu_Item *it;
|
|
|
|
Elm_Entry_Markup_Filter *tf;
|
|
|
|
|
|
|
|
if (sd->delay_write)
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->delay_write, ecore_timer_del);
|
|
|
|
if (sd->auto_save) _save_do(obj);
|
|
|
|
}
|
|
|
|
|
2017-09-11 22:38:51 -07:00
|
|
|
efl_event_freeze(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
eina_stringshare_del(sd->file);
|
|
|
|
|
|
|
|
ecore_job_del(sd->hov_deljob);
|
|
|
|
if ((sd->api) && (sd->api->obj_unhook))
|
|
|
|
sd->api->obj_unhook(obj); // module - unhook
|
|
|
|
|
|
|
|
evas_object_del(sd->mgf_proxy);
|
|
|
|
evas_object_del(sd->mgf_bg);
|
|
|
|
evas_object_del(sd->mgf_clip);
|
|
|
|
|
|
|
|
entries = eina_list_remove(entries, obj);
|
|
|
|
eina_stringshare_del(sd->cut_sel);
|
|
|
|
eina_stringshare_del(sd->text);
|
2016-06-22 10:02:32 -07:00
|
|
|
ecore_job_del(sd->deferred_decoration_job);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (sd->append_text_idler)
|
|
|
|
{
|
|
|
|
ecore_idler_del(sd->append_text_idler);
|
|
|
|
ELM_SAFE_FREE(sd->append_text_left, free);
|
|
|
|
sd->append_text_idler = NULL;
|
|
|
|
}
|
|
|
|
ecore_timer_del(sd->longpress_timer);
|
|
|
|
EINA_LIST_FREE(sd->items, it)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
eina_stringshare_del(it->icon_file);
|
|
|
|
eina_stringshare_del(it->icon_group);
|
|
|
|
free(it);
|
|
|
|
}
|
|
|
|
EINA_LIST_FREE(sd->markup_filters, tf)
|
|
|
|
{
|
|
|
|
_filter_free(tf);
|
|
|
|
}
|
|
|
|
ELM_SAFE_FREE(sd->delay_write, ecore_timer_del);
|
|
|
|
free(sd->input_panel_imdata);
|
|
|
|
eina_stringshare_del(sd->anchor_hover.hover_style);
|
|
|
|
|
2017-09-11 22:38:51 -07:00
|
|
|
efl_event_thaw(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (sd->start_handler)
|
|
|
|
{
|
|
|
|
evas_object_del(sd->start_handler);
|
|
|
|
evas_object_del(sd->end_handler);
|
2018-09-13 02:45:29 -07:00
|
|
|
}
|
2016-06-22 10:02:32 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
_anchors_free(sd);
|
|
|
|
_clear_text_selection(sd);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
ecore_job_del(sd->deferred_decoration_job);
|
|
|
|
sd->deferred_decoration_job = NULL;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-11-09 07:53:20 -08:00
|
|
|
if (sd->item_factory) efl_unref(sd->item_factory);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_destructor(efl_super(obj, MY_CLASS));
|
2016-06-22 10:02:32 -07:00
|
|
|
}
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
EOLIAN static void
|
2018-02-14 18:14:52 -08:00
|
|
|
_efl_ui_text_password_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool password)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
password = !!password;
|
|
|
|
|
|
|
|
if (sd->password == password) return;
|
|
|
|
sd->password = password;
|
|
|
|
|
|
|
|
elm_drop_target_del(obj, sd->drop_format,
|
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
|
|
|
if (password)
|
|
|
|
{
|
|
|
|
sd->single_line = EINA_TRUE;
|
|
|
|
sd->line_wrap = ELM_WRAP_NONE;
|
|
|
|
efl_ui_text_input_hint_set(obj, ((sd->input_hints & ~ELM_INPUT_HINT_AUTO_COMPLETE) | ELM_INPUT_HINT_SENSITIVE_DATA));
|
2018-04-03 04:27:30 -07:00
|
|
|
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PASSWORD_TEXT);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->drop_format = _get_drop_format(obj);
|
|
|
|
elm_drop_target_add(obj, sd->drop_format,
|
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
|
|
|
|
|
|
|
efl_ui_text_input_hint_set(obj, ((sd->input_hints | ELM_INPUT_HINT_AUTO_COMPLETE) & ~ELM_INPUT_HINT_SENSITIVE_DATA));
|
2018-04-03 04:27:30 -07:00
|
|
|
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_ENTRY);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2017-10-23 22:03:46 -07:00
|
|
|
efl_ui_widget_theme_apply(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_password_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->password;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_text_calc_force(Eo *obj, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->calc_force = EINA_TRUE;
|
2016-06-08 08:37:35 -07:00
|
|
|
edje_object_calc_force(sd->entry_edje);
|
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char*
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_selection_get(const Eo *obj, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *start_obj, *end_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if ((sd->password)) return NULL;
|
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(obj, &start_obj, &end_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
return efl_canvas_text_range_text_get(obj, start_obj, end_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_selection_handler_disabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool disabled)
|
|
|
|
{
|
|
|
|
if (sd->sel_handler_disabled == disabled) return;
|
|
|
|
sd->sel_handler_disabled = disabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_selection_handler_disabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->sel_handler_disabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_text_entry_insert(Eo *obj, Efl_Ui_Text_Data *sd, const char *entry)
|
|
|
|
{
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *cur_obj = efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN);
|
2017-06-08 03:07:12 -07:00
|
|
|
efl_text_cursor_text_insert(obj, cur_obj, entry);
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->text_changed = EINA_TRUE;
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-04-06 04:30:40 -07:00
|
|
|
_efl_ui_text_efl_text_interactive_editable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool editable)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_editable_set(efl_super(obj, MY_CLASS), editable);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (sd->editable == editable) return;
|
|
|
|
sd->editable = editable;
|
2017-10-23 22:03:46 -07:00
|
|
|
efl_ui_widget_theme_apply(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
elm_drop_target_del(obj, sd->drop_format,
|
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
|
|
|
if (editable)
|
|
|
|
{
|
|
|
|
sd->drop_format = _get_drop_format(obj);
|
|
|
|
elm_drop_target_add(obj, sd->drop_format,
|
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
2016-12-01 03:25:11 -08:00
|
|
|
if (sd->cursor)
|
|
|
|
{
|
|
|
|
evas_object_show(sd->cursor);
|
|
|
|
evas_object_show(sd->cursor_bidi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!editable && sd->cursor)
|
|
|
|
{
|
|
|
|
evas_object_hide(sd->cursor);
|
|
|
|
evas_object_hide(sd->cursor_bidi);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_text_select_none(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
if ((sd->password)) return;
|
|
|
|
if (sd->sel_mode)
|
|
|
|
{
|
|
|
|
sd->sel_mode = EINA_FALSE;
|
|
|
|
if (!_elm_config->desktop_entry)
|
|
|
|
edje_object_part_text_select_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", EINA_FALSE);
|
2018-04-26 04:24:09 -07:00
|
|
|
edje_object_signal_emit(sd->entry_edje, "efl,state,select,off", "efl");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
if (sd->have_selection)
|
2017-12-12 22:19:43 -08:00
|
|
|
efl_event_callback_call(obj, EFL_UI_EVENT_SELECTION_CLEARED, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
sd->have_selection = EINA_FALSE;
|
2018-09-13 02:45:29 -07:00
|
|
|
_edje_signal_emit(sd, "selection,cleared", "efl.text");
|
|
|
|
efl_text_interactive_select_none(sd->text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
_hide_selection_handler(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-05 07:09:46 -07:00
|
|
|
_efl_ui_text_select_region_set(Eo *obj, Efl_Ui_Text_Data *sd, int start, int end)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *sel_start, *sel_end;
|
2016-10-05 07:09:46 -07:00
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
if ((sd->password)) return;
|
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(obj, &sel_start, &sel_end);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-06-08 03:07:12 -07:00
|
|
|
efl_text_cursor_position_set(obj, sel_start, start);
|
|
|
|
efl_text_cursor_position_set(obj, sel_end, end);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_cursor_selection_end(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
2018-04-26 03:27:43 -07:00
|
|
|
edje_object_part_text_select_extend(sd->entry_edje, "efl.text");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_selection_cut(Eo *obj, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
if ((sd->password)) return;
|
|
|
|
_cut_cb(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_selection_copy(Eo *obj, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
if ((sd->password)) return;
|
|
|
|
_copy_cb(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_selection_paste(Eo *obj, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
if ((sd->password)) return;
|
|
|
|
_paste_cb(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_context_menu_clear(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
Elm_Entry_Context_Menu_Item *it;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(sd->items, it)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
eina_stringshare_del(it->icon_file);
|
|
|
|
eina_stringshare_del(it->icon_group);
|
|
|
|
free(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_context_menu_item_add(Eo *obj, Efl_Ui_Text_Data *sd, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
|
|
|
|
{
|
|
|
|
Elm_Entry_Context_Menu_Item *it;
|
|
|
|
|
|
|
|
it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
|
|
|
|
if (!it) return;
|
|
|
|
|
|
|
|
sd->items = eina_list_append(sd->items, it);
|
|
|
|
it->obj = obj;
|
|
|
|
it->label = eina_stringshare_add(label);
|
|
|
|
it->icon_file = eina_stringshare_add(icon_file);
|
|
|
|
it->icon_type = icon_type;
|
|
|
|
it->func = func;
|
|
|
|
it->data = (void *)data;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_context_menu_disabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool disabled)
|
|
|
|
{
|
|
|
|
if (sd->context_menu == !disabled) return;
|
|
|
|
sd->context_menu = !disabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_context_menu_disabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return !sd->context_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_text_efl_file_file_set(Eo *obj, Efl_Ui_Text_Data *sd, const char *file, const char *group EINA_UNUSED)
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->delay_write, ecore_timer_del);
|
|
|
|
if (sd->auto_save) _save_do(obj);
|
|
|
|
eina_stringshare_replace(&sd->file, file);
|
|
|
|
Eina_Bool int_ret = _load_do(obj);
|
|
|
|
return int_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_file_file_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, const char **file, const char **group)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
if (file) *file = sd->file;
|
|
|
|
if (group) *group = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-12-21 13:46:06 -08:00
|
|
|
_efl_ui_text_cnp_mode_set(Eo *obj, Efl_Ui_Text_Data *sd, Efl_Ui_Selection_Format cnp_mode)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-12-21 13:46:06 -08:00
|
|
|
Elm_Sel_Format dnd_format = EFL_UI_SELECTION_FORMAT_MARKUP;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-12-21 13:46:06 -08:00
|
|
|
if (cnp_mode != EFL_UI_SELECTION_FORMAT_TARGETS)
|
2018-01-17 23:19:01 -08:00
|
|
|
{
|
2018-12-21 13:46:06 -08:00
|
|
|
if (cnp_mode & EFL_UI_SELECTION_FORMAT_VCARD)
|
2018-01-17 23:19:01 -08:00
|
|
|
ERR("VCARD format not supported for copy & paste!");
|
2018-12-21 13:46:06 -08:00
|
|
|
else if (cnp_mode & EFL_UI_SELECTION_FORMAT_HTML)
|
2018-01-17 23:19:01 -08:00
|
|
|
ERR("HTML format not supported for copy & paste!");
|
2018-12-21 13:46:06 -08:00
|
|
|
cnp_mode &= ~EFL_UI_SELECTION_FORMAT_VCARD;
|
|
|
|
cnp_mode &= ~EFL_UI_SELECTION_FORMAT_HTML;
|
2018-01-17 23:19:01 -08:00
|
|
|
}
|
|
|
|
|
2018-11-08 09:12:35 -08:00
|
|
|
if (sd->cnp_mode == cnp_mode) return;
|
|
|
|
sd->cnp_mode = cnp_mode;
|
2018-12-21 13:46:06 -08:00
|
|
|
if (sd->cnp_mode == EFL_UI_SELECTION_FORMAT_TEXT)
|
|
|
|
dnd_format = EFL_UI_SELECTION_FORMAT_TEXT;
|
|
|
|
else if (cnp_mode == EFL_UI_SELECTION_FORMAT_IMAGE)
|
2018-01-17 23:19:01 -08:00
|
|
|
dnd_format |= ELM_SEL_FORMAT_IMAGE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
elm_drop_target_del(obj, sd->drop_format,
|
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
2018-01-17 23:19:01 -08:00
|
|
|
sd->drop_format = dnd_format;
|
2016-06-08 08:37:35 -07:00
|
|
|
elm_drop_target_add(obj, sd->drop_format,
|
|
|
|
_dnd_enter_cb, NULL,
|
|
|
|
_dnd_leave_cb, NULL,
|
|
|
|
_dnd_pos_cb, NULL,
|
|
|
|
_dnd_drop_cb, NULL);
|
|
|
|
}
|
|
|
|
|
2018-12-21 13:46:06 -08:00
|
|
|
EOLIAN static Efl_Ui_Selection_Format
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_cnp_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->cnp_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-09-13 02:45:29 -07:00
|
|
|
_efl_ui_text_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool scroll)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
if (sd->scroll == scroll) return;
|
|
|
|
sd->scroll = scroll;
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
if (scroll)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
edje_object_part_swallow(sd->entry_edje, "efl.text", NULL);
|
2018-11-12 05:09:56 -08:00
|
|
|
sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj,
|
|
|
|
efl_ui_internal_text_scroller_initialize(efl_added,
|
|
|
|
sd->text_obj, sd->text_table));
|
|
|
|
efl_ui_scrollbar_bar_mode_set(sd->scroller, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
|
2018-09-13 02:45:29 -07:00
|
|
|
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->scroller);
|
|
|
|
evas_object_clip_set(sd->cursor,
|
|
|
|
efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller));
|
|
|
|
efl_event_callback_add(sd->scroller, EFL_GFX_ENTITY_EVENT_RESIZE,
|
|
|
|
_scroller_size_changed_cb, obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_content_set(sd->scroller, NULL);
|
2018-11-12 05:09:56 -08:00
|
|
|
edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_table);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_del(sd->scroller);
|
|
|
|
sd->scroller = NULL;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_scrollable_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_layout_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Elm_Input_Panel_Layout layout)
|
|
|
|
{
|
|
|
|
sd->input_panel_layout = layout;
|
|
|
|
|
|
|
|
edje_object_part_text_input_panel_layout_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Input_Panel_Layout)layout);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
if (layout == ELM_INPUT_PANEL_LAYOUT_PASSWORD)
|
|
|
|
efl_ui_text_input_hint_set(obj, ((sd->input_hints & ~ELM_INPUT_HINT_AUTO_COMPLETE) | ELM_INPUT_HINT_SENSITIVE_DATA));
|
|
|
|
else if (layout == ELM_INPUT_PANEL_LAYOUT_TERMINAL)
|
|
|
|
efl_ui_text_input_hint_set(obj, (sd->input_hints & ~ELM_INPUT_HINT_AUTO_COMPLETE));
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Elm_Input_Panel_Layout
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_input_panel_layout_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->input_panel_layout;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_layout_variation_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, int variation)
|
|
|
|
{
|
|
|
|
sd->input_panel_layout_variation = variation;
|
|
|
|
|
|
|
|
edje_object_part_text_input_panel_layout_variation_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", variation);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_input_panel_layout_variation_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->input_panel_layout_variation;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_autocapital_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Elm_Autocapital_Type autocapital_type)
|
|
|
|
{
|
|
|
|
sd->autocapital_type = autocapital_type;
|
|
|
|
edje_object_part_text_autocapital_type_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Text_Autocapital_Type)autocapital_type);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Elm_Autocapital_Type
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_autocapital_type_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->autocapital_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_prediction_allow_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool prediction)
|
|
|
|
{
|
|
|
|
sd->prediction_allow = prediction;
|
|
|
|
edje_object_part_text_prediction_allow_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", prediction);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_prediction_allow_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->prediction_allow;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_hint_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Elm_Input_Hints hints)
|
|
|
|
{
|
|
|
|
sd->input_hints = hints;
|
|
|
|
|
|
|
|
edje_object_part_text_input_hint_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Input_Hints)hints);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Elm_Input_Hints
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_input_hint_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->input_hints;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_enabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool enabled)
|
|
|
|
{
|
|
|
|
sd->input_panel_enable = enabled;
|
|
|
|
edje_object_part_text_input_panel_enabled_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", enabled);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_input_panel_enabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->input_panel_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_show(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
2018-04-26 03:27:43 -07:00
|
|
|
edje_object_part_text_input_panel_show(sd->entry_edje, "efl.text");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_hide(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
edje_object_part_text_input_panel_hide(sd->entry_edje, "efl.text");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_language_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Elm_Input_Panel_Lang lang)
|
|
|
|
{
|
|
|
|
sd->input_panel_lang = lang;
|
|
|
|
edje_object_part_text_input_panel_language_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Input_Panel_Lang)lang);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Elm_Input_Panel_Lang
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_input_panel_language_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->input_panel_lang;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_imdata_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, const void *data, int len)
|
|
|
|
{
|
|
|
|
free(sd->input_panel_imdata);
|
|
|
|
|
|
|
|
sd->input_panel_imdata = calloc(1, len);
|
|
|
|
sd->input_panel_imdata_len = len;
|
|
|
|
memcpy(sd->input_panel_imdata, data, len);
|
|
|
|
|
|
|
|
edje_object_part_text_input_panel_imdata_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", sd->input_panel_imdata,
|
2016-06-08 08:37:35 -07:00
|
|
|
sd->input_panel_imdata_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_imdata_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, void *data, int *len)
|
|
|
|
{
|
|
|
|
edje_object_part_text_input_panel_imdata_get
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", data, len);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_return_key_type_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Elm_Input_Panel_Return_Key_Type return_key_type)
|
|
|
|
{
|
|
|
|
sd->input_panel_return_key_type = return_key_type;
|
|
|
|
|
|
|
|
edje_object_part_text_input_panel_return_key_type_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", (Edje_Input_Panel_Return_Key_Type)return_key_type);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Elm_Input_Panel_Return_Key_Type
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_input_panel_return_key_type_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->input_panel_return_key_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_return_key_disabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool disabled)
|
|
|
|
{
|
|
|
|
sd->input_panel_return_key_disabled = disabled;
|
|
|
|
|
|
|
|
edje_object_part_text_input_panel_return_key_disabled_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", disabled);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_input_panel_return_key_disabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->input_panel_return_key_disabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_return_key_autoenabled_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool enabled)
|
|
|
|
{
|
|
|
|
sd->auto_return_key = enabled;
|
|
|
|
_return_key_enabled_check(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_text_input_panel_show_on_demand_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool ondemand)
|
|
|
|
{
|
|
|
|
sd->input_panel_show_on_demand = ondemand;
|
|
|
|
|
|
|
|
edje_object_part_text_input_panel_show_on_demand_set
|
2018-04-26 03:27:43 -07:00
|
|
|
(sd->entry_edje, "efl.text", ondemand);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_input_panel_show_on_demand_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return sd->input_panel_show_on_demand;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-01-07 20:55:35 -08:00
|
|
|
_efl_ui_text_efl_ui_widget_on_access_activate(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, Efl_Ui_Activate act)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-10-15 21:33:52 -07:00
|
|
|
if (act != EFL_UI_ACTIVATE_DEFAULT) return EINA_FALSE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (!elm_widget_disabled_get(obj) &&
|
|
|
|
!evas_object_freeze_events_get(obj))
|
|
|
|
{
|
2017-12-12 22:19:43 -08:00
|
|
|
efl_event_callback_call(obj, EFL_UI_EVENT_CLICKED, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (sd->editable && sd->input_panel_enable)
|
2018-04-26 03:27:43 -07:00
|
|
|
edje_object_part_text_input_panel_show(sd->entry_edje, "efl.text");
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ATSPI Accessibility
|
|
|
|
|
|
|
|
EOLIAN static Eina_Unicode
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_character_get(const Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, int offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-07-10 03:37:02 -07:00
|
|
|
const char *txt;
|
2016-06-08 08:37:35 -07:00
|
|
|
int idx = 0;
|
|
|
|
Eina_Unicode ret = 0;
|
|
|
|
if (offset < 0) return ret;
|
|
|
|
|
2016-07-10 03:37:02 -07:00
|
|
|
if (_pd->password) return ENTRY_PASSWORD_MASK_CHARACTER;
|
|
|
|
|
|
|
|
txt = efl_text_get(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!txt) return ret;
|
|
|
|
|
|
|
|
ret = eina_unicode_utf8_next_get(txt, &idx);
|
|
|
|
while (offset--) ret = eina_unicode_utf8_next_get(txt, &idx);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_character_count_get(const Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-07-10 03:37:02 -07:00
|
|
|
const char *txt;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-07-10 03:37:02 -07:00
|
|
|
txt = efl_text_get(obj);
|
|
|
|
if (!txt) return -1;
|
|
|
|
return eina_unicode_utf8_get_len(txt);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static char*
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_string_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *pd, Efl_Access_Text_Granularity granularity, int *start_offset, int *end_offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cur = NULL, *cur2 = NULL;
|
|
|
|
char *ret = NULL;
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
cur = evas_object_textblock_cursor_new(pd->text_obj);
|
|
|
|
cur2 = evas_object_textblock_cursor_new(pd->text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur || !cur2) goto fail;
|
|
|
|
|
|
|
|
evas_textblock_cursor_pos_set(cur, *start_offset);
|
|
|
|
if (evas_textblock_cursor_pos_get(cur) != *start_offset) goto fail;
|
|
|
|
|
|
|
|
switch (granularity)
|
|
|
|
{
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_CHAR:
|
2016-06-08 08:37:35 -07:00
|
|
|
break;
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_WORD:
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_textblock_cursor_word_start(cur);
|
|
|
|
break;
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_SENTENCE:
|
2016-06-08 08:37:35 -07:00
|
|
|
// TODO - add sentence support in textblock first
|
|
|
|
break;
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_LINE:
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_textblock_cursor_line_char_first(cur);
|
|
|
|
break;
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_PARAGRAPH:
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_textblock_cursor_paragraph_char_first(cur);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*start_offset = evas_textblock_cursor_pos_get(cur);
|
|
|
|
evas_textblock_cursor_copy(cur, cur2);
|
|
|
|
|
|
|
|
switch (granularity)
|
|
|
|
{
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_CHAR:
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_textblock_cursor_char_next(cur2);
|
|
|
|
break;
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_WORD:
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_textblock_cursor_word_end(cur2);
|
|
|
|
// since word_end sets cursor position ON (before) last
|
|
|
|
// char of word, we need to manually advance cursor to get
|
|
|
|
// proper string from function range_text_get
|
|
|
|
evas_textblock_cursor_char_next(cur2);
|
|
|
|
break;
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_SENTENCE:
|
2016-06-08 08:37:35 -07:00
|
|
|
// TODO - add sentence support in textblock first
|
|
|
|
break;
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_LINE:
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_textblock_cursor_line_char_last(cur2);
|
|
|
|
break;
|
2017-09-25 01:15:44 -07:00
|
|
|
case EFL_ACCESS_TEXT_GRANULARITY_PARAGRAPH:
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_textblock_cursor_paragraph_char_last(cur2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end_offset) *end_offset = evas_textblock_cursor_pos_get(cur2);
|
|
|
|
|
|
|
|
ret = evas_textblock_cursor_range_text_get(cur, cur2, EVAS_TEXTBLOCK_TEXT_PLAIN);
|
|
|
|
|
|
|
|
evas_textblock_cursor_free(cur);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
if (ret && pd->password)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
while (ret[i] != '\0')
|
|
|
|
ret[i++] = ENTRY_PASSWORD_MASK_CHARACTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (start_offset) *start_offset = -1;
|
|
|
|
if (end_offset) *end_offset = -1;
|
|
|
|
if (cur) evas_textblock_cursor_free(cur);
|
|
|
|
if (cur2) evas_textblock_cursor_free(cur2);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static char*
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_access_text_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *pd EINA_UNUSED, int start_offset, int end_offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cur = NULL, *cur2 = NULL;
|
|
|
|
char *ret = NULL;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = pd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur = evas_object_textblock_cursor_new(text_obj);
|
|
|
|
cur2 = evas_object_textblock_cursor_new(text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur || !cur2) goto fail;
|
|
|
|
|
|
|
|
evas_textblock_cursor_pos_set(cur, start_offset);
|
|
|
|
if (evas_textblock_cursor_pos_get(cur) != start_offset) goto fail;
|
|
|
|
|
|
|
|
evas_textblock_cursor_pos_set(cur2, end_offset);
|
|
|
|
if (evas_textblock_cursor_pos_get(cur2) != end_offset) goto fail;
|
|
|
|
|
|
|
|
ret = evas_textblock_cursor_range_text_get(cur, cur2, EVAS_TEXTBLOCK_TEXT_PLAIN);
|
|
|
|
|
|
|
|
evas_textblock_cursor_free(cur);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
if (ret && pd->password)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
while (ret[i] != '\0')
|
|
|
|
ret[i++] = ENTRY_PASSWORD_MASK_CHARACTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (cur) evas_textblock_cursor_free(cur);
|
|
|
|
if (cur2) evas_textblock_cursor_free(cur2);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_caret_offset_get(const Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-06-08 06:46:42 -07:00
|
|
|
return efl_text_cursor_position_get(obj, efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN));
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2017-09-25 01:15:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_caret_offset_set(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, int offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-06-08 06:46:42 -07:00
|
|
|
efl_text_cursor_position_set(obj, efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN), offset);
|
2016-06-08 08:37:35 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_selections_count_get(const Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return _efl_ui_text_selection_get(obj, _pd) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_access_selection_get(const Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, int selection_number, int *start_offset, int *end_offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
if (selection_number != 0) return;
|
|
|
|
|
|
|
|
elm_obj_entry_select_region_get(obj, start_offset, end_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-02-14 18:14:52 -08:00
|
|
|
_efl_ui_text_efl_access_text_access_selection_set(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, int selection_number, int start_offset, int end_offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
if (selection_number != 0) return EINA_FALSE;
|
|
|
|
|
|
|
|
_efl_ui_text_select_region_set(obj, _pd, start_offset, end_offset);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2017-09-25 01:15:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_selection_remove(Eo *obj, Efl_Ui_Text_Data *pd EINA_UNUSED, int selection_number)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
if (selection_number != 0) return EINA_FALSE;
|
|
|
|
_efl_ui_text_select_none(obj, pd);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2017-09-25 01:15:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_selection_add(Eo *obj, Efl_Ui_Text_Data *pd EINA_UNUSED, int start_offset, int end_offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
_efl_ui_text_select_region_set(obj, pd, start_offset, end_offset);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_List*
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_bounded_ranges_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *_pd EINA_UNUSED, Eina_Bool screen_coods EINA_UNUSED, Eina_Rect rect EINA_UNUSED, Efl_Access_Text_Clip_Type xclip EINA_UNUSED, Efl_Access_Text_Clip_Type yclip EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_offset_at_point_get(const Eo *obj, Efl_Ui_Text_Data *pd EINA_UNUSED, Eina_Bool screen_coods, int x, int y)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cur;
|
|
|
|
int ret;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = pd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
if (!text_obj) return -1;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur = evas_object_textblock_cursor_new(text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur) return -1;
|
|
|
|
|
|
|
|
if (screen_coods)
|
|
|
|
{
|
|
|
|
int ee_x, ee_y;
|
|
|
|
Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
|
|
|
|
ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
|
|
|
|
x -= ee_x;
|
|
|
|
y -= ee_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!evas_textblock_cursor_char_coord_set(cur, x, y))
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_free(cur);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = evas_textblock_cursor_pos_get(cur);
|
|
|
|
evas_textblock_cursor_free(cur);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_character_extents_get(const Eo *obj, Efl_Ui_Text_Data *pd EINA_UNUSED, int offset, Eina_Bool screen_coods, Eina_Rect *rect)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cur;
|
|
|
|
int ret;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = pd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
if (!text_obj) return EINA_FALSE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur = evas_object_textblock_cursor_new(text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur) return EINA_FALSE;
|
|
|
|
|
|
|
|
evas_textblock_cursor_pos_set(cur, offset);
|
|
|
|
|
|
|
|
ret = evas_textblock_cursor_char_geometry_get(cur, &rect->x, &rect->y, &rect->w, &rect->h);
|
|
|
|
evas_textblock_cursor_free(cur);
|
|
|
|
|
|
|
|
if (ret == -1) return EINA_FALSE;
|
|
|
|
|
|
|
|
if (screen_coods)
|
|
|
|
{
|
|
|
|
int ee_x, ee_y;
|
|
|
|
Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
|
|
|
|
ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
|
|
|
|
rect->x += ee_x;
|
|
|
|
rect->y += ee_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_range_extents_get(const Eo *obj, Efl_Ui_Text_Data *pd EINA_UNUSED, Eina_Bool screen_coods, int start_offset, int end_offset, Eina_Rect *rect)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cur1, *cur2;
|
|
|
|
int ret;
|
|
|
|
int x, xx, y, yy;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = pd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
if (!text_obj) return EINA_FALSE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur1 = evas_object_textblock_cursor_new(text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur1) return EINA_FALSE;
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur2 = evas_object_textblock_cursor_new(text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur2)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
evas_textblock_cursor_pos_set(cur1, start_offset);
|
|
|
|
evas_textblock_cursor_pos_set(cur2, end_offset);
|
|
|
|
|
|
|
|
ret = evas_textblock_cursor_char_geometry_get(cur1, &x, &y, NULL, NULL);
|
|
|
|
ret += evas_textblock_cursor_char_geometry_get(cur2, &xx, &yy, NULL, NULL);
|
|
|
|
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
|
|
|
|
if (ret != 0) return EINA_FALSE;
|
|
|
|
|
|
|
|
rect->x = x < xx ? x : xx;
|
|
|
|
rect->y = y < yy ? y : yy;
|
|
|
|
rect->w = abs(x - xx);
|
|
|
|
rect->h = abs(y - yy);
|
|
|
|
|
|
|
|
if (screen_coods)
|
|
|
|
{
|
|
|
|
int ee_x, ee_y;
|
|
|
|
Ecore_Evas *ee= ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
|
|
|
|
ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
|
|
|
|
rect->x += ee_x;
|
|
|
|
rect->y += ee_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2017-09-25 01:15:44 -07:00
|
|
|
static Efl_Access_Text_Attribute*
|
2018-04-17 11:09:44 -07:00
|
|
|
_textblock_node_format_to_atspi_text_attr(const Eo *obj,
|
2017-07-17 07:38:28 -07:00
|
|
|
Efl_Text_Annotate_Annotation *annotation)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-09-25 01:15:44 -07:00
|
|
|
Efl_Access_Text_Attribute *ret;
|
2016-06-08 08:37:35 -07:00
|
|
|
const char *txt;
|
|
|
|
|
2017-06-08 06:08:28 -07:00
|
|
|
txt = efl_text_annotation_get(obj, annotation);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!txt) return NULL;
|
|
|
|
|
2017-09-25 01:15:44 -07:00
|
|
|
ret = calloc(1, sizeof(Efl_Access_Text_Attribute));
|
2016-10-05 07:09:46 -07:00
|
|
|
if (!ret) return NULL;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
ret->value = eina_stringshare_add(txt);
|
|
|
|
int size = strlen(txt);
|
|
|
|
ret->name = eina_stringshare_add_length(txt, size);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_attribute_get(const Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, const char *attr_name EINA_UNUSED, int *start_offset, int *end_offset, char **value)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cur1, *cur2;
|
2017-09-25 01:15:44 -07:00
|
|
|
Efl_Access_Text_Attribute *attr;
|
2016-10-05 07:09:46 -07:00
|
|
|
Eina_Iterator *annotations;
|
2017-07-17 07:38:28 -07:00
|
|
|
Efl_Text_Annotate_Annotation *an;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur1 = evas_object_textblock_cursor_new(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur1) return EINA_FALSE;
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur2 = evas_object_textblock_cursor_new(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur2)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
evas_textblock_cursor_pos_set(cur1, *start_offset);
|
|
|
|
evas_textblock_cursor_pos_set(cur2, *end_offset);
|
|
|
|
|
2017-06-08 06:08:28 -07:00
|
|
|
annotations = efl_text_range_annotations_get(obj, cur1, cur2);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
if (!annotations) return EINA_FALSE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
EINA_ITERATOR_FOREACH(annotations, an)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-10-05 07:09:46 -07:00
|
|
|
attr = _textblock_node_format_to_atspi_text_attr(obj, an);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!attr) continue;
|
|
|
|
if (!strcmp(attr->name, attr_name))
|
|
|
|
{
|
|
|
|
*value = attr->value ? strdup(attr->value) : NULL;
|
|
|
|
elm_atspi_text_text_attribute_free(attr);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
elm_atspi_text_text_attribute_free(attr);
|
|
|
|
}
|
2016-10-05 07:09:46 -07:00
|
|
|
eina_iterator_free(annotations);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_List*
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_text_attributes_get(const Eo *obj, Efl_Ui_Text_Data *pd EINA_UNUSED, int *start_offset, int *end_offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cur1, *cur2;
|
2016-10-05 07:09:46 -07:00
|
|
|
Eina_List *ret = NULL;
|
2017-09-25 01:15:44 -07:00
|
|
|
Efl_Access_Text_Attribute *attr;
|
2016-10-05 07:09:46 -07:00
|
|
|
Eina_Iterator *annotations;
|
2017-07-17 07:38:28 -07:00
|
|
|
Efl_Text_Annotate_Annotation *an;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur1 = evas_object_textblock_cursor_new(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur1) return NULL;
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur2 = evas_object_textblock_cursor_new(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur2)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
evas_textblock_cursor_pos_set(cur1, *start_offset);
|
|
|
|
evas_textblock_cursor_pos_set(cur2, *end_offset);
|
|
|
|
|
2017-06-08 06:08:28 -07:00
|
|
|
annotations = efl_text_range_annotations_get(obj, cur1, cur2);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
if (!annotations) return NULL;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
EINA_ITERATOR_FOREACH(annotations, an)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-10-05 07:09:46 -07:00
|
|
|
attr = _textblock_node_format_to_atspi_text_attr(obj, an);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!attr) continue;
|
|
|
|
ret = eina_list_append(ret, attr);
|
|
|
|
}
|
2016-10-05 07:09:46 -07:00
|
|
|
eina_iterator_free(annotations);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_List*
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_efl_access_text_default_attributes_get(const Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Eina_List *ret = NULL;
|
2017-09-25 01:15:44 -07:00
|
|
|
Efl_Access_Text_Attribute *attr;
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *start, *end;
|
2016-10-05 07:09:46 -07:00
|
|
|
Eina_Iterator *annotations;
|
2017-07-17 07:38:28 -07:00
|
|
|
Efl_Text_Annotate_Annotation *an;
|
2016-10-05 07:09:46 -07:00
|
|
|
|
|
|
|
/* Retrieve all annotations in the text. */
|
2018-04-17 11:09:44 -07:00
|
|
|
Eo *mobj = (Eo *)obj; /* XXX const */
|
|
|
|
start = efl_text_cursor_new(mobj);
|
|
|
|
end = efl_text_cursor_new(mobj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-04-17 11:09:44 -07:00
|
|
|
efl_text_cursor_paragraph_first(mobj, start);
|
|
|
|
efl_text_cursor_paragraph_last(mobj, end);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-06-08 06:08:28 -07:00
|
|
|
annotations = efl_text_range_annotations_get(obj, start, end);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
EINA_ITERATOR_FOREACH(annotations, an)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-10-05 07:09:46 -07:00
|
|
|
attr = _textblock_node_format_to_atspi_text_attr(obj, an);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!attr) continue;
|
|
|
|
ret = eina_list_append(ret, attr);
|
|
|
|
}
|
2016-10-05 07:09:46 -07:00
|
|
|
eina_iterator_free(annotations);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2018-02-14 18:14:52 -08:00
|
|
|
_efl_ui_text_efl_access_editable_text_text_content_set(Eo *obj, Efl_Ui_Text_Data *pd EINA_UNUSED, const char *content)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-07-10 03:37:02 -07:00
|
|
|
efl_text_set(obj, content);
|
2016-06-08 08:37:35 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2017-09-25 01:15:44 -07:00
|
|
|
_efl_ui_text_efl_access_editable_text_insert(Eo *obj, Efl_Ui_Text_Data *pd, const char *string, int position)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *cur_obj = efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN);
|
2017-06-08 03:07:12 -07:00
|
|
|
efl_text_cursor_position_set(obj, cur_obj, position);
|
2016-10-05 07:09:46 -07:00
|
|
|
_efl_ui_text_entry_insert(obj, pd, string);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2017-09-25 01:15:44 -07:00
|
|
|
_efl_ui_text_efl_access_editable_text_copy(Eo *obj, Efl_Ui_Text_Data *pd, int start, int end)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-10-05 07:09:46 -07:00
|
|
|
_efl_ui_text_select_region_set(obj, pd, start, end);
|
2016-06-08 08:37:35 -07:00
|
|
|
efl_ui_text_selection_copy(obj);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2017-09-25 01:15:44 -07:00
|
|
|
_efl_ui_text_efl_access_editable_text_delete(Eo *obj, Efl_Ui_Text_Data *pd, int start_offset, int end_offset)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
|
|
|
Evas_Textblock_Cursor *cur1, *cur2;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = pd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
if (!text_obj) return EINA_FALSE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur1 = evas_object_textblock_cursor_new(text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur1) return EINA_FALSE;
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
cur2 = evas_object_textblock_cursor_new(text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
if (!cur2)
|
|
|
|
{
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
evas_textblock_cursor_pos_set(cur1, start_offset);
|
|
|
|
evas_textblock_cursor_pos_set(cur2, end_offset);
|
|
|
|
|
|
|
|
evas_textblock_cursor_range_delete(cur1, cur2);
|
|
|
|
|
|
|
|
evas_textblock_cursor_free(cur1);
|
|
|
|
evas_textblock_cursor_free(cur2);
|
|
|
|
|
2016-10-05 07:09:46 -07:00
|
|
|
_efl_ui_text_calc_force(obj, pd);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2017-09-25 01:15:44 -07:00
|
|
|
_efl_ui_text_efl_access_editable_text_paste(Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED, int position)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *cur_obj = efl_text_cursor_get(obj, EFL_TEXT_CURSOR_GET_MAIN);
|
2017-06-08 03:07:12 -07:00
|
|
|
efl_text_cursor_position_set(obj, cur_obj, position);
|
2016-06-08 08:37:35 -07:00
|
|
|
efl_ui_text_selection_paste(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2017-09-25 01:15:44 -07:00
|
|
|
_efl_ui_text_efl_access_editable_text_cut(Eo *obj, Efl_Ui_Text_Data *pd EINA_UNUSED, int start, int end)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-10-05 07:09:46 -07:00
|
|
|
_efl_ui_text_select_region_set(obj, pd, start, end);
|
2016-06-08 08:37:35 -07:00
|
|
|
efl_ui_text_selection_cut(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
EOLIAN static Efl_Access_State_Set
|
2018-04-03 04:27:30 -07:00
|
|
|
_efl_ui_text_efl_access_object_state_set_get(const Eo *obj, Efl_Ui_Text_Data *_pd EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-10-18 18:13:54 -07:00
|
|
|
Efl_Access_State_Set ret;
|
2018-04-03 04:27:30 -07:00
|
|
|
ret = efl_access_object_state_set_get(efl_super(obj, EFL_UI_TEXT_CLASS));
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
if (efl_text_interactive_editable_get(obj))
|
2017-10-18 18:13:54 -07:00
|
|
|
STATE_TYPE_SET(ret, EFL_ACCESS_STATE_EDITABLE);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-11-09 17:58:41 -08:00
|
|
|
EOLIAN static const char*
|
2018-04-03 04:27:30 -07:00
|
|
|
_efl_ui_text_efl_access_object_i18n_name_get(const Eo *obj, Efl_Ui_Text_Data *pd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-11-09 17:58:41 -08:00
|
|
|
const char *name;
|
2018-04-03 04:27:30 -07:00
|
|
|
name = efl_access_object_i18n_name_get(efl_super(obj, EFL_UI_TEXT_CLASS));
|
2016-06-08 08:37:35 -07:00
|
|
|
if (name && strncmp("", name, 1)) return name;
|
2018-04-26 03:27:43 -07:00
|
|
|
const char *ret = edje_object_part_text_get(pd->entry_edje, "efl.guide");
|
2016-11-09 17:58:41 -08:00
|
|
|
return ret;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2017-07-17 02:45:36 -07:00
|
|
|
EOLIAN static Efl_Text_Cursor_Cursor *
|
Canvas text cursor: move to Efl.Canvas.Text namespace
Originally it was its own object.
There are some valid claims that there is no justification for it to
remain an object.
Furthermore, it's apparent that it added little benefit: changes of
each cursors, in practice, triggered a query for all objects of the
same textblock. There wasn't real advantage to have a finer resolution
of controlling the cursors with their own events.
This ports back a lot of code, and changes a lot of other code in the
higher-up widgets, such as Efl.Ui.Text and co.
The usage was replaces from:
efl_canvas_text_cursor_char_next(cur_obj)
to
efl_canvas_text_cursor_char_next(text_obj, cur_obj)
that is, it is an operations on the TEXT OBJECT, rather than on the
(now removed) cursor object.
So, one less efl object to worry about now.
Hopefully, the port went smooth.
2017-06-05 04:52:10 -07:00
|
|
|
_efl_ui_text_cursor_new(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd EINA_UNUSED)
|
2016-06-22 05:05:47 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = sd->text_obj;
|
2017-06-08 03:07:12 -07:00
|
|
|
return efl_text_cursor_new(text_obj);
|
2016-06-22 05:05:47 -07:00
|
|
|
}
|
|
|
|
|
2016-06-28 05:24:35 -07:00
|
|
|
static void
|
|
|
|
_edje_signal_emit(Efl_Ui_Text_Data *sd, const char *sig, const char *src)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(sd->entry_edje, sig, src);
|
|
|
|
edje_object_signal_emit(sd->cursor, sig, src);
|
|
|
|
edje_object_signal_emit(sd->cursor_bidi, sig, src);
|
|
|
|
}
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
static inline Eo *
|
2017-11-14 03:38:49 -08:00
|
|
|
_decoration_create(Eo *obj, Efl_Ui_Text_Data *sd,
|
|
|
|
const char *group_name, Eina_Bool above)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *ret = NULL;
|
|
|
|
Eo *clip = efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller);
|
|
|
|
|
|
|
|
ret = efl_add(EFL_CANVAS_LAYOUT_CLASS, obj);
|
2017-11-14 03:38:49 -08:00
|
|
|
elm_widget_element_update(obj, ret, group_name);
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_object_smart_member_add(ret, sd->entry_edje);
|
|
|
|
if (above)
|
|
|
|
{
|
2018-11-12 05:09:56 -08:00
|
|
|
evas_object_stack_above(ret, sd->text_table);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
evas_object_stack_below(ret, NULL);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
evas_object_clip_set(ret, clip);
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_object_pass_events_set(ret, EINA_TRUE);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-12-01 03:25:11 -08:00
|
|
|
_create_text_cursors(Eo *obj, Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2017-11-14 03:38:49 -08:00
|
|
|
sd->cursor = _decoration_create(obj, sd, PART_NAME_CURSOR, EINA_TRUE);
|
|
|
|
sd->cursor_bidi = _decoration_create(obj, sd, PART_NAME_CURSOR, EINA_TRUE);
|
2016-12-01 03:25:11 -08:00
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
if (!efl_text_interactive_editable_get(obj))
|
2016-12-01 03:25:11 -08:00
|
|
|
{
|
|
|
|
evas_object_hide(sd->cursor);
|
|
|
|
evas_object_hide(sd->cursor_bidi);
|
|
|
|
}
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
static Eina_Position2D
|
|
|
|
_decoration_calc_offset(Efl_Ui_Text_Data *sd)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Position2D ret;
|
|
|
|
Eina_Position2D text;
|
|
|
|
Eina_Position2D ed = EINA_POSITION2D(0,0), scr = EINA_POSITION2D(0, 0);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
text = efl_gfx_entity_position_get(sd->text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
ret.x = ed.x + scr.x + text.x;
|
|
|
|
ret.y = ed.y + scr.y + text.y;
|
|
|
|
|
|
|
|
return ret;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_update_text_cursors(Eo *obj)
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Evas_Coord xx, yy, ww, hh;
|
2016-06-08 08:37:35 -07:00
|
|
|
Evas_Coord xx2, yy2;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Position2D off;
|
2016-06-08 08:37:35 -07:00
|
|
|
Eina_Bool bidi_cursor;
|
2017-09-09 03:21:06 -07:00
|
|
|
Eo *text_obj;
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
2016-06-22 10:02:32 -07:00
|
|
|
if (!sd->deferred_decoration_cursor) return;
|
|
|
|
sd->deferred_decoration_cursor = EINA_FALSE;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
text_obj = sd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
xx = yy = ww = hh = -1;
|
2018-09-13 02:45:29 -07:00
|
|
|
off =_decoration_calc_offset(sd);
|
2017-09-26 16:03:59 -07:00
|
|
|
bidi_cursor = efl_text_cursor_geometry_get(obj,
|
2017-06-08 06:46:42 -07:00
|
|
|
efl_text_cursor_get(text_obj, EFL_TEXT_CURSOR_GET_MAIN),
|
2017-06-08 03:07:12 -07:00
|
|
|
EFL_TEXT_CURSOR_TYPE_BEFORE, &xx, &yy, &ww, &hh, &xx2, &yy2,
|
2016-06-08 08:37:35 -07:00
|
|
|
NULL, NULL);
|
|
|
|
if (ww < 1) ww = 1;
|
|
|
|
if (hh < 1) hh = 1;
|
|
|
|
if (sd->cursor)
|
|
|
|
{
|
2018-11-21 07:38:24 -08:00
|
|
|
evas_object_geometry_set(sd->cursor, off.x + xx, off.y + yy, ww, hh);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
if (sd->cursor_bidi)
|
|
|
|
{
|
|
|
|
if (bidi_cursor)
|
|
|
|
{
|
2018-11-21 07:38:24 -08:00
|
|
|
evas_object_geometry_set(sd->cursor_bidi,
|
|
|
|
off.x + xx2, off.y + yy2 + (hh / 2),
|
|
|
|
ww, hh / 2);
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_object_resize(sd->cursor, ww, hh / 2);
|
|
|
|
evas_object_show(sd->cursor_bidi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_object_hide(sd->cursor_bidi);
|
|
|
|
}
|
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
if (sd->cursor_update)
|
|
|
|
{
|
|
|
|
sd->cursor_update = EINA_FALSE;
|
|
|
|
_cursor_geometry_recalc(obj);
|
|
|
|
}
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2017-06-07 22:50:14 -07:00
|
|
|
static void
|
|
|
|
_clear_text_selection(Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
Efl_Ui_Text_Rectangle *r;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(sd->sel, r)
|
|
|
|
{
|
|
|
|
free(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
static void
|
|
|
|
_update_text_selection(Eo *obj, Eo *text_obj)
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Position2D off;
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *sel_start, *sel_end;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
Eina_List *l;
|
|
|
|
Eina_Iterator *range;
|
|
|
|
Efl_Ui_Text_Rectangle *rect;
|
|
|
|
Eina_Rectangle *r;
|
|
|
|
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
2016-06-22 10:02:32 -07:00
|
|
|
if (!sd->deferred_decoration_selection) return;
|
|
|
|
sd->deferred_decoration_selection = EINA_FALSE;
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
off = _decoration_calc_offset(sd);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2016-10-05 07:10:20 -07:00
|
|
|
range = efl_canvas_text_range_simple_geometry_get(text_obj,
|
2016-06-08 08:37:35 -07:00
|
|
|
sel_start, sel_end);
|
|
|
|
|
2016-10-05 07:10:20 -07:00
|
|
|
l = sd->sel;
|
2016-06-08 08:37:35 -07:00
|
|
|
EINA_ITERATOR_FOREACH(range, r)
|
|
|
|
{
|
|
|
|
/* Create if there isn't a rectangle to populate. */
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
rect = calloc(1, sizeof(Efl_Ui_Text_Rectangle));
|
2016-10-05 07:10:20 -07:00
|
|
|
sd->sel = eina_list_append(sd->sel, rect);
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2017-11-14 03:38:49 -08:00
|
|
|
rect->obj_bg = _decoration_create(obj, sd, PART_NAME_SELECTION, EINA_FALSE);
|
2016-06-08 08:37:35 -07:00
|
|
|
evas_object_show(rect->obj_bg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rect = eina_list_data_get(l);
|
|
|
|
l = l->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rect->obj_bg)
|
|
|
|
{
|
2018-11-21 07:38:24 -08:00
|
|
|
evas_object_geometry_set(rect->obj_bg, off.x + r->x, off.y + r->y,
|
|
|
|
r->w, r->h);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
eina_iterator_free(range);
|
|
|
|
|
|
|
|
/* delete redundant rectection rects */
|
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
Eina_List *temp = l->next;
|
|
|
|
rect = eina_list_data_get(l);
|
|
|
|
if (rect)
|
|
|
|
{
|
2016-08-10 07:23:04 -07:00
|
|
|
if (rect->obj_bg) efl_del(rect->obj_bg);
|
2016-06-08 08:37:35 -07:00
|
|
|
free(rect);
|
|
|
|
}
|
2016-10-05 07:10:20 -07:00
|
|
|
sd->sel = eina_list_remove_list(sd->sel, l);
|
2016-06-08 08:37:35 -07:00
|
|
|
l = temp;
|
|
|
|
}
|
2016-07-10 09:52:14 -07:00
|
|
|
|
|
|
|
/* Update selection handlers */
|
|
|
|
_update_selection_handler(obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2016-06-22 05:12:15 -07:00
|
|
|
static void
|
2018-09-13 02:45:29 -07:00
|
|
|
_anchors_free(Efl_Ui_Text_Data *sd)
|
2016-06-22 05:12:15 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Anchor *an;
|
2016-06-22 05:12:15 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
EINA_LIST_FREE(sd->anchors, an)
|
2016-06-22 05:12:15 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Efl_Ui_Text_Rectangle *rect;
|
|
|
|
EINA_LIST_FREE(an->rects, rect)
|
2016-06-22 05:12:15 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
free(rect);
|
2016-06-22 05:12:15 -07:00
|
|
|
}
|
|
|
|
free(an->name);
|
|
|
|
free(an);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_anchor_format_parse(const char *item)
|
|
|
|
{
|
|
|
|
const char *start, *end;
|
|
|
|
char *tmp;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
start = strchr(item, '=');
|
|
|
|
if (!start) return NULL;
|
|
|
|
|
|
|
|
start++; /* Advance after the '=' */
|
|
|
|
/* If we can find a quote as the first non-space char,
|
|
|
|
* our new delimiter is a quote, not a space. */
|
|
|
|
while (*start == ' ')
|
|
|
|
start++;
|
|
|
|
|
|
|
|
if (*start == '\'')
|
|
|
|
{
|
|
|
|
start++;
|
|
|
|
end = strchr(start, '\'');
|
|
|
|
while ((end) && (end > start) && (end[-1] == '\\'))
|
|
|
|
end = strchr(end + 1, '\'');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
end = strchr(start, ' ');
|
|
|
|
while ((end) && (end > start) && (end[-1] == '\\'))
|
|
|
|
end = strchr(end + 1, ' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Null terminate before the spaces */
|
|
|
|
if (end) len = end - start;
|
|
|
|
else len = strlen(start);
|
|
|
|
|
|
|
|
tmp = malloc(len + 1);
|
|
|
|
strncpy(tmp, start, len);
|
|
|
|
tmp[len] = '\0';
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
static Anchor *
|
|
|
|
_anchor_get(Eo *obj, Efl_Ui_Text_Data *sd, Efl_Text_Annotate_Annotation *an)
|
2016-06-22 05:12:15 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Anchor *anc;
|
|
|
|
Eina_List *i;
|
|
|
|
const char *str;
|
2016-06-22 05:12:15 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
str = efl_text_annotation_get(obj, an);
|
2016-06-22 05:12:15 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
EINA_LIST_FOREACH(sd->anchors, i, anc)
|
2016-06-22 05:12:15 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
if (anc->annotation == an) break;
|
|
|
|
}
|
2016-06-22 05:12:15 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
if (!anc && (efl_text_annotation_is_item(obj, an) || !strncmp(str, "a ", 2)))
|
|
|
|
{
|
|
|
|
const char *p;
|
2016-10-05 07:10:20 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
anc = calloc(1, sizeof(Anchor));
|
|
|
|
if (anc)
|
2016-10-05 07:10:20 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
anc->obj = obj;
|
|
|
|
anc->annotation = an;
|
|
|
|
anc->item = efl_text_annotation_is_item(obj, an);
|
|
|
|
p = strstr(str, "href=");
|
2016-10-05 07:10:20 -07:00
|
|
|
if (p)
|
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
anc->name = _anchor_format_parse(p);
|
2016-10-05 07:10:20 -07:00
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->anchors = eina_list_append(sd->anchors, anc);
|
2016-06-22 05:12:15 -07:00
|
|
|
}
|
|
|
|
}
|
2016-10-05 07:10:20 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
return anc;
|
2016-10-05 07:10:20 -07:00
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* Recreates and updates the anchors in the text.
|
|
|
|
*/
|
2016-06-22 05:12:15 -07:00
|
|
|
static void
|
2018-09-13 02:45:29 -07:00
|
|
|
_anchors_update(Eo *obj, Efl_Ui_Text_Data *sd)
|
2016-06-22 05:12:15 -07:00
|
|
|
{
|
|
|
|
Evas_Object *smart, *clip;
|
2018-09-13 02:45:29 -07:00
|
|
|
Eina_Iterator *it;
|
|
|
|
Eina_Position2D off;
|
|
|
|
Efl_Text_Cursor_Cursor *start, *end;
|
|
|
|
Efl_Text_Annotate_Annotation *an;
|
|
|
|
Eina_List *i, *ii;
|
|
|
|
Anchor *anc;
|
2016-10-05 07:10:20 -07:00
|
|
|
|
2016-06-22 10:02:32 -07:00
|
|
|
if (!sd->deferred_decoration_anchor) return;
|
|
|
|
sd->deferred_decoration_anchor = EINA_FALSE;
|
|
|
|
|
2016-06-22 05:12:15 -07:00
|
|
|
if (sd->anchors_updated) return;
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->gen++;
|
2017-09-09 03:21:06 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
start = efl_text_cursor_new(sd->text_obj);
|
|
|
|
end = efl_text_cursor_new(sd->text_obj);
|
2016-06-22 05:12:15 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
/* Retrieve all annotations in the text. */
|
|
|
|
efl_text_cursor_paragraph_first(obj, start);
|
|
|
|
efl_text_cursor_paragraph_last(obj, end);
|
2016-06-22 05:12:15 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
it = efl_text_range_annotations_get(obj, start, end);
|
|
|
|
efl_text_cursor_free(sd->text_obj, start);
|
|
|
|
efl_text_cursor_free(sd->text_obj, end);
|
2017-09-19 10:16:59 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
smart = evas_object_smart_parent_get(obj);
|
|
|
|
clip = evas_object_clip_get(sd->text_obj);
|
|
|
|
off = _decoration_calc_offset(sd);
|
2016-10-05 07:10:20 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
EINA_ITERATOR_FOREACH(it, an)
|
|
|
|
{
|
|
|
|
anc = _anchor_get(obj, sd, an);
|
2016-10-05 07:10:20 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
if (anc)
|
|
|
|
{
|
|
|
|
anc->gen = sd->gen;
|
2016-10-05 07:10:20 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
if (anc->item)
|
2016-10-05 07:10:20 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Efl_Ui_Text_Rectangle *rect;
|
|
|
|
Evas_Coord cx, cy, cw, ch;
|
2016-10-05 07:10:20 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
// Item anchor (one rectangle)
|
|
|
|
if (!anc->rects)
|
2016-10-05 07:10:20 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *ob;
|
|
|
|
|
|
|
|
rect = calloc(1, sizeof(Efl_Ui_Text_Rectangle));
|
|
|
|
anc->rects = eina_list_append(anc->rects, rect);
|
|
|
|
|
|
|
|
ob = _item_get(obj, anc->name);
|
|
|
|
|
|
|
|
if (ob)
|
|
|
|
{
|
|
|
|
efl_canvas_group_member_add(smart, ob);
|
|
|
|
efl_gfx_stack_above(ob, obj);
|
|
|
|
efl_canvas_object_clip_set(ob, clip);
|
|
|
|
efl_canvas_object_pass_events_set(ob, EINA_TRUE);
|
|
|
|
rect->obj = ob;
|
|
|
|
}
|
2016-10-05 07:10:20 -07:00
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
rect = eina_list_data_get(anc->rects);
|
|
|
|
efl_text_item_geometry_get(sd->text_obj,
|
|
|
|
anc->annotation, &cx, &cy, &cw, &ch);
|
|
|
|
efl_gfx_entity_size_set(rect->obj, EINA_SIZE2D(cw, ch));
|
|
|
|
efl_gfx_entity_position_set(rect->obj,
|
|
|
|
EINA_POSITION2D(off.x + cx, off.y + cy));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Link anchor (multiple rectangles) i.e. "a href=..."
|
|
|
|
Eina_Iterator *range;
|
|
|
|
Eina_List *l;
|
|
|
|
Eina_Rectangle *r;
|
|
|
|
size_t count;
|
|
|
|
start = efl_text_cursor_new(obj);
|
|
|
|
end = efl_text_cursor_new(obj);
|
|
|
|
efl_text_annotation_positions_get(obj, anc->annotation,
|
|
|
|
start, end);
|
|
|
|
|
|
|
|
range = efl_canvas_text_range_geometry_get(obj, start, end);
|
|
|
|
count = eina_list_count(eina_iterator_container_get(range));
|
|
|
|
|
|
|
|
// Add additional rectangles if needed
|
|
|
|
while (count > eina_list_count(anc->rects))
|
2016-10-05 07:10:20 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Efl_Ui_Text_Rectangle *rect;
|
|
|
|
Eo *ob;
|
2016-10-05 07:10:20 -07:00
|
|
|
rect = calloc(1, sizeof(Efl_Ui_Text_Rectangle));
|
2018-09-13 02:45:29 -07:00
|
|
|
anc->rects = eina_list_append(anc->rects, rect);
|
2016-10-05 07:10:20 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
ob = _decoration_create(obj, sd, PART_NAME_ANCHOR, EINA_TRUE);
|
2016-10-05 07:10:20 -07:00
|
|
|
rect->obj_fg = ob;
|
2018-09-13 02:45:29 -07:00
|
|
|
// hit-rectangle
|
|
|
|
ob = evas_object_rectangle_add(obj);
|
2016-10-05 07:10:20 -07:00
|
|
|
evas_object_color_set(ob, 0, 0, 0, 0);
|
|
|
|
evas_object_smart_member_add(ob, smart);
|
2018-09-13 02:45:29 -07:00
|
|
|
evas_object_stack_above(ob, obj);
|
2016-10-05 07:10:20 -07:00
|
|
|
evas_object_clip_set(ob, clip);
|
|
|
|
evas_object_repeat_events_set(ob, EINA_TRUE);
|
|
|
|
rect->obj = ob;
|
2018-09-13 02:45:29 -07:00
|
|
|
//FIXME: add event handlers
|
2016-10-05 07:10:20 -07:00
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
// Remove extra rectangles if needed
|
|
|
|
while (count < eina_list_count(anc->rects))
|
2016-10-05 07:10:20 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Efl_Ui_Text_Rectangle *rect;
|
2016-06-22 05:12:15 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
rect = eina_list_data_get(anc->rects);
|
|
|
|
if (rect->obj) efl_del(rect->obj);
|
|
|
|
if (rect->obj_fg) efl_del(rect->obj_fg);
|
|
|
|
if (rect->obj_bg) efl_del(rect->obj_bg);
|
|
|
|
free(rect);
|
|
|
|
anc->rects = eina_list_remove_list(anc->rects, anc->rects);
|
2016-06-22 05:12:15 -07:00
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
|
|
|
|
l = anc->rects;
|
|
|
|
EINA_ITERATOR_FOREACH(range, r)
|
2016-06-22 05:12:15 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Efl_Ui_Text_Rectangle *rect;
|
|
|
|
|
|
|
|
rect = eina_list_data_get(l);
|
|
|
|
if (rect->obj_bg)
|
|
|
|
{
|
2018-11-21 07:38:24 -08:00
|
|
|
evas_object_geometry_set(rect->obj_bg,
|
|
|
|
off.x + r->x, off.y + r->y,
|
|
|
|
r->w, r->h);
|
2018-09-13 02:45:29 -07:00
|
|
|
evas_object_show(rect->obj_bg);
|
|
|
|
}
|
|
|
|
if (rect->obj_fg)
|
|
|
|
{
|
2018-11-21 07:38:24 -08:00
|
|
|
evas_object_geometry_set(rect->obj_fg,
|
|
|
|
off.x + r->x, off.y + r->y,
|
|
|
|
r->w, r->h);
|
2018-09-13 02:45:29 -07:00
|
|
|
evas_object_show(rect->obj_fg);
|
|
|
|
}
|
|
|
|
if (rect->obj)
|
|
|
|
{
|
2018-11-21 07:38:24 -08:00
|
|
|
evas_object_geometry_set(rect->obj,
|
|
|
|
off.x + r->x, off.y + r->y,
|
|
|
|
r->w, r->h);
|
2018-09-13 02:45:29 -07:00
|
|
|
evas_object_show(rect->obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
l = eina_list_next(l);
|
2016-06-22 05:12:15 -07:00
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
eina_iterator_free(range);
|
2016-06-22 05:12:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-13 02:45:29 -07:00
|
|
|
eina_iterator_free(it);
|
2016-06-22 05:12:15 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
// Remove anchors that weren't matched to any annotation
|
|
|
|
EINA_LIST_FOREACH_SAFE(sd->anchors, i, ii, anc)
|
|
|
|
{
|
|
|
|
if (anc->gen != sd->gen)
|
|
|
|
{
|
|
|
|
Efl_Ui_Text_Rectangle *rect;
|
|
|
|
sd->anchors = eina_list_remove_list(sd->anchors, i);
|
|
|
|
EINA_LIST_FREE(anc->rects, rect)
|
|
|
|
{
|
|
|
|
efl_del(rect->obj);
|
|
|
|
efl_del(rect->obj_bg);
|
|
|
|
efl_del(rect->obj_fg);
|
|
|
|
free(rect);
|
|
|
|
}
|
|
|
|
free(anc->name);
|
|
|
|
free(anc);
|
|
|
|
}
|
|
|
|
}
|
2016-06-22 05:12:15 -07:00
|
|
|
}
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
static void
|
|
|
|
_update_decorations(Eo *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *text_obj = sd->text_obj;
|
2016-06-08 08:37:35 -07:00
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_event_freeze(sd->text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
_update_text_cursors(obj);
|
|
|
|
_update_text_selection(obj, text_obj);
|
2016-06-22 05:12:15 -07:00
|
|
|
_anchors_update(obj, sd);
|
2018-09-13 02:45:29 -07:00
|
|
|
efl_event_thaw(sd->text_obj);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-06-22 10:02:32 -07:00
|
|
|
_deferred_decoration_job(void *data)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2016-06-22 10:02:32 -07:00
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
2016-06-08 08:37:35 -07:00
|
|
|
_update_decorations(data);
|
2017-09-11 22:38:51 -07:00
|
|
|
sd->deferred_decoration_job = NULL;
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2016-06-22 10:02:32 -07:00
|
|
|
static void
|
|
|
|
_decoration_defer(Eo *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
2017-09-11 22:38:51 -07:00
|
|
|
if (!sd->deferred_decoration_job)
|
|
|
|
{
|
|
|
|
sd->deferred_decoration_job =
|
|
|
|
ecore_job_add(_deferred_decoration_job, obj);
|
|
|
|
}
|
2016-06-22 10:02:32 -07:00
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
static void
|
|
|
|
_selection_defer(Eo *obj, Efl_Ui_Text_Data *sd)
|
|
|
|
{
|
|
|
|
sd->deferred_decoration_selection = EINA_TRUE;
|
|
|
|
_decoration_defer(obj);
|
|
|
|
}
|
|
|
|
|
2016-06-22 10:02:32 -07:00
|
|
|
static void
|
|
|
|
_decoration_defer_all(Eo *obj)
|
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
sd->deferred_decoration_anchor = EINA_TRUE;
|
|
|
|
sd->deferred_decoration_cursor = EINA_TRUE;
|
|
|
|
sd->deferred_decoration_selection = EINA_TRUE;
|
|
|
|
_decoration_defer(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-02-07 03:41:52 -08:00
|
|
|
_efl_ui_text_changed_cb(void *data, const Efl_Event *event)
|
2016-06-22 10:02:32 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
if (efl_invalidated_get(event->object)) return;
|
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
|
|
|
sd->text_changed = EINA_TRUE;
|
|
|
|
sd->cursor_update = EINA_TRUE;
|
2018-11-12 05:09:56 -08:00
|
|
|
_update_guide_text(data, sd);
|
2019-02-07 03:41:52 -08:00
|
|
|
efl_event_callback_call(event->object, EFL_UI_TEXT_EVENT_CHANGED, NULL);
|
2018-09-13 02:45:29 -07:00
|
|
|
elm_layout_sizing_eval(data);
|
|
|
|
_decoration_defer(data);
|
2016-06-22 10:02:32 -07:00
|
|
|
}
|
|
|
|
|
2017-12-12 22:05:15 -08:00
|
|
|
static void
|
2017-12-12 22:12:13 -08:00
|
|
|
_efl_ui_text_changed_user_cb(void *data, const Efl_Event *event)
|
2017-12-12 22:05:15 -08:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
Eo *obj = data;
|
|
|
|
|
|
|
|
if (efl_invalidated_get(event->object)) return;
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
sd->text_changed = EINA_TRUE;
|
2018-11-12 05:09:56 -08:00
|
|
|
_update_guide_text(data, sd);
|
2018-09-13 02:45:29 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
_decoration_defer_all(obj);
|
2017-12-12 22:05:15 -08:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_efl_ui_text_cursor_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
if (efl_invalidated_get(event->object)) return;
|
2016-06-22 10:02:32 -07:00
|
|
|
EFL_UI_TEXT_DATA_GET(data, sd);
|
2016-07-10 07:30:51 -07:00
|
|
|
sd->cur_changed = EINA_TRUE;
|
2018-09-13 02:45:29 -07:00
|
|
|
sd->cursor_update = EINA_TRUE;
|
2017-09-11 22:38:51 -07:00
|
|
|
sd->deferred_decoration_cursor = EINA_TRUE;
|
|
|
|
_decoration_defer(data);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2018-09-13 02:45:29 -07:00
|
|
|
static void
|
|
|
|
_scroller_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
if (efl_invalidated_get(event->object)) return;
|
|
|
|
|
|
|
|
_decoration_defer_all(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_text_size_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
if (efl_invalidated_get(event->object)) return;
|
|
|
|
|
|
|
|
_decoration_defer_all(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_text_position_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
|
|
|
{
|
|
|
|
if (efl_invalidated_get(event->object)) return;
|
|
|
|
|
|
|
|
_decoration_defer_all(data);
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_efl_ui_text_selection_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2016-06-08 08:37:35 -07:00
|
|
|
{
|
2018-09-13 02:45:29 -07:00
|
|
|
if (efl_invalidated_get(event->object)) return;
|
2016-06-28 05:24:35 -07:00
|
|
|
Eo *obj = data;
|
2017-07-17 02:45:36 -07:00
|
|
|
Efl_Text_Cursor_Cursor *start, *end;
|
2016-06-28 05:24:35 -07:00
|
|
|
char *text;
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
|
|
|
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_selection_cursors_get(obj, &start, &end);
|
2016-06-28 05:24:35 -07:00
|
|
|
|
|
|
|
text = efl_canvas_text_range_text_get(obj, start, end);
|
|
|
|
if (!text || (text[0] == '\0'))
|
|
|
|
{
|
2018-04-26 03:27:43 -07:00
|
|
|
_edje_signal_emit(sd, "selection,cleared", "efl.text");
|
2016-06-28 05:24:35 -07:00
|
|
|
sd->have_selection = EINA_FALSE;
|
2018-09-13 02:45:29 -07:00
|
|
|
_selection_clear(data, 0);
|
2016-06-28 05:24:35 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!sd->have_selection)
|
|
|
|
{
|
2018-04-26 03:27:43 -07:00
|
|
|
_edje_signal_emit(sd, "selection,start", "efl.text");
|
2016-06-28 05:24:35 -07:00
|
|
|
}
|
2018-04-26 03:27:43 -07:00
|
|
|
_edje_signal_emit(sd, "selection,changed", "efl.text");
|
2016-06-28 05:24:35 -07:00
|
|
|
sd->have_selection = EINA_TRUE;
|
2018-12-21 13:46:06 -08:00
|
|
|
_selection_store(EFL_UI_SELECTION_TYPE_PRIMARY, obj);
|
2016-06-28 05:24:35 -07:00
|
|
|
}
|
2016-06-30 12:39:29 -07:00
|
|
|
if (text) free(text);
|
2018-09-13 02:45:29 -07:00
|
|
|
_selection_defer(obj, sd);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_text_move_cb(void *data, Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2016-06-22 10:02:32 -07:00
|
|
|
_decoration_defer_all(data);
|
2016-06-08 08:37:35 -07:00
|
|
|
}
|
|
|
|
|
2017-11-09 07:53:20 -08:00
|
|
|
static void
|
|
|
|
_efl_ui_text_item_factory_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *pd,
|
|
|
|
Efl_Canvas_Text_Factory *item_factory)
|
|
|
|
{
|
|
|
|
if (pd->item_factory) efl_unref(pd->item_factory);
|
|
|
|
pd->item_factory = efl_ref(item_factory);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eo *
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_text_item_factory_get(const Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *pd)
|
2017-11-09 07:53:20 -08:00
|
|
|
{
|
|
|
|
return pd->item_factory;
|
|
|
|
}
|
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
/* Efl.Part begin */
|
|
|
|
|
2018-11-12 08:57:24 -08:00
|
|
|
#define STRCMP(X, Y) strncmp((X), (Y), strlen(X))
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_text_text_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *pd,
|
|
|
|
const char *part, const char *text)
|
|
|
|
{
|
|
|
|
if (!STRCMP("efl.text_guide", part))
|
|
|
|
{
|
|
|
|
efl_text_set(pd->text_guide_obj, text);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!STRCMP("efl.text", part))
|
|
|
|
{
|
|
|
|
efl_text_set(pd->text_obj, text);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static const char *
|
|
|
|
_efl_ui_text_text_get(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *pd,
|
|
|
|
const char *part)
|
|
|
|
{
|
|
|
|
if (!STRCMP("efl.text_guide", part))
|
|
|
|
{
|
|
|
|
return efl_text_get(pd->text_guide_obj);
|
|
|
|
}
|
|
|
|
else if (!STRCMP("efl.text", part))
|
|
|
|
{
|
|
|
|
return efl_text_get(pd->text_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef STRCMP
|
|
|
|
|
|
|
|
ELM_PART_OVERRIDE(efl_ui_text, EFL_UI_TEXT, Efl_Ui_Text_Data)
|
|
|
|
ELM_PART_OVERRIDE_TEXT_SET(efl_ui_text, EFL_UI_TEXT, Efl_Ui_Text_Data)
|
|
|
|
ELM_PART_OVERRIDE_TEXT_GET(efl_ui_text, EFL_UI_TEXT, Efl_Ui_Text_Data)
|
|
|
|
#include "efl_ui_text_part.eo.c"
|
2016-06-08 08:37:35 -07:00
|
|
|
|
|
|
|
/* Efl.Part end */
|
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
//ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
|
2017-07-27 23:35:10 -07:00
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
#define EFL_UI_TEXT_EXTRA_OPS \
|
2018-09-13 02:45:29 -07:00
|
|
|
ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_text)
|
2017-05-18 01:52:17 -07:00
|
|
|
|
2016-06-08 08:37:35 -07:00
|
|
|
#include "efl_ui_text.eo.c"
|
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
EOLIAN static Eo *
|
|
|
|
_efl_ui_text_async_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
|
2017-09-11 22:38:51 -07:00
|
|
|
{
|
|
|
|
EFL_UI_TEXT_DATA_GET(obj, sd);
|
2017-12-06 00:33:03 -08:00
|
|
|
|
2017-09-11 22:38:51 -07:00
|
|
|
sd->async.enabled = EINA_TRUE;
|
|
|
|
|
2017-12-06 00:33:03 -08:00
|
|
|
// FIXME: should we have to keep this efl_ui_text_xxx classes?
|
|
|
|
// Then, going to make new theme for these classes? ex) efl/text_async?
|
|
|
|
if (!elm_widget_theme_klass_get(obj))
|
|
|
|
elm_widget_theme_klass_set(obj, "text");
|
|
|
|
obj = efl_constructor(efl_super(obj, EFL_UI_TEXT_ASYNC_CLASS));
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2018-11-12 05:14:11 -08:00
|
|
|
_update_text_theme(obj, sd);
|
2017-12-06 00:33:03 -08:00
|
|
|
return obj;
|
|
|
|
}
|
2017-09-11 22:38:51 -07:00
|
|
|
|
|
|
|
#include "efl_ui_text_async.eo.c"
|
|
|
|
|
2016-06-22 06:22:27 -07:00
|
|
|
#undef MY_CLASS
|
|
|
|
#define MY_CLASS EFL_UI_TEXT_EDITABLE_CLASS
|
|
|
|
|
2017-09-11 22:38:51 -07:00
|
|
|
|
2016-06-22 06:22:27 -07:00
|
|
|
EOLIAN static Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_efl_ui_text_editable_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
|
2016-06-22 06:22:27 -07:00
|
|
|
{
|
2017-12-06 00:33:03 -08:00
|
|
|
// FIXME: should we have to keep this efl_ui_text_xxx classes?
|
|
|
|
// Then, going to make new theme for these classes? ex) efl/text_editable?
|
|
|
|
if (!elm_widget_theme_klass_get(obj))
|
|
|
|
elm_widget_theme_klass_set(obj, "text");
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2018-04-06 04:30:40 -07:00
|
|
|
efl_text_interactive_editable_set(obj, EINA_TRUE);
|
2016-06-22 06:22:27 -07:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "efl_ui_text_editable.eo.c"
|