2008-10-14 01:05:30 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
|
|
|
Evas_Object *ent;
|
2009-03-19 06:36:46 -07:00
|
|
|
Evas_Object *hoversel;
|
2008-11-18 22:23:08 -08:00
|
|
|
Ecore_Job *deferred_recalc_job;
|
|
|
|
Ecore_Event_Handler *sel_notify_handler;
|
|
|
|
Ecore_Event_Handler *sel_clear_handler;
|
2009-03-19 06:36:46 -07:00
|
|
|
Ecore_Timer *longpress_timer;
|
2008-11-18 22:23:08 -08:00
|
|
|
const char *cut_sel;
|
2008-10-17 20:55:44 -07:00
|
|
|
Evas_Coord lastw;
|
2009-03-19 06:36:46 -07:00
|
|
|
Evas_Coord downx, downy;
|
2008-10-22 01:58:56 -07:00
|
|
|
Evas_Bool changed : 1;
|
|
|
|
Evas_Bool linewrap : 1;
|
|
|
|
Evas_Bool single_line : 1;
|
|
|
|
Evas_Bool password : 1;
|
2008-10-24 19:11:06 -07:00
|
|
|
Evas_Bool editable : 1;
|
2008-11-18 22:23:08 -08:00
|
|
|
Evas_Bool selection_asked : 1;
|
|
|
|
Evas_Bool have_selection : 1;
|
2009-03-19 06:36:46 -07:00
|
|
|
Evas_Bool selmode : 1;
|
2008-10-14 01:05:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void _del_hook(Evas_Object *obj);
|
2008-11-15 05:58:50 -08:00
|
|
|
static void _theme_hook(Evas_Object *obj);
|
2008-10-14 01:05:30 -07:00
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
2008-10-16 02:17:57 -07:00
|
|
|
static void _on_focus_hook(void *data, Evas_Object *obj);
|
2008-10-17 07:40:54 -07:00
|
|
|
static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2008-11-15 05:58:50 -08:00
|
|
|
static const char *_getbase(Evas_Object *obj);
|
2008-10-16 02:17:57 -07:00
|
|
|
static void _signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
|
|
|
|
static void _signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source);
|
|
|
|
static void _signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
|
|
|
|
static void _signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source);
|
|
|
|
static void _signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source);
|
|
|
|
static void _signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
|
|
|
|
static void _signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source);
|
|
|
|
static void _signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source);
|
2008-10-14 01:05:30 -07:00
|
|
|
|
2008-11-18 00:45:38 -08:00
|
|
|
static Eina_List *entries = NULL;
|
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2008-11-18 00:45:38 -08:00
|
|
|
entries = eina_list_remove(entries, obj);
|
2008-12-09 22:33:24 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2008-11-18 22:23:08 -08:00
|
|
|
ecore_event_handler_del(wd->sel_notify_handler);
|
|
|
|
ecore_event_handler_del(wd->sel_clear_handler);
|
2008-12-09 22:33:24 -08:00
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
|
2008-10-17 20:55:44 -07:00
|
|
|
if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
|
2008-10-14 01:05:30 -07:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
2008-11-15 05:58:50 -08:00
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2008-11-15 05:58:50 -08:00
|
|
|
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
|
|
|
|
elm_entry_entry_set(obj, t);
|
2009-02-25 07:54:26 -08:00
|
|
|
eina_stringshare_del(t);
|
2009-02-02 21:09:03 -08:00
|
|
|
edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * _elm_config->scale);
|
2008-11-15 05:58:50 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2008-10-17 20:55:44 -07:00
|
|
|
static void
|
|
|
|
_elm_win_recalc_job(void *data)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
|
|
|
Evas_Coord resw, resh, minminw;
|
|
|
|
|
|
|
|
wd->deferred_recalc_job = NULL;
|
|
|
|
evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
|
|
|
|
resh = 0;
|
|
|
|
minminw = 0;
|
|
|
|
edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
|
|
|
|
minminw = minw;
|
|
|
|
edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
|
|
|
|
evas_object_size_hint_min_set(data, minminw, minh);
|
|
|
|
evas_object_size_hint_max_set(data, minminw, maxh);
|
|
|
|
}
|
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
2008-10-17 07:40:54 -07:00
|
|
|
Evas_Coord resw, resh, minminw;
|
|
|
|
|
|
|
|
if (wd->linewrap)
|
|
|
|
{
|
|
|
|
evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
|
2008-10-17 20:55:44 -07:00
|
|
|
if ((resw == wd->lastw) && (!wd->changed)) return;
|
|
|
|
wd->changed = 0;
|
|
|
|
wd->lastw = resw;
|
|
|
|
if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
|
|
|
|
wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
|
2008-10-17 07:40:54 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-17 20:55:44 -07:00
|
|
|
evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
|
2008-10-17 07:40:54 -07:00
|
|
|
edje_object_size_min_calc(wd->ent, &minw, &minh);
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
}
|
2008-10-14 01:05:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_on_focus_hook(void *data, Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2008-11-18 02:11:57 -08:00
|
|
|
Evas_Object *top = elm_widget_top_get(obj);
|
2008-11-26 21:41:13 -08:00
|
|
|
if (!wd->editable) return;
|
2008-11-16 21:58:21 -08:00
|
|
|
if (elm_widget_focus_get(obj))
|
|
|
|
{
|
|
|
|
evas_object_focus_set(wd->ent, 1);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
|
2008-11-18 02:11:57 -08:00
|
|
|
elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
|
2008-11-16 21:58:21 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
|
|
|
|
evas_object_focus_set(wd->ent, 0);
|
2008-11-18 02:11:57 -08:00
|
|
|
elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
|
2008-11-16 21:58:21 -08:00
|
|
|
}
|
2008-10-14 01:05:30 -07:00
|
|
|
}
|
|
|
|
|
2009-03-19 06:36:46 -07:00
|
|
|
static void
|
|
|
|
_hoversel_position(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
|
|
|
|
evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
|
|
|
|
edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
|
|
|
|
&cx, &cy, &cw, &ch);
|
|
|
|
evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
|
|
|
|
if (cw < mw)
|
|
|
|
{
|
|
|
|
cx += (cw - mw) / 2;
|
|
|
|
cw = mw;
|
|
|
|
}
|
|
|
|
if (ch < mh)
|
|
|
|
{
|
|
|
|
cy += (ch - mh) / 2;
|
|
|
|
ch = mh;
|
|
|
|
}
|
|
|
|
evas_object_move(wd->hoversel, x + cx, y + cy);
|
|
|
|
evas_object_resize(wd->hoversel, cw, ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
if (wd->hoversel) _hoversel_position(data);
|
|
|
|
}
|
|
|
|
|
2008-10-17 07:40:54 -07:00
|
|
|
static void
|
|
|
|
_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
if (wd->linewrap) _sizing_eval(data);
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->hoversel) _hoversel_position(data);
|
|
|
|
// Evas_Coord ww, hh;
|
|
|
|
// evas_object_geometry_get(wd->ent, NULL, NULL, &ww, &hh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dismissed(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
if (wd->hoversel) evas_object_hide(wd->hoversel);
|
|
|
|
if (wd->selmode)
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
|
2009-03-20 08:08:33 -07:00
|
|
|
elm_widget_scroll_freeze_pop(data);
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_select(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
wd->selmode = 1;
|
|
|
|
edje_object_part_text_select_none(wd->ent, "elm.text");
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 1);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
|
|
|
|
elm_widget_scroll_hold_push(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_paste(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
evas_object_smart_callback_call(data, "selection,paste", NULL);
|
|
|
|
if (wd->sel_notify_handler)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
|
|
|
if (elm_win_xwindow_get(elm_widget_top_get(data)))
|
|
|
|
{
|
|
|
|
ecore_x_selection_primary_request
|
|
|
|
(elm_win_xwindow_get(elm_widget_top_get(data)),
|
|
|
|
ECORE_X_SELECTION_TARGET_UTF8_STRING);
|
|
|
|
wd->selection_asked = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_store_selection(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
const char *sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
|
|
|
|
if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
|
|
|
|
wd->cut_sel = eina_stringshare_add(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cut(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
wd->selmode = 0;
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
|
|
|
elm_widget_scroll_hold_pop(data);
|
|
|
|
_store_selection(data);
|
|
|
|
edje_object_part_text_insert(wd->ent, "elm.text", "");
|
|
|
|
edje_object_part_text_select_none(wd->ent, "elm.text");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_copy(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
wd->selmode = 0;
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
|
|
|
elm_widget_scroll_hold_pop(data);
|
|
|
|
_store_selection(data);
|
|
|
|
edje_object_part_text_select_none(wd->ent, "elm.text");
|
|
|
|
}
|
|
|
|
|
2009-03-22 21:55:37 -07:00
|
|
|
static void
|
|
|
|
_cancel(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
wd->selmode = 0;
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
|
|
|
elm_widget_scroll_hold_pop(data);
|
|
|
|
edje_object_part_text_select_none(wd->ent, "elm.text");
|
|
|
|
}
|
|
|
|
|
2009-03-19 06:36:46 -07:00
|
|
|
static int
|
|
|
|
_long_press(void *data)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
if (wd->hoversel) evas_object_del(wd->hoversel);
|
|
|
|
wd->hoversel = elm_hoversel_add(data);
|
|
|
|
elm_widget_sub_object_add(data, wd->hoversel);
|
|
|
|
elm_hoversel_label_set(wd->hoversel, "Text");
|
|
|
|
elm_hoversel_hover_parent_set(wd->hoversel, elm_widget_top_get(data));
|
|
|
|
evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
|
|
|
|
if (!wd->selmode)
|
|
|
|
{
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE, _select, data);
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE, _paste, data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE, _copy, data);
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE, _cut, data);
|
2009-03-22 21:55:37 -07:00
|
|
|
elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE, _cancel, data);
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
if (wd->hoversel)
|
|
|
|
{
|
|
|
|
_hoversel_position(data);
|
|
|
|
evas_object_show(wd->hoversel);
|
|
|
|
elm_hoversel_hover_begin(wd->hoversel);
|
|
|
|
}
|
|
|
|
wd->longpress_timer = NULL;
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
2009-03-20 08:08:33 -07:00
|
|
|
edje_object_part_text_select_abort(wd->ent, "elm.text");
|
2009-03-19 06:36:46 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
|
|
|
if (ev->button != 1) return;
|
|
|
|
// if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
|
|
|
|
if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer);
|
2009-03-20 08:08:33 -07:00
|
|
|
elm_widget_scroll_freeze_push(data);
|
2009-03-19 06:36:46 -07:00
|
|
|
wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
|
|
|
|
wd->downx = ev->canvas.x;
|
|
|
|
wd->downy = ev->canvas.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
|
|
|
if (ev->button != 1) return;
|
|
|
|
if (wd->longpress_timer)
|
|
|
|
{
|
2009-03-20 08:08:33 -07:00
|
|
|
elm_widget_scroll_freeze_pop(data);
|
2009-03-19 06:36:46 -07:00
|
|
|
ecore_timer_del(wd->longpress_timer);
|
|
|
|
wd->longpress_timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Evas_Event_Mouse_Move *ev = event_info;
|
|
|
|
if (!wd->selmode)
|
|
|
|
{
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
|
|
|
{
|
|
|
|
if (wd->longpress_timer)
|
|
|
|
{
|
2009-03-20 08:08:33 -07:00
|
|
|
elm_widget_scroll_freeze_pop(data);
|
2009-03-19 06:36:46 -07:00
|
|
|
ecore_timer_del(wd->longpress_timer);
|
|
|
|
wd->longpress_timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (wd->longpress_timer)
|
|
|
|
{
|
|
|
|
Evas_Coord dx, dy;
|
|
|
|
|
|
|
|
dx = wd->downx - ev->cur.canvas.x;
|
|
|
|
dx *= dx;
|
|
|
|
dy = wd->downy - ev->cur.canvas.y;
|
|
|
|
dy *= dy;
|
|
|
|
if ((dx + dy) >
|
|
|
|
((_elm_config->finger_size / 2) *
|
|
|
|
(_elm_config->finger_size / 2)))
|
|
|
|
{
|
2009-03-20 08:08:33 -07:00
|
|
|
elm_widget_scroll_freeze_pop(data);
|
2009-03-19 06:36:46 -07:00
|
|
|
ecore_timer_del(wd->longpress_timer);
|
|
|
|
wd->longpress_timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (wd->longpress_timer)
|
|
|
|
{
|
|
|
|
Evas_Coord dx, dy;
|
|
|
|
|
|
|
|
dx = wd->downx - ev->cur.canvas.x;
|
|
|
|
dx *= dx;
|
|
|
|
dy = wd->downy - ev->cur.canvas.y;
|
|
|
|
dy *= dy;
|
|
|
|
if ((dx + dy) >
|
|
|
|
((_elm_config->finger_size / 2) *
|
|
|
|
(_elm_config->finger_size / 2)))
|
|
|
|
{
|
2009-03-20 08:08:33 -07:00
|
|
|
elm_widget_scroll_freeze_pop(data);
|
2009-03-19 06:36:46 -07:00
|
|
|
ecore_timer_del(wd->longpress_timer);
|
|
|
|
wd->longpress_timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-10-17 07:40:54 -07:00
|
|
|
}
|
|
|
|
|
2008-11-15 05:58:50 -08:00
|
|
|
static const char *
|
|
|
|
_getbase(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (wd->editable)
|
|
|
|
{
|
|
|
|
if (wd->password) return "base-password";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->single_line) return "base-single";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->linewrap) return "base";
|
|
|
|
else return "base-nowrap";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->password) return "base-password";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->single_line) return "base-single-noedit";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->linewrap) return "base-noedit";
|
|
|
|
else return "base-nowrap-noedit";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "base";
|
|
|
|
}
|
|
|
|
|
2008-11-18 22:23:08 -08:00
|
|
|
static char *
|
|
|
|
_str_append(char *str, const char *txt, int *len, int *alloc)
|
|
|
|
{
|
|
|
|
int txt_len = strlen(txt);
|
|
|
|
if (txt_len <= 0) return str;
|
|
|
|
if ((*len + txt_len) >= *alloc)
|
|
|
|
{
|
|
|
|
char *str2;
|
|
|
|
int alloc2;
|
|
|
|
|
|
|
|
alloc2 = *alloc + txt_len + 128;
|
|
|
|
str2 = realloc(str, alloc2);
|
|
|
|
if (!str2) return str;
|
|
|
|
*alloc = alloc2;
|
|
|
|
str = str2;
|
|
|
|
}
|
|
|
|
strcpy(str + *len, txt);
|
|
|
|
*len += txt_len;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_mkup_to_text(const char *mkup)
|
|
|
|
{
|
|
|
|
char *str = NULL;
|
|
|
|
int str_len = 0, str_alloc = 0;
|
|
|
|
char *s, *p;
|
|
|
|
char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
|
|
|
|
|
2009-02-25 18:13:34 -08:00
|
|
|
if (!mkup) return NULL;
|
2008-11-18 22:23:08 -08:00
|
|
|
tag_start = tag_end = esc_start = esc_end = NULL;
|
|
|
|
p = (char *)mkup;
|
|
|
|
s = p;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if ((*p == 0) ||
|
|
|
|
(tag_end) || (esc_end) ||
|
|
|
|
(tag_start) || (esc_start))
|
|
|
|
{
|
|
|
|
if (tag_end)
|
|
|
|
{
|
|
|
|
char *ttag, *match;
|
|
|
|
|
|
|
|
ttag = malloc(tag_end - tag_start);
|
|
|
|
if (ttag)
|
|
|
|
{
|
|
|
|
strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
|
|
|
|
ttag[tag_end - tag_start - 1] = 0;
|
|
|
|
if (!strcmp(ttag, "br"))
|
|
|
|
str = _str_append(str, "\n", &str_len, &str_alloc);
|
|
|
|
else if (!strcmp(ttag, "\n"))
|
|
|
|
str = _str_append(str, "\n", &str_len, &str_alloc);
|
|
|
|
else if (!strcmp(ttag, "\\n"))
|
|
|
|
str = _str_append(str, "\n", &str_len, &str_alloc);
|
|
|
|
else if (!strcmp(ttag, "\t"))
|
|
|
|
str = _str_append(str, "\t", &str_len, &str_alloc);
|
|
|
|
else if (!strcmp(ttag, "\\t"))
|
|
|
|
str = _str_append(str, "\t", &str_len, &str_alloc);
|
|
|
|
free(ttag);
|
|
|
|
}
|
|
|
|
tag_start = tag_end = NULL;
|
|
|
|
}
|
|
|
|
else if (esc_end)
|
|
|
|
{
|
|
|
|
ts = malloc(esc_end - esc_start + 1);
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
const char *esc;
|
|
|
|
strncpy(ts, esc_start, esc_end - esc_start);
|
|
|
|
ts[esc_end - esc_start] = 0;
|
|
|
|
esc = evas_textblock_escape_string_get(ts);
|
|
|
|
if (esc)
|
|
|
|
str = _str_append(str, esc, &str_len, &str_alloc);
|
|
|
|
free(ts);
|
|
|
|
}
|
|
|
|
esc_start = esc_end = NULL;
|
|
|
|
}
|
|
|
|
else if (*p == 0)
|
|
|
|
{
|
|
|
|
ts = malloc(p - s + 1);
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
strncpy(ts, s, p - s);
|
|
|
|
ts[p - s] = 0;
|
|
|
|
str = _str_append(str, ts, &str_len, &str_alloc);
|
|
|
|
free(ts);
|
|
|
|
}
|
|
|
|
s = NULL;
|
|
|
|
}
|
|
|
|
if (*p == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (*p == '<')
|
|
|
|
{
|
|
|
|
if (!esc_start)
|
|
|
|
{
|
|
|
|
tag_start = p;
|
|
|
|
tag_end = NULL;
|
|
|
|
ts = malloc(p - s + 1);
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
strncpy(ts, s, p - s);
|
|
|
|
ts[p - s] = 0;
|
|
|
|
str = _str_append(str, ts, &str_len, &str_alloc);
|
|
|
|
free(ts);
|
|
|
|
}
|
|
|
|
s = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*p == '>')
|
|
|
|
{
|
|
|
|
if (tag_start)
|
|
|
|
{
|
|
|
|
tag_end = p;
|
|
|
|
s = p + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*p == '&')
|
|
|
|
{
|
|
|
|
if (!tag_start)
|
|
|
|
{
|
|
|
|
esc_start = p;
|
|
|
|
esc_end = NULL;
|
|
|
|
ts = malloc(p - s + 1);
|
|
|
|
if (ts)
|
|
|
|
{
|
|
|
|
strncpy(ts, s, p - s);
|
|
|
|
ts[p - s] = 0;
|
|
|
|
str = _str_append(str, ts, &str_len, &str_alloc);
|
|
|
|
free(ts);
|
|
|
|
}
|
|
|
|
s = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*p == ';')
|
|
|
|
{
|
|
|
|
if (esc_start)
|
|
|
|
{
|
|
|
|
esc_end = p;
|
|
|
|
s = p + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_text_to_mkup(const char *text)
|
|
|
|
{
|
|
|
|
char *str = NULL;
|
|
|
|
int str_len = 0, str_alloc = 0;
|
2008-12-08 15:46:46 -08:00
|
|
|
int ch, pos = 0, pos2 = 0;
|
2008-11-18 22:23:08 -08:00
|
|
|
|
2009-02-25 18:13:34 -08:00
|
|
|
if (!text) return NULL;
|
2008-11-18 22:23:08 -08:00
|
|
|
for (;;)
|
|
|
|
{
|
2008-11-27 15:36:21 -08:00
|
|
|
// FIXME: use evas_string_char_next_get()
|
2008-12-08 15:46:46 -08:00
|
|
|
pos = pos2;
|
|
|
|
ch = evas_common_font_utf8_get_next((unsigned char *)(text), &pos2);
|
2008-11-18 22:23:08 -08:00
|
|
|
if (ch <= 0) break;
|
|
|
|
if (ch == '\n') str = _str_append(str, "<br>", &str_len, &str_alloc);
|
|
|
|
else if (ch == '\t') str = _str_append(str, "<\t>", &str_len, &str_alloc);
|
2009-03-12 22:50:38 -07:00
|
|
|
else if (ch == '<') str = _str_append(str, "<", &str_len, &str_alloc);
|
|
|
|
else if (ch == '>') str = _str_append(str, ">", &str_len, &str_alloc);
|
2009-03-19 06:36:46 -07:00
|
|
|
else if (ch == '&') str = _str_append(str, "&", &str_len, &str_alloc);
|
2008-11-18 22:23:08 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char tstr[16];
|
|
|
|
|
|
|
|
strncpy(tstr, text + pos, pos2 - pos);
|
|
|
|
tstr[pos2 - pos] = 0;
|
|
|
|
str = _str_append(str, tstr, &str_len, &str_alloc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2008-10-16 02:17:57 -07:00
|
|
|
static void
|
|
|
|
_signal_entry_changed(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
evas_object_smart_callback_call(data, "changed", NULL);
|
2008-10-17 20:55:44 -07:00
|
|
|
wd->changed = 1;
|
2008-10-16 02:17:57 -07:00
|
|
|
_sizing_eval(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_selection_start(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
|
|
|
Evas_Object *entry;
|
|
|
|
EINA_LIST_FOREACH(entries, l, entry)
|
2008-11-18 00:45:38 -08:00
|
|
|
{
|
2009-02-25 11:50:45 -08:00
|
|
|
if (entry != data) elm_entry_select_none(entry);
|
2008-11-18 00:45:38 -08:00
|
|
|
}
|
2008-11-18 22:23:08 -08:00
|
|
|
wd->have_selection = 1;
|
|
|
|
evas_object_smart_callback_call(data, "selection,start", NULL);
|
|
|
|
if (wd->sel_notify_handler)
|
|
|
|
{
|
|
|
|
char *txt = _mkup_to_text(elm_entry_selection_get(data));
|
|
|
|
if (txt)
|
|
|
|
{
|
2008-12-09 22:43:21 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
|
|
|
if (elm_win_xwindow_get(elm_widget_top_get(data)))
|
|
|
|
ecore_x_selection_primary_set
|
|
|
|
(elm_win_xwindow_get(elm_widget_top_get(data)),
|
|
|
|
txt, strlen(txt));
|
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
free(txt);
|
|
|
|
}
|
|
|
|
}
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_selection_changed(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-11-18 22:23:08 -08:00
|
|
|
wd->have_selection = 1;
|
2008-10-16 02:17:57 -07:00
|
|
|
evas_object_smart_callback_call(data, "selection,changed", NULL);
|
2008-11-18 22:23:08 -08:00
|
|
|
if (wd->sel_notify_handler)
|
|
|
|
{
|
|
|
|
char *txt = _mkup_to_text(elm_entry_selection_get(data));
|
|
|
|
if (txt)
|
|
|
|
{
|
2008-12-09 22:43:21 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
|
|
|
if (elm_win_xwindow_get(elm_widget_top_get(data)))
|
|
|
|
ecore_x_selection_primary_set
|
2008-11-18 22:23:08 -08:00
|
|
|
(elm_win_xwindow_get(elm_widget_top_get(data)),
|
|
|
|
txt, strlen(txt));
|
2008-12-09 22:43:21 -08:00
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
free(txt);
|
|
|
|
}
|
|
|
|
}
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_selection_cleared(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-11-18 22:23:08 -08:00
|
|
|
if (!wd->have_selection) return;
|
|
|
|
wd->have_selection = 0;
|
2008-10-16 02:17:57 -07:00
|
|
|
evas_object_smart_callback_call(data, "selection,cleared", NULL);
|
2008-11-18 22:23:08 -08:00
|
|
|
if (wd->sel_notify_handler)
|
|
|
|
{
|
|
|
|
if (wd->cut_sel)
|
|
|
|
{
|
2008-12-09 22:43:21 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
|
|
|
if (elm_win_xwindow_get(elm_widget_top_get(data)))
|
2009-03-20 08:08:33 -07:00
|
|
|
{
|
|
|
|
char *t;
|
|
|
|
|
|
|
|
t = _mkup_to_text(wd->cut_sel);
|
|
|
|
if (t)
|
|
|
|
{
|
|
|
|
ecore_x_selection_primary_set
|
|
|
|
(elm_win_xwindow_get(elm_widget_top_get(data)),
|
|
|
|
t, strlen(t));
|
|
|
|
free(t);
|
|
|
|
}
|
|
|
|
}
|
2008-12-09 22:43:21 -08:00
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
eina_stringshare_del(wd->cut_sel);
|
|
|
|
wd->cut_sel = NULL;
|
|
|
|
}
|
|
|
|
else
|
2008-12-09 22:43:21 -08:00
|
|
|
{
|
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
|
|
|
if (elm_win_xwindow_get(elm_widget_top_get(data)))
|
|
|
|
ecore_x_selection_primary_clear();
|
|
|
|
#endif
|
|
|
|
}
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_entry_paste_request(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-10-17 20:55:44 -07:00
|
|
|
evas_object_smart_callback_call(data, "selection,paste", NULL);
|
2008-11-18 22:23:08 -08:00
|
|
|
if (wd->sel_notify_handler)
|
|
|
|
{
|
2008-12-09 22:43:21 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
|
|
|
if (elm_win_xwindow_get(elm_widget_top_get(data)))
|
|
|
|
{
|
|
|
|
ecore_x_selection_primary_request
|
|
|
|
(elm_win_xwindow_get(elm_widget_top_get(data)),
|
|
|
|
ECORE_X_SELECTION_TARGET_UTF8_STRING);
|
|
|
|
wd->selection_asked = 1;
|
|
|
|
}
|
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_entry_copy_notify(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-10-17 20:55:44 -07:00
|
|
|
evas_object_smart_callback_call(data, "selection,copy", NULL);
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_entry_cut_notify(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-11-18 22:23:08 -08:00
|
|
|
char *txt;
|
2008-10-17 20:55:44 -07:00
|
|
|
evas_object_smart_callback_call(data, "selection,cut", NULL);
|
2008-11-18 22:23:08 -08:00
|
|
|
if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
|
|
|
|
wd->cut_sel = NULL;
|
|
|
|
txt = _mkup_to_text(elm_entry_selection_get(data));
|
|
|
|
if (txt)
|
|
|
|
{
|
|
|
|
wd->cut_sel = eina_stringshare_add(txt);
|
|
|
|
free(txt);
|
|
|
|
}
|
|
|
|
edje_object_part_text_insert(wd->ent, "elm.text", "");
|
2008-10-17 20:55:44 -07:00
|
|
|
wd->changed = 1;
|
|
|
|
_sizing_eval(data);
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_cursor_changed(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-10-16 23:41:07 -07:00
|
|
|
Evas_Coord cx, cy, cw, ch;
|
2008-10-16 02:17:57 -07:00
|
|
|
evas_object_smart_callback_call(data, "cursor,changed", NULL);
|
2008-10-16 23:41:07 -07:00
|
|
|
edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", &cx, &cy, &cw, &ch);
|
2008-10-17 07:40:54 -07:00
|
|
|
elm_widget_show_region_set(data, cx, cy, cw, ch);
|
2008-10-16 23:41:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_anchor_down(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_anchor_up(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-10-24 19:11:06 -07:00
|
|
|
Elm_Entry_Anchor_Info ei;
|
2008-10-17 07:51:17 -07:00
|
|
|
char *buf, *buf2, *p, *p2, *n;
|
|
|
|
int buflen;
|
2008-10-17 07:53:07 -07:00
|
|
|
p = strrchr(emission, ',');
|
2008-10-17 07:51:17 -07:00
|
|
|
if (p)
|
|
|
|
{
|
2009-02-25 07:54:26 -08:00
|
|
|
const Eina_List *geoms;
|
2008-10-24 19:11:06 -07:00
|
|
|
|
2008-10-17 07:51:17 -07:00
|
|
|
n = p + 1;
|
|
|
|
p2 = p -1;
|
|
|
|
while (p2 >= emission)
|
|
|
|
{
|
|
|
|
if (*p2 == ',') break;
|
|
|
|
p2--;
|
|
|
|
}
|
|
|
|
p2++;
|
|
|
|
buf2 = alloca(5 + p - p2);
|
|
|
|
strncpy(buf2, p2, p - p2);
|
|
|
|
buf2[p - p2] = 0;
|
2008-10-24 19:11:06 -07:00
|
|
|
ei.name = n;
|
|
|
|
ei.button = atoi(buf2);
|
|
|
|
ei.x = ei.y = ei.w = ei.h = 0;
|
|
|
|
geoms = edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
|
|
|
|
if (geoms)
|
|
|
|
{
|
|
|
|
Evas_Textblock_Rectangle *r;
|
2009-02-25 07:54:26 -08:00
|
|
|
const Eina_List *l;
|
2008-10-24 19:11:06 -07:00
|
|
|
Evas_Coord px, py, x, y;
|
|
|
|
|
|
|
|
evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
|
|
|
|
evas_pointer_output_xy_get(evas_object_evas_get(wd->ent), &px, &py);
|
|
|
|
EINA_LIST_FOREACH(geoms, l, r)
|
|
|
|
{
|
|
|
|
if (((r->x + x) <= px) && ((r->y + y) <= py) &&
|
|
|
|
((r->x + x + r->w) > px) && ((r->y + y + r->h) > py))
|
|
|
|
{
|
|
|
|
ei.x = r->x + x;
|
|
|
|
ei.y = r->y + y;
|
|
|
|
ei.w = r->w;
|
|
|
|
ei.h = r->h;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
evas_object_smart_callback_call(data, "anchor,clicked", &ei);
|
2008-10-17 07:51:17 -07:00
|
|
|
}
|
2008-10-16 23:41:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_anchor_move(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_anchor_in(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_signal_anchor_out(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
2008-10-22 01:58:56 -07:00
|
|
|
static void
|
|
|
|
_signal_key_enter(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
evas_object_smart_callback_call(data, "activated", NULL);
|
|
|
|
}
|
|
|
|
|
2008-12-09 22:33:24 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2008-11-18 22:23:08 -08:00
|
|
|
static int
|
|
|
|
_event_selection_notify(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Ecore_X_Event_Selection_Notify *ev = event;
|
|
|
|
if (!wd->selection_asked) return 1;
|
|
|
|
if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
|
|
|
|
(ev->selection == ECORE_X_SELECTION_PRIMARY))
|
|
|
|
{
|
|
|
|
Ecore_X_Selection_Data_Text *text_data;
|
|
|
|
|
|
|
|
text_data = ev->data;
|
|
|
|
if (text_data->data.content == ECORE_X_SELECTION_CONTENT_TEXT)
|
|
|
|
{
|
|
|
|
if (text_data->text)
|
|
|
|
{
|
|
|
|
char *txt = _text_to_mkup(text_data->text);
|
|
|
|
if (txt)
|
|
|
|
{
|
|
|
|
elm_entry_entry_insert(data, txt);
|
|
|
|
free(txt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wd->selection_asked = 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_event_selection_clear(void *data, int type, void *event)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Ecore_X_Event_Selection_Clear *ev = event;
|
|
|
|
if (!wd->have_selection) return 1;
|
|
|
|
if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
|
|
|
|
(ev->selection == ECORE_X_SELECTION_PRIMARY))
|
|
|
|
{
|
|
|
|
elm_entry_select_none(data);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2008-12-09 22:33:24 -08:00
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_entry_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
wd = ELM_NEW(Widget_Data);
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
obj = elm_widget_add(e);
|
|
|
|
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
|
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
2008-11-15 05:58:50 -08:00
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
2008-10-14 01:05:30 -07:00
|
|
|
elm_widget_can_focus_set(obj, 1);
|
2008-10-17 07:40:54 -07:00
|
|
|
|
|
|
|
wd->linewrap = 1;
|
2008-10-24 19:11:06 -07:00
|
|
|
wd->editable = 1;
|
2008-10-14 01:05:30 -07:00
|
|
|
|
|
|
|
wd->ent = edje_object_add(e);
|
2009-03-19 06:36:46 -07:00
|
|
|
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOVE, _move, obj);
|
2008-10-17 07:40:54 -07:00
|
|
|
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_RESIZE, _resize, obj);
|
2009-03-19 06:36:46 -07:00
|
|
|
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, obj);
|
|
|
|
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP, _mouse_up, obj);
|
|
|
|
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, obj);
|
2008-10-17 07:40:54 -07:00
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
_elm_theme_set(wd->ent, "entry", "base", "default");
|
2008-10-16 02:17:57 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text", _signal_entry_changed, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text", _signal_selection_start, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text", _signal_selection_changed, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text", _signal_selection_cleared, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text", _signal_entry_paste_request, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text", _signal_entry_copy_notify, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text", _signal_entry_cut_notify, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text", _signal_cursor_changed, obj);
|
2008-10-16 23:41:07 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text", _signal_anchor_down, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text", _signal_anchor_up, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text", _signal_anchor_move, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text", _signal_anchor_in, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text", _signal_anchor_out, obj);
|
2008-10-22 01:58:56 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text", _signal_key_enter, obj);
|
2008-11-16 04:17:42 -08:00
|
|
|
edje_object_part_text_set(wd->ent, "elm.text", "<br>");
|
2008-10-14 01:05:30 -07:00
|
|
|
elm_widget_resize_object_set(obj, wd->ent);
|
2008-11-16 04:17:42 -08:00
|
|
|
_sizing_eval(obj);
|
2008-11-18 22:23:08 -08:00
|
|
|
|
2008-12-09 22:33:24 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2008-11-18 22:23:08 -08:00
|
|
|
if (elm_win_xwindow_get(elm_widget_top_get(parent)) != 0)
|
|
|
|
{
|
|
|
|
wd->sel_notify_handler =
|
|
|
|
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
|
|
|
|
_event_selection_notify, obj);
|
|
|
|
wd->sel_clear_handler =
|
|
|
|
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR,
|
|
|
|
_event_selection_clear, obj);
|
|
|
|
}
|
2008-12-09 22:33:24 -08:00
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
|
2008-11-18 00:45:38 -08:00
|
|
|
entries = eina_list_prepend(entries, obj);
|
2008-10-14 01:05:30 -07:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2008-10-22 01:58:56 -07:00
|
|
|
EAPI void
|
|
|
|
elm_entry_single_line_set(Evas_Object *obj, Evas_Bool single_line)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2008-10-22 01:58:56 -07:00
|
|
|
if (wd->single_line == single_line) return;
|
|
|
|
wd->single_line = single_line;
|
|
|
|
wd->linewrap = 0;
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2008-10-24 19:11:06 -07:00
|
|
|
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
|
2008-10-22 01:58:56 -07:00
|
|
|
elm_entry_entry_set(obj, t);
|
2009-02-25 07:54:26 -08:00
|
|
|
eina_stringshare_del(t);
|
2008-10-22 01:58:56 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_entry_password_set(Evas_Object *obj, Evas_Bool password)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2008-10-22 01:58:56 -07:00
|
|
|
if (wd->password == password) return;
|
|
|
|
wd->password = password;
|
|
|
|
wd->single_line = 1;
|
|
|
|
wd->linewrap = 0;
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2008-10-24 19:11:06 -07:00
|
|
|
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
|
2008-10-22 01:58:56 -07:00
|
|
|
elm_entry_entry_set(obj, t);
|
2009-02-25 07:54:26 -08:00
|
|
|
eina_stringshare_del(t);
|
2008-10-22 01:58:56 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
EAPI void
|
|
|
|
elm_entry_entry_set(Evas_Object *obj, const char *entry)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2008-11-16 04:17:42 -08:00
|
|
|
if (!entry) entry = "<br>";
|
2008-10-14 01:05:30 -07:00
|
|
|
edje_object_part_text_set(wd->ent, "elm.text", entry);
|
2008-10-16 23:41:07 -07:00
|
|
|
// debug
|
2008-10-24 19:11:06 -07:00
|
|
|
#if 0
|
2008-10-16 23:41:07 -07:00
|
|
|
{
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l, *an;
|
|
|
|
const char *anchor;
|
2008-10-16 23:41:07 -07:00
|
|
|
an = edje_object_part_text_anchor_list_get(wd->ent, "elm.text");
|
2009-02-25 11:50:45 -08:00
|
|
|
EINA_LIST_FOREACH(an, l, anchor)
|
|
|
|
printf("ANCHOR: %s\n", anchor);
|
2008-10-16 23:41:07 -07:00
|
|
|
}
|
2008-10-24 19:11:06 -07:00
|
|
|
#endif
|
2008-10-17 20:55:44 -07:00
|
|
|
wd->changed = 1;
|
2008-10-14 01:05:30 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
2008-10-15 02:58:44 -07:00
|
|
|
|
|
|
|
EAPI const char *
|
2009-02-25 07:54:26 -08:00
|
|
|
elm_entry_entry_get(const Evas_Object *obj)
|
2008-10-15 02:58:44 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
return edje_object_part_text_get(wd->ent, "elm.text");
|
|
|
|
}
|
2008-10-16 02:17:57 -07:00
|
|
|
|
|
|
|
EAPI const char *
|
2009-02-25 07:54:26 -08:00
|
|
|
elm_entry_selection_get(const Evas_Object *obj)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
return edje_object_part_text_selection_get(wd->ent, "elm.text");
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_entry_entry_insert(Evas_Object *obj, const char *entry)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
edje_object_part_text_insert(wd->ent, "elm.text", entry);
|
2008-10-17 20:55:44 -07:00
|
|
|
wd->changed = 1;
|
2008-10-16 02:17:57 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2008-10-17 07:40:54 -07:00
|
|
|
EAPI void
|
|
|
|
elm_entry_line_wrap_set(Evas_Object *obj, Evas_Bool wrap)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2008-10-17 07:40:54 -07:00
|
|
|
if (wd->linewrap == wrap) return;
|
|
|
|
wd->linewrap = wrap;
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2008-10-24 19:11:06 -07:00
|
|
|
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
|
|
|
|
elm_entry_entry_set(obj, t);
|
2009-02-25 07:54:26 -08:00
|
|
|
eina_stringshare_del(t);
|
2008-10-24 19:11:06 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_entry_editable_set(Evas_Object *obj, Evas_Bool editable)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2008-10-24 19:11:06 -07:00
|
|
|
if (wd->editable == editable) return;
|
|
|
|
wd->editable = editable;
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2008-10-24 19:11:06 -07:00
|
|
|
_elm_theme_set(wd->ent, "entry", _getbase(obj), "default");
|
2008-10-17 07:40:54 -07:00
|
|
|
elm_entry_entry_set(obj, t);
|
2009-02-25 07:54:26 -08:00
|
|
|
eina_stringshare_del(t);
|
2008-10-17 07:40:54 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
2008-11-18 00:45:38 -08:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_entry_select_none(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->selmode)
|
|
|
|
{
|
|
|
|
wd->selmode = 0;
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
|
|
|
}
|
2008-11-18 22:23:08 -08:00
|
|
|
wd->have_selection = 0;
|
2008-11-18 00:45:38 -08:00
|
|
|
edje_object_part_text_select_none(wd->ent, "elm.text");
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_entry_select_all(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->selmode)
|
|
|
|
{
|
|
|
|
wd->selmode = 0;
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
|
|
|
}
|
2008-11-18 22:23:08 -08:00
|
|
|
wd->have_selection = 1;
|
2008-11-18 00:45:38 -08:00
|
|
|
edje_object_part_text_select_all(wd->ent, "elm.text");
|
|
|
|
}
|
2009-01-26 16:44:29 -08:00
|
|
|
|
|
|
|
EAPI char *
|
|
|
|
elm_entry_markup_to_utf8(const char *s)
|
|
|
|
{
|
|
|
|
return _mkup_to_text(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI char *
|
|
|
|
elm_entry_utf8_to_markup(const char *s)
|
|
|
|
{
|
|
|
|
return _text_to_mkup(s);
|
|
|
|
}
|