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 struct _Multibuttonentry_Item
42 Evas_Coord vw, rw; // vw: visual width, real width
46 typedef struct _Elm_Multibuttonentry_Item_Filter
48 Elm_Multibuttonentry_Item_Filter_callback callback_func;
50 } Elm_Multibuttonentry_Item_Filter;
52 typedef struct _Widget_Data Widget_Data;
59 Evas_Object *guidetext;
60 Evas_Object *end; // used to represent the total number of invisible buttons
62 Evas_Object *rect_for_end;
63 MultiButtonEntry_Closed_Button_Type end_type;
67 Eina_List *filter_list;
70 Multibuttonentry_View_State view_state;
72 Evas_Coord w_box, h_box;
75 Eina_Bool last_btn_select: 1;
76 Elm_Multibuttonentry_Item_Filter_callback add_callback;
77 void *add_callback_data;
80 static const char *widtype = NULL;
81 static void _del_hook(Evas_Object *obj);
82 static void _theme_hook(Evas_Object *obj);
83 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
84 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
85 static void _sizing_eval(Evas_Object *obj);
86 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
87 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
88 static void _event_init(Evas_Object *obj);
89 static void _shrink_mode_set(Evas_Object *obj, int shrink);
90 static void _view_update(Evas_Object *obj);
91 static void _set_label(Evas_Object *obj, const char *str);
92 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
93 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
94 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
95 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
96 static void _del_button_item(Elm_Multibuttonentry_Item *item);
97 static void _select_button(Evas_Object *obj, Evas_Object *btn);
98 static Elm_Multibuttonentry_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos,
99 const Elm_Multibuttonentry_Item *reference, void *data);
100 static void _add_button(Evas_Object *obj, const char *str);
101 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
102 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
103 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
104 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
106 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
107 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
108 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
109 static void _view_init(Evas_Object *obj);
110 static void _set_vis_guidetext(Evas_Object *obj);
111 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
112 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
113 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
116 _del_hook(Evas_Object *obj)
118 Widget_Data *wd = elm_widget_data_get(obj);
123 Elm_Multibuttonentry_Item *item;
124 EINA_LIST_FREE(wd->items, item)
126 _del_button_obj(obj, item->button);
133 if (wd->entry) evas_object_del (wd->entry);
134 if (wd->label) evas_object_del (wd->label);
135 if (wd->guidetext) evas_object_del (wd->guidetext);
136 if (wd->end) evas_object_del (wd->end);
137 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
141 _theme_hook(Evas_Object *obj)
143 Widget_Data *wd = elm_widget_data_get(obj);
145 Elm_Multibuttonentry_Item *item;
149 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
150 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
151 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
153 EINA_LIST_FOREACH(wd->items, l, item)
156 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
157 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
164 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
166 Widget_Data *wd = elm_widget_data_get(obj);
169 if (elm_widget_focus_get(obj))
171 wd->focused = EINA_TRUE;
172 evas_object_smart_callback_call(obj, "focused", NULL);
176 wd->focused = EINA_FALSE;
177 evas_object_smart_callback_call(obj, "unfocused", NULL);
184 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
190 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
192 Widget_Data *wd = elm_widget_data_get(obj);
195 edje_object_signal_emit(wd->base, emission, source);
199 _sizing_eval(Evas_Object *obj)
201 Widget_Data *wd = elm_widget_data_get(obj);
202 Evas_Coord minw = -1, minh = -1;
203 Evas_Coord left, right, top, bottom;
206 evas_object_size_hint_min_get(wd->box, &minw, &minh);
207 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
208 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
210 minw += (left + right);
211 minh += (top + bottom);
213 evas_object_size_hint_min_set(obj, minw, minh);
217 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
219 Widget_Data *wd = elm_widget_data_get(data);
221 if (!wd || !wd->base) return;
222 wd->focused = EINA_TRUE;
225 evas_object_smart_callback_call(data, "clicked", NULL);
229 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
231 Evas_Object *eo = (Evas_Object *)data;
232 Widget_Data *wd = elm_widget_data_get(data);
239 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
241 Widget_Data *wd = elm_widget_data_get(data);
245 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
247 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
248 else if (wd->h_box > h) evas_object_smart_callback_call (data, "shrank", NULL);
257 _event_init(Evas_Object *obj)
259 Widget_Data *wd = elm_widget_data_get(obj);
261 if (!wd || !wd->base) return;
264 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
265 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
270 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
271 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
276 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
277 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
278 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
279 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
280 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
281 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
282 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
287 _set_vis_guidetext(Evas_Object *obj)
289 Widget_Data *wd = elm_widget_data_get(obj);
292 elm_box_unpack(wd->box, wd->guidetext);
293 elm_box_unpack(wd->box, wd->entry);
294 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
296 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
297 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
299 evas_object_hide(wd->entry);
300 elm_box_pack_end(wd->box, wd->guidetext);
301 evas_object_show(wd->guidetext);
302 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
306 evas_object_hide(wd->guidetext);
307 elm_box_pack_end(wd->box, wd->entry);
308 evas_object_show(wd->entry);
309 if (elm_widget_focus_get(obj) || wd->focused)
311 elm_object_focus_set(wd->entry, EINA_TRUE);
312 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
317 _shrink_mode_set(Evas_Object *obj, int shrink)
319 Widget_Data *wd = elm_widget_data_get(obj);
321 Elm_Multibuttonentry_Item *item;
323 if (!wd || !wd->box) return;
324 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
325 evas_object_hide(wd->entry);
326 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
327 evas_object_hide(wd->guidetext);
328 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
330 evas_object_hide(wd->rect_for_end);
331 evas_object_hide(wd->end);
332 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
337 Evas_Coord w=0, w_tmp=0;
338 Evas_Coord box_inner_item_width_padding = 0;
340 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
341 // unpack all items and entry
342 elm_box_unpack_all(wd->box);
343 EINA_LIST_FOREACH(wd->items, l, item)
347 evas_object_hide(item->button);
348 item->visible = EINA_FALSE;
351 // pack buttons only 1line
356 elm_box_pack_end(wd->box, wd->label);
357 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
359 w -= box_inner_item_width_padding;
363 int count = eina_list_count(wd->items);
364 Evas_Coord button_min_width = 0;
365 /* Evas_Coord button_min_height = 0; */
366 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
368 const char *size_str;
369 size_str = edje_object_data_get(wd->end, "closed_button_width");
370 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
372 size_str = edje_object_data_get(wd->end, "closed_button_height");
373 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
377 EINA_LIST_FOREACH(wd->items, l, item)
381 int w_label_count = 0;
384 elm_box_pack_end(wd->box, item->button);
385 evas_object_show(item->button);
386 item->visible = EINA_TRUE;
389 w -= box_inner_item_width_padding;
392 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
396 snprintf(buf, sizeof(buf), "... + %d", count);
397 elm_object_text_set(wd->end, buf);
398 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
401 if (w < 0 || w < w_label_count)
403 elm_box_unpack(wd->box, item->button);
404 evas_object_hide(item->button);
405 item->visible = EINA_FALSE;
408 snprintf(buf, sizeof(buf), "... + %d", count);
409 elm_object_text_set(wd->end, buf);
410 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
412 elm_box_pack_end(wd->box, wd->end);
413 evas_object_show(wd->end);
415 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
416 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
420 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
422 if (w < button_min_width)
425 Evas_Coord closed_height = 0;
426 const char *height_str = edje_object_data_get(wd->base, "closed_height");
428 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
429 elm_box_unpack(wd->box, item->button);
430 evas_object_hide(item->button);
431 item->visible = EINA_FALSE;
434 rectSize = w - button_min_width;
435 if (!wd->rect_for_end)
437 Evas *e = evas_object_evas_get(obj);
438 wd->rect_for_end= evas_object_rectangle_add(e);
439 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
441 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get() );
442 elm_box_pack_end(wd->box, wd->rect_for_end);
443 evas_object_show(wd->rect_for_end);
445 elm_box_pack_end(wd->box, wd->end);
446 evas_object_show(wd->end);
448 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
449 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
458 // unpack all items and entry
459 elm_box_unpack_all(wd->box);
460 EINA_LIST_FOREACH(wd->items, l, item)
464 evas_object_hide(item->button);
465 item->visible = EINA_FALSE;
468 evas_object_hide(wd->end);
470 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
472 // pack buttons only 1line
474 if (wd->label) elm_box_pack_end(wd->box, wd->label);
478 EINA_LIST_FOREACH(wd->items, l, item)
482 elm_box_pack_end(wd->box, item->button);
483 evas_object_show(item->button);
484 item->visible = EINA_TRUE;
488 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
489 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)wd->shrink);
491 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
493 _set_vis_guidetext(obj);
498 _view_update(Evas_Object *obj)
500 Evas_Coord width = 1, height = 1;
501 Widget_Data *wd = elm_widget_data_get(obj);
503 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
508 elm_box_unpack(wd->box, wd->label);
509 elm_box_pack_start(wd->box, wd->label);
510 evas_object_size_hint_min_get(wd->label, &width, &height);
515 Evas_Coord guide_text_width = wd->w_box - width;
516 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
519 // update buttons in shrink mode
520 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
521 _shrink_mode_set(obj, 1);
524 _set_vis_guidetext(obj);
528 _set_label(Evas_Object *obj, const char* str)
530 Widget_Data *wd = elm_widget_data_get(obj);
532 if (!wd || !str) return;
535 Evas_Coord width, height, sum_width = 0;
536 evas_object_size_hint_min_set(wd->label, 0, 0);
537 evas_object_resize(wd->label, 0, 0);
538 edje_object_part_text_set(wd->label, "mbe.label", str);
540 if (!strcmp(str, ""))
542 /* FIXME: not work yet */
543 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
544 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
549 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
550 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
554 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
557 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
560 evas_object_size_hint_min_set(wd->label, sum_width, height);
562 evas_object_show(wd->label);
567 _set_guidetext(Evas_Object *obj, const char* str)
569 Widget_Data *wd = elm_widget_data_get(obj);
571 if (!wd || !str) return;
574 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
575 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
576 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
577 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
580 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
585 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
587 Widget_Data *wd = elm_widget_data_get(obj);
588 Elm_Multibuttonentry_Item *item = NULL;
592 item = eina_list_data_get(wd->current);
594 if (item && item->button)
598 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
599 edje_object_signal_emit(item->button, "default", "");
602 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
603 edje_object_signal_emit(item->button, "focused", "");
604 evas_object_smart_callback_call(obj, "item,selected", item);
607 edje_object_signal_emit(item->button, "default", "");
615 _change_current_button(Evas_Object *obj, Evas_Object *btn)
617 Widget_Data *wd = elm_widget_data_get(obj);
619 Elm_Multibuttonentry_Item *item;
623 // change the state of previous button to "default"
624 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
626 // change the current
627 EINA_LIST_FOREACH(wd->items, l, item)
629 if (item->button == btn)
635 // change the state of current button to "focused"
636 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
640 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
642 Widget_Data *wd = elm_widget_data_get(data);
644 Elm_Multibuttonentry_Item *item = NULL;
645 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
647 _change_current_button(data, obj);
650 if ((item = eina_list_data_get(wd->current)) != NULL)
652 evas_object_smart_callback_call(data, "item,clicked", item);
653 _select_button(data, item->button);
658 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
660 Widget_Data *wd = elm_widget_data_get(obj);
662 if (!wd || !btn) return;
664 evas_object_del(btn);
668 _del_button_item(Elm_Multibuttonentry_Item *item)
671 Elm_Multibuttonentry_Item *_item;
675 Evas_Object *obj = WIDGET(item);
676 wd = elm_widget_data_get(obj);
678 EINA_LIST_FOREACH(wd->items, l, _item)
682 wd->items = eina_list_remove(wd->items, _item);
683 elm_box_unpack(wd->box, _item->button);
685 evas_object_smart_callback_call(obj, "item,deleted", _item);
687 _del_button_obj(obj, _item->button);
690 if (wd->current == l)
695 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
696 _shrink_mode_set(obj, 1);
698 if (!eina_list_count(wd->items))
699 _set_vis_guidetext(obj);
703 _select_button(Evas_Object *obj, Evas_Object *btn)
705 Widget_Data *wd = elm_widget_data_get(obj);
710 _change_current_button(obj, btn);
711 if (elm_widget_focus_get(obj))
713 elm_object_focus_set(wd->entry, EINA_FALSE);
714 evas_object_focus_set(btn, EINA_TRUE);
719 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
720 if (elm_widget_focus_get(obj))
721 elm_object_focus_set(wd->entry, EINA_TRUE);
726 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
729 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
730 Evas_Coord w_btn = 0, button_max_width = 0;
731 const char *size_str;
733 size_str = edje_object_data_get(btn, "button_max_size");
734 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
736 // decide the size of button
737 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
738 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
739 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
740 w_btn = w_text + 2*padding_outer + 2*padding_inner;
744 if (button_max_width < w_btn)
745 vw = button_max_width;
750 evas_object_resize(btn, vw, h_btn);
751 evas_object_size_hint_min_set(btn, vw, h_btn);
753 if (realw) *realw = rw;
754 if (vieww) *vieww = vw;
757 static Elm_Multibuttonentry_Item*
758 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
760 Elm_Multibuttonentry_Item *item;
761 Elm_Multibuttonentry_Item_Filter *item_filter;
764 Evas_Coord width = -1, height = -1;
765 char *str_utf8 = NULL;
766 Widget_Data *wd = elm_widget_data_get(obj);
768 if (!wd || !wd->box || !wd->entry) return NULL;
770 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
772 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
776 btn = edje_object_add(evas_object_evas_get(obj));
777 str_utf8 = elm_entry_markup_to_utf8(str);
779 //entry is cleared when text is made to button
780 elm_object_text_set(wd->entry, "");
782 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
783 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
784 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
786 evas_object_size_hint_min_set(btn, width, height);
788 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
789 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
790 evas_object_show(btn);
793 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
797 _resize_button(btn, &rw, &vw);
802 item->visible = EINA_TRUE;
806 case MULTIBUTTONENTRY_POS_START:
807 wd->items = eina_list_prepend(wd->items, item);
808 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
810 elm_widget_sub_object_add(obj, btn);
811 _shrink_mode_set(obj, 1);
816 elm_box_pack_after(wd->box, btn, wd->label);
818 elm_box_pack_start(wd->box, btn);
819 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
820 _set_vis_guidetext(obj);
823 case MULTIBUTTONENTRY_POS_END:
824 wd->items = eina_list_append(wd->items, item);
825 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
827 elm_widget_sub_object_add(obj, btn);
828 evas_object_hide(btn);
832 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
833 _set_vis_guidetext(obj);
835 elm_box_pack_before(wd->box, btn, wd->entry);
837 elm_box_pack_end(wd->box, btn);
840 case MULTIBUTTONENTRY_POS_BEFORE:
842 wd->items = eina_list_prepend_relative(wd->items, item, reference);
844 wd->items = eina_list_append(wd->items, item);
845 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
847 elm_widget_sub_object_add(obj, btn);
848 evas_object_hide(btn);
849 _shrink_mode_set(obj, 1);
854 elm_box_pack_before(wd->box, btn, reference->button);
857 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
858 _set_vis_guidetext(obj);
860 elm_box_pack_before(wd->box, btn, wd->entry);
862 elm_box_pack_end(wd->box, btn);
866 case MULTIBUTTONENTRY_POS_AFTER:
868 wd->items = eina_list_append_relative(wd->items, item, reference);
870 wd->items = eina_list_append(wd->items, item);
871 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
873 elm_widget_sub_object_add(obj, btn);
874 _shrink_mode_set(obj, 1);
879 elm_box_pack_after(wd->box, btn, reference->button);
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);
895 evas_object_smart_callback_call(obj, "item,added", item);
903 _add_button(Evas_Object *obj, const char *str)
905 Widget_Data *wd = elm_widget_data_get(obj);
908 _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
911 static Elm_Multibuttonentry_Item_Filter*
912 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
914 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
915 if (!item_filter) return NULL;
917 item_filter->callback_func= func;
918 item_filter->data = data;
924 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
930 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
932 Widget_Data *wd = elm_widget_data_get(data);
933 Elm_Multibuttonentry_Item *item = NULL;
935 if (!wd || !wd->base || !wd->box) return;
937 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
939 if (wd->last_btn_select)
942 ((strcmp(ev->keyname, "BackSpace") == 0) ||
943 (strcmp(ev->keyname, "BackSpace (") == 0)))
945 item = eina_list_data_get(wd->current);
948 _del_button_item(item);
949 elm_object_focus_set(wd->entry, EINA_TRUE);
952 else if (((!wd->current && (wd->n_str == 0) &&
953 (strcmp(ev->keyname, "BackSpace") == 0)) ||
954 (strcmp(ev->keyname, "BackSpace (") == 0)))
956 item = eina_list_data_get(eina_list_last(wd->items));
958 _select_button(data, item->button);
962 wd->last_btn_select = EINA_TRUE;
966 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
968 Widget_Data *wd = elm_widget_data_get(data);
969 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
973 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
974 wd->last_btn_select = EINA_FALSE;
978 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
980 Widget_Data *wd = elm_widget_data_get(data);
981 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
984 if (!wd || !wd->base || !wd->box) return;
986 str = elm_object_text_get(wd->entry);
988 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
990 _add_button(data, str);
996 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
998 Widget_Data *wd = elm_widget_data_get(data);
1001 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1002 elm_object_focus_set(wd->entry, EINA_TRUE);
1006 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1008 Widget_Data *wd = elm_widget_data_get(data);
1009 Elm_Multibuttonentry_Item *item = NULL;
1015 item = eina_list_data_get(wd->current);
1016 elm_object_focus_set(wd->entry, EINA_FALSE);
1017 evas_object_focus_set(item->button, EINA_TRUE);
1022 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1024 Widget_Data *wd = elm_widget_data_get(data);
1029 str = elm_object_text_get(wd->entry);
1031 _add_button(data, str);
1035 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1037 Widget_Data *wd = elm_widget_data_get(data);
1042 str = elm_object_text_get(wd->entry);
1043 wd->n_str = strlen(str);
1047 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1049 Evas_Coord en_x, en_y, en_w, en_h;
1050 Evas_Coord bx_x, bx_y;
1052 Widget_Data *wd = elm_widget_data_get(data);
1055 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1056 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1058 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w, en_h, EINA_TRUE);
1062 _view_init(Evas_Object *obj)
1064 Widget_Data *wd = elm_widget_data_get(obj);
1070 wd->box = elm_box_add (obj);
1071 if (!wd->box) return;
1072 elm_widget_sub_object_add(obj, wd->box);
1073 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1074 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1075 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1079 wd->label = edje_object_add(evas_object_evas_get(obj));
1080 if (!wd->label) return;
1081 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1082 _set_label(obj, "");
1083 elm_widget_sub_object_add(obj, wd->label);
1088 wd->entry = elm_entry_add (obj);
1089 if (!wd->entry) return;
1090 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1091 elm_object_text_set(wd->entry, "");
1092 elm_entry_cursor_end_set(wd->entry);
1093 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1094 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1095 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1096 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1097 evas_object_show(wd->entry);
1098 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1103 const char *end_type;
1105 end_type = edje_object_data_get(wd->base, "closed_button_type");
1106 if (!end_type || !strcmp(end_type, "label"))
1108 wd->end = elm_label_add (obj);
1109 if (!wd->end) return;
1110 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1111 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1115 const char *size_str;
1116 wd->end = edje_object_add(evas_object_evas_get(obj));
1117 if (!wd->end) return;
1118 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1119 Evas_Coord button_min_width = 0;
1120 Evas_Coord button_min_height = 0;
1122 size_str = edje_object_data_get(wd->end, "closed_button_width");
1123 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1124 size_str = edje_object_data_get(wd->end, "closed_button_height");
1125 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1127 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1128 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1129 elm_widget_sub_object_add(obj, wd->end);
1135 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1137 Evas_Coord minw, minh, mnw, mnh, ww;
1138 Evas_Coord w, cw = 0, cmaxh = 0;
1140 Evas_Object_Box_Option *opt;
1143 /* FIXME: need to calc max */
1147 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1148 evas_object_size_hint_min_get(box, &minw, NULL);
1150 EINA_LIST_FOREACH(priv->children, l, opt)
1152 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1153 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1157 if (mnw != -1 && (w - cw) >= mnw)
1172 if (cmaxh < mnh) cmaxh = mnh;
1177 evas_object_size_hint_min_set(box, minw, minh);
1181 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1183 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1185 Evas_Object_Box_Option *opt;
1189 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1191 EINA_LIST_FOREACH(priv->children, l, opt)
1193 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1194 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1198 if (mnw != -1 && (w - cw) >= mnw)
1208 if (index > obj_index) return cmaxh;
1214 if (cmaxh < mnh) cmaxh = mnh;
1223 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1225 Evas_Coord x, y, w, h, xx, yy;
1228 Evas_Coord minw, minh;
1230 Evas_Object_Box_Option *opt;
1232 _calculate_box_min_size(o, priv);
1234 evas_object_geometry_get(o, &x, &y, &w, &h);
1236 evas_object_size_hint_min_get(o, &minw, &minh);
1237 evas_object_size_hint_align_get(o, &ax, &ay);
1240 x = x + ((w - minw) * (1.0 - ax));
1245 y = y + ((h - minh) * (1.0 - ay));
1252 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1254 EINA_LIST_FOREACH(priv->children, l, opt)
1256 Evas_Coord mnw, mnh, mxw, mxh;
1261 evas_object_size_hint_align_get(obj, &ax, &ay);
1262 evas_object_size_hint_weight_get(obj, &wx, &wy);
1263 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1264 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1266 if (ax == -1.0) {fw = 1; ax = 0.5;}
1267 if (ay == -1.0) {fh = 1; ay = 0.5;}
1268 Evas_Coord ww, hh, ow, oh;
1272 if (mnw != -1 && (w - cw) >= mnw)
1279 hh = _calculate_item_max_height(o, priv, obj_index);
1283 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1286 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1295 evas_object_move(obj,
1296 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1297 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1298 evas_object_resize(obj, ow, oh);
1301 if (cmaxh < hh) cmaxh = hh;
1308 elm_multibuttonentry_add(Evas_Object *parent)
1314 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1316 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1317 elm_widget_type_set(obj, "multibuttonentry");
1318 elm_widget_sub_object_add(parent, obj);
1319 elm_widget_data_set(obj, wd);
1321 elm_widget_del_hook_set(obj, _del_hook);
1322 elm_widget_theme_hook_set(obj, _theme_hook);
1323 elm_widget_event_hook_set(obj, _event_hook);
1324 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1325 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1327 wd->base = edje_object_add(e);
1328 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1329 elm_widget_resize_object_set(obj, wd->base);
1330 elm_widget_can_focus_set(obj, EINA_TRUE);
1332 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1333 wd->focused = EINA_FALSE;
1334 wd->last_btn_select = EINA_TRUE;
1336 wd->rect_for_end= NULL;
1337 wd->add_callback = NULL;
1338 wd->add_callback_data = NULL;
1347 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1349 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1350 Widget_Data *wd = elm_widget_data_get(obj);
1352 if (!wd) return NULL;
1358 elm_multibuttonentry_label_get(const Evas_Object *obj)
1360 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1361 Widget_Data *wd = elm_widget_data_get(obj);
1363 if (!wd) return NULL;
1364 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1369 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1371 ELM_CHECK_WIDTYPE(obj, widtype);
1372 Widget_Data *wd = elm_widget_data_get(obj);
1376 _set_label(obj, label);
1378 _set_label(obj, "");
1382 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1384 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1385 Widget_Data *wd = elm_widget_data_get(obj);
1387 if (!wd) return NULL;
1388 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1393 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1395 ELM_CHECK_WIDTYPE(obj, widtype);
1396 Widget_Data *wd = elm_widget_data_get(obj);
1400 _set_guidetext(obj, guidetext);
1402 _set_guidetext(obj, "");
1406 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1408 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1409 Widget_Data *wd = elm_widget_data_get(obj);
1412 return wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? 1 : 0;
1416 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1418 ELM_CHECK_WIDTYPE(obj, widtype);
1419 Widget_Data *wd = elm_widget_data_get(obj);
1421 if (!wd || !wd->box ||
1422 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? 1 : 0) == shrink) return;
1423 _shrink_mode_set(obj, shrink);
1426 EAPI Elm_Multibuttonentry_Item *
1427 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1429 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1430 Widget_Data *wd = elm_widget_data_get(obj);
1431 Elm_Multibuttonentry_Item *item;
1433 if (!wd || !label) return NULL;
1434 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1438 EAPI Elm_Multibuttonentry_Item *
1439 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1441 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1442 Widget_Data *wd = elm_widget_data_get(obj);
1443 Elm_Multibuttonentry_Item *item;
1445 if (!wd || !label) return NULL;
1446 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1450 EAPI Elm_Multibuttonentry_Item *
1451 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Multibuttonentry_Item *before, const char *label, void *data)
1453 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1454 Widget_Data *wd = elm_widget_data_get(obj);
1455 Elm_Multibuttonentry_Item *item;
1457 if (!wd || !label) return NULL;
1458 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, data);
1462 EAPI Elm_Multibuttonentry_Item *
1463 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Multibuttonentry_Item *after, const char *label, void *data)
1465 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1466 Widget_Data *wd = elm_widget_data_get(obj);
1467 Elm_Multibuttonentry_Item *item;
1469 if (!wd || !label) return NULL;
1470 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, data);
1474 EAPI const Eina_List *
1475 elm_multibuttonentry_items_get(const Evas_Object *obj)
1477 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1478 Widget_Data *wd = elm_widget_data_get(obj);
1480 if (!wd) return NULL;
1484 EAPI Elm_Multibuttonentry_Item *
1485 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1487 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1488 Widget_Data *wd = elm_widget_data_get(obj);
1490 if (!wd || !wd->items) return NULL;
1491 return eina_list_data_get(wd->items);
1494 EAPI Elm_Multibuttonentry_Item *
1495 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1497 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1498 Widget_Data *wd = elm_widget_data_get(obj);
1500 if (!wd || !wd->items) return NULL;
1501 return eina_list_data_get(eina_list_last(wd->items));
1504 EAPI Elm_Multibuttonentry_Item *
1505 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1507 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1508 Widget_Data *wd = elm_widget_data_get(obj);
1510 if (!wd || !wd->current) return NULL;
1511 return eina_list_data_get(wd->current);
1515 elm_multibuttonentry_item_select(Elm_Multibuttonentry_Item *item, Eina_Bool selected)
1519 Elm_Multibuttonentry_Item *_item;
1522 ELM_CHECK_WIDTYPE(WIDGET(item), widtype);
1523 wd = elm_widget_data_get(WIDGET(item));
1526 EINA_LIST_FOREACH(wd->items, l, _item)
1531 _select_button(WIDGET(item), item->button);
1533 _select_button(WIDGET(item), NULL);
1539 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1541 ELM_CHECK_WIDTYPE(obj, widtype);
1542 Widget_Data *wd = elm_widget_data_get(obj);
1545 _select_button(obj, NULL);
1549 elm_multibuttonentry_clear(Evas_Object *obj)
1551 ELM_CHECK_WIDTYPE(obj, widtype);
1552 Widget_Data *wd = elm_widget_data_get(obj);
1557 Elm_Multibuttonentry_Item *item;
1558 EINA_LIST_FREE(wd->items, item)
1560 elm_box_unpack(wd->box, item->button);
1561 _del_button_obj(obj, item->button);
1571 elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
1574 _del_button_item(item);
1578 elm_multibuttonentry_item_label_get(const Elm_Multibuttonentry_Item *item)
1582 Elm_Multibuttonentry_Item *_item;
1583 if (!item) return NULL;
1584 ELM_CHECK_WIDTYPE(WIDGET(item), widtype) NULL;
1585 wd = elm_widget_data_get(WIDGET(item));
1586 if (!wd || !wd->items) return NULL;
1588 EINA_LIST_FOREACH(wd->items, l, _item)
1591 return edje_object_part_text_get(_item->button, "elm.btn.text");
1598 elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
1602 Elm_Multibuttonentry_Item *_item;
1603 if (!item || !str) return;
1604 ELM_CHECK_WIDTYPE(WIDGET(item), widtype);
1605 wd = elm_widget_data_get(WIDGET(item));
1606 if (!wd || !wd->items) return;
1608 EINA_LIST_FOREACH(wd->items, l, _item)
1611 edje_object_part_text_set(_item->button, "elm.btn.text", str);
1612 _resize_button(_item->button, &_item->rw, &_item->vw);
1617 EAPI Elm_Multibuttonentry_Item *
1618 elm_multibuttonentry_item_prev_get(const Elm_Multibuttonentry_Item *item)
1622 Elm_Multibuttonentry_Item *_item;
1623 if (!item) return NULL;
1624 ELM_CHECK_WIDTYPE(WIDGET(item), widtype) NULL;
1625 wd = elm_widget_data_get(WIDGET(item));
1626 if (!wd || !wd->items) return NULL;
1628 EINA_LIST_FOREACH(wd->items, l, _item)
1631 l = eina_list_prev(l);
1632 if (!l) return NULL;
1633 return eina_list_data_get(l);
1638 EAPI Elm_Multibuttonentry_Item *
1639 elm_multibuttonentry_item_next_get(const Elm_Multibuttonentry_Item *item)
1643 Elm_Multibuttonentry_Item *_item;
1645 if (!item) return NULL;
1646 ELM_CHECK_WIDTYPE(WIDGET(item), widtype) NULL;
1647 wd = elm_widget_data_get(WIDGET(item));
1648 if (!wd || !wd->items) return NULL;
1650 EINA_LIST_FOREACH(wd->items, l, _item)
1653 l = eina_list_next(l);
1654 if (!l) return NULL;
1655 return eina_list_data_get(l);
1661 elm_multibuttonentry_item_data_get(const Elm_Multibuttonentry_Item *item)
1663 if (!item) return NULL;
1668 elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
1675 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1677 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1678 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1681 Widget_Data *wd = elm_widget_data_get(obj);
1684 ELM_CHECK_WIDTYPE(obj, widtype);
1685 EINA_SAFETY_ON_NULL_RETURN(func);
1687 new_item_filter= _filter_new(func, data);
1688 if (!new_item_filter) return;
1690 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1692 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1694 printf("Already Registered this item filter!!!!\n");
1698 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1702 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1704 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1705 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1707 Widget_Data *wd = elm_widget_data_get(obj);
1710 ELM_CHECK_WIDTYPE(obj, widtype);
1711 EINA_SAFETY_ON_NULL_RETURN(func);
1713 new_item_filter = _filter_new(func, data);
1714 if (!new_item_filter) return;
1716 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1718 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1720 printf("Already Registered this item filter!!!!\n");
1724 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1728 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1732 Elm_Multibuttonentry_Item_Filter *item_filter;
1734 wd = elm_widget_data_get(obj);
1736 EINA_SAFETY_ON_NULL_RETURN(func);
1738 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1740 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1742 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1743 _filter_free(item_filter);