2008-10-14 01:05:30 -07:00
|
|
|
#include <Elementary.h>
|
2010-09-17 15:28:29 -07:00
|
|
|
#include <Elementary_Cursor.h>
|
2008-10-14 01:05:30 -07:00
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Entry Entry
|
|
|
|
*
|
|
|
|
* An entry is a convenience widget which shows
|
|
|
|
* a box that the user can enter text into. Unlike a
|
|
|
|
* @ref Scrolled_Entry widget, entries DO NOT scroll with user
|
|
|
|
* input. Entry widgets are capable of expanding past the
|
|
|
|
* boundaries of the window, thus resizing the window to its
|
|
|
|
* own length.
|
2010-04-27 01:12:59 -07:00
|
|
|
*
|
|
|
|
* You can also insert "items" in the entry with:
|
|
|
|
*
|
2010-04-27 23:13:06 -07:00
|
|
|
* \<item size=16x16 vsize=full href=emoticon/haha\>\</item\>
|
2010-04-27 01:12:59 -07:00
|
|
|
*
|
|
|
|
* for example. sizing can be set bu size=WxH, relsize=WxH or absize=WxH with
|
|
|
|
* vsize=ascent or vsize=full. the href=NAME sets the item name. Entry
|
|
|
|
* supports a list of emoticon names by default. These are:
|
|
|
|
*
|
2010-06-05 21:32:41 -07:00
|
|
|
* - emoticon/angry
|
|
|
|
* - emoticon/angry-shout
|
|
|
|
* - emoticon/crazy-laugh
|
|
|
|
* - emoticon/evil-laugh
|
|
|
|
* - emoticon/evil
|
|
|
|
* - emoticon/goggle-smile
|
|
|
|
* - emoticon/grumpy
|
|
|
|
* - emoticon/grumpy-smile
|
|
|
|
* - emoticon/guilty
|
|
|
|
* - emoticon/guilty-smile
|
|
|
|
* - emoticon/haha
|
|
|
|
* - emoticon/half-smile
|
|
|
|
* - emoticon/happy-panting
|
|
|
|
* - emoticon/happy
|
|
|
|
* - emoticon/indifferent
|
|
|
|
* - emoticon/kiss
|
|
|
|
* - emoticon/knowing-grin
|
|
|
|
* - emoticon/laugh
|
|
|
|
* - emoticon/little-bit-sorry
|
|
|
|
* - emoticon/love-lots
|
|
|
|
* - emoticon/love
|
|
|
|
* - emoticon/minimal-smile
|
|
|
|
* - emoticon/not-happy
|
|
|
|
* - emoticon/not-impressed
|
|
|
|
* - emoticon/omg
|
|
|
|
* - emoticon/opensmile
|
|
|
|
* - emoticon/smile
|
|
|
|
* - emoticon/sorry
|
|
|
|
* - emoticon/squint-laugh
|
|
|
|
* - emoticon/surprised
|
|
|
|
* - emoticon/suspicious
|
|
|
|
* - emoticon/tongue-dangling
|
|
|
|
* - emoticon/tongue-poke
|
|
|
|
* - emoticon/uh
|
|
|
|
* - emoticon/unhappy
|
|
|
|
* - emoticon/very-sorry
|
|
|
|
* - emoticon/what
|
|
|
|
* - emoticon/wink
|
|
|
|
* - emoticon/worried
|
|
|
|
* - emoticon/wtf
|
2010-04-12 01:12:02 -07:00
|
|
|
*
|
2010-04-27 01:12:59 -07:00
|
|
|
* These are built-in currently, but you can add your own item provieer that
|
|
|
|
* can create inlined objects in the text and fill the space allocated to the
|
|
|
|
* item with a custom object of your own.
|
|
|
|
*
|
|
|
|
* See the entry test for some more examples of use of this.
|
|
|
|
*
|
2010-04-12 01:12:02 -07:00
|
|
|
* Signals that you can add callbacks for are:
|
2010-06-05 21:32:41 -07:00
|
|
|
* - "changed" - The text within the entry was changed
|
|
|
|
* - "activated" - The entry has received focus and the cursor
|
|
|
|
* - "press" - The entry has been clicked
|
|
|
|
* - "longpressed" - The entry has been clicked for a couple seconds
|
|
|
|
* - "clicked" - The entry has been clicked
|
|
|
|
* - "clicked,double" - The entry has been double clicked
|
|
|
|
* - "focused" - The entry has received focus
|
|
|
|
* - "unfocused" - The entry has lost focus
|
|
|
|
* - "selection,paste" - A paste action has occurred
|
|
|
|
* - "selection,copy" - A copy action has occurred
|
|
|
|
* - "selection,cut" - A cut action has occurred
|
|
|
|
* - "selection,start" - A selection has begun
|
|
|
|
* - "selection,changed" - The selection has changed
|
|
|
|
* - "selection,cleared" - The selection has been cleared
|
|
|
|
* - "cursor,changed" - The cursor has changed
|
|
|
|
* - "anchor,clicked" - The anchor has been clicked
|
2010-04-12 01:12:02 -07:00
|
|
|
*/
|
|
|
|
|
2009-12-01 03:03:14 -08:00
|
|
|
typedef struct _Mod_Api Mod_Api;
|
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
typedef struct _Widget_Data Widget_Data;
|
2009-09-02 05:48:00 -07:00
|
|
|
typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
|
2010-04-27 01:06:42 -07:00
|
|
|
typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
|
2008-10-14 01:05:30 -07:00
|
|
|
|
|
|
|
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;
|
2009-07-06 23:46:51 -07:00
|
|
|
Ecore_Event_Handler *sel_notify_handler;
|
2008-11-18 22:23:08 -08:00
|
|
|
Ecore_Event_Handler *sel_clear_handler;
|
2009-03-19 06:36:46 -07:00
|
|
|
Ecore_Timer *longpress_timer;
|
2010-06-22 18:28:57 -07:00
|
|
|
/* Only for clipboard */
|
2008-11-18 22:23:08 -08:00
|
|
|
const char *cut_sel;
|
2010-03-11 00:08:15 -08:00
|
|
|
const char *text;
|
2008-10-17 20:55:44 -07:00
|
|
|
Evas_Coord lastw;
|
2009-03-19 06:36:46 -07:00
|
|
|
Evas_Coord downx, downy;
|
2009-05-04 22:10:13 -07:00
|
|
|
Evas_Coord cx, cy, cw, ch;
|
2009-09-02 05:48:00 -07:00
|
|
|
Eina_List *items;
|
2010-04-27 01:06:42 -07:00
|
|
|
Eina_List *item_providers;
|
2010-06-23 19:54:03 -07:00
|
|
|
Ecore_Job *hovdeljob;
|
2009-12-01 03:03:14 -08:00
|
|
|
Mod_Api *api; // module api if supplied
|
2009-06-17 08:35:19 -07:00
|
|
|
Eina_Bool changed : 1;
|
|
|
|
Eina_Bool linewrap : 1;
|
2009-10-22 15:10:23 -07:00
|
|
|
Eina_Bool char_linewrap : 1;
|
2009-06-17 08:35:19 -07:00
|
|
|
Eina_Bool single_line : 1;
|
|
|
|
Eina_Bool password : 1;
|
|
|
|
Eina_Bool editable : 1;
|
|
|
|
Eina_Bool selection_asked : 1;
|
|
|
|
Eina_Bool have_selection : 1;
|
|
|
|
Eina_Bool selmode : 1;
|
|
|
|
Eina_Bool deferred_cur : 1;
|
2009-08-26 05:51:27 -07:00
|
|
|
Eina_Bool disabled : 1;
|
2009-10-10 22:48:24 -07:00
|
|
|
Eina_Bool context_menu : 1;
|
2010-09-06 23:56:16 -07:00
|
|
|
Eina_Bool drag_selection_asked : 1;
|
2008-10-14 01:05:30 -07:00
|
|
|
};
|
|
|
|
|
2009-09-02 05:48:00 -07:00
|
|
|
struct _Elm_Entry_Context_Menu_Item
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
const char *label;
|
|
|
|
const char *icon_file;
|
|
|
|
const char *icon_group;
|
|
|
|
Elm_Icon_Type icon_type;
|
2010-03-16 08:31:38 -07:00
|
|
|
Evas_Smart_Cb func;
|
2009-09-02 05:48:00 -07:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2010-04-27 01:06:42 -07:00
|
|
|
struct _Elm_Entry_Item_Provider
|
|
|
|
{
|
|
|
|
Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2010-09-06 23:56:16 -07:00
|
|
|
|
|
|
|
static Eina_Bool _drag_drop_cb(void *data, Evas_Object *obj, Elm_Drop_Data *);
|
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);
|
2009-08-26 05:51:27 -07:00
|
|
|
static void _disable_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
|
|
|
|
2010-03-26 03:59:56 -07:00
|
|
|
static const char SIG_CHANGED[] = "changed";
|
|
|
|
static const char SIG_ACTIVATED[] = "activated";
|
|
|
|
static const char SIG_PRESS[] = "press";
|
|
|
|
static const char SIG_LONGPRESSED[] = "longpressed";
|
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
|
|
|
static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
|
2010-03-26 04:25:55 -07:00
|
|
|
static const char SIG_FOCUSED[] = "focused";
|
|
|
|
static const char SIG_UNFOCUSED[] = "unfocused";
|
2010-03-26 03:59:56 -07:00
|
|
|
static const char SIG_SELECTION_PASTE[] = "selection,paste";
|
|
|
|
static const char SIG_SELECTION_COPY[] = "selection,copy";
|
|
|
|
static const char SIG_SELECTION_CUT[] = "selection,cut";
|
|
|
|
static const char SIG_SELECTION_START[] = "selection,start";
|
|
|
|
static const char SIG_SELECTION_CHANGED[] = "selection,changed";
|
|
|
|
static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
|
|
|
|
static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
|
|
|
|
static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
|
|
|
|
static const Evas_Smart_Cb_Description _signals[] = {
|
|
|
|
{SIG_CHANGED, ""},
|
|
|
|
{SIG_ACTIVATED, ""},
|
|
|
|
{SIG_PRESS, ""},
|
|
|
|
{SIG_LONGPRESSED, ""},
|
2010-03-26 04:25:55 -07:00
|
|
|
{SIG_CLICKED, ""},
|
|
|
|
{SIG_CLICKED_DOUBLE, ""},
|
|
|
|
{SIG_FOCUSED, ""},
|
|
|
|
{SIG_UNFOCUSED, ""},
|
2010-03-26 03:59:56 -07:00
|
|
|
{SIG_SELECTION_PASTE, ""},
|
|
|
|
{SIG_SELECTION_COPY, ""},
|
|
|
|
{SIG_SELECTION_CUT, ""},
|
|
|
|
{SIG_SELECTION_START, ""},
|
|
|
|
{SIG_SELECTION_CHANGED, ""},
|
|
|
|
{SIG_SELECTION_CLEARED, ""},
|
|
|
|
{SIG_CURSOR_CHANGED, ""},
|
|
|
|
{SIG_ANCHOR_CLICKED, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2008-11-18 00:45:38 -08:00
|
|
|
static Eina_List *entries = NULL;
|
|
|
|
|
2009-12-01 03:03:14 -08:00
|
|
|
struct _Mod_Api
|
|
|
|
{
|
|
|
|
void (*obj_hook) (Evas_Object *obj);
|
|
|
|
void (*obj_unhook) (Evas_Object *obj);
|
|
|
|
void (*obj_longpress) (Evas_Object *obj);
|
|
|
|
};
|
|
|
|
|
|
|
|
static Mod_Api *
|
2010-03-09 09:51:30 -08:00
|
|
|
_module(Evas_Object *obj __UNUSED__)
|
2009-12-01 03:03:14 -08:00
|
|
|
{
|
|
|
|
static Elm_Module *m = NULL;
|
|
|
|
if (m) goto ok; // already found - just use
|
|
|
|
if (!(m = _elm_module_find_as("entry/api"))) return NULL;
|
|
|
|
// get module api
|
|
|
|
m->api = malloc(sizeof(Mod_Api));
|
|
|
|
if (!m->api) return NULL;
|
|
|
|
((Mod_Api *)(m->api) )->obj_hook = // called on creation
|
|
|
|
_elm_module_symbol_get(m, "obj_hook");
|
|
|
|
((Mod_Api *)(m->api) )->obj_unhook = // called on deletion
|
|
|
|
_elm_module_symbol_get(m, "obj_unhook");
|
|
|
|
((Mod_Api *)(m->api) )->obj_longpress = // called on long press menu
|
|
|
|
_elm_module_symbol_get(m, "obj_longpress");
|
|
|
|
ok: // ok - return api
|
|
|
|
return m->api;
|
|
|
|
}
|
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-02 05:48:00 -07:00
|
|
|
Elm_Entry_Context_Menu_Item *it;
|
2010-04-27 01:06:42 -07:00
|
|
|
Elm_Entry_Item_Provider *ip;
|
2009-09-26 11:00:51 -07:00
|
|
|
|
2010-06-23 19:54:03 -07:00
|
|
|
if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
|
2009-12-01 03:03:14 -08:00
|
|
|
if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj); // module - unhook
|
2010-02-08 19:27:11 -08:00
|
|
|
|
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);
|
2009-07-06 23:46:51 -07:00
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
if (wd->cut_sel) eina_stringshare_del(wd->cut_sel);
|
2010-03-11 00:08:15 -08:00
|
|
|
if (wd->text) eina_stringshare_del(wd->text);
|
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);
|
2009-09-02 05:48:00 -07:00
|
|
|
EINA_LIST_FREE(wd->items, it)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
eina_stringshare_del(it->icon_file);
|
|
|
|
eina_stringshare_del(it->icon_group);
|
|
|
|
free(it);
|
|
|
|
}
|
2010-04-27 01:06:42 -07:00
|
|
|
EINA_LIST_FREE(wd->item_providers, ip)
|
|
|
|
{
|
|
|
|
free(ip);
|
|
|
|
}
|
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-09-26 11:00:51 -07:00
|
|
|
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
|
2008-11-15 05:58:50 -08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-08-26 05:51:27 -07:00
|
|
|
static void
|
|
|
|
_disable_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:00:51 -07:00
|
|
|
|
2009-08-26 05:51:27 -07:00
|
|
|
if (elm_widget_disabled_get(obj))
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
|
|
|
|
wd->disabled = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,enabled", "elm");
|
|
|
|
wd->disabled = EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-17 20:55:44 -07:00
|
|
|
static void
|
|
|
|
_elm_win_recalc_job(void *data)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
Evas_Coord minw = -1, minh = -1, maxh = -1;
|
2008-10-17 20:55:44 -07:00
|
|
|
Evas_Coord resw, resh, minminw;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-17 20:55:44 -07:00
|
|
|
wd->deferred_recalc_job = NULL;
|
|
|
|
evas_object_geometry_get(wd->ent, NULL, NULL, &resw, &resh);
|
|
|
|
resh = 0;
|
|
|
|
edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, 0, 0);
|
2009-09-21 05:50:34 -07:00
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
2008-10-17 20:55:44 -07:00
|
|
|
minminw = minw;
|
|
|
|
edje_object_size_min_restricted_calc(wd->ent, &minw, &minh, resw, 0);
|
2009-09-21 05:50:34 -07:00
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
2008-10-17 20:55:44 -07:00
|
|
|
evas_object_size_hint_min_set(data, minminw, minh);
|
2009-09-21 05:50:34 -07:00
|
|
|
if (wd->single_line) maxh = minh;
|
2009-04-23 05:58:34 -07:00
|
|
|
evas_object_size_hint_max_set(data, -1, maxh);
|
2009-05-04 22:10:13 -07:00
|
|
|
if (wd->deferred_cur)
|
|
|
|
elm_widget_show_region_set(data, wd->cx, wd->cy, wd->cw, wd->ch);
|
2008-10-17 20:55:44 -07:00
|
|
|
}
|
|
|
|
|
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;
|
2010-03-09 03:42:53 -08:00
|
|
|
Evas_Coord resw, resh;
|
|
|
|
if (!wd) return;
|
2009-10-22 15:10:23 -07:00
|
|
|
if (wd->linewrap || wd->char_linewrap)
|
2008-10-17 07:40:54 -07:00
|
|
|
{
|
|
|
|
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;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->changed = EINA_FALSE;
|
2008-10-17 20:55:44 -07:00
|
|
|
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);
|
2009-09-21 05:50:34 -07:00
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
2008-10-17 07:40:54 -07:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
2009-09-21 05:50:34 -07:00
|
|
|
if (wd->single_line) maxh = minh;
|
2008-10-17 07:40:54 -07:00
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
}
|
2008-10-14 01:05:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
|
2008-10-14 01:05:30 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2008-11-18 02:11:57 -08:00
|
|
|
Evas_Object *top = elm_widget_top_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
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))
|
|
|
|
{
|
2010-09-18 19:30:14 -07:00
|
|
|
evas_object_focus_set(wd->ent, EINA_TRUE);
|
2009-07-06 23:46:51 -07:00
|
|
|
edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
|
|
|
|
if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
|
2010-03-26 04:25:55 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
|
2008-11-16 21:58:21 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
edje_object_signal_emit(wd->ent, "elm,action,unfocus", "elm");
|
2010-09-18 19:30:14 -07:00
|
|
|
evas_object_focus_set(wd->ent, EINA_FALSE);
|
2009-07-06 23:46:51 -07:00
|
|
|
if (top) elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_OFF);
|
2010-03-26 04:25:55 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
|
2008-11-16 21:58:21 -08:00
|
|
|
}
|
2008-10-14 01:05:30 -07:00
|
|
|
}
|
|
|
|
|
2010-06-15 08:04:05 -07:00
|
|
|
static void
|
|
|
|
_signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
edje_object_signal_emit(wd->ent, emission, source);
|
|
|
|
}
|
|
|
|
|
2010-09-09 11:53:36 -07:00
|
|
|
static void
|
|
|
|
_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
edje_object_signal_callback_add(wd->ent, emission, source, func_cb, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source))
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
return edje_object_signal_callback_del(wd->ent, emission, source, func_cb);
|
|
|
|
}
|
|
|
|
|
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;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-03-19 06:36:46 -07:00
|
|
|
evas_object_geometry_get(wd->ent, &x, &y, NULL, NULL);
|
2009-07-06 23:46:51 -07:00
|
|
|
edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
|
|
|
|
&cx, &cy, &cw, &ch);
|
2009-03-19 06:36:46 -07:00
|
|
|
evas_object_size_hint_min_get(wd->hoversel, &mw, &mh);
|
|
|
|
if (cw < mw)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
cx += (cw - mw) / 2;
|
|
|
|
cw = mw;
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
if (ch < mh)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
cy += (ch - mh) / 2;
|
|
|
|
ch = mh;
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
evas_object_move(wd->hoversel, x + cx, y + cy);
|
|
|
|
evas_object_resize(wd->hoversel, cw, ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-09-26 11:00:51 -07:00
|
|
|
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->hoversel) _hoversel_position(data);
|
|
|
|
}
|
|
|
|
|
2008-10-17 07:40:54 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-10-17 07:40:54 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-12-07 06:19:20 -08:00
|
|
|
if (wd->linewrap || wd->char_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
|
2010-06-23 19:54:03 -07:00
|
|
|
_hover_del(void *data)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-06-23 19:54:03 -07:00
|
|
|
|
|
|
|
if (wd->hoversel)
|
|
|
|
{
|
|
|
|
evas_object_del(wd->hoversel);
|
|
|
|
wd->hoversel = NULL;
|
|
|
|
}
|
|
|
|
wd->hovdeljob = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dismissed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
if (!wd) return;
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->hoversel) evas_object_hide(wd->hoversel);
|
|
|
|
if (wd->selmode)
|
2010-03-25 21:45:11 -07:00
|
|
|
{
|
|
|
|
if (!wd->password)
|
2010-09-18 19:30:14 -07:00
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
|
2010-03-25 21:45:11 -07:00
|
|
|
}
|
2009-03-20 08:08:33 -07:00
|
|
|
elm_widget_scroll_freeze_pop(data);
|
2010-06-23 19:54:03 -07:00
|
|
|
if (wd->hovdeljob) ecore_job_del(wd->hovdeljob);
|
|
|
|
wd->hovdeljob = ecore_job_add(_hover_del, data);
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_select(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->selmode = EINA_TRUE;
|
2009-03-19 06:36:46 -07:00
|
|
|
edje_object_part_text_select_none(wd->ent, "elm.text");
|
2010-03-25 21:45:11 -07:00
|
|
|
if (!wd->password)
|
2010-09-18 19:30:14 -07:00
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", EINA_TRUE);
|
2009-03-19 06:36:46 -07:00
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,on", "elm");
|
|
|
|
elm_widget_scroll_hold_push(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->sel_notify_handler)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2010-08-16 07:52:36 -07:00
|
|
|
wd->selection_asked = EINA_TRUE;
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data);
|
2009-07-06 23:46:51 -07:00
|
|
|
#endif
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-14 23:29:49 -07:00
|
|
|
_store_selection(Elm_Sel_Type seltype, Evas_Object *obj)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-06-05 21:09:56 -07:00
|
|
|
const char *sel;
|
|
|
|
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-06-05 21:09:56 -07:00
|
|
|
sel = edje_object_part_text_selection_get(wd->ent, "elm.text");
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_selection_set(seltype, obj, ELM_SEL_FORMAT_MARKUP, sel);
|
2010-06-22 18:28:57 -07:00
|
|
|
if (seltype == ELM_SEL_CLIPBOARD)
|
|
|
|
eina_stringshare_replace(&wd->cut_sel, sel);
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-09-26 11:00:51 -07:00
|
|
|
|
2010-06-17 01:50:43 -07:00
|
|
|
/* Store it */
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->selmode = EINA_FALSE;
|
2009-03-19 06:36:46 -07:00
|
|
|
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);
|
2010-06-17 01:50:43 -07:00
|
|
|
_store_selection(ELM_SEL_CLIPBOARD, data);
|
2009-03-19 06:36:46 -07:00
|
|
|
edje_object_part_text_insert(wd->ent, "elm.text", "");
|
|
|
|
edje_object_part_text_select_none(wd->ent, "elm.text");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->selmode = EINA_FALSE;
|
2009-03-19 06:36:46 -07:00
|
|
|
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);
|
2010-06-17 01:50:43 -07:00
|
|
|
_store_selection(ELM_SEL_CLIPBOARD, data);
|
|
|
|
// edje_object_part_text_select_none(wd->ent, "elm.text");
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
|
2009-03-22 21:55:37 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_cancel(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-03-22 21:55:37 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->selmode = EINA_FALSE;
|
2009-03-22 21:55:37 -07:00
|
|
|
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-09-02 05:48:00 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_item_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-09-02 05:48:00 -07:00
|
|
|
{
|
|
|
|
Elm_Entry_Context_Menu_Item *it = data;
|
|
|
|
Evas_Object *obj2 = it->obj;
|
|
|
|
if (it->func) it->func(it->data, obj2, NULL);
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2009-03-19 06:36:46 -07:00
|
|
|
_long_press(void *data)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-05-13 05:21:52 -07:00
|
|
|
Evas_Object *top;
|
2009-09-02 05:48:00 -07:00
|
|
|
const Eina_List *l;
|
|
|
|
const Elm_Entry_Context_Menu_Item *it;
|
2010-06-25 02:58:14 -07:00
|
|
|
if (!wd) return ECORE_CALLBACK_CANCEL;
|
2009-12-01 03:03:14 -08:00
|
|
|
if ((wd->api) && (wd->api->obj_longpress))
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
2009-12-01 03:03:14 -08:00
|
|
|
wd->api->obj_longpress(data);
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
2009-12-03 14:26:37 -08:00
|
|
|
else if (wd->context_menu)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
2010-01-18 02:28:00 -08:00
|
|
|
const char *context_menu_orientation;
|
2010-02-08 19:27:11 -08:00
|
|
|
|
2009-12-01 03:03:14 -08:00
|
|
|
if (wd->hoversel) evas_object_del(wd->hoversel);
|
|
|
|
else elm_widget_scroll_freeze_push(data);
|
|
|
|
wd->hoversel = elm_hoversel_add(data);
|
2010-01-18 02:28:00 -08:00
|
|
|
context_menu_orientation = edje_object_data_get
|
|
|
|
(wd->ent, "context_menu_orientation");
|
|
|
|
if ((context_menu_orientation) &&
|
|
|
|
(!strcmp(context_menu_orientation, "horizontal")))
|
2010-09-18 19:30:14 -07:00
|
|
|
elm_hoversel_horizontal_set(wd->hoversel, EINA_TRUE);
|
2009-12-01 03:03:14 -08:00
|
|
|
elm_object_style_set(wd->hoversel, "entry");
|
|
|
|
elm_widget_sub_object_add(data, wd->hoversel);
|
|
|
|
elm_hoversel_label_set(wd->hoversel, "Text");
|
|
|
|
top = elm_widget_top_get(data);
|
|
|
|
if (top) elm_hoversel_hover_parent_set(wd->hoversel, top);
|
|
|
|
evas_object_smart_callback_add(wd->hoversel, "dismissed", _dismissed, data);
|
|
|
|
if (!wd->selmode)
|
|
|
|
{
|
2010-03-25 21:45:11 -07:00
|
|
|
if (!wd->password)
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Select", NULL, ELM_ICON_NONE,
|
|
|
|
_select, data);
|
2010-01-27 01:23:54 -08:00
|
|
|
if (1) // need way to detect if someone has a selection
|
|
|
|
{
|
|
|
|
if (wd->editable)
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Paste", NULL, ELM_ICON_NONE,
|
|
|
|
_paste, data);
|
|
|
|
}
|
2009-12-01 03:03:14 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-25 21:45:11 -07:00
|
|
|
if (!wd->password)
|
2010-01-27 01:23:54 -08:00
|
|
|
{
|
2010-03-25 21:45:11 -07:00
|
|
|
if (wd->have_selection)
|
|
|
|
{
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Copy", NULL, ELM_ICON_NONE,
|
|
|
|
_copy, data);
|
|
|
|
if (wd->editable)
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Cut", NULL, ELM_ICON_NONE,
|
|
|
|
_cut, data);
|
|
|
|
}
|
|
|
|
elm_hoversel_item_add(wd->hoversel, "Cancel", NULL, ELM_ICON_NONE,
|
|
|
|
_cancel, data);
|
2010-01-27 01:23:54 -08:00
|
|
|
}
|
2009-12-01 03:03:14 -08:00
|
|
|
}
|
|
|
|
EINA_LIST_FOREACH(wd->items, l, it)
|
|
|
|
{
|
|
|
|
elm_hoversel_item_add(wd->hoversel, it->label, it->icon_file,
|
|
|
|
it->icon_type, _item_clicked, it);
|
|
|
|
}
|
|
|
|
if (wd->hoversel)
|
|
|
|
{
|
|
|
|
_hoversel_position(data);
|
|
|
|
evas_object_show(wd->hoversel);
|
|
|
|
elm_hoversel_hover_begin(wd->hoversel);
|
|
|
|
}
|
2009-12-03 14:26:37 -08:00
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
|
|
|
edje_object_part_text_select_abort(wd->ent, "elm.text");
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
wd->longpress_timer = NULL;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
|
2010-06-25 02:58:14 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-03-19 06:36:46 -07:00
|
|
|
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);
|
|
|
|
wd->longpress_timer = ecore_timer_add(1.0, _long_press, data);
|
|
|
|
wd->downx = ev->canvas.x;
|
|
|
|
wd->downy = ev->canvas.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-03-19 06:36:46 -07:00
|
|
|
if (ev->button != 1) return;
|
|
|
|
if (wd->longpress_timer)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
ecore_timer_del(wd->longpress_timer);
|
|
|
|
wd->longpress_timer = NULL;
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2009-03-19 06:36:46 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Evas_Event_Mouse_Move *ev = event_info;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-03-19 06:36:46 -07:00
|
|
|
if (!wd->selmode)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
|
|
|
{
|
|
|
|
if (wd->longpress_timer)
|
|
|
|
{
|
|
|
|
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)))
|
|
|
|
{
|
|
|
|
ecore_timer_del(wd->longpress_timer);
|
|
|
|
wd->longpress_timer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
|
|
|
else if (wd->longpress_timer)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
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)))
|
|
|
|
{
|
|
|
|
ecore_timer_del(wd->longpress_timer);
|
|
|
|
wd->longpress_timer = NULL;
|
|
|
|
}
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
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);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return "base";
|
2008-11-15 05:58:50 -08:00
|
|
|
if (wd->editable)
|
|
|
|
{
|
|
|
|
if (wd->password) return "base-password";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->single_line) return "base-single";
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->linewrap) return "base";
|
2010-02-03 07:26:14 -08:00
|
|
|
else if (wd->char_linewrap) return "base-charwrap";
|
2008-11-15 05:58:50 -08:00
|
|
|
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";
|
2010-02-03 07:26:14 -08:00
|
|
|
else if (wd->char_linewrap) return "base-noedit-charwrap";
|
2008-11-15 05:58:50 -08:00
|
|
|
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);
|
2009-09-26 11:00:51 -07:00
|
|
|
|
2008-11-18 22:23:08 -08:00
|
|
|
if (txt_len <= 0) return str;
|
|
|
|
if ((*len + txt_len) >= *alloc)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
char *str2;
|
|
|
|
int alloc2;
|
|
|
|
|
|
|
|
alloc2 = *alloc + txt_len + 128;
|
|
|
|
str2 = realloc(str, alloc2);
|
|
|
|
if (!str2) return str;
|
|
|
|
*alloc = alloc2;
|
|
|
|
str = str2;
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
|
|
|
strcpy(str + *len, txt);
|
|
|
|
*len += txt_len;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2010-08-16 02:06:19 -07:00
|
|
|
/*FIXME: Sholud be implemented somewhere else, it really depends on the context
|
|
|
|
* because some markups can be implemented otherwise according to style.
|
|
|
|
* probably doing it in textblock and making it translate according to it's
|
|
|
|
* style is correct. */
|
2008-11-18 22:23:08 -08:00
|
|
|
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-07-06 23:46:51 -07:00
|
|
|
|
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 (;;)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
if ((*p == 0) ||
|
|
|
|
(tag_end) || (esc_end) ||
|
|
|
|
(tag_start) || (esc_start))
|
|
|
|
{
|
|
|
|
if (tag_end)
|
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
char *ttag;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
|
|
|
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);
|
2010-08-16 02:06:19 -07:00
|
|
|
else if (!strcmp(ttag, "ps")) /* Unicode paragraph separator */
|
|
|
|
str = _str_append(str, "\xE2\x80\xA9", &str_len, &str_alloc);
|
2009-07-06 23:46:51 -07:00
|
|
|
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);
|
|
|
|
}
|
2010-03-01 17:04:38 -08:00
|
|
|
break;
|
2009-07-06 23:46:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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++;
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2010-06-17 01:50:43 -07:00
|
|
|
|
2008-11-18 22:23:08 -08:00
|
|
|
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;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2009-02-25 18:13:34 -08:00
|
|
|
if (!text) return NULL;
|
2008-11-18 22:23:08 -08:00
|
|
|
for (;;)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
pos = pos2;
|
2010-03-09 03:42:53 -08:00
|
|
|
pos2 = evas_string_char_next_get((char *)(text), pos2, &ch);
|
2009-10-12 03:10:12 -07:00
|
|
|
if ((ch <= 0) || (pos2 <= 0)) break;
|
2009-10-22 15:10:23 -07:00
|
|
|
if (ch == '\n')
|
2009-09-26 11:00:51 -07:00
|
|
|
str = _str_append(str, "<br>", &str_len, &str_alloc);
|
2009-10-22 15:10:23 -07:00
|
|
|
else if (ch == '\t')
|
2009-09-26 11:00:51 -07:00
|
|
|
str = _str_append(str, "<\t>", &str_len, &str_alloc);
|
2009-10-22 15:10:23 -07:00
|
|
|
else if (ch == '<')
|
2009-09-26 11:00:51 -07:00
|
|
|
str = _str_append(str, "<", &str_len, &str_alloc);
|
2009-10-22 15:10:23 -07:00
|
|
|
else if (ch == '>')
|
2009-09-26 11:00:51 -07:00
|
|
|
str = _str_append(str, ">", &str_len, &str_alloc);
|
2009-10-22 15:10:23 -07:00
|
|
|
else if (ch == '&')
|
2009-09-26 11:00:51 -07:00
|
|
|
str = _str_append(str, "&", &str_len, &str_alloc);
|
2010-09-01 07:30:31 -07:00
|
|
|
else if (ch == 0x2029) /* PS */
|
|
|
|
str = _str_append(str, "<ps>", &str_len, &str_alloc);
|
2009-07-06 23:46:51 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char tstr[16];
|
|
|
|
|
|
|
|
strncpy(tstr, text + pos, pos2 - pos);
|
|
|
|
tstr[pos2 - pos] = 0;
|
|
|
|
str = _str_append(str, tstr, &str_len, &str_alloc);
|
|
|
|
}
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2008-10-16 02:17:57 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_entry_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->changed = EINA_TRUE;
|
2008-10-16 02:17:57 -07:00
|
|
|
_sizing_eval(data);
|
2010-03-11 00:08:15 -08:00
|
|
|
if (wd->text) eina_stringshare_del(wd->text);
|
|
|
|
wd->text = NULL;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_selection_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
|
|
|
Evas_Object *entry;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-02-25 11:50:45 -08:00
|
|
|
EINA_LIST_FOREACH(entries, l, entry)
|
2008-11-18 00:45:38 -08:00
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
if (entry != data) elm_entry_select_none(entry);
|
2008-11-18 00:45:38 -08:00
|
|
|
}
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->have_selection = EINA_TRUE;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
|
2010-06-21 22:12:08 -07:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2008-11-18 22:23:08 -08:00
|
|
|
if (wd->sel_notify_handler)
|
|
|
|
{
|
2010-06-22 18:28:57 -07:00
|
|
|
const char *txt = elm_entry_selection_get(data);
|
2010-06-21 22:12:08 -07:00
|
|
|
Evas_Object *top;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2010-06-21 22:12:08 -07:00
|
|
|
top = elm_widget_top_get(data);
|
|
|
|
if ((top) && (elm_win_xwindow_get(top)))
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP, txt);
|
2009-07-06 23:46:51 -07:00
|
|
|
}
|
2010-06-21 22:12:08 -07:00
|
|
|
#endif
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_selection_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->have_selection = EINA_TRUE;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_selection_set(ELM_SEL_PRIMARY, obj, ELM_SEL_FORMAT_MARKUP,
|
2010-06-17 01:50:43 -07:00
|
|
|
elm_entry_selection_get(data));
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_selection_cleared(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-11-18 22:23:08 -08:00
|
|
|
if (!wd->have_selection) return;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->have_selection = EINA_FALSE;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
|
2008-11-18 22:23:08 -08:00
|
|
|
if (wd->sel_notify_handler)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
if (wd->cut_sel)
|
|
|
|
{
|
2008-12-09 22:43:21 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2009-07-06 23:46:51 -07:00
|
|
|
Evas_Object *top;
|
|
|
|
|
|
|
|
top = elm_widget_top_get(data);
|
|
|
|
if ((top) && (elm_win_xwindow_get(top)))
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_selection_set(ELM_SEL_PRIMARY, data, ELM_SEL_FORMAT_MARKUP,
|
2010-06-21 22:12:08 -07:00
|
|
|
wd->cut_sel);
|
2009-07-06 23:46:51 -07:00
|
|
|
#endif
|
|
|
|
eina_stringshare_del(wd->cut_sel);
|
|
|
|
wd->cut_sel = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-09 22:43:21 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2009-07-06 23:46:51 -07:00
|
|
|
Evas_Object *top;
|
|
|
|
|
|
|
|
top = elm_widget_top_get(data);
|
|
|
|
if ((top) && (elm_win_xwindow_get(top)))
|
2010-06-22 18:28:57 -07:00
|
|
|
elm_selection_clear(ELM_SEL_PRIMARY, data);
|
2009-07-06 23:46:51 -07:00
|
|
|
#endif
|
|
|
|
}
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_entry_paste_request(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_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
|
2009-07-06 23:46:51 -07:00
|
|
|
Evas_Object *top;
|
|
|
|
|
|
|
|
top = elm_widget_top_get(data);
|
|
|
|
if ((top) && (elm_win_xwindow_get(top)))
|
|
|
|
{
|
2010-08-16 07:52:36 -07:00
|
|
|
wd->selection_asked = EINA_TRUE;
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_selection_get(ELM_SEL_CLIPBOARD, ELM_SEL_FORMAT_MARKUP, data);
|
2009-07-06 23:46:51 -07:00
|
|
|
}
|
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_entry_copy_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
|
2010-06-17 01:50:43 -07:00
|
|
|
elm_entry_selection_get(data));
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_entry_cut_notify(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_selection_set(ELM_SEL_CLIPBOARD, obj, ELM_SEL_FORMAT_MARKUP,
|
2010-06-17 01:50:43 -07:00
|
|
|
elm_entry_selection_get(data));
|
2008-11-18 22:23:08 -08:00
|
|
|
edje_object_part_text_insert(wd->ent, "elm.text", "");
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->changed = EINA_TRUE;
|
2008-10-17 20:55:44 -07:00
|
|
|
_sizing_eval(data);
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_cursor_changed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 02:17:57 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-10-16 23:41:07 -07:00
|
|
|
Evas_Coord cx, cy, cw, ch;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
&cx, &cy, &cw, &ch);
|
2009-05-04 22:10:13 -07:00
|
|
|
if (!wd->deferred_recalc_job)
|
|
|
|
elm_widget_show_region_set(data, cx, cy, cw, ch);
|
|
|
|
else
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
wd->deferred_cur = EINA_TRUE;
|
|
|
|
wd->cx = cx;
|
|
|
|
wd->cy = cy;
|
|
|
|
wd->cw = cw;
|
|
|
|
wd->ch = ch;
|
2009-05-04 22:10:13 -07:00
|
|
|
}
|
2008-10-16 23:41:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_anchor_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 23:41:07 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-16 23:41:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_anchor_up(void *data, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
|
2008-10-16 23:41:07 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2008-10-24 19:11:06 -07:00
|
|
|
Elm_Entry_Anchor_Info ei;
|
2010-03-09 03:42:53 -08:00
|
|
|
char *buf2, *p, *p2, *n;
|
|
|
|
if (!wd) return;
|
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;
|
2009-07-06 23:46:51 -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;
|
2009-10-22 15:10:23 -07:00
|
|
|
geoms =
|
2009-09-26 11:00:51 -07:00
|
|
|
edje_object_part_text_anchor_geometry_get(wd->ent, "elm.text", ei.name);
|
2008-10-24 19:11:06 -07:00
|
|
|
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)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
if (((r->x + x) <= px) && ((r->y + y) <= py) &&
|
2008-10-24 19:11:06 -07:00
|
|
|
((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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-26 05:51:27 -07:00
|
|
|
if (!wd->disabled)
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei);
|
2008-10-17 07:51:17 -07:00
|
|
|
}
|
2008-10-16 23:41:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_anchor_move(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 23:41:07 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-16 23:41:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_anchor_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 23:41:07 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-16 23:41:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_anchor_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-16 23:41:07 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-16 02:17:57 -07:00
|
|
|
}
|
|
|
|
|
2008-10-22 01:58:56 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_key_enter(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2008-10-22 01:58:56 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
|
2008-10-22 01:58:56 -07:00
|
|
|
}
|
|
|
|
|
2009-12-01 03:03:14 -08:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_mouse_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2009-12-01 03:03:14 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_PRESS, NULL);
|
2009-12-01 03:03:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_mouse_up(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2009-12-01 03:03:14 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
|
2009-12-01 03:03:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_signal_mouse_double(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2009-12-01 03:03:14 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-26 03:59:56 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
|
2009-12-01 03:03:14 -08:00
|
|
|
}
|
|
|
|
|
2008-12-09 22:33:24 -08:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2010-03-09 09:51:30 -08:00
|
|
|
_event_selection_notify(void *data, int type __UNUSED__, void *event)
|
2008-11-18 22:23:08 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Ecore_X_Event_Selection_Notify *ev = event;
|
2010-06-25 02:58:14 -07:00
|
|
|
if (!wd) return ECORE_CALLBACK_PASS_ON;
|
2010-09-06 23:56:16 -07:00
|
|
|
if (!wd->selection_asked && !wd->drag_selection_asked)
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2010-06-22 18:28:57 -07:00
|
|
|
|
2008-11-18 22:23:08 -08:00
|
|
|
if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
|
|
|
|
(ev->selection == ECORE_X_SELECTION_PRIMARY))
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
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);
|
2009-09-26 11:00:51 -07:00
|
|
|
|
2009-07-06 23:46:51 -07:00
|
|
|
if (txt)
|
|
|
|
{
|
|
|
|
elm_entry_entry_insert(data, txt);
|
|
|
|
free(txt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wd->selection_asked = EINA_FALSE;
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
2010-09-06 23:56:16 -07:00
|
|
|
else if (ev->selection == ECORE_X_SELECTION_XDND)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
/* Massive FIXME: this should be at the drag point */
|
|
|
|
elm_entry_entry_insert(data, txt);
|
|
|
|
free(txt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wd->drag_selection_asked = EINA_FALSE;
|
|
|
|
|
|
|
|
ecore_x_dnd_send_finished();
|
|
|
|
|
|
|
|
}
|
2010-06-25 02:58:14 -07:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2010-08-18 12:18:42 -07:00
|
|
|
_event_selection_clear(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
|
2008-11-18 22:23:08 -08:00
|
|
|
{
|
2010-08-18 12:18:42 -07:00
|
|
|
/*
|
2008-11-18 22:23:08 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Ecore_X_Event_Selection_Clear *ev = event;
|
2010-09-18 19:30:14 -07:00
|
|
|
if (!wd) return ECORE_CALLBACK_PASS_ON;
|
|
|
|
if (!wd->have_selection) return ECORE_CALLBACK_PASS_ON;
|
2008-11-18 22:23:08 -08:00
|
|
|
if ((ev->selection == ECORE_X_SELECTION_CLIPBOARD) ||
|
|
|
|
(ev->selection == ECORE_X_SELECTION_PRIMARY))
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
elm_entry_select_none(data);
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
2010-06-17 01:50:43 -07:00
|
|
|
return 1;*/
|
2010-06-25 02:58:14 -07:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2008-11-18 22:23:08 -08:00
|
|
|
}
|
2010-09-06 23:56:16 -07:00
|
|
|
|
|
|
|
|
|
|
|
static Eina_Bool
|
2010-09-09 12:39:30 -07:00
|
|
|
_drag_drop_cb(void *data __UNUSED__, Evas_Object *obj, Elm_Drop_Data *drop)
|
2010-09-06 23:56:16 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd;
|
|
|
|
Eina_Bool rv;
|
|
|
|
|
|
|
|
wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
printf("Inserting at (%d,%d) %s\n",drop->x,drop->y,(char*)drop->data);
|
|
|
|
|
|
|
|
edje_object_part_text_cursor_copy(wd->ent, "elm.text",
|
|
|
|
EDJE_CURSOR_MAIN,/*->*/EDJE_CURSOR_USER);
|
|
|
|
rv = edje_object_part_text_cursor_coord_set(wd->ent,"elm.text",
|
|
|
|
EDJE_CURSOR_MAIN,drop->x,drop->y);
|
|
|
|
if (!rv) printf("Warning: Failed to position cursor: paste anyway\n");
|
|
|
|
elm_entry_entry_insert(obj, drop->data);
|
|
|
|
edje_object_part_text_cursor_copy(wd->ent, "elm.text",
|
|
|
|
EDJE_CURSOR_USER,/*->*/EDJE_CURSOR_MAIN);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2008-12-09 22:33:24 -08:00
|
|
|
#endif
|
2008-11-18 22:23:08 -08:00
|
|
|
|
2010-04-26 07:59:01 -07:00
|
|
|
static Evas_Object *
|
2010-08-18 12:18:42 -07:00
|
|
|
_get_item(void *data, Evas_Object *edje __UNUSED__, const char *part __UNUSED__, const char *item)
|
2010-04-26 07:59:01 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
Evas_Object *o;
|
2010-04-27 01:06:42 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Elm_Entry_Item_Provider *ip;
|
|
|
|
int ok = 0;
|
2010-04-26 07:59:01 -07:00
|
|
|
|
2010-04-27 01:06:42 -07:00
|
|
|
EINA_LIST_FOREACH(wd->item_providers, l, ip)
|
|
|
|
{
|
|
|
|
o = ip->func(ip->data, data, item);
|
|
|
|
if (o) return o;
|
|
|
|
}
|
2010-04-26 07:59:01 -07:00
|
|
|
o = edje_object_add(evas_object_evas_get(data));
|
2010-04-27 01:06:42 -07:00
|
|
|
if (!strncmp(item, "emoticon/", 9))
|
2010-05-11 18:03:46 -07:00
|
|
|
ok = _elm_theme_object_set(data, o, "entry", item, elm_widget_style_get(data));
|
2010-04-27 01:06:42 -07:00
|
|
|
if (!ok)
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(data, o, "entry/emoticon", "wtf", elm_widget_style_get(data));
|
2010-04-26 07:59:01 -07:00
|
|
|
return o;
|
|
|
|
}
|
2010-04-12 01:12:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This adds an entry to @p parent object.
|
|
|
|
*
|
|
|
|
* @param parent The parent object
|
|
|
|
* @return The new object or NULL if it cannot be created
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-10-14 01:05:30 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_entry_add(Evas_Object *parent)
|
|
|
|
{
|
2009-05-13 05:21:52 -07:00
|
|
|
Evas_Object *obj, *top;
|
2008-10-14 01:05:30 -07:00
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
wd = ELM_NEW(Widget_Data);
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
obj = elm_widget_add(e);
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "entry");
|
2009-05-13 05:21:52 -07:00
|
|
|
elm_widget_type_set(obj, "entry");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
2008-10-14 01:05:30 -07:00
|
|
|
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);
|
2009-08-26 05:51:27 -07:00
|
|
|
elm_widget_disable_hook_set(obj, _disable_hook);
|
2010-06-15 08:04:05 -07:00
|
|
|
elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
|
2010-09-09 11:53:36 -07:00
|
|
|
elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
|
|
|
|
elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
|
2010-09-17 15:28:29 -07:00
|
|
|
elm_object_cursor_set(obj, ELM_CURSOR_XTERM);
|
2010-09-27 21:28:14 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
|
|
|
elm_widget_highlight_ignore_set(obj, EINA_TRUE);
|
2008-10-17 07:40:54 -07:00
|
|
|
|
2009-10-10 22:48:24 -07:00
|
|
|
wd->linewrap = EINA_TRUE;
|
2009-10-22 15:10:23 -07:00
|
|
|
wd->char_linewrap= EINA_FALSE;
|
2009-10-10 22:48:24 -07:00
|
|
|
wd->editable = EINA_TRUE;
|
|
|
|
wd->disabled = EINA_FALSE;
|
|
|
|
wd->context_menu = EINA_TRUE;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-10-14 01:05:30 -07:00
|
|
|
wd->ent = edje_object_add(e);
|
2010-04-26 07:59:01 -07:00
|
|
|
edje_object_item_provider_set(wd->ent, _get_item, obj);
|
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-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_DOWN,
|
2009-09-26 11:00:51 -07:00
|
|
|
_mouse_down, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_UP,
|
2009-09-26 11:00:51 -07:00
|
|
|
_mouse_up, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
evas_object_event_callback_add(wd->ent, EVAS_CALLBACK_MOUSE_MOVE,
|
2009-09-26 11:00:51 -07:00
|
|
|
_mouse_move, obj);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->ent, "entry", "base", "default");
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,changed", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_entry_changed, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "selection,start", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_selection_start, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "selection,changed", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_selection_changed, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "selection,cleared", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_selection_cleared, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,paste,request", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_entry_paste_request, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,copy,notify", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_entry_copy_notify, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,cut,notify", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_entry_cut_notify, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "cursor,changed", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_cursor_changed, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,down,*", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_anchor_down, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,up,*", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_anchor_up, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,move,*", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_anchor_move, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,in,*", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_anchor_in, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "anchor,mouse,out,*", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_anchor_out, obj);
|
2009-10-22 15:10:23 -07:00
|
|
|
edje_object_signal_callback_add(wd->ent, "entry,key,enter", "elm.text",
|
2009-09-26 11:00:51 -07:00
|
|
|
_signal_key_enter, obj);
|
2009-12-01 03:03:14 -08:00
|
|
|
edje_object_signal_callback_add(wd->ent, "mouse,down,1", "elm.text",
|
|
|
|
_signal_mouse_down, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "mouse,up,1", "elm.text",
|
|
|
|
_signal_mouse_up, obj);
|
|
|
|
edje_object_signal_callback_add(wd->ent, "mouse,down,1,double", "elm.text",
|
|
|
|
_signal_mouse_double, obj);
|
2010-03-11 00:08:15 -08:00
|
|
|
edje_object_part_text_set(wd->ent, "elm.text", "");
|
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
|
2009-05-13 05:21:52 -07:00
|
|
|
top = elm_widget_top_get(obj);
|
|
|
|
if ((top) && (elm_win_xwindow_get(top)))
|
2008-11-18 22:23:08 -08:00
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
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-11-18 22:23:08 -08:00
|
|
|
}
|
2010-09-06 23:56:16 -07:00
|
|
|
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP,_drag_drop_cb, NULL);
|
2008-12-09 22:33:24 -08:00
|
|
|
#endif
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-11-18 00:45:38 -08:00
|
|
|
entries = eina_list_prepend(entries, obj);
|
2010-02-08 19:27:11 -08:00
|
|
|
|
2009-12-01 03:03:14 -08:00
|
|
|
// module - find module for entry
|
|
|
|
wd->api = _module(obj);
|
|
|
|
// if found - hook in
|
|
|
|
if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
|
2010-02-08 19:27:11 -08:00
|
|
|
|
2010-03-26 03:59:56 -07:00
|
|
|
// TODO: convert Elementary to subclassing of Evas_Smart_Class
|
|
|
|
// TODO: and save some bytes, making descriptions per-class and not instance!
|
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _signals);
|
2008-10-14 01:05:30 -07:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This sets the entry object not to line wrap. All input will
|
|
|
|
* be on a single line, and the entry box will extend with user input.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param single_line If true, the text in the entry
|
|
|
|
* will be on a single line.
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-10-22 01:58:56 -07:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
|
2008-10-22 01:58:56 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-22 01:58:56 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-22 01:58:56 -07:00
|
|
|
if (wd->single_line == single_line) return;
|
|
|
|
wd->single_line = single_line;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->linewrap = EINA_FALSE;
|
2009-10-22 15:10:23 -07:00
|
|
|
wd->char_linewrap = EINA_FALSE;
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
|
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);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This returns true if the entry has been set to single line mode.
|
|
|
|
* See also elm_entry_single_line_set().
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return single_line If true, the text in the entry is set to display
|
|
|
|
* on a single line.
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2010-03-25 10:27:00 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_entry_single_line_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
return wd->single_line;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This sets the entry object to password mode. All text entered
|
|
|
|
* and/or displayed within the widget will be replaced with asterisks (*).
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param password If true, password mode is enabled.
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-10-22 01:58:56 -07:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_entry_password_set(Evas_Object *obj, Eina_Bool password)
|
2008-10-22 01:58:56 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-22 01:58:56 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-22 01:58:56 -07:00
|
|
|
if (wd->password == password) return;
|
|
|
|
wd->password = password;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->single_line = EINA_TRUE;
|
|
|
|
wd->linewrap = EINA_FALSE;
|
2009-10-22 15:10:23 -07:00
|
|
|
wd->char_linewrap = EINA_FALSE;
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
|
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);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This returns whether password mode is enabled.
|
|
|
|
* See also elm_entry_password_set().
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return If true, the entry is set to display all characters
|
|
|
|
* as asterisks (*).
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2010-03-25 10:27:00 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_entry_password_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
return wd->password;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This sets the text displayed within the entry to @p entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param entry The text to be displayed
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-10-14 01:05:30 -07:00
|
|
|
EAPI void
|
|
|
|
elm_entry_entry_set(Evas_Object *obj, const char *entry)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-14 01:05:30 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-11 00:08:15 -08:00
|
|
|
if (!entry) entry = "";
|
2008-10-14 01:05:30 -07:00
|
|
|
edje_object_part_text_set(wd->ent, "elm.text", entry);
|
2010-03-11 00:08:15 -08:00
|
|
|
if (wd->text) eina_stringshare_del(wd->text);
|
|
|
|
wd->text = NULL;
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->changed = EINA_TRUE;
|
2008-10-14 01:05:30 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
2008-10-15 02:58:44 -07:00
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This returns the text currently shown in object @p entry.
|
|
|
|
* See also elm_entry_entry_set().
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return The currently displayed text or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
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
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2008-10-15 02:58:44 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-23 20:06:00 -07:00
|
|
|
const char *text;
|
2009-06-17 08:35:19 -07:00
|
|
|
if (!wd) return NULL;
|
2010-03-11 00:08:15 -08:00
|
|
|
if (wd->text) return wd->text;
|
2009-11-09 14:15:26 -08:00
|
|
|
text = edje_object_part_text_get(wd->ent, "elm.text");
|
2010-03-01 15:23:53 -08:00
|
|
|
if (!text)
|
|
|
|
{
|
|
|
|
ERR("text=NULL for edje %p, part 'elm.text'", wd->ent);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-03-13 13:01:26 -08:00
|
|
|
eina_stringshare_replace(&wd->text, text);
|
2010-03-11 00:08:15 -08:00
|
|
|
return wd->text;
|
2008-10-15 02:58:44 -07:00
|
|
|
}
|
2008-10-16 02:17:57 -07:00
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This returns all selected text within the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return The selected text within the entry or NULL on failure
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
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
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2008-10-16 02:17:57 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-06-17 08:35:19 -07:00
|
|
|
if (!wd) return NULL;
|
2008-10-16 02:17:57 -07:00
|
|
|
return edje_object_part_text_selection_get(wd->ent, "elm.text");
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This inserts text in @p entry at the beginning of the entry
|
|
|
|
* object.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param entry The text to insert
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-10-16 02:17:57 -07:00
|
|
|
EAPI void
|
|
|
|
elm_entry_entry_insert(Evas_Object *obj, const char *entry)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-16 02:17:57 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-16 02:17:57 -07:00
|
|
|
edje_object_part_text_insert(wd->ent, "elm.text", entry);
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->changed = EINA_TRUE;
|
2008-10-16 02:17:57 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This enables word line wrapping in the entry object. It is the opposite
|
|
|
|
* of elm_entry_single_line_set(). Additionally, setting this disables
|
|
|
|
* character line wrapping.
|
|
|
|
* See also elm_entry_line_char_wrap_set().
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param wrap If true, the entry will be wrapped once it reaches the end
|
|
|
|
* of the object. Wrapping will occur at the end of the word before the end of the
|
|
|
|
* object.
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-10-17 07:40:54 -07:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
|
2008-10-17 07:40:54 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-17 07:40:54 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-17 07:40:54 -07:00
|
|
|
if (wd->linewrap == wrap) return;
|
|
|
|
wd->linewrap = wrap;
|
2009-10-22 15:10:23 -07:00
|
|
|
if(wd->linewrap)
|
|
|
|
wd->char_linewrap = EINA_FALSE;
|
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
|
2009-10-22 15:10:23 -07:00
|
|
|
elm_entry_entry_set(obj, t);
|
|
|
|
eina_stringshare_del(t);
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This enables character line wrapping in the entry object. It is the opposite
|
|
|
|
* of elm_entry_single_line_set(). Additionally, setting this disables
|
|
|
|
* word line wrapping.
|
|
|
|
* See also elm_entry_line_wrap_set().
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param wrap If true, the entry will be wrapped once it reaches the end
|
|
|
|
* of the object. Wrapping will occur immediately upon reaching the end of the object.
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-10-22 15:10:23 -07:00
|
|
|
EAPI void
|
|
|
|
elm_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-10-22 15:10:23 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
const char *t;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-10-22 15:10:23 -07:00
|
|
|
if (wd->char_linewrap == wrap) return;
|
|
|
|
wd->char_linewrap = wrap;
|
|
|
|
if(wd->char_linewrap)
|
|
|
|
wd->linewrap = EINA_FALSE;
|
2009-02-25 22:09:15 -08:00
|
|
|
t = eina_stringshare_add(elm_entry_entry_get(obj));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
|
2008-10-24 19:11:06 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This sets the editable attribute of the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param editable If true, the entry will be editable by the user.
|
|
|
|
* If false, it will be set to the disabled state.
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-10-24 19:11:06 -07:00
|
|
|
EAPI void
|
2009-06-17 08:35:19 -07:00
|
|
|
elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
|
2008-10-24 19:11:06 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-24 19:11:06 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-02-25 07:54:26 -08:00
|
|
|
const char *t;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
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));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), elm_widget_style_get(obj));
|
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);
|
2010-09-06 23:56:16 -07:00
|
|
|
|
2010-09-09 01:59:38 -07:00
|
|
|
#ifdef HAVE_ELEMENTARY_X
|
2010-09-06 23:56:16 -07:00
|
|
|
if (editable)
|
2010-09-07 21:55:05 -07:00
|
|
|
elm_drop_target_add(obj, ELM_SEL_FORMAT_MARKUP, _drag_drop_cb, NULL);
|
2010-09-06 23:56:16 -07:00
|
|
|
else
|
|
|
|
elm_drop_target_del(obj);
|
2010-09-09 01:59:38 -07:00
|
|
|
#endif
|
2008-10-17 07:40:54 -07:00
|
|
|
}
|
2008-11-18 00:45:38 -08:00
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This gets the editable attribute of the entry.
|
|
|
|
* See also elm_entry_editable_set().
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return If true, the entry is editable by the user.
|
|
|
|
* If false, it is not editable by the user
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2010-03-25 10:27:00 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_entry_editable_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
return wd->editable;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This drops any existing text selection within the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-11-18 00:45:38 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_select_none(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-11-18 00:45:38 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->selmode)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
wd->selmode = EINA_FALSE;
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->have_selection = EINA_FALSE;
|
2008-11-18 00:45:38 -08:00
|
|
|
edje_object_part_text_select_none(wd->ent, "elm.text");
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This selects all text within the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2008-11-18 00:45:38 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_select_all(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-11-18 00:45:38 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-03-19 06:36:46 -07:00
|
|
|
if (wd->selmode)
|
|
|
|
{
|
2009-07-06 23:46:51 -07:00
|
|
|
wd->selmode = EINA_FALSE;
|
|
|
|
edje_object_part_text_select_allow_set(wd->ent, "elm.text", 0);
|
|
|
|
edje_object_signal_emit(wd->ent, "elm,state,select,off", "elm");
|
2009-03-19 06:36:46 -07:00
|
|
|
}
|
2009-06-17 08:35:19 -07:00
|
|
|
wd->have_selection = EINA_TRUE;
|
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
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This moves the cursor one place to the right within the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return EINA_TRUE upon success, EINA_FALSE upon failure
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_entry_cursor_next(Evas_Object *obj)
|
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
return edje_object_part_text_cursor_next(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This moves the cursor one place to the left within the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return EINA_TRUE upon success, EINA_FALSE upon failure
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_entry_cursor_prev(Evas_Object *obj)
|
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
return edje_object_part_text_cursor_prev(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This moves the cursor one line up within the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return EINA_TRUE upon success, EINA_FALSE upon failure
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_entry_cursor_up(Evas_Object *obj)
|
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
return edje_object_part_text_cursor_up(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This moves the cursor one line down within the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return EINA_TRUE upon success, EINA_FALSE upon failure
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_entry_cursor_down(Evas_Object *obj)
|
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
return edje_object_part_text_cursor_down(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This moves the cursor to the beginning of the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_cursor_begin_set(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 03:03:14 -08:00
|
|
|
edje_object_part_text_cursor_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This moves the cursor to the end of the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_cursor_end_set(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 03:03:14 -08:00
|
|
|
edje_object_part_text_cursor_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This moves the cursor to the beginning of the current line.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_cursor_line_begin_set(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 03:03:14 -08:00
|
|
|
edje_object_part_text_cursor_line_begin_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This moves the cursor to the end of the current line.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_cursor_line_end_set(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 03:03:14 -08:00
|
|
|
edje_object_part_text_cursor_line_end_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This begins a selection within the entry as though
|
|
|
|
* the user were holding down the mouse button to make a selection.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_cursor_selection_begin(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-10 22:35:07 -08:00
|
|
|
edje_object_part_text_select_begin(wd->ent, "elm.text");
|
2009-12-01 03:03:14 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This ends a selection within the entry as though
|
|
|
|
* the user had just released the mouse button while making a selection.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_cursor_selection_end(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-03-10 22:35:07 -08:00
|
|
|
edje_object_part_text_select_extend(wd->ent, "elm.text");
|
2009-12-01 03:03:14 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* TODO: fill this in
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return TODO: fill this in
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI Eina_Bool
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_entry_cursor_is_format_get(const Evas_Object *obj)
|
2009-12-01 03:03:14 -08:00
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
return edje_object_part_text_cursor_is_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This returns whether the cursor is visible.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return If true, the cursor is visible.
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI Eina_Bool
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_entry_cursor_is_visible_format_get(const Evas_Object *obj)
|
2009-12-01 03:03:14 -08:00
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
2009-12-01 03:03:14 -08:00
|
|
|
return edje_object_part_text_cursor_is_visible_format_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* TODO: fill this in
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return TODO: fill this in
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI const char *
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_entry_cursor_content_get(const Evas_Object *obj)
|
2009-12-01 03:03:14 -08:00
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return NULL;
|
2009-12-01 03:03:14 -08:00
|
|
|
return edje_object_part_text_cursor_content_get(wd->ent, "elm.text", EDJE_CURSOR_MAIN);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This executes a "cut" action on the selected text in the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_selection_cut(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 03:03:14 -08:00
|
|
|
_cut(obj, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This executes a "copy" action on the selected text in the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_selection_copy(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 03:03:14 -08:00
|
|
|
_copy(obj, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This executes a "paste" action in the entry.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-12-01 03:03:14 -08:00
|
|
|
EAPI void
|
|
|
|
elm_entry_selection_paste(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 03:03:14 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 03:03:14 -08:00
|
|
|
_paste(obj, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This clears and frees the items in a entry's contextual (right click) menu.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-09-02 05:48:00 -07:00
|
|
|
EAPI void
|
|
|
|
elm_entry_context_menu_clear(Evas_Object *obj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-09-02 05:48:00 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Elm_Entry_Context_Menu_Item *it;
|
|
|
|
if (!wd) return;
|
|
|
|
EINA_LIST_FREE(wd->items, it)
|
|
|
|
{
|
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
eina_stringshare_del(it->icon_file);
|
|
|
|
eina_stringshare_del(it->icon_group);
|
|
|
|
free(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This adds an item to the entry's contextual menu.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param label The item's text label
|
|
|
|
* @param icon_file The item's icon file
|
|
|
|
* @param icon_type The item's icon type
|
|
|
|
* @param func The callback to execute when the item is clicked
|
|
|
|
* @param data The data to associate with the item for related functions
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-09-02 05:48:00 -07:00
|
|
|
EAPI void
|
2010-03-16 08:31:38 -07:00
|
|
|
elm_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
|
2009-09-02 05:48:00 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-09-02 05:48:00 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Elm_Entry_Context_Menu_Item *it;
|
|
|
|
if (!wd) return;
|
|
|
|
it = calloc(1, sizeof(Elm_Entry_Context_Menu_Item));
|
|
|
|
if (!it) return;
|
|
|
|
wd->items = eina_list_append(wd->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;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This disables the entry's contextual (right click) menu.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param disabled If true, the menu is disabled
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-10-10 22:48:24 -07:00
|
|
|
EAPI void
|
|
|
|
elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-10-10 22:48:24 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
if (wd->context_menu == !disabled) return;
|
|
|
|
wd->context_menu = !disabled;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This returns whether the entry's contextual (right click) menu is disabled.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @return If true, the menu is disabled
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-10-10 22:48:24 -07:00
|
|
|
EAPI Eina_Bool
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_entry_context_menu_disabled_get(const Evas_Object *obj)
|
2009-10-10 22:48:24 -07:00
|
|
|
{
|
2010-03-09 03:42:53 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-10-10 22:48:24 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
return !wd->context_menu;
|
|
|
|
}
|
|
|
|
|
2010-04-27 01:06:42 -07:00
|
|
|
/**
|
|
|
|
* This appends a custom item provider to the list for that entry
|
|
|
|
*
|
|
|
|
* This appends the given callback. The list is walked from beginning to end
|
|
|
|
* with each function called given the item href string in the text. If the
|
|
|
|
* function returns an object handle other than NULL (it should create an
|
|
|
|
* and object to do this), then this object is used to replace that item. If
|
|
|
|
* not the next provider is called until one provides an item object, or the
|
|
|
|
* default provider in entry does.
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param func The function called to provide the item object
|
|
|
|
* @param data The data passed to @p func
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
if (!func) return;
|
|
|
|
Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
|
|
|
|
if (!ip) return;
|
|
|
|
ip->func = func;
|
|
|
|
ip->data = data;
|
|
|
|
wd->item_providers = eina_list_append(wd->item_providers, ip);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This prepends a custom item provider to the list for that entry
|
|
|
|
*
|
|
|
|
* This prepends the given callback. See elm_entry_item_provider_append() for
|
|
|
|
* more information
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param func The function called to provide the item object
|
|
|
|
* @param data The data passed to @p func
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
if (!func) return;
|
|
|
|
Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
|
|
|
|
if (!ip) return;
|
|
|
|
ip->func = func;
|
|
|
|
ip->data = data;
|
|
|
|
wd->item_providers = eina_list_prepend(wd->item_providers, ip);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This removes a custom item provider to the list for that entry
|
|
|
|
*
|
|
|
|
* This removes the given callback. See elm_entry_item_provider_append() for
|
|
|
|
* more information
|
|
|
|
*
|
|
|
|
* @param obj The entry object
|
|
|
|
* @param func The function called to provide the item object
|
|
|
|
* @param data The data passed to @p func
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Eina_List *l;
|
|
|
|
Elm_Entry_Item_Provider *ip;
|
|
|
|
if (!wd) return;
|
|
|
|
if (!func) return;
|
|
|
|
EINA_LIST_FOREACH(wd->item_providers, l, ip)
|
|
|
|
{
|
|
|
|
if ((ip->func == func) && (ip->data == data))
|
|
|
|
{
|
|
|
|
wd->item_providers = eina_list_remove_list(wd->item_providers, l);
|
|
|
|
free(ip);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This converts a markup (HTML-like) string into UTF-8.
|
|
|
|
*
|
|
|
|
* @param s The string (in markup) to be converted
|
|
|
|
* @return The converted string (in UTF-8)
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-01-26 16:44:29 -08:00
|
|
|
EAPI char *
|
|
|
|
elm_entry_markup_to_utf8(const char *s)
|
|
|
|
{
|
2010-03-24 22:13:59 -07:00
|
|
|
char *ss = _mkup_to_text(s);
|
|
|
|
if (!ss) ss = strdup("");
|
|
|
|
return ss;
|
2009-01-26 16:44:29 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* This converts a UTF-8 string into markup (HTML-like).
|
|
|
|
*
|
|
|
|
* @param s The string (in UTF-8) to be converted
|
|
|
|
* @return The converted string (in markup)
|
|
|
|
*
|
|
|
|
* @ingroup Entry
|
|
|
|
*/
|
2009-01-26 16:44:29 -08:00
|
|
|
EAPI char *
|
|
|
|
elm_entry_utf8_to_markup(const char *s)
|
|
|
|
{
|
2010-03-24 22:13:59 -07:00
|
|
|
char *ss = _text_to_mkup(s);
|
|
|
|
if (!ss) ss = strdup("");
|
|
|
|
return ss;
|
2009-01-26 16:44:29 -08:00
|
|
|
}
|
2010-09-06 23:56:16 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
|