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_Object_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, void *data);
100 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
101 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
102 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
103 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
104 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
105 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
106 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
107 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
108 static void _view_init(Evas_Object *obj);
109 static void _set_vis_guidetext(Evas_Object *obj);
110 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
111 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
112 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
113 static void _item_text_set_hook(Elm_Object_Item *it,
116 static const char *_item_text_get_hook(const Elm_Object_Item *it,
119 // XXX: use evas_object_smart_callback_descriptions_set for smart callbacks.
122 _del_hook(Evas_Object *obj)
124 Widget_Data *wd = elm_widget_data_get(obj);
129 Elm_Multibuttonentry_Item *item;
130 EINA_LIST_FREE(wd->items, item)
132 _del_button_obj(obj, item->button);
139 if (wd->entry) evas_object_del (wd->entry);
140 if (wd->label) evas_object_del (wd->label);
141 if (wd->guidetext) evas_object_del (wd->guidetext);
142 if (wd->end) evas_object_del (wd->end);
143 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
147 _theme_hook(Evas_Object *obj)
149 Widget_Data *wd = elm_widget_data_get(obj);
151 Elm_Multibuttonentry_Item *item;
155 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
156 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
157 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
159 EINA_LIST_FOREACH(wd->items, l, item)
162 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
163 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
170 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
172 Widget_Data *wd = elm_widget_data_get(obj);
176 if (elm_widget_focus_get(obj))
180 elm_entry_input_panel_show(wd->entry);
182 else if (((!wd->current) || (!eina_list_count(wd->items))))
184 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
186 elm_entry_input_panel_show(wd->entry);
188 wd->focused = EINA_TRUE;
189 evas_object_smart_callback_call(obj, "focused", NULL);
193 wd->focused = EINA_FALSE;
196 elm_entry_input_panel_hide(wd->entry);
197 evas_object_smart_callback_call(obj, "unfocused", NULL);
202 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
208 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
210 Widget_Data *wd = elm_widget_data_get(obj);
213 edje_object_signal_emit(wd->base, emission, source);
217 _sizing_eval(Evas_Object *obj)
219 Widget_Data *wd = elm_widget_data_get(obj);
220 Evas_Coord minw = -1, minh = -1;
221 Evas_Coord left, right, top, bottom;
224 evas_object_size_hint_min_get(wd->box, &minw, &minh);
225 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
226 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
228 minw += (left + right);
229 minh += (top + bottom);
231 evas_object_size_hint_min_set(obj, minw, minh);
235 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
237 Widget_Data *wd = elm_widget_data_get(data);
239 if (!wd || !wd->base) return;
240 wd->focused = EINA_TRUE;
243 elm_entry_input_panel_show(wd->entry);
245 evas_object_smart_callback_call(data, "clicked", NULL);
249 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
251 Evas_Object *eo = (Evas_Object *)data;
252 Widget_Data *wd = elm_widget_data_get(data);
259 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
261 Widget_Data *wd = elm_widget_data_get(data);
265 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
267 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
268 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
277 _event_init(Evas_Object *obj)
279 Widget_Data *wd = elm_widget_data_get(obj);
281 if (!wd || !wd->base) return;
284 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
285 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
290 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
291 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
296 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
297 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
298 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
299 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
300 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
301 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
302 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
307 _set_vis_guidetext(Evas_Object *obj)
309 Widget_Data *wd = elm_widget_data_get(obj);
312 elm_box_unpack(wd->box, wd->guidetext);
313 elm_box_unpack(wd->box, wd->entry);
314 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
316 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
317 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
319 evas_object_hide(wd->entry);
320 elm_box_pack_end(wd->box, wd->guidetext);
321 evas_object_show(wd->guidetext);
322 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
326 evas_object_hide(wd->guidetext);
327 elm_box_pack_end(wd->box, wd->entry);
328 evas_object_show(wd->entry);
329 if (elm_widget_focus_get(obj) || wd->focused)
331 elm_object_focus_set(wd->entry, EINA_TRUE);
332 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
337 _shrink_mode_set(Evas_Object *obj, int shrink)
339 Widget_Data *wd = elm_widget_data_get(obj);
341 Elm_Multibuttonentry_Item *item;
343 if (!wd || !wd->box) return;
344 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
345 evas_object_hide(wd->entry);
346 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
347 evas_object_hide(wd->guidetext);
348 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
350 evas_object_hide(wd->rect_for_end);
351 evas_object_hide(wd->end);
352 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
357 Evas_Coord w=0, w_tmp=0;
358 Evas_Coord box_inner_item_width_padding = 0;
360 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
361 // unpack all items and entry
362 elm_box_unpack_all(wd->box);
363 EINA_LIST_FOREACH(wd->items, l, item)
367 evas_object_hide(item->button);
368 item->visible = EINA_FALSE;
371 // pack buttons only 1line
376 elm_box_pack_end(wd->box, wd->label);
377 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
379 w -= box_inner_item_width_padding;
383 int count = eina_list_count(wd->items);
384 Evas_Coord button_min_width = 0;
385 /* Evas_Coord button_min_height = 0; */
386 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
388 const char *size_str;
389 size_str = edje_object_data_get(wd->end, "closed_button_width");
390 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
392 size_str = edje_object_data_get(wd->end, "closed_button_height");
393 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
397 EINA_LIST_FOREACH(wd->items, l, item)
401 int w_label_count = 0;
404 elm_box_pack_end(wd->box, item->button);
405 evas_object_show(item->button);
406 item->visible = EINA_TRUE;
409 w -= box_inner_item_width_padding;
412 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
416 snprintf(buf, sizeof(buf), "... + %d", count);
417 elm_object_text_set(wd->end, buf);
418 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
421 if (w < 0 || w < w_label_count)
423 elm_box_unpack(wd->box, item->button);
424 evas_object_hide(item->button);
425 item->visible = EINA_FALSE;
428 snprintf(buf, sizeof(buf), "... + %d", count);
429 elm_object_text_set(wd->end, buf);
430 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
432 elm_box_pack_end(wd->box, wd->end);
433 evas_object_show(wd->end);
435 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
436 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
440 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
442 if (w < button_min_width)
445 Evas_Coord closed_height = 0;
446 const char *height_str = edje_object_data_get(wd->base, "closed_height");
448 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
449 elm_box_unpack(wd->box, item->button);
450 evas_object_hide(item->button);
451 item->visible = EINA_FALSE;
454 rectSize = w - button_min_width;
455 if (!wd->rect_for_end)
457 Evas *e = evas_object_evas_get(obj);
458 wd->rect_for_end= evas_object_rectangle_add(e);
459 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
461 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get() );
462 elm_box_pack_end(wd->box, wd->rect_for_end);
463 evas_object_show(wd->rect_for_end);
465 elm_box_pack_end(wd->box, wd->end);
466 evas_object_show(wd->end);
468 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
469 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
478 // unpack all items and entry
479 elm_box_unpack_all(wd->box);
480 EINA_LIST_FOREACH(wd->items, l, item)
484 evas_object_hide(item->button);
485 item->visible = EINA_FALSE;
488 evas_object_hide(wd->end);
490 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
492 // pack buttons only 1line
494 if (wd->label) elm_box_pack_end(wd->box, wd->label);
498 EINA_LIST_FOREACH(wd->items, l, item)
502 elm_box_pack_end(wd->box, item->button);
503 evas_object_show(item->button);
504 item->visible = EINA_TRUE;
508 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
509 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)(long)wd->shrink);
511 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
513 _set_vis_guidetext(obj);
518 _view_update(Evas_Object *obj)
520 Evas_Coord width = 1, height = 1;
521 Widget_Data *wd = elm_widget_data_get(obj);
523 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
528 elm_box_unpack(wd->box, wd->label);
529 elm_box_pack_start(wd->box, wd->label);
530 evas_object_size_hint_min_get(wd->label, &width, &height);
535 Evas_Coord guide_text_width = wd->w_box - width;
536 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
539 // update buttons in shrink mode
540 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
541 _shrink_mode_set(obj, 1);
544 _set_vis_guidetext(obj);
548 _set_label(Evas_Object *obj, const char *str)
550 Widget_Data *wd = elm_widget_data_get(obj);
552 if (!wd || !str) return;
555 Evas_Coord width, height, sum_width = 0;
556 evas_object_size_hint_min_set(wd->label, 0, 0);
557 evas_object_resize(wd->label, 0, 0);
558 edje_object_part_text_set(wd->label, "mbe.label", str);
560 if (!strcmp(str, ""))
562 /* FIXME: not work yet */
563 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
564 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
569 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
570 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
574 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
577 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
580 evas_object_size_hint_min_set(wd->label, sum_width, height);
582 evas_object_show(wd->label);
587 _set_guidetext(Evas_Object *obj, const char *str)
589 Widget_Data *wd = elm_widget_data_get(obj);
591 if (!wd || !str) return;
593 if (wd->guidetext==NULL)
594 wd->guidetext = edje_object_add(evas_object_evas_get (obj));
598 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
599 "guidetext", elm_widget_style_get(obj));
600 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
601 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
603 edje_object_part_text_set(wd->guidetext, "elm.text", str);
609 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
611 Widget_Data *wd = elm_widget_data_get(obj);
612 Elm_Multibuttonentry_Item *item = NULL;
616 item = eina_list_data_get(wd->current);
618 if (item && item->button)
622 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
623 edje_object_signal_emit(item->button, "default", "");
626 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
627 edje_object_signal_emit(item->button, "focused", "");
628 evas_object_smart_callback_call(obj, "item,selected", item);
631 edje_object_signal_emit(item->button, "default", "");
639 _change_current_button(Evas_Object *obj, Evas_Object *btn)
641 Widget_Data *wd = elm_widget_data_get(obj);
643 Elm_Multibuttonentry_Item *item;
647 // change the state of previous button to "default"
648 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
650 // change the current
651 EINA_LIST_FOREACH(wd->items, l, item)
653 if (item->button == btn)
659 // change the state of current button to "focused"
660 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
664 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
666 Widget_Data *wd = elm_widget_data_get(data);
668 Elm_Multibuttonentry_Item *item = NULL;
669 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
671 _change_current_button(data, obj);
674 if ((item = eina_list_data_get(wd->current)) != NULL)
676 evas_object_smart_callback_call(data, "item,clicked", item);
677 _select_button(data, item->button);
682 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
684 Widget_Data *wd = elm_widget_data_get(obj);
686 if (!wd || !btn) return;
688 evas_object_del(btn);
692 _del_button_item(Elm_Multibuttonentry_Item *item)
695 Elm_Multibuttonentry_Item *_item;
699 Evas_Object *obj = WIDGET(item);
700 wd = elm_widget_data_get(obj);
702 EINA_LIST_FOREACH(wd->items, l, _item)
706 wd->items = eina_list_remove(wd->items, _item);
707 elm_box_unpack(wd->box, _item->button);
709 evas_object_smart_callback_call(obj, "item,deleted", _item);
711 _del_button_obj(obj, _item->button);
713 if (wd->current == l)
718 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
719 _shrink_mode_set(obj, 1);
721 if (!eina_list_count(wd->items))
722 _set_vis_guidetext(obj);
726 _select_button(Evas_Object *obj, Evas_Object *btn)
728 Widget_Data *wd = elm_widget_data_get(obj);
733 _change_current_button(obj, btn);
734 if (elm_widget_focus_get(obj))
736 elm_object_focus_set(wd->entry, EINA_FALSE);
737 evas_object_focus_set(btn, EINA_TRUE);
742 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
743 if (elm_widget_focus_get(obj))
744 elm_object_focus_set(wd->entry, EINA_TRUE);
749 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
752 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
753 Evas_Coord w_btn = 0, button_max_width = 0;
754 const char *size_str;
756 size_str = edje_object_data_get(btn, "button_max_size");
757 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
759 // decide the size of button
760 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
761 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
762 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
763 w_btn = w_text + 2*padding_outer + 2*padding_inner;
767 if (button_max_width < w_btn)
768 vw = button_max_width;
773 evas_object_resize(btn, vw, h_btn);
774 evas_object_size_hint_min_set(btn, vw, h_btn);
776 if (realw) *realw = rw;
777 if (vieww) *vieww = vw;
781 _item_del_pre_hook(Elm_Object_Item *it)
783 _del_button_item((Elm_Multibuttonentry_Item *) it);
787 static Elm_Object_Item*
788 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, void *data)
790 Elm_Multibuttonentry_Item *item;
791 Elm_Multibuttonentry_Item_Filter *item_filter;
792 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
795 Evas_Coord width = -1, height = -1;
796 char *str_utf8 = NULL;
797 Widget_Data *wd = elm_widget_data_get(obj);
799 if (!wd || !wd->box || !wd->entry) return NULL;
800 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
801 if (!str) return NULL;
803 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
805 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
809 btn = edje_object_add(evas_object_evas_get(obj));
810 str_utf8 = elm_entry_markup_to_utf8(str);
812 //entry is cleared when text is made to button
813 elm_object_text_set(wd->entry, "");
815 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
816 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
817 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
819 evas_object_size_hint_min_set(btn, width, height);
821 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
822 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
823 evas_object_show(btn);
826 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
829 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
830 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
831 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
832 elm_widget_item_data_set(item, data);
834 _resize_button(btn, &rw, &vw);
838 item->visible = EINA_TRUE;
842 case MULTIBUTTONENTRY_POS_START:
843 wd->items = eina_list_prepend(wd->items, item);
844 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
846 elm_widget_sub_object_add(obj, btn);
847 _shrink_mode_set(obj, 1);
852 elm_box_pack_after(wd->box, btn, wd->label);
854 elm_box_pack_start(wd->box, btn);
855 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
856 _set_vis_guidetext(obj);
859 case MULTIBUTTONENTRY_POS_END:
860 wd->items = eina_list_append(wd->items, item);
861 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
863 elm_widget_sub_object_add(obj, btn);
864 evas_object_hide(btn);
868 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
869 _set_vis_guidetext(obj);
871 elm_box_pack_before(wd->box, btn, wd->entry);
873 elm_box_pack_end(wd->box, btn);
876 case MULTIBUTTONENTRY_POS_BEFORE:
878 wd->items = eina_list_prepend_relative(wd->items, item, reference);
880 wd->items = eina_list_append(wd->items, item);
881 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
883 elm_widget_sub_object_add(obj, btn);
884 evas_object_hide(btn);
885 _shrink_mode_set(obj, 1);
890 elm_box_pack_before(wd->box, btn, reference->button);
893 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
894 _set_vis_guidetext(obj);
896 elm_box_pack_before(wd->box, btn, wd->entry);
898 elm_box_pack_end(wd->box, btn);
902 case MULTIBUTTONENTRY_POS_AFTER:
904 wd->items = eina_list_append_relative(wd->items, item, reference);
906 wd->items = eina_list_append(wd->items, item);
907 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
909 elm_widget_sub_object_add(obj, btn);
910 _shrink_mode_set(obj, 1);
915 elm_box_pack_after(wd->box, btn, reference->button);
918 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
919 _set_vis_guidetext(obj);
921 elm_box_pack_before(wd->box, btn, wd->entry);
923 elm_box_pack_end(wd->box, btn);
931 evas_object_smart_callback_call(obj, "item,added", item);
935 return (Elm_Object_Item *)item;
938 static Elm_Multibuttonentry_Item_Filter*
939 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
941 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
942 if (!item_filter) return NULL;
944 item_filter->callback_func= func;
945 item_filter->data = data;
951 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
957 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
959 Widget_Data *wd = elm_widget_data_get(data);
960 Elm_Multibuttonentry_Item *item = NULL;
962 if (!wd || !wd->base || !wd->box) return;
964 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
966 if (wd->last_btn_select)
969 ((strcmp(ev->keyname, "BackSpace") == 0) ||
970 (strcmp(ev->keyname, "Delete") == 0)))
972 item = eina_list_data_get(wd->current);
975 _del_button_item(item);
976 elm_widget_item_free(item);
977 elm_object_focus_set(wd->entry, EINA_TRUE);
980 else if (((!wd->current && (wd->n_str == 0) &&
981 (strcmp(ev->keyname, "BackSpace") == 0)) ||
982 (strcmp(ev->keyname, "Delete") == 0)))
984 item = eina_list_data_get(eina_list_last(wd->items));
986 _select_button(data, item->button);
990 wd->last_btn_select = EINA_TRUE;
994 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
996 Widget_Data *wd = elm_widget_data_get(data);
997 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1001 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1002 wd->last_btn_select = EINA_FALSE;
1006 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1008 Widget_Data *wd = elm_widget_data_get(data);
1009 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1012 if (!wd || !wd->base || !wd->box) return;
1014 str = elm_object_text_get(wd->entry);
1016 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1018 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
1024 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1026 Widget_Data *wd = elm_widget_data_get(data);
1029 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1030 elm_object_focus_set(wd->entry, EINA_TRUE);
1034 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1036 Widget_Data *wd = elm_widget_data_get(data);
1037 Elm_Multibuttonentry_Item *item = NULL;
1043 item = eina_list_data_get(wd->current);
1044 elm_object_focus_set(wd->entry, EINA_FALSE);
1045 evas_object_focus_set(item->button, EINA_TRUE);
1050 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1052 Widget_Data *wd = elm_widget_data_get(data);
1057 str = elm_object_text_get(wd->entry);
1059 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
1063 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1065 Widget_Data *wd = elm_widget_data_get(data);
1070 str = elm_object_text_get(wd->entry);
1071 wd->n_str = strlen(str);
1075 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1077 Evas_Coord en_x, en_y, en_w, en_h;
1078 Evas_Coord bx_x, bx_y;
1080 Widget_Data *wd = elm_widget_data_get(data);
1083 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1084 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1087 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
1092 _view_init(Evas_Object *obj)
1094 Widget_Data *wd = elm_widget_data_get(obj);
1100 wd->box = elm_box_add (obj);
1101 if (!wd->box) return;
1102 elm_widget_sub_object_add(obj, wd->box);
1103 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1104 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1105 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1109 wd->label = edje_object_add(evas_object_evas_get(obj));
1110 if (!wd->label) return;
1111 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1112 _set_label(obj, "");
1113 elm_widget_sub_object_add(obj, wd->label);
1118 wd->entry = elm_entry_add (obj);
1119 if (!wd->entry) return;
1120 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1121 elm_object_text_set(wd->entry, "");
1122 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1123 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1124 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1125 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1126 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1127 evas_object_show(wd->entry);
1128 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1133 const char *end_type;
1135 end_type = edje_object_data_get(wd->base, "closed_button_type");
1136 if (!end_type || !strcmp(end_type, "label"))
1138 wd->end = elm_label_add (obj);
1139 if (!wd->end) return;
1140 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1141 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1145 const char *size_str;
1146 wd->end = edje_object_add(evas_object_evas_get(obj));
1147 if (!wd->end) return;
1148 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1149 Evas_Coord button_min_width = 0;
1150 Evas_Coord button_min_height = 0;
1152 size_str = edje_object_data_get(wd->end, "closed_button_width");
1153 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1154 size_str = edje_object_data_get(wd->end, "closed_button_height");
1155 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1157 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1158 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1159 elm_widget_sub_object_add(obj, wd->end);
1165 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1167 Evas_Coord minw, minh, mnw, mnh, ww;
1168 Evas_Coord w, cw = 0, cmaxh = 0;
1170 Evas_Object_Box_Option *opt;
1173 /* FIXME: need to calc max */
1177 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1178 evas_object_size_hint_min_get(box, &minw, NULL);
1180 EINA_LIST_FOREACH(priv->children, l, opt)
1182 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1183 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1187 if (mnw != -1 && (w - cw) >= mnw)
1202 if (cmaxh < mnh) cmaxh = mnh;
1207 evas_object_size_hint_min_set(box, minw, minh);
1211 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1213 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1215 Evas_Object_Box_Option *opt;
1219 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1221 EINA_LIST_FOREACH(priv->children, l, opt)
1223 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1224 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1228 if (mnw != -1 && (w - cw) >= mnw)
1238 if (index > obj_index) return cmaxh;
1244 if (cmaxh < mnh) cmaxh = mnh;
1253 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1255 Evas_Coord x, y, w, h, xx, yy;
1258 Evas_Coord minw, minh;
1260 Evas_Object_Box_Option *opt;
1262 _calculate_box_min_size(o, priv);
1264 evas_object_geometry_get(o, &x, &y, &w, &h);
1266 evas_object_size_hint_min_get(o, &minw, &minh);
1267 evas_object_size_hint_align_get(o, &ax, &ay);
1270 x = x + ((w - minw) * (1.0 - ax));
1275 y = y + ((h - minh) * (1.0 - ay));
1282 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1284 EINA_LIST_FOREACH(priv->children, l, opt)
1286 Evas_Coord mnw, mnh, mxw, mxh;
1291 evas_object_size_hint_align_get(obj, &ax, &ay);
1292 evas_object_size_hint_weight_get(obj, &wx, &wy);
1293 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1294 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1296 if (ax == -1.0) {fw = 1; ax = 0.5;}
1297 if (ay == -1.0) {fh = 1; ay = 0.5;}
1298 Evas_Coord ww, hh, ow, oh;
1302 if (mnw != -1 && (w - cw) >= mnw)
1309 hh = _calculate_item_max_height(o, priv, obj_index);
1313 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1316 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1325 evas_object_move(obj,
1326 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1327 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1328 evas_object_resize(obj, ow, oh);
1331 if (cmaxh < hh) cmaxh = hh;
1338 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1340 Elm_Multibuttonentry_Item *item;
1341 if (part && strcmp(part, "default")) return;
1343 item = (Elm_Multibuttonentry_Item *) it;
1344 edje_object_part_text_set(item->button, "elm.btn.text", label);
1345 _resize_button(item->button, &item->rw, &item->vw);
1349 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1351 Elm_Multibuttonentry_Item *item;
1352 if (part && strcmp(part, "default")) return NULL;
1353 item = (Elm_Multibuttonentry_Item *) it;
1354 return edje_object_part_text_get(item->button, "elm.btn.text");
1358 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1360 ELM_CHECK_WIDTYPE(obj, widtype);
1361 if (part && strcmp(part, "default")) return;
1362 if (label) _set_label(obj, label);
1363 else _set_label(obj, "");
1367 _text_get_hook(const Evas_Object *obj, const char *part)
1369 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1371 if (part && strcmp(part, "default")) return NULL;
1372 wd = elm_widget_data_get(obj);
1373 if (!wd) return NULL;
1374 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1379 elm_multibuttonentry_add(Evas_Object *parent)
1385 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1387 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1388 elm_widget_type_set(obj, "multibuttonentry");
1389 elm_widget_sub_object_add(parent, obj);
1390 elm_widget_data_set(obj, wd);
1392 elm_widget_del_hook_set(obj, _del_hook);
1393 elm_widget_theme_hook_set(obj, _theme_hook);
1394 elm_widget_event_hook_set(obj, _event_hook);
1395 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1396 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1397 elm_widget_text_set_hook_set(obj, _text_set_hook);
1398 elm_widget_text_get_hook_set(obj, _text_get_hook);
1400 wd->base = edje_object_add(e);
1401 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1402 elm_widget_resize_object_set(obj, wd->base);
1403 elm_widget_can_focus_set(obj, EINA_TRUE);
1405 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1406 wd->focused = EINA_FALSE;
1407 wd->last_btn_select = EINA_TRUE;
1409 wd->rect_for_end= NULL;
1410 wd->add_callback = NULL;
1411 wd->add_callback_data = NULL;
1420 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1422 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1423 Widget_Data *wd = elm_widget_data_get(obj);
1425 if (!wd) return NULL;
1431 elm_multibuttonentry_label_get(const Evas_Object *obj)
1433 return _text_get_hook(obj, NULL);
1437 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1439 _text_set_hook(obj, NULL, label);
1443 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1445 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1446 Widget_Data *wd = elm_widget_data_get(obj);
1448 if (!wd) return NULL;
1449 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1454 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1456 ELM_CHECK_WIDTYPE(obj, widtype);
1457 Widget_Data *wd = elm_widget_data_get(obj);
1461 _set_guidetext(obj, guidetext);
1464 EINA_DEPRECATED EAPI int
1465 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1467 if (elm_multibuttonentry_expanded_get(obj))
1474 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1476 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1477 Widget_Data *wd = elm_widget_data_get(obj);
1480 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1484 EINA_DEPRECATED EAPI void
1485 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1488 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
1491 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
1495 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1497 ELM_CHECK_WIDTYPE(obj, widtype);
1498 Widget_Data *wd = elm_widget_data_get(obj);
1500 if (!wd || !wd->box ||
1501 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1504 _shrink_mode_set(obj, 0);
1506 _shrink_mode_set(obj, 1);
1510 EAPI Elm_Object_Item *
1511 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1513 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1516 EAPI Elm_Object_Item *
1517 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1519 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1522 EAPI Elm_Object_Item *
1523 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
1525 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, data);
1528 EAPI Elm_Object_Item *
1529 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
1531 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, data);
1534 EAPI const Eina_List *
1535 elm_multibuttonentry_items_get(const Evas_Object *obj)
1537 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1538 Widget_Data *wd = elm_widget_data_get(obj);
1539 if (!wd) return NULL;
1543 EAPI Elm_Object_Item *
1544 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1546 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1547 Widget_Data *wd = elm_widget_data_get(obj);
1548 if (!wd) return NULL;
1549 return eina_list_data_get(wd->items);
1552 EAPI Elm_Object_Item *
1553 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1555 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1556 Widget_Data *wd = elm_widget_data_get(obj);
1557 if (!wd) return NULL;
1558 return eina_list_data_get(eina_list_last(wd->items));
1561 EAPI Elm_Object_Item *
1562 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1564 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1565 Widget_Data *wd = elm_widget_data_get(obj);
1566 if (!wd) return NULL;
1567 return eina_list_data_get(wd->current);
1571 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
1573 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1574 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1575 if (selected) _select_button(WIDGET(item), item->button);
1576 else _select_button(WIDGET(item), NULL);
1580 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1582 ELM_CHECK_WIDTYPE(obj, widtype);
1583 Widget_Data *wd = elm_widget_data_get(obj);
1585 _select_button(obj, NULL);
1589 elm_multibuttonentry_clear(Evas_Object *obj)
1591 ELM_CHECK_WIDTYPE(obj, widtype);
1592 Elm_Multibuttonentry_Item *item;
1593 Widget_Data *wd = elm_widget_data_get(obj);
1598 EINA_LIST_FREE(wd->items, item)
1600 elm_box_unpack(wd->box, item->button);
1601 _del_button_obj(obj, item->button);
1611 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1613 elm_object_item_del(it);
1617 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1619 return _item_text_get_hook(it, NULL);
1623 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1625 _item_text_set_hook(it, NULL, str);
1628 EAPI Elm_Object_Item *
1629 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1631 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1634 Elm_Multibuttonentry_Item *_item;
1636 wd = elm_widget_data_get(WIDGET(it));
1637 if (!wd) return NULL;
1639 EINA_LIST_FOREACH(wd->items, l, _item)
1641 if (_item == (Elm_Multibuttonentry_Item *) it)
1643 l = eina_list_prev(l);
1644 if (!l) return NULL;
1645 return eina_list_data_get(l);
1651 EAPI Elm_Object_Item *
1652 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1654 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1657 Elm_Multibuttonentry_Item *_item;
1658 wd = elm_widget_data_get(WIDGET(it));
1659 if (!wd) return NULL;
1661 EINA_LIST_FOREACH(wd->items, l, _item)
1663 if (_item == (Elm_Multibuttonentry_Item *) it)
1665 l = eina_list_next(l);
1666 if (!l) return NULL;
1667 return eina_list_data_get(l);
1674 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1676 return elm_widget_item_data_get(it);
1680 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1682 return elm_widget_item_data_set(it, data);
1686 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1688 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1689 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1692 Widget_Data *wd = elm_widget_data_get(obj);
1695 ELM_CHECK_WIDTYPE(obj, widtype);
1696 EINA_SAFETY_ON_NULL_RETURN(func);
1698 new_item_filter= _filter_new(func, data);
1699 if (!new_item_filter) return;
1701 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1703 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1705 printf("Already Registered this item filter!!!!\n");
1709 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1713 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1715 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1716 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1718 Widget_Data *wd = elm_widget_data_get(obj);
1721 ELM_CHECK_WIDTYPE(obj, widtype);
1722 EINA_SAFETY_ON_NULL_RETURN(func);
1724 new_item_filter = _filter_new(func, data);
1725 if (!new_item_filter) return;
1727 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1729 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1731 printf("Already Registered this item filter!!!!\n");
1735 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1739 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1743 Elm_Multibuttonentry_Item_Filter *item_filter;
1745 wd = elm_widget_data_get(obj);
1747 EINA_SAFETY_ON_NULL_RETURN(func);
1749 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1751 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1753 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1754 _filter_free(item_filter);