3 typedef struct _E_Widget_Data E_Widget_Data;
8 void (*func) (void *data, void *data2);
13 /* local subsystem functions */
14 static void _e_wid_del_hook(Evas_Object *obj);
15 static void _e_wid_focus_hook(Evas_Object *obj);
16 static void _e_wid_disable_hook(Evas_Object *obj);
17 static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info);
18 static void _e_wid_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
19 static void _e_wid_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
20 static void _e_wid_changed_cb(void *data, Evas_Object *obj, void *event_info);
21 static void _e_wid_keydown(void *data, Evas *e, Evas_Object *obj, void *event_info);
23 /* externally accessible functions */
26 * Creates a new entry widget
28 * @param evas the evas where to add the new entry widget
29 * @param text_location the location where to store the text of the entry.
30 * @param func DOCUMENT ME!
31 * @param data DOCUMENT ME!
32 * @param data2 DOCUMENT ME!
33 * The current value will be used to initialize the entry
34 * @return Returns the new entry widget
37 *e_widget_entry_add(Evas *evas, char **text_location, void (*func) (void *data, void *data2), void *data, void *data2)
41 Evas_Coord minw, minh;
43 obj = e_widget_add(evas);
45 e_widget_del_hook_set(obj, _e_wid_del_hook);
46 e_widget_focus_hook_set(obj, _e_wid_focus_hook);
47 e_widget_disable_hook_set(obj, _e_wid_disable_hook);
49 wd = calloc(1, sizeof(E_Widget_Data));
50 e_widget_data_set(obj, wd);
51 wd->text_location = text_location;
53 o = e_entry_add(evas);
56 e_widget_sub_object_add(obj, o);
57 e_widget_resize_object_set(obj, o);
58 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
59 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _e_wid_in, obj);
60 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _e_wid_out, obj);
61 evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _e_wid_keydown, obj);
63 if ((text_location) && (*text_location))
64 e_entry_text_set(o, *text_location);
66 e_entry_size_min_get(o, &minw, &minh);
67 e_widget_size_min_set(obj, minw, minh);
72 evas_object_smart_callback_add(o, "changed", _e_wid_changed_cb, obj);
78 * Sets the text of the entry widget
80 * @param entry an entry widget
81 * @param text the text to set
84 e_widget_entry_text_set(Evas_Object *entry, const char *text)
88 if (!(entry) || (!(wd = e_widget_data_get(entry))))
90 e_entry_text_set(wd->o_entry, text);
94 * Gets the text of the entry widget
96 * @param entry an entry widget
97 * @return Returns the text of the entry widget
100 e_widget_entry_text_get(Evas_Object *entry)
104 if (!(entry) || (!(wd = e_widget_data_get(entry))))
106 return e_entry_text_get(wd->o_entry);
110 * Clears the entry widget
112 * @param entry an entry widget
115 e_widget_entry_clear(Evas_Object *entry)
119 if (!(entry) || (!(wd = e_widget_data_get(entry))))
121 e_entry_clear(wd->o_entry);
125 * Sets whether or not the entry widget is in password mode. In password mode,
126 * the entry displays '*' instead of the characters
128 * @param entry an entry widget
129 * @param password_mode 1 to turn on password mode, 0 to turn it off
132 e_widget_entry_password_set(Evas_Object *entry, int password_mode)
136 if (!(entry) || (!(wd = e_widget_data_get(entry))))
138 e_entry_password_set(wd->o_entry, password_mode);
142 * Sets whether or not the entry widget is user-editable. This still
143 * allows copying and selecting, just no inserting or deleting of text.
145 * @param entry an entry widget
146 * @param readonly_mode 1 to enable read-only mode, 0 to turn it off
149 e_widget_entry_readonly_set(Evas_Object *entry, int readonly_mode)
153 if (!(entry) || (!(wd = e_widget_data_get(entry))))
157 e_entry_disable(wd->o_entry);
159 e_entry_enable(wd->o_entry);
163 * Gets the editable object of the entry widget. It will allow you to have
164 * better control on the text, the cursor or the selection of the entry with
165 * the e_editable_*() functions.
167 * @param entry an entry widget
168 * @return Returns the editable object of the entry widget
171 e_widget_entry_editable_object_get(Evas_Object *entry)
175 if (!(entry) || (!(wd = e_widget_data_get(entry))))
177 return e_entry_editable_object_get(wd->o_entry);
181 /* Private functions */
184 _e_wid_del_hook(Evas_Object *obj)
188 if (!(obj) || (!(wd = e_widget_data_get(obj))))
194 _e_wid_focus_hook(Evas_Object *obj)
198 if (!(obj) || (!(wd = e_widget_data_get(obj))))
201 if (e_widget_focus_get(obj))
202 e_entry_focus(wd->o_entry);
204 e_entry_unfocus(wd->o_entry);
208 _e_wid_disable_hook(Evas_Object *obj)
212 if (!(obj) || (!(wd = e_widget_data_get(obj))))
215 if (e_widget_disabled_get(obj))
216 e_entry_disable(wd->o_entry);
218 e_entry_enable(wd->o_entry);
222 _e_wid_focus_steal(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
224 e_widget_focus_steal(data);
228 _e_wid_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
232 p = e_widget_pointer_get(data);
233 if (p) e_pointer_type_push(p, data, "entry");
237 _e_wid_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
241 p = e_widget_pointer_get(data);
242 if (p) e_pointer_type_pop(p, data, "entry");
246 _e_wid_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
252 if (!(entry = data) || (!(wd = e_widget_data_get(entry))))
255 if (wd->text_location)
257 text = e_entry_text_get(wd->o_entry);
258 free(*wd->text_location);
259 *wd->text_location = text ? strdup(text) : NULL;
261 e_widget_change(data);
263 if (wd->func) wd->func(wd->data, wd->data2);
267 _e_wid_keydown(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
269 evas_object_smart_callback_call(data, "key_down", event_info);