1 #include <Elementary.h>
7 typedef enum _Multibuttonentry_Pos
9 MULTIBUTTONENTRY_POS_START,
10 MULTIBUTTONENTRY_POS_END,
11 MULTIBUTTONENTRY_POS_BEFORE,
12 MULTIBUTTONENTRY_POS_AFTER,
13 } Multibuttonentry_Pos;
15 typedef enum _Multibuttonentry_Button_State
17 MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
18 MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
19 } Multibuttonentry_Button_State;
22 typedef enum _MultiButtonEntry_Closed_Button_Type
24 MULTIBUTTONENTRY_CLOSED_IMAGE,
25 MULTIBUTTONENTRY_CLOSED_LABEL
26 } MultiButtonEntry_Closed_Button_Type;
28 typedef enum _Multibuttonentry_View_State
30 MULTIBUTTONENTRY_VIEW_NONE,
31 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
32 MULTIBUTTONENTRY_VIEW_ENTRY,
33 MULTIBUTTONENTRY_VIEW_SHRINK
34 } Multibuttonentry_View_State;
36 typedef struct _Widget_Data Widget_Data;
37 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
39 struct _Multibuttonentry_Item
43 Evas_Coord vw, rw; // vw: visual width, real width
48 typedef struct _Elm_Multibuttonentry_Item_Filter
50 Elm_Multibuttonentry_Item_Filter_Cb callback_func;
52 } Elm_Multibuttonentry_Item_Filter;
60 Evas_Object *guidetext;
61 Evas_Object *end; // used to represent the total number of invisible buttons
63 Evas_Object *rect_for_end;
64 MultiButtonEntry_Closed_Button_Type end_type;
68 Eina_List *filter_list;
70 const char *labeltxt, *guidetexttxt;
73 Multibuttonentry_View_State view_state;
75 Evas_Coord w_box, h_box;
78 Eina_Bool last_btn_select: 1;
79 Elm_Multibuttonentry_Item_Filter_Cb add_callback;
80 void *add_callback_data;
83 static const char *widtype = NULL;
84 static void _del_hook(Evas_Object *obj);
85 static void _theme_hook(Evas_Object *obj);
86 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
87 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
88 static void _sizing_eval(Evas_Object *obj);
89 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
90 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
91 static void _event_init(Evas_Object *obj);
92 static void _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink);
93 static void _view_update(Evas_Object *obj);
94 static void _set_label(Evas_Object *obj, const char *str);
95 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
96 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
97 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
98 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
99 static void _del_button_item(Elm_Multibuttonentry_Item *item);
100 static void _select_button(Evas_Object *obj, Evas_Object *btn);
101 static Elm_Object_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data);
102 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
103 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
104 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
107 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
108 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
109 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
110 static void _view_init(Evas_Object *obj);
111 static void _set_vis_guidetext(Evas_Object *obj);
112 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
113 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
114 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
115 static void _item_text_set_hook(Elm_Object_Item *it,
118 static const char *_item_text_get_hook(const Elm_Object_Item *it,
122 * Change Shrink to Expand.
124 * use evas_object_smart_callback_descriptions_set for smart callbacks.
128 _del_hook(Evas_Object *obj)
130 Widget_Data *wd = elm_widget_data_get(obj);
135 Elm_Multibuttonentry_Item *item;
136 EINA_LIST_FREE(wd->items, item)
138 _del_button_obj(obj, item->button);
145 if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
146 if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
147 if (wd->entry) evas_object_del(wd->entry);
148 if (wd->label) evas_object_del(wd->label);
149 if (wd->guidetext) evas_object_del(wd->guidetext);
150 if (wd->end) evas_object_del(wd->end);
151 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
155 _theme_hook(Evas_Object *obj)
157 Widget_Data *wd = elm_widget_data_get(obj);
159 Elm_Multibuttonentry_Item *item;
163 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
164 if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
165 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
167 EINA_LIST_FOREACH(wd->items, l, item)
170 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
171 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
178 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
180 Widget_Data *wd = elm_widget_data_get(obj);
184 if (elm_widget_focus_get(obj))
188 elm_entry_input_panel_show(wd->entry);
190 else if (((!wd->current) || (!eina_list_count(wd->items))))
192 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
194 elm_entry_input_panel_show(wd->entry);
196 wd->focused = EINA_TRUE;
197 evas_object_smart_callback_call(obj, "focused", NULL);
201 wd->focused = EINA_FALSE;
204 elm_entry_input_panel_hide(wd->entry);
205 evas_object_smart_callback_call(obj, "unfocused", NULL);
210 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
216 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
218 Widget_Data *wd = elm_widget_data_get(obj);
221 edje_object_signal_emit(wd->base, emission, source);
225 _sizing_eval(Evas_Object *obj)
227 Widget_Data *wd = elm_widget_data_get(obj);
228 Evas_Coord minw = -1, minh = -1;
229 Evas_Coord left, right, top, bottom;
232 evas_object_size_hint_min_get(wd->box, &minw, &minh);
233 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
234 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
236 minw += (left + right);
237 minh += (top + bottom);
239 evas_object_size_hint_min_set(obj, minw, minh);
243 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
245 Widget_Data *wd = elm_widget_data_get(data);
247 if (!wd || !wd->base) return;
248 wd->focused = EINA_TRUE;
251 elm_entry_input_panel_show(wd->entry);
253 evas_object_smart_callback_call(data, "clicked", NULL);
257 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
259 Evas_Object *eo = (Evas_Object *)data;
260 Widget_Data *wd = elm_widget_data_get(data);
267 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
269 Widget_Data *wd = elm_widget_data_get(data);
273 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
275 if (wd->h_box < h) evas_object_smart_callback_call(data, "expanded", NULL);
276 else if (wd->h_box > h) evas_object_smart_callback_call(data, "contracted", NULL);
285 _event_init(Evas_Object *obj)
287 Widget_Data *wd = elm_widget_data_get(obj);
289 if (!wd || !wd->base) return;
292 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
293 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
298 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
299 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
304 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
305 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
306 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
307 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
308 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
309 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
310 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
315 _set_vis_guidetext(Evas_Object *obj)
317 Widget_Data *wd = elm_widget_data_get(obj);
320 elm_box_unpack(wd->box, wd->guidetext);
321 elm_box_unpack(wd->box, wd->entry);
322 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
324 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
325 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
327 evas_object_hide(wd->entry);
328 elm_box_pack_end(wd->box, wd->guidetext);
329 evas_object_show(wd->guidetext);
330 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
334 evas_object_hide(wd->guidetext);
335 elm_box_pack_end(wd->box, wd->entry);
336 evas_object_show(wd->entry);
337 if (elm_widget_focus_get(obj) || wd->focused)
339 elm_object_focus_set(wd->entry, EINA_TRUE);
340 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
345 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
347 Widget_Data *wd = elm_widget_data_get(obj);
349 Elm_Multibuttonentry_Item *item;
351 if (!wd || !wd->box) return;
352 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
353 evas_object_hide(wd->entry);
354 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
355 evas_object_hide(wd->guidetext);
356 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
358 evas_object_hide(wd->rect_for_end);
359 evas_object_hide(wd->end);
360 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
363 if (shrink == EINA_TRUE)
365 Evas_Coord w = 0, w_tmp = 0;
366 Evas_Coord box_inner_item_width_padding = 0;
368 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
369 // unpack all items and entry
370 elm_box_unpack_all(wd->box);
371 EINA_LIST_FOREACH(wd->items, l, item)
375 evas_object_hide(item->button);
376 item->visible = EINA_FALSE;
379 // pack buttons only 1line
384 elm_box_pack_end(wd->box, wd->label);
385 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
387 w -= box_inner_item_width_padding;
391 int count = eina_list_count(wd->items);
392 Evas_Coord button_min_width = 0;
393 /* Evas_Coord button_min_height = 0; */
394 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
396 const char *size_str;
397 size_str = edje_object_data_get(wd->end, "closed_button_width");
398 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
400 size_str = edje_object_data_get(wd->end, "closed_button_height");
401 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
405 EINA_LIST_FOREACH(wd->items, l, item)
409 int w_label_count = 0;
412 elm_box_pack_end(wd->box, item->button);
413 evas_object_show(item->button);
414 item->visible = EINA_TRUE;
417 w -= box_inner_item_width_padding;
420 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
424 snprintf(buf, sizeof(buf), "... + %d", count);
425 elm_object_text_set(wd->end, buf);
426 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
429 if (w < 0 || w < w_label_count)
431 elm_box_unpack(wd->box, item->button);
432 evas_object_hide(item->button);
433 item->visible = EINA_FALSE;
436 snprintf(buf, sizeof(buf), "... + %d", count);
437 elm_object_text_set(wd->end, buf);
438 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
440 elm_box_pack_end(wd->box, wd->end);
441 evas_object_show(wd->end);
443 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
444 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
448 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
450 if (w < button_min_width)
453 Evas_Coord closed_height = 0;
454 const char *height_str = edje_object_data_get(wd->base, "closed_height");
456 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
457 elm_box_unpack(wd->box, item->button);
458 evas_object_hide(item->button);
459 item->visible = EINA_FALSE;
462 rectSize = w - button_min_width;
463 if (!wd->rect_for_end)
465 Evas *e = evas_object_evas_get(obj);
466 wd->rect_for_end = evas_object_rectangle_add(e);
467 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
469 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
470 elm_box_pack_end(wd->box, wd->rect_for_end);
471 evas_object_show(wd->rect_for_end);
473 elm_box_pack_end(wd->box, wd->end);
474 evas_object_show(wd->end);
476 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
477 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
486 // unpack all items and entry
487 elm_box_unpack_all(wd->box);
488 EINA_LIST_FOREACH(wd->items, l, item)
492 evas_object_hide(item->button);
493 item->visible = EINA_FALSE;
496 evas_object_hide(wd->end);
498 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
500 // pack buttons only 1line
502 if (wd->label) elm_box_pack_end(wd->box, wd->label);
506 EINA_LIST_FOREACH(wd->items, l, item)
510 elm_box_pack_end(wd->box, item->button);
511 evas_object_show(item->button);
512 item->visible = EINA_TRUE;
516 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
517 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)(long)wd->shrink);
519 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
521 _set_vis_guidetext(obj);
526 _view_update(Evas_Object *obj)
528 Evas_Coord width = 1, height = 1;
529 Widget_Data *wd = elm_widget_data_get(obj);
531 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
536 elm_box_unpack(wd->box, wd->label);
537 elm_box_pack_start(wd->box, wd->label);
538 evas_object_size_hint_min_get(wd->label, &width, &height);
543 Evas_Coord guide_text_width = wd->w_box - width;
544 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
547 // update buttons in shrink mode
548 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
549 _shrink_mode_set(obj, EINA_TRUE);
552 _set_vis_guidetext(obj);
556 _set_label(Evas_Object *obj, const char *str)
558 Widget_Data *wd = elm_widget_data_get(obj);
560 if (!wd || !str) return;
561 eina_stringshare_replace(&wd->labeltxt, str);
564 Evas_Coord width, height, sum_width = 0;
565 evas_object_size_hint_min_set(wd->label, 0, 0);
566 evas_object_resize(wd->label, 0, 0);
567 edje_object_part_text_set(wd->label, "mbe.label", str);
569 if (!strcmp(str, ""))
571 /* FIXME: not work yet */
572 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
573 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
578 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
579 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
583 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
586 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
589 evas_object_size_hint_min_set(wd->label, sum_width, height);
591 evas_object_show(wd->label);
596 _set_guidetext(Evas_Object *obj, const char *str)
598 Widget_Data *wd = elm_widget_data_get(obj);
600 if (!wd || !str) return;
602 eina_stringshare_replace(&wd->guidetexttxt, str);
603 if (wd->guidetext == NULL)
604 wd->guidetext = edje_object_add(evas_object_evas_get(obj));
608 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
609 "guidetext", elm_widget_style_get(obj));
610 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
611 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
613 edje_object_part_text_set(wd->guidetext, "elm.text", str);
619 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
621 Widget_Data *wd = elm_widget_data_get(obj);
622 Elm_Multibuttonentry_Item *item = NULL;
626 item = eina_list_data_get(wd->current);
628 if (item && item->button)
632 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
633 edje_object_signal_emit(item->button, "default", "");
636 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
637 edje_object_signal_emit(item->button, "focused", "");
638 evas_object_smart_callback_call(obj, "item,selected", item);
641 edje_object_signal_emit(item->button, "default", "");
649 _change_current_button(Evas_Object *obj, Evas_Object *btn)
651 Widget_Data *wd = elm_widget_data_get(obj);
653 Elm_Multibuttonentry_Item *item;
657 // change the state of previous button to "default"
658 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
660 // change the current
661 EINA_LIST_FOREACH(wd->items, l, item)
663 if (item->button == btn)
669 // change the state of current button to "focused"
670 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
674 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
676 Widget_Data *wd = elm_widget_data_get(data);
678 Elm_Multibuttonentry_Item *item = NULL;
679 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
681 _change_current_button(data, obj);
684 if ((item = eina_list_data_get(wd->current)) != NULL)
686 evas_object_smart_callback_call(data, "item,clicked", item);
687 _select_button(data, item->button);
692 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
694 Widget_Data *wd = elm_widget_data_get(obj);
696 if (!wd || !btn) return;
698 evas_object_del(btn);
702 _del_button_item(Elm_Multibuttonentry_Item *item)
705 Elm_Multibuttonentry_Item *_item;
709 Evas_Object *obj = WIDGET(item);
710 wd = elm_widget_data_get(obj);
712 EINA_LIST_FOREACH(wd->items, l, _item)
716 wd->items = eina_list_remove(wd->items, _item);
717 elm_box_unpack(wd->box, _item->button);
719 evas_object_smart_callback_call(obj, "item,deleted", _item);
721 _del_button_obj(obj, _item->button);
723 if (wd->current == l)
728 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
729 _shrink_mode_set(obj, EINA_TRUE);
731 if (!eina_list_count(wd->items))
732 _set_vis_guidetext(obj);
736 _select_button(Evas_Object *obj, Evas_Object *btn)
738 Widget_Data *wd = elm_widget_data_get(obj);
743 _change_current_button(obj, btn);
744 if (elm_widget_focus_get(obj))
746 elm_object_focus_set(wd->entry, EINA_FALSE);
747 evas_object_focus_set(btn, EINA_TRUE);
752 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
753 if (elm_widget_focus_get(obj))
754 elm_object_focus_set(wd->entry, EINA_TRUE);
759 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
762 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
763 Evas_Coord w_btn = 0, button_max_width = 0;
764 const char *size_str;
766 size_str = edje_object_data_get(btn, "button_max_size");
767 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
769 // decide the size of button
770 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
771 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
772 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
773 w_btn = w_text + 2*padding_outer + 2*padding_inner;
777 if (button_max_width < w_btn)
778 vw = button_max_width;
783 evas_object_resize(btn, vw, h_btn);
784 evas_object_size_hint_min_set(btn, vw, h_btn);
786 if (realw) *realw = rw;
787 if (vieww) *vieww = vw;
791 _item_del_pre_hook(Elm_Object_Item *it)
793 _del_button_item((Elm_Multibuttonentry_Item *)it);
797 static Elm_Object_Item*
798 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
800 Elm_Multibuttonentry_Item *item;
801 Elm_Multibuttonentry_Item_Filter *item_filter;
802 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
805 Evas_Coord width = -1, height = -1;
806 char *str_utf8 = NULL;
807 Widget_Data *wd = elm_widget_data_get(obj);
809 if (!wd || !wd->box || !wd->entry) return NULL;
810 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
811 if (!str) return NULL;
813 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
815 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
819 btn = edje_object_add(evas_object_evas_get(obj));
820 str_utf8 = elm_entry_markup_to_utf8(str);
822 //entry is cleared when text is made to button
823 elm_object_text_set(wd->entry, "");
825 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
826 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
827 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
829 evas_object_size_hint_min_set(btn, width, height);
831 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
832 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
833 evas_object_show(btn);
836 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
839 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
840 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
841 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
842 elm_widget_item_data_set(item, data);
844 _resize_button(btn, &rw, &vw);
848 item->visible = EINA_TRUE;
857 case MULTIBUTTONENTRY_POS_START:
858 wd->items = eina_list_prepend(wd->items, item);
859 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
861 elm_widget_sub_object_add(obj, btn);
862 _shrink_mode_set(obj, EINA_TRUE);
867 elm_box_pack_after(wd->box, btn, wd->label);
869 elm_box_pack_start(wd->box, btn);
870 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
871 _set_vis_guidetext(obj);
874 case MULTIBUTTONENTRY_POS_END:
875 wd->items = eina_list_append(wd->items, item);
876 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
878 elm_widget_sub_object_add(obj, btn);
879 evas_object_hide(btn);
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);
891 case MULTIBUTTONENTRY_POS_BEFORE:
893 wd->items = eina_list_prepend_relative(wd->items, item, reference);
895 wd->items = eina_list_append(wd->items, item);
896 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
898 elm_widget_sub_object_add(obj, btn);
899 evas_object_hide(btn);
900 _shrink_mode_set(obj, EINA_TRUE);
905 elm_box_pack_before(wd->box, btn, reference->button);
908 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
909 _set_vis_guidetext(obj);
911 elm_box_pack_before(wd->box, btn, wd->entry);
913 elm_box_pack_end(wd->box, btn);
917 case MULTIBUTTONENTRY_POS_AFTER:
919 wd->items = eina_list_append_relative(wd->items, item, reference);
921 wd->items = eina_list_append(wd->items, item);
922 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
924 elm_widget_sub_object_add(obj, btn);
925 _shrink_mode_set(obj, EINA_TRUE);
930 elm_box_pack_after(wd->box, btn, reference->button);
933 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
934 _set_vis_guidetext(obj);
936 elm_box_pack_before(wd->box, btn, wd->entry);
938 elm_box_pack_end(wd->box, btn);
946 evas_object_smart_callback_call(obj, "item,added", item);
950 return (Elm_Object_Item *)item;
953 static Elm_Multibuttonentry_Item_Filter*
954 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
956 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
957 if (!item_filter) return NULL;
959 item_filter->callback_func= func;
960 item_filter->data = data;
966 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
972 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
974 Widget_Data *wd = elm_widget_data_get(data);
975 Elm_Multibuttonentry_Item *item = NULL;
977 if (!wd || !wd->base || !wd->box) return;
979 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
981 if (wd->last_btn_select)
984 ((strcmp(ev->keyname, "BackSpace") == 0) ||
985 (strcmp(ev->keyname, "Delete") == 0)))
987 item = eina_list_data_get(wd->current);
990 _del_button_item(item);
991 elm_widget_item_free(item);
992 elm_object_focus_set(wd->entry, EINA_TRUE);
995 else if (((!wd->current && (wd->n_str == 0) &&
996 (strcmp(ev->keyname, "BackSpace") == 0)) ||
997 (strcmp(ev->keyname, "Delete") == 0)))
999 item = eina_list_data_get(eina_list_last(wd->items));
1001 _select_button(data, item->button);
1005 wd->last_btn_select = EINA_TRUE;
1009 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1011 Widget_Data *wd = elm_widget_data_get(data);
1012 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1016 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1017 wd->last_btn_select = EINA_FALSE;
1021 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1023 Widget_Data *wd = elm_widget_data_get(data);
1024 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1027 if (!wd || !wd->base || !wd->box) return;
1029 str = elm_object_text_get(wd->entry);
1031 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1033 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1039 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1041 Widget_Data *wd = elm_widget_data_get(data);
1044 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1045 elm_object_focus_set(wd->entry, EINA_TRUE);
1049 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1051 Widget_Data *wd = elm_widget_data_get(data);
1052 Elm_Multibuttonentry_Item *item = NULL;
1058 item = eina_list_data_get(wd->current);
1059 elm_object_focus_set(wd->entry, EINA_FALSE);
1060 evas_object_focus_set(item->button, EINA_TRUE);
1065 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1067 Widget_Data *wd = elm_widget_data_get(data);
1072 str = elm_object_text_get(wd->entry);
1074 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1078 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1080 Widget_Data *wd = elm_widget_data_get(data);
1085 str = elm_object_text_get(wd->entry);
1086 wd->n_str = strlen(str);
1090 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1092 Evas_Coord en_x, en_y, en_w, en_h;
1093 Evas_Coord bx_x, bx_y;
1095 Widget_Data *wd = elm_widget_data_get(data);
1098 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1099 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1102 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
1107 _view_init(Evas_Object *obj)
1109 Widget_Data *wd = elm_widget_data_get(obj);
1115 wd->box = elm_box_add(obj);
1116 if (!wd->box) return;
1117 elm_widget_sub_object_add(obj, wd->box);
1118 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1119 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1120 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1124 wd->label = edje_object_add(evas_object_evas_get(obj));
1125 if (!wd->label) return;
1126 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1127 _set_label(obj, "");
1128 elm_widget_sub_object_add(obj, wd->label);
1133 wd->entry = elm_entry_add(obj);
1134 if (!wd->entry) return;
1135 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1136 elm_object_text_set(wd->entry, "");
1137 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1138 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1139 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1140 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1141 if (wd->box) elm_box_pack_end(wd->box, wd->entry);
1142 evas_object_show(wd->entry);
1143 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1148 const char *end_type;
1150 end_type = edje_object_data_get(wd->base, "closed_button_type");
1151 if (!end_type || !strcmp(end_type, "label"))
1153 wd->end = elm_label_add(obj);
1154 if (!wd->end) return;
1155 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1156 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1160 const char *size_str;
1161 wd->end = edje_object_add(evas_object_evas_get(obj));
1162 if (!wd->end) return;
1163 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1164 Evas_Coord button_min_width = 0;
1165 Evas_Coord button_min_height = 0;
1167 size_str = edje_object_data_get(wd->end, "closed_button_width");
1168 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1169 size_str = edje_object_data_get(wd->end, "closed_button_height");
1170 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1172 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1173 evas_object_size_hint_min_set(wd->end,
1174 button_min_width * _elm_config->scale,
1175 button_min_height * _elm_config->scale);
1176 elm_widget_sub_object_add(obj, wd->end);
1182 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1184 Evas_Coord minw, minh, mnw, mnh, ww;
1185 Evas_Coord w, cw = 0, cmaxh = 0;
1187 Evas_Object_Box_Option *opt;
1190 /* FIXME: need to calc max */
1194 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1195 evas_object_size_hint_min_get(box, &minw, NULL);
1197 EINA_LIST_FOREACH(priv->children, l, opt)
1199 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1200 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1204 if (mnw != -1 && (w - cw) >= mnw)
1219 if (cmaxh < mnh) cmaxh = mnh;
1224 evas_object_size_hint_min_set(box, minw, minh);
1228 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1230 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1232 Evas_Object_Box_Option *opt;
1233 int local_index = 0;
1236 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1238 EINA_LIST_FOREACH(priv->children, l, opt)
1240 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1241 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1245 if (mnw != -1 && (w - cw) >= mnw)
1255 if (local_index > obj_index) return cmaxh;
1261 if (cmaxh < mnh) cmaxh = mnh;
1270 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1272 Evas_Coord x, y, w, h, xx, yy;
1275 Evas_Coord minw, minh;
1277 Evas_Object_Box_Option *opt;
1279 _calculate_box_min_size(o, priv);
1281 evas_object_geometry_get(o, &x, &y, &w, &h);
1283 evas_object_size_hint_min_get(o, &minw, &minh);
1284 evas_object_size_hint_align_get(o, &ax, &ay);
1287 x = x + ((w - minw) * (1.0 - ax));
1292 y = y + ((h - minh) * (1.0 - ay));
1299 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1301 EINA_LIST_FOREACH(priv->children, l, opt)
1303 Evas_Coord mnw, mnh, mxw, mxh;
1308 evas_object_size_hint_align_get(obj, &ax, &ay);
1309 evas_object_size_hint_weight_get(obj, &wx, &wy);
1310 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1311 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1313 if (ax == -1.0) {fw = 1; ax = 0.5;}
1314 if (ay == -1.0) {fh = 1; ay = 0.5;}
1315 Evas_Coord ww, hh, ow, oh;
1319 if (mnw != -1 && (w - cw) >= mnw)
1326 hh = _calculate_item_max_height(o, priv, obj_index);
1330 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1333 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1342 evas_object_move(obj,
1343 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1344 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1345 evas_object_resize(obj, ow, oh);
1348 if (cmaxh < hh) cmaxh = hh;
1355 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1357 Elm_Multibuttonentry_Item *item;
1358 if (part && strcmp(part, "default")) return;
1360 item = (Elm_Multibuttonentry_Item *)it;
1361 edje_object_part_text_set(item->button, "elm.btn.text", label);
1362 _resize_button(item->button, &item->rw, &item->vw);
1366 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1368 Elm_Multibuttonentry_Item *item;
1369 if (part && strcmp(part, "default")) return NULL;
1370 item = (Elm_Multibuttonentry_Item *)it;
1371 return edje_object_part_text_get(item->button, "elm.btn.text");
1375 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1377 ELM_CHECK_WIDTYPE(obj, widtype);
1378 if (!part || !strcmp(part, "default"))
1380 if (label) _set_label(obj, label);
1381 else _set_label(obj, "");
1383 else if (!strcmp(part, "guide"))
1385 if (label) _set_guidetext(obj, label);
1386 else _set_guidetext(obj, "");
1391 _text_get_hook(const Evas_Object *obj, const char *part)
1393 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1394 Widget_Data *wd = elm_widget_data_get(obj);
1395 if (!wd) return NULL;
1397 if (!part || !strcmp(part, "default"))
1399 return wd->labeltxt;
1401 else if (!strcmp(part, "guide"))
1403 return wd->guidetexttxt;
1409 elm_multibuttonentry_add(Evas_Object *parent)
1415 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1417 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1418 elm_widget_type_set(obj, "multibuttonentry");
1419 elm_widget_sub_object_add(parent, obj);
1420 elm_widget_data_set(obj, wd);
1422 elm_widget_del_hook_set(obj, _del_hook);
1423 elm_widget_theme_hook_set(obj, _theme_hook);
1424 elm_widget_event_hook_set(obj, _event_hook);
1425 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1426 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1427 elm_widget_text_set_hook_set(obj, _text_set_hook);
1428 elm_widget_text_get_hook_set(obj, _text_get_hook);
1430 wd->base = edje_object_add(e);
1431 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1432 elm_widget_resize_object_set(obj, wd->base);
1433 elm_widget_can_focus_set(obj, EINA_TRUE);
1435 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1436 wd->focused = EINA_FALSE;
1437 wd->last_btn_select = EINA_TRUE;
1439 wd->rect_for_end = NULL;
1440 wd->add_callback = NULL;
1441 wd->add_callback_data = NULL;
1450 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1452 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1453 Widget_Data *wd = elm_widget_data_get(obj);
1455 if (!wd) return NULL;
1460 EINA_DEPRECATED EAPI const char *
1461 elm_multibuttonentry_label_get(const Evas_Object *obj)
1463 return _text_get_hook(obj, NULL);
1466 EINA_DEPRECATED EAPI void
1467 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1469 _text_set_hook(obj, NULL, label);
1472 EINA_DEPRECATED EAPI const char *
1473 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1475 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1476 Widget_Data *wd = elm_widget_data_get(obj);
1478 if (!wd) return NULL;
1479 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1483 EINA_DEPRECATED EAPI void
1484 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1486 ELM_CHECK_WIDTYPE(obj, widtype);
1487 Widget_Data *wd = elm_widget_data_get(obj);
1491 _set_guidetext(obj, guidetext);
1494 EINA_DEPRECATED EAPI int
1495 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1497 if (elm_multibuttonentry_expanded_get(obj))
1504 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1506 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1507 Widget_Data *wd = elm_widget_data_get(obj);
1510 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1514 EINA_DEPRECATED EAPI void
1515 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1518 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
1521 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
1525 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1527 ELM_CHECK_WIDTYPE(obj, widtype);
1528 Widget_Data *wd = elm_widget_data_get(obj);
1530 if (!wd || !wd->box ||
1531 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1534 _shrink_mode_set(obj, EINA_FALSE);
1536 _shrink_mode_set(obj, EINA_TRUE);
1540 EAPI Elm_Object_Item *
1541 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1543 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
1546 EAPI Elm_Object_Item *
1547 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1549 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
1552 EAPI Elm_Object_Item *
1553 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
1555 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
1558 EAPI Elm_Object_Item *
1559 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
1561 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
1564 EAPI const Eina_List *
1565 elm_multibuttonentry_items_get(const Evas_Object *obj)
1567 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1568 Widget_Data *wd = elm_widget_data_get(obj);
1569 if (!wd) return NULL;
1573 EAPI Elm_Object_Item *
1574 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1576 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1577 Widget_Data *wd = elm_widget_data_get(obj);
1578 if (!wd) return NULL;
1579 return eina_list_data_get(wd->items);
1582 EAPI Elm_Object_Item *
1583 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1585 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1586 Widget_Data *wd = elm_widget_data_get(obj);
1587 if (!wd) return NULL;
1588 return eina_list_data_get(eina_list_last(wd->items));
1591 EAPI Elm_Object_Item *
1592 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1594 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1595 Widget_Data *wd = elm_widget_data_get(obj);
1596 if (!wd) return NULL;
1597 return eina_list_data_get(wd->current);
1601 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1603 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1604 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
1605 if (selected) _select_button(WIDGET(item), item->button);
1606 else _select_button(WIDGET(item), NULL);
1610 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
1612 //TODO : To be implemented.
1613 if (!it) return EINA_FALSE;
1618 elm_multibuttonentry_clear(Evas_Object *obj)
1620 ELM_CHECK_WIDTYPE(obj, widtype);
1621 Elm_Multibuttonentry_Item *item;
1622 Widget_Data *wd = elm_widget_data_get(obj);
1627 EINA_LIST_FREE(wd->items, item)
1629 elm_box_unpack(wd->box, item->button);
1630 _del_button_obj(obj, item->button);
1640 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1642 elm_object_item_del(it);
1646 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1648 return _item_text_get_hook(it, NULL);
1652 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1654 _item_text_set_hook(it, NULL, str);
1657 EAPI Elm_Object_Item *
1658 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1660 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1663 Elm_Multibuttonentry_Item *_item;
1665 wd = elm_widget_data_get(WIDGET(it));
1666 if (!wd) return NULL;
1668 EINA_LIST_FOREACH(wd->items, l, _item)
1670 if (_item == (Elm_Multibuttonentry_Item *)it)
1672 l = eina_list_prev(l);
1673 if (!l) return NULL;
1674 return eina_list_data_get(l);
1680 EAPI Elm_Object_Item *
1681 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1683 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1686 Elm_Multibuttonentry_Item *_item;
1687 wd = elm_widget_data_get(WIDGET(it));
1688 if (!wd) return NULL;
1690 EINA_LIST_FOREACH(wd->items, l, _item)
1692 if (_item == (Elm_Multibuttonentry_Item *)it)
1694 l = eina_list_next(l);
1695 if (!l) return NULL;
1696 return eina_list_data_get(l);
1703 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1705 return elm_widget_item_data_get(it);
1709 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1711 return elm_widget_item_data_set(it, data);
1715 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1717 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1718 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1721 Widget_Data *wd = elm_widget_data_get(obj);
1724 ELM_CHECK_WIDTYPE(obj, widtype);
1725 EINA_SAFETY_ON_NULL_RETURN(func);
1727 new_item_filter= _filter_new(func, data);
1728 if (!new_item_filter) return;
1730 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1732 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1734 printf("Already Registered this item filter!!!!\n");
1738 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1742 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1744 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1745 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1747 Widget_Data *wd = elm_widget_data_get(obj);
1750 ELM_CHECK_WIDTYPE(obj, widtype);
1751 EINA_SAFETY_ON_NULL_RETURN(func);
1753 new_item_filter = _filter_new(func, data);
1754 if (!new_item_filter) return;
1756 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1758 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1760 printf("Already Registered this item filter!!!!\n");
1764 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1768 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1772 Elm_Multibuttonentry_Item_Filter *item_filter;
1774 wd = elm_widget_data_get(obj);
1776 EINA_SAFETY_ON_NULL_RETURN(func);
1778 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1780 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1782 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1783 _filter_free(item_filter);