3 typedef struct _E_Widget_Data E_Widget_Data;
11 static void _e_wid_del_hook(Evas_Object *obj);
12 static void _e_wid_focus_hook(Evas_Object *obj);
13 static void _e_wid_do(Evas_Object *obj);
14 static void _e_wid_activate_hook(Evas_Object *obj);
15 static void _e_wid_disable_hook(Evas_Object *obj);
16 static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source);
17 static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info);
19 /* local subsystem functions */
21 /* externally accessible functions */
24 * Creates a check box widget
27 * @param label the text to asign to check widget
28 * @param val pointer to int where changes are stored
29 * @return the newly created evas object
32 e_widget_check_add(Evas *evas, const char *label, int *val)
38 obj = e_widget_add(evas);
40 e_widget_del_hook_set(obj, _e_wid_del_hook);
41 e_widget_focus_hook_set(obj, _e_wid_focus_hook);
42 e_widget_activate_hook_set(obj, _e_wid_activate_hook);
43 e_widget_disable_hook_set(obj, _e_wid_disable_hook);
44 wd = calloc(1, sizeof(E_Widget_Data));
46 e_widget_data_set(obj, wd);
48 o = edje_object_add(evas);
50 e_theme_edje_object_set(o, "base/theme/widgets",
52 edje_object_signal_callback_add(o, "e,action,toggle", "*", _e_wid_signal_cb1, obj);
53 edje_object_part_text_set(o, "e.text.label", label);
55 edje_object_size_min_calc(o, &mw, &mh);
56 e_widget_size_min_set(obj, mw, mh);
59 if (*(wd->valptr)) edje_object_signal_emit(o, "e,state,checked", "e");
62 e_widget_sub_object_add(obj, o);
63 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
64 e_widget_resize_object_set(obj, o);
70 * Sets the value of the check box
72 * @param check the check box widget
73 * @param checked the value to set the widget too
76 e_widget_check_checked_set(Evas_Object *check, int checked)
80 wd = e_widget_data_get(check);
82 *(wd->valptr) = checked;
84 edje_object_signal_emit(wd->o_check, "e,state,checked", "e");
86 edje_object_signal_emit(wd->o_check, "e,state,unchecked", "e");
90 * Sets the value of the check box
92 * @param check the check box widget
93 * @param val pointer to int where changes are stored
96 e_widget_check_valptr_set(Evas_Object *check, int *val)
101 wd = e_widget_data_get(check);
102 state = wd->valptr ? *wd->valptr : 0;
104 if (state == (wd->valptr && *wd->valptr)) return;
105 if (wd->valptr && *wd->valptr)
106 edje_object_signal_emit(wd->o_check, "e,state,checked", "e");
108 edje_object_signal_emit(wd->o_check, "e,state,unchecked", "e");
112 *Get the value of the check box
114 * @param check the check box widget
115 * @return the value of the check box
118 e_widget_check_checked_get(Evas_Object *check)
123 wd = e_widget_data_get(check);
133 * Creates a check box widget with icon
135 * @param evas pointer
136 * @param label the text to asign to check widget
137 * @param icon the path to the icon file
138 * @param icon_w the minimum wdith of the icon
139 * @param icon_h the minumum height of the icon
140 * @param val pointer to int where changes are stored
141 * @return the newly created evas object
144 e_widget_check_icon_add(Evas *evas, const char *label, const char *icon, int icon_w, int icon_h, int *val)
146 Evas_Object *obj, *o, *o2;
150 obj = e_widget_add(evas);
152 e_widget_del_hook_set(obj, _e_wid_del_hook);
153 e_widget_focus_hook_set(obj, _e_wid_focus_hook);
154 e_widget_activate_hook_set(obj, _e_wid_activate_hook);
155 e_widget_disable_hook_set(obj, _e_wid_disable_hook);
156 wd = calloc(1, sizeof(E_Widget_Data));
158 e_widget_data_set(obj, wd);
160 o = edje_object_add(evas);
162 e_theme_edje_object_set(o, "base/theme/widgets",
163 "e/widgets/check_icon");
164 edje_object_signal_callback_add(o, "e,action,toggle", "*", _e_wid_signal_cb1, obj);
165 edje_object_part_text_set(o, "e.text.label", label);
169 edje_object_signal_emit(o, "e,state,labeled", "e");
170 edje_object_message_signal_process(o);
176 o2 = e_icon_add(evas);
177 e_icon_file_set(o2, icon);
181 o2 = edje_object_add(evas);
182 e_util_edje_icon_set(o2, icon);
184 edje_extern_object_min_size_set(o2, icon_w, icon_h);
185 edje_object_part_swallow(wd->o_check, "e.swallow.icon", o2);
186 evas_object_show(o2);
187 e_widget_sub_object_add(obj, o2);
191 edje_object_size_min_calc(o, &mw, &mh);
192 e_widget_size_min_set(obj, mw, mh);
195 if (*(wd->valptr)) edje_object_signal_emit(o, "e,state,checked", "e");
198 e_widget_sub_object_add(obj, o);
199 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
200 e_widget_resize_object_set(obj, o);
206 _e_wid_del_hook(Evas_Object *obj)
210 wd = e_widget_data_get(obj);
215 _e_wid_focus_hook(Evas_Object *obj)
219 wd = e_widget_data_get(obj);
220 if (e_widget_focus_get(obj))
222 edje_object_signal_emit(wd->o_check, "e,state,focused", "e");
223 evas_object_focus_set(wd->o_check, 1);
227 edje_object_signal_emit(wd->o_check, "e,state,unfocused", "e");
228 evas_object_focus_set(wd->o_check, 0);
233 _e_wid_do(Evas_Object *obj)
237 if (e_widget_disabled_get(obj)) return;
239 wd = e_widget_data_get(obj);
242 if (*(wd->valptr) == 0)
245 edje_object_signal_emit(wd->o_check, "e,state,checked", "e");
250 edje_object_signal_emit(wd->o_check, "e,state,unchecked", "e");
253 evas_object_smart_callback_call(obj, "changed", NULL);
254 e_widget_change(obj);
258 _e_wid_activate_hook(Evas_Object *obj)
264 _e_wid_disable_hook(Evas_Object *obj)
268 wd = e_widget_data_get(obj);
269 if (e_widget_disabled_get(obj))
270 edje_object_signal_emit(wd->o_check, "e,state,disabled", "e");
272 edje_object_signal_emit(wd->o_check, "e,state,enabled", "e");
276 _e_wid_signal_cb1(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
282 _e_wid_focus_steal(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
284 e_widget_focus_steal(data);