1 #include <Elementary.h>
7 typedef enum _Multibuttonentry_Pos
9 MULTIBUTTONENTRY_POS_START,
10 MULTIBUTTONENTRY_POS_END,
11 MULTIBUTTONENTRY_POS_BEFORE,
12 MULTIBUTTONENTRY_POS_AFTER,
13 } Multibuttonentry_Pos;
15 typedef enum _Multibuttonentry_Button_State
17 MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
18 MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
19 } Multibuttonentry_Button_State;
22 typedef enum _MultiButtonEntry_Closed_Button_Type
24 MULTIBUTTONENTRY_CLOSED_IMAGE,
25 MULTIBUTTONENTRY_CLOSED_LABEL
26 } MultiButtonEntry_Closed_Button_Type;
28 typedef enum _Multibuttonentry_View_State
30 MULTIBUTTONENTRY_VIEW_NONE,
31 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
32 MULTIBUTTONENTRY_VIEW_ENTRY,
33 MULTIBUTTONENTRY_VIEW_SHRINK
34 } Multibuttonentry_View_State;
36 typedef struct _Widget_Data Widget_Data;
37 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
39 struct _Multibuttonentry_Item
43 Evas_Coord vw, rw; // vw: visual width, real width
48 typedef struct _Elm_Multibuttonentry_Item_Filter
50 Elm_Multibuttonentry_Item_Filter_Cb callback_func;
52 } Elm_Multibuttonentry_Item_Filter;
60 Evas_Object *guidetext;
61 Evas_Object *end; // used to represent the total number of invisible buttons
63 Evas_Object *rect_for_end;
64 MultiButtonEntry_Closed_Button_Type end_type;
68 Eina_List *filter_list;
70 const char *labeltxt, *guidetexttxt;
73 Multibuttonentry_View_State view_state;
75 Evas_Coord w_box, h_box;
78 Eina_Bool last_btn_select: 1;
79 Elm_Multibuttonentry_Item_Filter_Cb add_callback;
80 void *add_callback_data;
83 static const char *widtype = NULL;
84 static void _del_hook(Evas_Object *obj);
85 static void _theme_hook(Evas_Object *obj);
86 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
87 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
88 static void _sizing_eval(Evas_Object *obj);
89 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
90 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
91 static void _event_init(Evas_Object *obj);
92 static void _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink);
93 static void _view_update(Evas_Object *obj);
94 static void _set_label(Evas_Object *obj, const char *str);
95 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
96 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
97 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
98 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
99 static void _del_button_item(Elm_Multibuttonentry_Item *item);
100 static void _select_button(Evas_Object *obj, Evas_Object *btn);
101 static Elm_Object_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data);
102 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
103 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
104 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
107 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
108 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
109 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
110 static void _view_init(Evas_Object *obj);
111 static void _set_vis_guidetext(Evas_Object *obj);
112 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
113 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
114 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
115 static void _item_text_set_hook(Elm_Object_Item *it,
118 static const char *_item_text_get_hook(const Elm_Object_Item *it,
123 * use evas_object_smart_callback_descriptions_set for smart callbacks.
127 _del_hook(Evas_Object *obj)
129 Widget_Data *wd = elm_widget_data_get(obj);
134 Elm_Multibuttonentry_Item *item;
135 EINA_LIST_FREE(wd->items, item)
137 _del_button_obj(obj, item->button);
144 if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
145 if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
146 if (wd->entry) evas_object_del(wd->entry);
147 if (wd->label) evas_object_del(wd->label);
148 if (wd->guidetext) evas_object_del(wd->guidetext);
149 if (wd->end) evas_object_del(wd->end);
150 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
154 _theme_hook(Evas_Object *obj)
156 Widget_Data *wd = elm_widget_data_get(obj);
158 Elm_Multibuttonentry_Item *item;
162 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
163 if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
164 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
166 EINA_LIST_FOREACH(wd->items, l, item)
169 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
170 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
177 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
179 Widget_Data *wd = elm_widget_data_get(obj);
183 if (elm_widget_focus_get(obj))
187 elm_entry_input_panel_show(wd->entry);
189 else if (((!wd->current) || (!eina_list_count(wd->items))))
191 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
193 elm_entry_input_panel_show(wd->entry);
195 wd->focused = EINA_TRUE;
196 evas_object_smart_callback_call(obj, "focused", NULL);
200 wd->focused = EINA_FALSE;
203 elm_entry_input_panel_hide(wd->entry);
204 evas_object_smart_callback_call(obj, "unfocused", NULL);
209 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
215 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
217 Widget_Data *wd = elm_widget_data_get(obj);
220 edje_object_signal_emit(wd->base, emission, source);
224 _sizing_eval(Evas_Object *obj)
226 Widget_Data *wd = elm_widget_data_get(obj);
227 Evas_Coord minw = -1, minh = -1;
228 Evas_Coord left, right, top, bottom;
231 evas_object_size_hint_min_get(wd->box, &minw, &minh);
232 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
233 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
235 minw += (left + right);
236 minh += (top + bottom);
238 evas_object_size_hint_min_set(obj, minw, minh);
242 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
244 Widget_Data *wd = elm_widget_data_get(data);
246 if (!wd || !wd->base) return;
247 wd->focused = EINA_TRUE;
250 elm_entry_input_panel_show(wd->entry);
252 evas_object_smart_callback_call(data, "clicked", NULL);
256 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
258 Evas_Object *eo = (Evas_Object *)data;
259 Widget_Data *wd = elm_widget_data_get(data);
266 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
268 Widget_Data *wd = elm_widget_data_get(data);
272 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
274 if (wd->h_box < h) evas_object_smart_callback_call(data, "expanded", NULL);
275 else if (wd->h_box > h) evas_object_smart_callback_call(data, "contracted", NULL);
284 _event_init(Evas_Object *obj)
286 Widget_Data *wd = elm_widget_data_get(obj);
288 if (!wd || !wd->base) return;
291 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
292 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
297 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
298 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
303 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
304 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
305 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
306 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
307 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
308 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
309 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
314 _set_vis_guidetext(Evas_Object *obj)
316 Widget_Data *wd = elm_widget_data_get(obj);
319 elm_box_unpack(wd->box, wd->guidetext);
320 elm_box_unpack(wd->box, wd->entry);
321 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
323 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
324 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
326 evas_object_hide(wd->entry);
327 elm_box_pack_end(wd->box, wd->guidetext);
328 evas_object_show(wd->guidetext);
329 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
333 evas_object_hide(wd->guidetext);
334 elm_box_pack_end(wd->box, wd->entry);
335 evas_object_show(wd->entry);
336 if (elm_widget_focus_get(obj) || wd->focused)
338 elm_object_focus_set(wd->entry, EINA_TRUE);
339 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
344 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
346 Widget_Data *wd = elm_widget_data_get(obj);
348 Elm_Multibuttonentry_Item *item;
350 if (!wd || !wd->box) return;
351 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
352 evas_object_hide(wd->entry);
353 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
354 evas_object_hide(wd->guidetext);
355 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
357 evas_object_hide(wd->rect_for_end);
358 evas_object_hide(wd->end);
359 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
362 if (shrink == EINA_TRUE)
364 Evas_Coord w = 0, w_tmp = 0;
365 Evas_Coord box_inner_item_width_padding = 0;
367 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
368 // unpack all items and entry
369 elm_box_unpack_all(wd->box);
370 EINA_LIST_FOREACH(wd->items, l, item)
374 evas_object_hide(item->button);
375 item->visible = EINA_FALSE;
378 // pack buttons only 1line
383 elm_box_pack_end(wd->box, wd->label);
384 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
386 w -= box_inner_item_width_padding;
390 int count = eina_list_count(wd->items);
391 Evas_Coord button_min_width = 0;
392 /* Evas_Coord button_min_height = 0; */
393 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
395 const char *size_str;
396 size_str = edje_object_data_get(wd->end, "closed_button_width");
397 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
399 size_str = edje_object_data_get(wd->end, "closed_button_height");
400 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
404 EINA_LIST_FOREACH(wd->items, l, item)
408 int w_label_count = 0;
411 elm_box_pack_end(wd->box, item->button);
412 evas_object_show(item->button);
413 item->visible = EINA_TRUE;
416 w -= box_inner_item_width_padding;
419 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
423 snprintf(buf, sizeof(buf), "... + %d", count);
424 elm_object_text_set(wd->end, buf);
425 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
428 if (w < 0 || w < w_label_count)
430 elm_box_unpack(wd->box, item->button);
431 evas_object_hide(item->button);
432 item->visible = EINA_FALSE;
435 snprintf(buf, sizeof(buf), "... + %d", count);
436 elm_object_text_set(wd->end, buf);
437 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
439 elm_box_pack_end(wd->box, wd->end);
440 evas_object_show(wd->end);
442 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
443 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)1);
447 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
449 if (w < button_min_width)
452 Evas_Coord closed_height = 0;
453 const char *height_str = edje_object_data_get(wd->base, "closed_height");
455 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
456 elm_box_unpack(wd->box, item->button);
457 evas_object_hide(item->button);
458 item->visible = EINA_FALSE;
461 rectSize = w - button_min_width;
462 if (!wd->rect_for_end)
464 Evas *e = evas_object_evas_get(obj);
465 wd->rect_for_end = evas_object_rectangle_add(e);
466 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
468 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
469 elm_box_pack_end(wd->box, wd->rect_for_end);
470 evas_object_show(wd->rect_for_end);
472 elm_box_pack_end(wd->box, wd->end);
473 evas_object_show(wd->end);
475 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
476 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)0);
485 // unpack all items and entry
486 elm_box_unpack_all(wd->box);
487 EINA_LIST_FOREACH(wd->items, l, item)
491 evas_object_hide(item->button);
492 item->visible = EINA_FALSE;
495 evas_object_hide(wd->end);
497 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
499 // pack buttons only 1line
501 if (wd->label) elm_box_pack_end(wd->box, wd->label);
505 EINA_LIST_FOREACH(wd->items, l, item)
509 elm_box_pack_end(wd->box, item->button);
510 evas_object_show(item->button);
511 item->visible = EINA_TRUE;
515 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
516 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)(long)wd->shrink);
518 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
520 _set_vis_guidetext(obj);
525 _view_update(Evas_Object *obj)
527 Evas_Coord width = 1, height = 1;
528 Widget_Data *wd = elm_widget_data_get(obj);
530 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
535 elm_box_unpack(wd->box, wd->label);
536 elm_box_pack_start(wd->box, wd->label);
537 evas_object_size_hint_min_get(wd->label, &width, &height);
542 Evas_Coord guide_text_width = wd->w_box - width;
543 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
546 // update buttons in shrink mode
547 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
548 _shrink_mode_set(obj, EINA_TRUE);
551 _set_vis_guidetext(obj);
555 _set_label(Evas_Object *obj, const char *str)
557 Widget_Data *wd = elm_widget_data_get(obj);
559 if (!wd || !str) return;
560 eina_stringshare_replace(&wd->labeltxt, str);
563 Evas_Coord width, height, sum_width = 0;
564 evas_object_size_hint_min_set(wd->label, 0, 0);
565 evas_object_resize(wd->label, 0, 0);
566 edje_object_part_text_set(wd->label, "mbe.label", str);
568 if (!strcmp(str, ""))
570 /* FIXME: not work yet */
571 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
572 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
577 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
578 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
582 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
585 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
588 evas_object_size_hint_min_set(wd->label, sum_width, height);
590 evas_object_show(wd->label);
595 _set_guidetext(Evas_Object *obj, const char *str)
597 Widget_Data *wd = elm_widget_data_get(obj);
599 if (!wd || !str) return;
601 eina_stringshare_replace(&wd->guidetexttxt, str);
602 if (wd->guidetext == NULL)
603 wd->guidetext = edje_object_add(evas_object_evas_get(obj));
607 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
608 "guidetext", elm_widget_style_get(obj));
609 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
610 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
612 edje_object_part_text_set(wd->guidetext, "elm.text", str);
618 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
620 Widget_Data *wd = elm_widget_data_get(obj);
621 Elm_Multibuttonentry_Item *item = NULL;
625 item = eina_list_data_get(wd->current);
627 if (item && item->button)
631 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
632 edje_object_signal_emit(item->button, "default", "");
635 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
636 edje_object_signal_emit(item->button, "focused", "");
637 evas_object_smart_callback_call(obj, "item,selected", item);
640 edje_object_signal_emit(item->button, "default", "");
648 _change_current_button(Evas_Object *obj, Evas_Object *btn)
650 Widget_Data *wd = elm_widget_data_get(obj);
652 Elm_Multibuttonentry_Item *item;
656 // change the state of previous button to "default"
657 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
659 // change the current
660 EINA_LIST_FOREACH(wd->items, l, item)
662 if (item->button == btn)
668 // change the state of current button to "focused"
669 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
673 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
675 Widget_Data *wd = elm_widget_data_get(data);
677 Elm_Multibuttonentry_Item *item = NULL;
678 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
680 _change_current_button(data, obj);
683 if ((item = eina_list_data_get(wd->current)) != NULL)
685 evas_object_smart_callback_call(data, "item,clicked", item);
686 _select_button(data, item->button);
691 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
693 Widget_Data *wd = elm_widget_data_get(obj);
695 if (!wd || !btn) return;
697 evas_object_del(btn);
701 _del_button_item(Elm_Multibuttonentry_Item *item)
704 Elm_Multibuttonentry_Item *_item;
708 Evas_Object *obj = WIDGET(item);
709 wd = elm_widget_data_get(obj);
711 EINA_LIST_FOREACH(wd->items, l, _item)
715 wd->items = eina_list_remove(wd->items, _item);
716 elm_box_unpack(wd->box, _item->button);
718 evas_object_smart_callback_call(obj, "item,deleted", _item);
720 _del_button_obj(obj, _item->button);
722 if (wd->current == l)
727 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
728 _shrink_mode_set(obj, EINA_TRUE);
730 if (!eina_list_count(wd->items))
731 _set_vis_guidetext(obj);
735 _select_button(Evas_Object *obj, Evas_Object *btn)
737 Widget_Data *wd = elm_widget_data_get(obj);
742 _change_current_button(obj, btn);
743 if (elm_widget_focus_get(obj))
745 elm_object_focus_set(wd->entry, EINA_FALSE);
746 evas_object_focus_set(btn, EINA_TRUE);
751 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
752 if (elm_widget_focus_get(obj))
753 elm_object_focus_set(wd->entry, EINA_TRUE);
758 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
761 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
762 Evas_Coord w_btn = 0, button_max_width = 0;
763 const char *size_str;
765 size_str = edje_object_data_get(btn, "button_max_size");
766 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
768 // decide the size of button
769 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
770 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
771 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
772 w_btn = w_text + 2*padding_outer + 2*padding_inner;
776 if (button_max_width < w_btn)
777 vw = button_max_width;
782 evas_object_resize(btn, vw, h_btn);
783 evas_object_size_hint_min_set(btn, vw, h_btn);
785 if (realw) *realw = rw;
786 if (vieww) *vieww = vw;
790 _item_del_pre_hook(Elm_Object_Item *it)
792 _del_button_item((Elm_Multibuttonentry_Item *)it);
796 static Elm_Object_Item*
797 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
799 Elm_Multibuttonentry_Item *item;
800 Elm_Multibuttonentry_Item_Filter *item_filter;
801 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
804 Evas_Coord width = -1, height = -1;
805 char *str_utf8 = NULL;
806 Widget_Data *wd = elm_widget_data_get(obj);
808 if (!wd || !wd->box || !wd->entry) return NULL;
809 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
810 if (!str) return NULL;
812 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
814 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
818 btn = edje_object_add(evas_object_evas_get(obj));
819 str_utf8 = elm_entry_markup_to_utf8(str);
821 //entry is cleared when text is made to button
822 elm_object_text_set(wd->entry, "");
824 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
825 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
826 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
828 evas_object_size_hint_min_set(btn, width, height);
830 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
831 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
832 evas_object_show(btn);
835 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
838 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
839 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
840 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
841 elm_widget_item_data_set(item, data);
843 _resize_button(btn, &rw, &vw);
847 item->visible = EINA_TRUE;
856 case MULTIBUTTONENTRY_POS_START:
857 wd->items = eina_list_prepend(wd->items, item);
858 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
860 elm_widget_sub_object_add(obj, btn);
861 _shrink_mode_set(obj, EINA_TRUE);
866 elm_box_pack_after(wd->box, btn, wd->label);
868 elm_box_pack_start(wd->box, btn);
869 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
870 _set_vis_guidetext(obj);
873 case MULTIBUTTONENTRY_POS_END:
874 wd->items = eina_list_append(wd->items, item);
875 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
877 elm_widget_sub_object_add(obj, btn);
878 evas_object_hide(btn);
882 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
883 _set_vis_guidetext(obj);
885 elm_box_pack_before(wd->box, btn, wd->entry);
887 elm_box_pack_end(wd->box, btn);
890 case MULTIBUTTONENTRY_POS_BEFORE:
892 wd->items = eina_list_prepend_relative(wd->items, item, reference);
894 wd->items = eina_list_append(wd->items, item);
895 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
897 elm_widget_sub_object_add(obj, btn);
898 evas_object_hide(btn);
899 _shrink_mode_set(obj, EINA_TRUE);
904 elm_box_pack_before(wd->box, btn, reference->button);
907 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
908 _set_vis_guidetext(obj);
910 elm_box_pack_before(wd->box, btn, wd->entry);
912 elm_box_pack_end(wd->box, btn);
916 case MULTIBUTTONENTRY_POS_AFTER:
918 wd->items = eina_list_append_relative(wd->items, item, reference);
920 wd->items = eina_list_append(wd->items, item);
921 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
923 elm_widget_sub_object_add(obj, btn);
924 _shrink_mode_set(obj, EINA_TRUE);
929 elm_box_pack_after(wd->box, btn, reference->button);
932 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
933 _set_vis_guidetext(obj);
935 elm_box_pack_before(wd->box, btn, wd->entry);
937 elm_box_pack_end(wd->box, btn);
945 evas_object_smart_callback_call(obj, "item,added", item);
949 return (Elm_Object_Item *)item;
952 static Elm_Multibuttonentry_Item_Filter*
953 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
955 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
956 if (!item_filter) return NULL;
958 item_filter->callback_func= func;
959 item_filter->data = data;
965 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
971 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
973 Widget_Data *wd = elm_widget_data_get(data);
974 Elm_Multibuttonentry_Item *item = NULL;
976 if (!wd || !wd->base || !wd->box) return;
978 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
980 if (wd->last_btn_select)
983 ((strcmp(ev->keyname, "BackSpace") == 0) ||
984 (strcmp(ev->keyname, "Delete") == 0)))
986 item = eina_list_data_get(wd->current);
989 _del_button_item(item);
990 elm_widget_item_free(item);
991 elm_object_focus_set(wd->entry, EINA_TRUE);
994 else if (((!wd->current && (wd->n_str == 0) &&
995 (strcmp(ev->keyname, "BackSpace") == 0)) ||
996 (strcmp(ev->keyname, "Delete") == 0)))
998 item = eina_list_data_get(eina_list_last(wd->items));
1000 _select_button(data, item->button);
1004 wd->last_btn_select = EINA_TRUE;
1008 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1010 Widget_Data *wd = elm_widget_data_get(data);
1011 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1015 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1016 wd->last_btn_select = EINA_FALSE;
1020 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1022 Widget_Data *wd = elm_widget_data_get(data);
1023 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1026 if (!wd || !wd->base || !wd->box) return;
1028 str = elm_object_text_get(wd->entry);
1030 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1032 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1038 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1040 Widget_Data *wd = elm_widget_data_get(data);
1043 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1044 elm_object_focus_set(wd->entry, EINA_TRUE);
1048 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1050 Widget_Data *wd = elm_widget_data_get(data);
1051 Elm_Multibuttonentry_Item *item = NULL;
1057 item = eina_list_data_get(wd->current);
1058 elm_object_focus_set(wd->entry, EINA_FALSE);
1059 evas_object_focus_set(item->button, EINA_TRUE);
1064 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1066 Widget_Data *wd = elm_widget_data_get(data);
1071 str = elm_object_text_get(wd->entry);
1073 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1077 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1079 Widget_Data *wd = elm_widget_data_get(data);
1084 str = elm_object_text_get(wd->entry);
1085 wd->n_str = strlen(str);
1089 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1091 Evas_Coord en_x, en_y, en_w, en_h;
1092 Evas_Coord bx_x, bx_y;
1094 Widget_Data *wd = elm_widget_data_get(data);
1097 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1098 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1101 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
1106 _view_init(Evas_Object *obj)
1108 Widget_Data *wd = elm_widget_data_get(obj);
1114 wd->box = elm_box_add(obj);
1115 if (!wd->box) return;
1116 elm_widget_sub_object_add(obj, wd->box);
1117 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1118 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1119 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1123 wd->label = edje_object_add(evas_object_evas_get(obj));
1124 if (!wd->label) return;
1125 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1126 _set_label(obj, "");
1127 elm_widget_sub_object_add(obj, wd->label);
1132 wd->entry = elm_entry_add(obj);
1133 if (!wd->entry) return;
1134 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1135 elm_object_text_set(wd->entry, "");
1136 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1137 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1138 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1139 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1140 if (wd->box) elm_box_pack_end(wd->box, wd->entry);
1141 evas_object_show(wd->entry);
1142 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1147 const char *end_type;
1149 end_type = edje_object_data_get(wd->base, "closed_button_type");
1150 if (!end_type || !strcmp(end_type, "label"))
1152 wd->end = elm_label_add(obj);
1153 if (!wd->end) return;
1154 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1155 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1159 const char *size_str;
1160 wd->end = edje_object_add(evas_object_evas_get(obj));
1161 if (!wd->end) return;
1162 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1163 Evas_Coord button_min_width = 0;
1164 Evas_Coord button_min_height = 0;
1166 size_str = edje_object_data_get(wd->end, "closed_button_width");
1167 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1168 size_str = edje_object_data_get(wd->end, "closed_button_height");
1169 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1171 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1172 evas_object_size_hint_min_set(wd->end,
1173 button_min_width * _elm_config->scale,
1174 button_min_height * _elm_config->scale);
1175 elm_widget_sub_object_add(obj, wd->end);
1181 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1183 Evas_Coord minw, minh, mnw, mnh, ww;
1184 Evas_Coord w, cw = 0, cmaxh = 0;
1186 Evas_Object_Box_Option *opt;
1189 /* FIXME: need to calc max */
1193 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1194 evas_object_size_hint_min_get(box, &minw, NULL);
1196 EINA_LIST_FOREACH(priv->children, l, opt)
1198 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1199 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1203 if (mnw != -1 && (w - cw) >= mnw)
1218 if (cmaxh < mnh) cmaxh = mnh;
1223 evas_object_size_hint_min_set(box, minw, minh);
1227 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1229 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1231 Evas_Object_Box_Option *opt;
1232 int local_index = 0;
1235 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1237 EINA_LIST_FOREACH(priv->children, l, opt)
1239 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1240 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1244 if (mnw != -1 && (w - cw) >= mnw)
1254 if (local_index > obj_index) return cmaxh;
1260 if (cmaxh < mnh) cmaxh = mnh;
1269 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1271 Evas_Coord x, y, w, h, xx, yy;
1274 Evas_Coord minw, minh;
1276 Evas_Object_Box_Option *opt;
1278 _calculate_box_min_size(o, priv);
1280 evas_object_geometry_get(o, &x, &y, &w, &h);
1282 evas_object_size_hint_min_get(o, &minw, &minh);
1283 evas_object_size_hint_align_get(o, &ax, &ay);
1286 x = x + ((w - minw) * (1.0 - ax));
1291 y = y + ((h - minh) * (1.0 - ay));
1298 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1300 EINA_LIST_FOREACH(priv->children, l, opt)
1302 Evas_Coord mnw, mnh, mxw, mxh;
1307 evas_object_size_hint_align_get(obj, &ax, &ay);
1308 evas_object_size_hint_weight_get(obj, &wx, &wy);
1309 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1310 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1312 if (ax == -1.0) {fw = 1; ax = 0.5;}
1313 if (ay == -1.0) {fh = 1; ay = 0.5;}
1314 Evas_Coord ww, hh, ow, oh;
1318 if (mnw != -1 && (w - cw) >= mnw)
1325 hh = _calculate_item_max_height(o, priv, obj_index);
1329 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1332 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1341 evas_object_move(obj,
1342 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1343 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1344 evas_object_resize(obj, ow, oh);
1347 if (cmaxh < hh) cmaxh = hh;
1354 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1356 Elm_Multibuttonentry_Item *item;
1357 if (part && strcmp(part, "default")) return;
1359 item = (Elm_Multibuttonentry_Item *)it;
1360 edje_object_part_text_set(item->button, "elm.btn.text", label);
1361 _resize_button(item->button, &item->rw, &item->vw);
1365 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1367 Elm_Multibuttonentry_Item *item;
1368 if (part && strcmp(part, "default")) return NULL;
1369 item = (Elm_Multibuttonentry_Item *)it;
1370 return edje_object_part_text_get(item->button, "elm.btn.text");
1374 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1376 ELM_CHECK_WIDTYPE(obj, widtype);
1377 if (!part || !strcmp(part, "default"))
1379 if (label) _set_label(obj, label);
1380 else _set_label(obj, "");
1382 else if (!strcmp(part, "guide"))
1384 if (label) _set_guidetext(obj, label);
1385 else _set_guidetext(obj, "");
1390 _text_get_hook(const Evas_Object *obj, const char *part)
1392 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1393 Widget_Data *wd = elm_widget_data_get(obj);
1394 if (!wd) return NULL;
1396 if (!part || !strcmp(part, "default"))
1398 return wd->labeltxt;
1400 else if (!strcmp(part, "guide"))
1402 return wd->guidetexttxt;
1408 elm_multibuttonentry_add(Evas_Object *parent)
1414 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1416 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1417 elm_widget_type_set(obj, "multibuttonentry");
1418 elm_widget_sub_object_add(parent, obj);
1419 elm_widget_data_set(obj, wd);
1421 elm_widget_del_hook_set(obj, _del_hook);
1422 elm_widget_theme_hook_set(obj, _theme_hook);
1423 elm_widget_event_hook_set(obj, _event_hook);
1424 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1425 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1426 elm_widget_text_set_hook_set(obj, _text_set_hook);
1427 elm_widget_text_get_hook_set(obj, _text_get_hook);
1429 wd->base = edje_object_add(e);
1430 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1431 elm_widget_resize_object_set(obj, wd->base);
1432 elm_widget_can_focus_set(obj, EINA_TRUE);
1434 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1435 wd->focused = EINA_FALSE;
1436 wd->last_btn_select = EINA_TRUE;
1438 wd->rect_for_end = NULL;
1439 wd->add_callback = NULL;
1440 wd->add_callback_data = NULL;
1449 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1451 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1452 Widget_Data *wd = elm_widget_data_get(obj);
1454 if (!wd) return NULL;
1460 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1462 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1463 Widget_Data *wd = elm_widget_data_get(obj);
1466 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1471 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1473 ELM_CHECK_WIDTYPE(obj, widtype);
1474 Widget_Data *wd = elm_widget_data_get(obj);
1476 if (!wd || !wd->box ||
1477 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1480 _shrink_mode_set(obj, EINA_FALSE);
1482 _shrink_mode_set(obj, EINA_TRUE);
1486 EAPI Elm_Object_Item *
1487 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1489 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
1492 EAPI Elm_Object_Item *
1493 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1495 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
1498 EAPI Elm_Object_Item *
1499 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
1501 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
1504 EAPI Elm_Object_Item *
1505 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
1507 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
1510 EAPI const Eina_List *
1511 elm_multibuttonentry_items_get(const Evas_Object *obj)
1513 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1514 Widget_Data *wd = elm_widget_data_get(obj);
1515 if (!wd) return NULL;
1519 EAPI Elm_Object_Item *
1520 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1522 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1523 Widget_Data *wd = elm_widget_data_get(obj);
1524 if (!wd) return NULL;
1525 return eina_list_data_get(wd->items);
1528 EAPI Elm_Object_Item *
1529 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1531 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1532 Widget_Data *wd = elm_widget_data_get(obj);
1533 if (!wd) return NULL;
1534 return eina_list_data_get(eina_list_last(wd->items));
1537 EAPI Elm_Object_Item *
1538 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1540 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1541 Widget_Data *wd = elm_widget_data_get(obj);
1542 if (!wd) return NULL;
1543 return eina_list_data_get(wd->current);
1547 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1549 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1550 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
1551 if (selected) _select_button(WIDGET(item), item->button);
1552 else _select_button(WIDGET(item), NULL);
1556 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
1558 //TODO : To be implemented.
1559 if (!it) return EINA_FALSE;
1564 elm_multibuttonentry_clear(Evas_Object *obj)
1566 ELM_CHECK_WIDTYPE(obj, widtype);
1567 Elm_Multibuttonentry_Item *item;
1568 Widget_Data *wd = elm_widget_data_get(obj);
1573 EINA_LIST_FREE(wd->items, item)
1575 elm_box_unpack(wd->box, item->button);
1576 _del_button_obj(obj, item->button);
1585 EAPI Elm_Object_Item *
1586 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1588 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1591 Elm_Multibuttonentry_Item *_item;
1593 wd = elm_widget_data_get(WIDGET(it));
1594 if (!wd) return NULL;
1596 EINA_LIST_FOREACH(wd->items, l, _item)
1598 if (_item == (Elm_Multibuttonentry_Item *)it)
1600 l = eina_list_prev(l);
1601 if (!l) return NULL;
1602 return eina_list_data_get(l);
1608 EAPI Elm_Object_Item *
1609 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1611 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1614 Elm_Multibuttonentry_Item *_item;
1615 wd = elm_widget_data_get(WIDGET(it));
1616 if (!wd) return NULL;
1618 EINA_LIST_FOREACH(wd->items, l, _item)
1620 if (_item == (Elm_Multibuttonentry_Item *)it)
1622 l = eina_list_next(l);
1623 if (!l) return NULL;
1624 return eina_list_data_get(l);
1631 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1633 return elm_widget_item_data_get(it);
1637 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1639 return elm_widget_item_data_set(it, data);
1643 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1645 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1646 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1649 Widget_Data *wd = elm_widget_data_get(obj);
1652 ELM_CHECK_WIDTYPE(obj, widtype);
1653 EINA_SAFETY_ON_NULL_RETURN(func);
1655 new_item_filter= _filter_new(func, data);
1656 if (!new_item_filter) return;
1658 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1660 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1662 printf("Already Registered this item filter!!!!\n");
1666 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1670 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1672 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1673 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1675 Widget_Data *wd = elm_widget_data_get(obj);
1678 ELM_CHECK_WIDTYPE(obj, widtype);
1679 EINA_SAFETY_ON_NULL_RETURN(func);
1681 new_item_filter = _filter_new(func, data);
1682 if (!new_item_filter) return;
1684 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1686 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1688 printf("Already Registered this item filter!!!!\n");
1692 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1696 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1700 Elm_Multibuttonentry_Item_Filter *item_filter;
1702 wd = elm_widget_data_get(obj);
1704 EINA_SAFETY_ON_NULL_RETURN(func);
1706 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1708 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1710 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1711 _filter_free(item_filter);