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_NUM
14 } Multibuttonentry_Pos;
16 typedef enum _Multibuttonentry_Button_State
18 MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
19 MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
20 MULTIBUTTONENTRY_BUTTON_STATE_NUM
21 } Multibuttonentry_Button_State;
23 typedef enum _MultiButtonEntry_Closed_Button_Type
25 MULTIBUTTONENTRY_CLOSED_IMAGE,
26 MULTIBUTTONENTRY_CLOSED_LABEL
27 } MultiButtonEntry_Closed_Button_Type;
29 typedef enum _Multibuttonentry_View_State
31 MULTIBUTTONENTRY_VIEW_NONE,
32 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
33 MULTIBUTTONENTRY_VIEW_ENTRY,
34 MULTIBUTTONENTRY_VIEW_SHRINK
35 } Multibuttonentry_View_State;
37 typedef struct _Widget_Data Widget_Data;
38 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
40 struct _Multibuttonentry_Item
44 Evas_Coord vw, rw; // vw: visual width, real width
48 typedef struct _Elm_Multibuttonentry_Item_Filter
50 Elm_Multibuttonentry_Item_Filter_callback 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;
71 Multibuttonentry_View_State view_state;
73 Evas_Coord w_box, h_box;
76 Eina_Bool last_btn_select: 1;
77 Elm_Multibuttonentry_Item_Filter_callback add_callback;
78 void *add_callback_data;
81 static const char *widtype = NULL;
82 static void _del_hook(Evas_Object *obj);
83 static void _theme_hook(Evas_Object *obj);
84 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
85 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
86 static void _sizing_eval(Evas_Object *obj);
87 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
88 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
89 static void _event_init(Evas_Object *obj);
90 static void _shrink_mode_set(Evas_Object *obj, int shrink);
91 static void _view_update(Evas_Object *obj);
92 static void _set_label(Evas_Object *obj, const char *str);
93 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
94 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
95 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
96 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
97 static void _del_button_item(Elm_Multibuttonentry_Item *item);
98 static void _select_button(Evas_Object *obj, Evas_Object *btn);
99 static Elm_Multibuttonentry_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos,
100 const Elm_Multibuttonentry_Item *reference, void *data);
101 static void _add_button(Evas_Object *obj, const char *str);
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);
117 _del_hook(Evas_Object *obj)
119 Widget_Data *wd = elm_widget_data_get(obj);
124 Elm_Multibuttonentry_Item *item;
125 EINA_LIST_FREE(wd->items, item)
127 _del_button_obj(obj, item->button);
134 if (wd->entry) evas_object_del (wd->entry);
135 if (wd->label) evas_object_del (wd->label);
136 if (wd->guidetext) evas_object_del (wd->guidetext);
137 if (wd->end) evas_object_del (wd->end);
138 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
142 _theme_hook(Evas_Object *obj)
144 Widget_Data *wd = elm_widget_data_get(obj);
146 Elm_Multibuttonentry_Item *item;
150 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
151 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
152 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
154 EINA_LIST_FOREACH(wd->items, l, item)
157 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
158 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
165 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
167 Widget_Data *wd = elm_widget_data_get(obj);
170 if (elm_widget_focus_get(obj))
172 wd->focused = EINA_TRUE;
173 evas_object_smart_callback_call(obj, "focused", NULL);
177 wd->focused = EINA_FALSE;
178 evas_object_smart_callback_call(obj, "unfocused", NULL);
185 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
191 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
193 Widget_Data *wd = elm_widget_data_get(obj);
196 edje_object_signal_emit(wd->base, emission, source);
200 _sizing_eval(Evas_Object *obj)
202 Widget_Data *wd = elm_widget_data_get(obj);
203 Evas_Coord minw = -1, minh = -1;
204 Evas_Coord left, right, top, bottom;
207 evas_object_size_hint_min_get(wd->box, &minw, &minh);
208 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
209 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
211 minw += (left + right);
212 minh += (top + bottom);
214 evas_object_size_hint_min_set(obj, minw, minh);
218 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
220 Widget_Data *wd = elm_widget_data_get(data);
222 if (!wd || !wd->base) return;
223 wd->focused = EINA_TRUE;
226 evas_object_smart_callback_call(data, "clicked", NULL);
230 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
232 Evas_Object *eo = (Evas_Object *)data;
233 Widget_Data *wd = elm_widget_data_get(data);
240 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
242 Widget_Data *wd = elm_widget_data_get(data);
246 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
248 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
249 else if (wd->h_box > h) evas_object_smart_callback_call (data, "shrank", NULL);
258 _event_init(Evas_Object *obj)
260 Widget_Data *wd = elm_widget_data_get(obj);
262 if (!wd || !wd->base) return;
265 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
266 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
271 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
272 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
277 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
278 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
279 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
280 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
281 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
282 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
283 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
288 _set_vis_guidetext(Evas_Object *obj)
290 Widget_Data *wd = elm_widget_data_get(obj);
293 elm_box_unpack(wd->box, wd->guidetext);
294 elm_box_unpack(wd->box, wd->entry);
295 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
297 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
298 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
300 evas_object_hide(wd->entry);
301 elm_box_pack_end(wd->box, wd->guidetext);
302 evas_object_show(wd->guidetext);
303 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
307 evas_object_hide(wd->guidetext);
308 elm_box_pack_end(wd->box, wd->entry);
309 evas_object_show(wd->entry);
310 if (elm_widget_focus_get(obj) || wd->focused)
312 elm_object_focus_set(wd->entry, EINA_TRUE);
313 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
318 _shrink_mode_set(Evas_Object *obj, int shrink)
320 Widget_Data *wd = elm_widget_data_get(obj);
322 Elm_Multibuttonentry_Item *item;
324 if (!wd || !wd->box) return;
325 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
326 evas_object_hide(wd->entry);
327 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
328 evas_object_hide(wd->guidetext);
329 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
331 evas_object_hide(wd->rect_for_end);
332 evas_object_hide(wd->end);
333 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
338 Evas_Coord w=0, w_tmp=0;
339 Evas_Coord box_inner_item_width_padding = 0;
341 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
342 // unpack all items and entry
343 elm_box_unpack_all(wd->box);
344 EINA_LIST_FOREACH(wd->items, l, item)
348 evas_object_hide(item->button);
349 item->visible = EINA_FALSE;
352 // pack buttons only 1line
357 elm_box_pack_end(wd->box, wd->label);
358 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
360 w -= box_inner_item_width_padding;
364 int count = eina_list_count(wd->items);
365 Evas_Coord button_min_width = 0;
366 /* Evas_Coord button_min_height = 0; */
367 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
369 const char *size_str;
370 size_str = edje_object_data_get(wd->end, "closed_button_width");
371 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
373 size_str = edje_object_data_get(wd->end, "closed_button_height");
374 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
378 EINA_LIST_FOREACH(wd->items, l, item)
382 int w_label_count = 0;
385 elm_box_pack_end(wd->box, item->button);
386 evas_object_show(item->button);
387 item->visible = EINA_TRUE;
390 w -= box_inner_item_width_padding;
393 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
397 snprintf(buf, sizeof(buf), "... + %d", count);
398 elm_object_text_set(wd->end, buf);
399 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
402 if (w < 0 || w < w_label_count)
404 elm_box_unpack(wd->box, item->button);
405 evas_object_hide(item->button);
406 item->visible = EINA_FALSE;
409 snprintf(buf, sizeof(buf), "... + %d", count);
410 elm_object_text_set(wd->end, buf);
411 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
413 elm_box_pack_end(wd->box, wd->end);
414 evas_object_show(wd->end);
416 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
417 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
421 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
423 if (w < button_min_width)
426 Evas_Coord closed_height = 0;
427 const char *height_str = edje_object_data_get(wd->base, "closed_height");
429 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
430 elm_box_unpack(wd->box, item->button);
431 evas_object_hide(item->button);
432 item->visible = EINA_FALSE;
435 rectSize = w - button_min_width;
436 if (!wd->rect_for_end)
438 Evas *e = evas_object_evas_get(obj);
439 wd->rect_for_end= evas_object_rectangle_add(e);
440 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
442 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get() );
443 elm_box_pack_end(wd->box, wd->rect_for_end);
444 evas_object_show(wd->rect_for_end);
446 elm_box_pack_end(wd->box, wd->end);
447 evas_object_show(wd->end);
449 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
450 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
459 // unpack all items and entry
460 elm_box_unpack_all(wd->box);
461 EINA_LIST_FOREACH(wd->items, l, item)
465 evas_object_hide(item->button);
466 item->visible = EINA_FALSE;
469 evas_object_hide(wd->end);
471 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
473 // pack buttons only 1line
475 if (wd->label) elm_box_pack_end(wd->box, wd->label);
479 EINA_LIST_FOREACH(wd->items, l, item)
483 elm_box_pack_end(wd->box, item->button);
484 evas_object_show(item->button);
485 item->visible = EINA_TRUE;
489 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
490 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)wd->shrink);
492 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
494 _set_vis_guidetext(obj);
499 _view_update(Evas_Object *obj)
501 Evas_Coord width = 1, height = 1;
502 Widget_Data *wd = elm_widget_data_get(obj);
504 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
509 elm_box_unpack(wd->box, wd->label);
510 elm_box_pack_start(wd->box, wd->label);
511 evas_object_size_hint_min_get(wd->label, &width, &height);
516 Evas_Coord guide_text_width = wd->w_box - width;
517 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
520 // update buttons in shrink mode
521 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
522 _shrink_mode_set(obj, 1);
525 _set_vis_guidetext(obj);
529 _set_label(Evas_Object *obj, const char* str)
531 Widget_Data *wd = elm_widget_data_get(obj);
533 if (!wd || !str) return;
536 Evas_Coord width, height, sum_width = 0;
537 evas_object_size_hint_min_set(wd->label, 0, 0);
538 evas_object_resize(wd->label, 0, 0);
539 edje_object_part_text_set(wd->label, "mbe.label", str);
541 if (!strcmp(str, ""))
543 /* FIXME: not work yet */
544 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
545 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
550 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
551 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
555 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
558 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
561 evas_object_size_hint_min_set(wd->label, sum_width, height);
563 evas_object_show(wd->label);
568 _set_guidetext(Evas_Object *obj, const char* str)
570 Widget_Data *wd = elm_widget_data_get(obj);
572 if (!wd || !str) return;
575 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
576 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
577 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
578 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
581 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
586 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
588 Widget_Data *wd = elm_widget_data_get(obj);
589 Elm_Multibuttonentry_Item *item = NULL;
593 item = eina_list_data_get(wd->current);
595 if (item && item->button)
599 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
600 edje_object_signal_emit(item->button, "default", "");
603 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
604 edje_object_signal_emit(item->button, "focused", "");
605 evas_object_smart_callback_call(obj, "item,selected", item);
608 edje_object_signal_emit(item->button, "default", "");
616 _change_current_button(Evas_Object *obj, Evas_Object *btn)
618 Widget_Data *wd = elm_widget_data_get(obj);
620 Elm_Multibuttonentry_Item *item;
624 // change the state of previous button to "default"
625 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
627 // change the current
628 EINA_LIST_FOREACH(wd->items, l, item)
630 if (item->button == btn)
636 // change the state of current button to "focused"
637 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
641 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
643 Widget_Data *wd = elm_widget_data_get(data);
645 Elm_Multibuttonentry_Item *item = NULL;
646 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
648 _change_current_button(data, obj);
651 if ((item = eina_list_data_get(wd->current)) != NULL)
653 evas_object_smart_callback_call(data, "item,clicked", item);
654 _select_button(data, item->button);
659 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
661 Widget_Data *wd = elm_widget_data_get(obj);
663 if (!wd || !btn) return;
665 evas_object_del(btn);
669 _del_button_item(Elm_Multibuttonentry_Item *item)
672 Elm_Multibuttonentry_Item *_item;
676 Evas_Object *obj = WIDGET(item);
677 wd = elm_widget_data_get(obj);
679 EINA_LIST_FOREACH(wd->items, l, _item)
683 wd->items = eina_list_remove(wd->items, _item);
684 elm_box_unpack(wd->box, _item->button);
686 evas_object_smart_callback_call(obj, "item,deleted", _item);
688 _del_button_obj(obj, _item->button);
691 if (wd->current == l)
696 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
697 _shrink_mode_set(obj, 1);
699 if (!eina_list_count(wd->items))
700 _set_vis_guidetext(obj);
704 _select_button(Evas_Object *obj, Evas_Object *btn)
706 Widget_Data *wd = elm_widget_data_get(obj);
711 _change_current_button(obj, btn);
712 if (elm_widget_focus_get(obj))
714 elm_object_focus_set(wd->entry, EINA_FALSE);
715 evas_object_focus_set(btn, EINA_TRUE);
720 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
721 if (elm_widget_focus_get(obj))
722 elm_object_focus_set(wd->entry, EINA_TRUE);
727 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
730 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
731 Evas_Coord w_btn = 0, button_max_width = 0;
732 const char *size_str;
734 size_str = edje_object_data_get(btn, "button_max_size");
735 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
737 // decide the size of button
738 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
739 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
740 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
741 w_btn = w_text + 2*padding_outer + 2*padding_inner;
745 if (button_max_width < w_btn)
746 vw = button_max_width;
751 evas_object_resize(btn, vw, h_btn);
752 evas_object_size_hint_min_set(btn, vw, h_btn);
754 if (realw) *realw = rw;
755 if (vieww) *vieww = vw;
758 static Elm_Multibuttonentry_Item*
759 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
761 Elm_Multibuttonentry_Item *item;
762 Elm_Multibuttonentry_Item_Filter *item_filter;
765 Evas_Coord width = -1, height = -1;
766 char *str_utf8 = NULL;
767 Widget_Data *wd = elm_widget_data_get(obj);
769 if (!wd || !wd->box || !wd->entry) return NULL;
771 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
773 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
777 btn = edje_object_add(evas_object_evas_get(obj));
778 str_utf8 = elm_entry_markup_to_utf8(str);
780 //entry is cleared when text is made to button
781 elm_object_text_set(wd->entry, "");
783 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
784 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
785 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
787 evas_object_size_hint_min_set(btn, width, height);
789 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
790 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
791 evas_object_show(btn);
794 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
797 elm_widget_item_data_set(item, data);
799 _resize_button(btn, &rw, &vw);
803 item->visible = EINA_TRUE;
807 case MULTIBUTTONENTRY_POS_START:
808 wd->items = eina_list_prepend(wd->items, item);
809 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
811 elm_widget_sub_object_add(obj, btn);
812 _shrink_mode_set(obj, 1);
817 elm_box_pack_after(wd->box, btn, wd->label);
819 elm_box_pack_start(wd->box, btn);
820 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
821 _set_vis_guidetext(obj);
824 case MULTIBUTTONENTRY_POS_END:
825 wd->items = eina_list_append(wd->items, item);
826 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
828 elm_widget_sub_object_add(obj, btn);
829 evas_object_hide(btn);
833 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
834 _set_vis_guidetext(obj);
836 elm_box_pack_before(wd->box, btn, wd->entry);
838 elm_box_pack_end(wd->box, btn);
841 case MULTIBUTTONENTRY_POS_BEFORE:
843 wd->items = eina_list_prepend_relative(wd->items, item, reference);
845 wd->items = eina_list_append(wd->items, item);
846 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
848 elm_widget_sub_object_add(obj, btn);
849 evas_object_hide(btn);
850 _shrink_mode_set(obj, 1);
855 elm_box_pack_before(wd->box, btn, reference->button);
858 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
859 _set_vis_guidetext(obj);
861 elm_box_pack_before(wd->box, btn, wd->entry);
863 elm_box_pack_end(wd->box, btn);
867 case MULTIBUTTONENTRY_POS_AFTER:
869 wd->items = eina_list_append_relative(wd->items, item, reference);
871 wd->items = eina_list_append(wd->items, item);
872 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
874 elm_widget_sub_object_add(obj, btn);
875 _shrink_mode_set(obj, 1);
880 elm_box_pack_after(wd->box, btn, reference->button);
883 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
884 _set_vis_guidetext(obj);
886 elm_box_pack_before(wd->box, btn, wd->entry);
888 elm_box_pack_end(wd->box, btn);
896 evas_object_smart_callback_call(obj, "item,added", item);
904 _add_button(Evas_Object *obj, const char *str)
906 Widget_Data *wd = elm_widget_data_get(obj);
909 _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
912 static Elm_Multibuttonentry_Item_Filter*
913 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
915 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
916 if (!item_filter) return NULL;
918 item_filter->callback_func= func;
919 item_filter->data = data;
925 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
931 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
933 Widget_Data *wd = elm_widget_data_get(data);
934 Elm_Multibuttonentry_Item *item = NULL;
936 if (!wd || !wd->base || !wd->box) return;
938 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
940 if (wd->last_btn_select)
943 ((strcmp(ev->keyname, "BackSpace") == 0) ||
944 (strcmp(ev->keyname, "BackSpace (") == 0)))
946 item = eina_list_data_get(wd->current);
949 _del_button_item(item);
950 elm_object_focus_set(wd->entry, EINA_TRUE);
953 else if (((!wd->current && (wd->n_str == 0) &&
954 (strcmp(ev->keyname, "BackSpace") == 0)) ||
955 (strcmp(ev->keyname, "BackSpace (") == 0)))
957 item = eina_list_data_get(eina_list_last(wd->items));
959 _select_button(data, item->button);
963 wd->last_btn_select = EINA_TRUE;
967 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
969 Widget_Data *wd = elm_widget_data_get(data);
970 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
974 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
975 wd->last_btn_select = EINA_FALSE;
979 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
981 Widget_Data *wd = elm_widget_data_get(data);
982 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
985 if (!wd || !wd->base || !wd->box) return;
987 str = elm_object_text_get(wd->entry);
989 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
991 _add_button(data, str);
997 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
999 Widget_Data *wd = elm_widget_data_get(data);
1002 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1003 elm_object_focus_set(wd->entry, EINA_TRUE);
1007 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1009 Widget_Data *wd = elm_widget_data_get(data);
1010 Elm_Multibuttonentry_Item *item = NULL;
1016 item = eina_list_data_get(wd->current);
1017 elm_object_focus_set(wd->entry, EINA_FALSE);
1018 evas_object_focus_set(item->button, EINA_TRUE);
1023 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1025 Widget_Data *wd = elm_widget_data_get(data);
1030 str = elm_object_text_get(wd->entry);
1032 _add_button(data, str);
1036 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1038 Widget_Data *wd = elm_widget_data_get(data);
1043 str = elm_object_text_get(wd->entry);
1044 wd->n_str = strlen(str);
1048 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1050 Evas_Coord en_x, en_y, en_w, en_h;
1051 Evas_Coord bx_x, bx_y;
1053 Widget_Data *wd = elm_widget_data_get(data);
1056 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1057 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1059 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w, en_h, EINA_TRUE);
1063 _view_init(Evas_Object *obj)
1065 Widget_Data *wd = elm_widget_data_get(obj);
1071 wd->box = elm_box_add (obj);
1072 if (!wd->box) return;
1073 elm_widget_sub_object_add(obj, wd->box);
1074 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1075 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1076 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1080 wd->label = edje_object_add(evas_object_evas_get(obj));
1081 if (!wd->label) return;
1082 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1083 _set_label(obj, "");
1084 elm_widget_sub_object_add(obj, wd->label);
1089 wd->entry = elm_entry_add (obj);
1090 if (!wd->entry) return;
1091 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1092 elm_object_text_set(wd->entry, "");
1093 elm_entry_cursor_end_set(wd->entry);
1094 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1095 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1096 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1097 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1098 evas_object_show(wd->entry);
1099 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1104 const char *end_type;
1106 end_type = edje_object_data_get(wd->base, "closed_button_type");
1107 if (!end_type || !strcmp(end_type, "label"))
1109 wd->end = elm_label_add (obj);
1110 if (!wd->end) return;
1111 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1112 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1116 const char *size_str;
1117 wd->end = edje_object_add(evas_object_evas_get(obj));
1118 if (!wd->end) return;
1119 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1120 Evas_Coord button_min_width = 0;
1121 Evas_Coord button_min_height = 0;
1123 size_str = edje_object_data_get(wd->end, "closed_button_width");
1124 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1125 size_str = edje_object_data_get(wd->end, "closed_button_height");
1126 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1128 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1129 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1130 elm_widget_sub_object_add(obj, wd->end);
1136 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1138 Evas_Coord minw, minh, mnw, mnh, ww;
1139 Evas_Coord w, cw = 0, cmaxh = 0;
1141 Evas_Object_Box_Option *opt;
1144 /* FIXME: need to calc max */
1148 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1149 evas_object_size_hint_min_get(box, &minw, NULL);
1151 EINA_LIST_FOREACH(priv->children, l, opt)
1153 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1154 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1158 if (mnw != -1 && (w - cw) >= mnw)
1173 if (cmaxh < mnh) cmaxh = mnh;
1178 evas_object_size_hint_min_set(box, minw, minh);
1182 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1184 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1186 Evas_Object_Box_Option *opt;
1190 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1192 EINA_LIST_FOREACH(priv->children, l, opt)
1194 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1195 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1199 if (mnw != -1 && (w - cw) >= mnw)
1209 if (index > obj_index) return cmaxh;
1215 if (cmaxh < mnh) cmaxh = mnh;
1224 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1226 Evas_Coord x, y, w, h, xx, yy;
1229 Evas_Coord minw, minh;
1231 Evas_Object_Box_Option *opt;
1233 _calculate_box_min_size(o, priv);
1235 evas_object_geometry_get(o, &x, &y, &w, &h);
1237 evas_object_size_hint_min_get(o, &minw, &minh);
1238 evas_object_size_hint_align_get(o, &ax, &ay);
1241 x = x + ((w - minw) * (1.0 - ax));
1246 y = y + ((h - minh) * (1.0 - ay));
1253 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1255 EINA_LIST_FOREACH(priv->children, l, opt)
1257 Evas_Coord mnw, mnh, mxw, mxh;
1262 evas_object_size_hint_align_get(obj, &ax, &ay);
1263 evas_object_size_hint_weight_get(obj, &wx, &wy);
1264 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1265 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1267 if (ax == -1.0) {fw = 1; ax = 0.5;}
1268 if (ay == -1.0) {fh = 1; ay = 0.5;}
1269 Evas_Coord ww, hh, ow, oh;
1273 if (mnw != -1 && (w - cw) >= mnw)
1280 hh = _calculate_item_max_height(o, priv, obj_index);
1284 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1287 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1296 evas_object_move(obj,
1297 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1298 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1299 evas_object_resize(obj, ow, oh);
1302 if (cmaxh < hh) cmaxh = hh;
1309 elm_multibuttonentry_add(Evas_Object *parent)
1315 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1317 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1318 elm_widget_type_set(obj, "multibuttonentry");
1319 elm_widget_sub_object_add(parent, obj);
1320 elm_widget_data_set(obj, wd);
1322 elm_widget_del_hook_set(obj, _del_hook);
1323 elm_widget_theme_hook_set(obj, _theme_hook);
1324 elm_widget_event_hook_set(obj, _event_hook);
1325 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1326 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1328 wd->base = edje_object_add(e);
1329 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1330 elm_widget_resize_object_set(obj, wd->base);
1331 elm_widget_can_focus_set(obj, EINA_TRUE);
1333 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1334 wd->focused = EINA_FALSE;
1335 wd->last_btn_select = EINA_TRUE;
1337 wd->rect_for_end= NULL;
1338 wd->add_callback = NULL;
1339 wd->add_callback_data = NULL;
1348 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1350 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1351 Widget_Data *wd = elm_widget_data_get(obj);
1353 if (!wd) return NULL;
1359 elm_multibuttonentry_label_get(const Evas_Object *obj)
1361 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1362 Widget_Data *wd = elm_widget_data_get(obj);
1364 if (!wd) return NULL;
1365 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1370 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1372 ELM_CHECK_WIDTYPE(obj, widtype);
1373 Widget_Data *wd = elm_widget_data_get(obj);
1377 _set_label(obj, label);
1379 _set_label(obj, "");
1383 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1385 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1386 Widget_Data *wd = elm_widget_data_get(obj);
1388 if (!wd) return NULL;
1389 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1394 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1396 ELM_CHECK_WIDTYPE(obj, widtype);
1397 Widget_Data *wd = elm_widget_data_get(obj);
1401 _set_guidetext(obj, guidetext);
1403 _set_guidetext(obj, "");
1407 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1409 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1410 Widget_Data *wd = elm_widget_data_get(obj);
1413 return wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? 1 : 0;
1417 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1419 ELM_CHECK_WIDTYPE(obj, widtype);
1420 Widget_Data *wd = elm_widget_data_get(obj);
1422 if (!wd || !wd->box ||
1423 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? 1 : 0) == shrink) return;
1424 _shrink_mode_set(obj, shrink);
1427 EAPI Elm_Object_Item *
1428 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1430 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1431 Elm_Multibuttonentry_Item *item;
1432 if (!label) return NULL;
1433 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1434 return (Elm_Object_Item *) item;
1437 EAPI Elm_Object_Item *
1438 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1440 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1441 Elm_Multibuttonentry_Item *item;
1442 if (!label) return NULL;
1443 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1444 return (Elm_Object_Item *) item;
1447 EAPI Elm_Object_Item *
1448 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1450 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1451 Elm_Multibuttonentry_Item *item;
1452 if (!label) return NULL;
1453 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE,
1454 (Elm_Multibuttonentry_Item *) before, data);
1455 return (Elm_Object_Item *) item;
1458 EAPI Elm_Object_Item *
1459 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
1461 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1462 Elm_Multibuttonentry_Item *item;
1463 if (!label) return NULL;
1464 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER,
1465 (Elm_Multibuttonentry_Item *) after, data);
1466 return (Elm_Object_Item *) item;
1469 EAPI const Eina_List *
1470 elm_multibuttonentry_items_get(const Evas_Object *obj)
1472 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1473 Widget_Data *wd = elm_widget_data_get(obj);
1474 if (!wd) return NULL;
1478 EAPI Elm_Object_Item *
1479 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1481 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1482 Widget_Data *wd = elm_widget_data_get(obj);
1483 if (!wd) return NULL;
1484 return eina_list_data_get(wd->items);
1487 EAPI Elm_Object_Item *
1488 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1490 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1491 Widget_Data *wd = elm_widget_data_get(obj);
1492 if (!wd) return NULL;
1493 return eina_list_data_get(eina_list_last(wd->items));
1496 EAPI Elm_Object_Item *
1497 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1499 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1500 Widget_Data *wd = elm_widget_data_get(obj);
1501 if (!wd) return NULL;
1502 return eina_list_data_get(wd->current);
1506 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
1508 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1509 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1510 if (selected) _select_button(WIDGET(item), item->button);
1511 else _select_button(WIDGET(item), NULL);
1515 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1517 ELM_CHECK_WIDTYPE(obj, widtype);
1518 Widget_Data *wd = elm_widget_data_get(obj);
1520 _select_button(obj, NULL);
1524 elm_multibuttonentry_clear(Evas_Object *obj)
1526 ELM_CHECK_WIDTYPE(obj, widtype);
1527 Elm_Multibuttonentry_Item *item;
1528 Widget_Data *wd = elm_widget_data_get(obj);
1533 EINA_LIST_FREE(wd->items, item)
1535 elm_box_unpack(wd->box, item->button);
1536 _del_button_obj(obj, item->button);
1546 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1548 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1549 _del_button_item((Elm_Multibuttonentry_Item *) it);
1553 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1555 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1556 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1557 return edje_object_part_text_get(item->button, "elm.btn.text");
1561 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1563 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1564 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1566 edje_object_part_text_set(item->button, "elm.btn.text", str);
1567 _resize_button(item->button, &item->rw, &item->vw);
1570 EAPI Elm_Object_Item *
1571 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1573 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1576 Elm_Multibuttonentry_Item *_item;
1578 wd = elm_widget_data_get(WIDGET(it));
1579 if (!wd) return NULL;
1581 EINA_LIST_FOREACH(wd->items, l, _item)
1583 if (_item == (Elm_Multibuttonentry_Item *) it)
1585 l = eina_list_prev(l);
1586 if (!l) return NULL;
1587 return eina_list_data_get(l);
1593 EAPI Elm_Object_Item *
1594 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1596 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1599 Elm_Multibuttonentry_Item *_item;
1600 wd = elm_widget_data_get(WIDGET(it));
1601 if (!wd) return NULL;
1603 EINA_LIST_FOREACH(wd->items, l, _item)
1605 if (_item == (Elm_Multibuttonentry_Item *) it)
1607 l = eina_list_next(l);
1608 if (!l) return NULL;
1609 return eina_list_data_get(l);
1616 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1618 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1619 return elm_widget_item_data_get(it);
1623 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1625 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1626 return elm_widget_item_data_set(it, data);
1630 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1632 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1633 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1636 Widget_Data *wd = elm_widget_data_get(obj);
1639 ELM_CHECK_WIDTYPE(obj, widtype);
1640 EINA_SAFETY_ON_NULL_RETURN(func);
1642 new_item_filter= _filter_new(func, data);
1643 if (!new_item_filter) return;
1645 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1647 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1649 printf("Already Registered this item filter!!!!\n");
1653 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1657 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1659 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1660 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1662 Widget_Data *wd = elm_widget_data_get(obj);
1665 ELM_CHECK_WIDTYPE(obj, widtype);
1666 EINA_SAFETY_ON_NULL_RETURN(func);
1668 new_item_filter = _filter_new(func, data);
1669 if (!new_item_filter) return;
1671 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1673 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1675 printf("Already Registered this item filter!!!!\n");
1679 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1683 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1687 Elm_Multibuttonentry_Item_Filter *item_filter;
1689 wd = elm_widget_data_get(obj);
1691 EINA_SAFETY_ON_NULL_RETURN(func);
1693 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1695 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1697 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1698 _filter_free(item_filter);