1 #include <Elementary.h>
7 typedef enum _Multibuttonentry_Pos
9 MULTIBUTTONENTRY_POS_START,
10 MULTIBUTTONENTRY_POS_END,
11 MULTIBUTTONENTRY_POS_BEFORE,
12 MULTIBUTTONENTRY_POS_AFTER,
13 } Multibuttonentry_Pos;
15 typedef enum _Multibuttonentry_Button_State
17 MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
18 MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
19 } Multibuttonentry_Button_State;
22 typedef enum _MultiButtonEntry_Closed_Button_Type
24 MULTIBUTTONENTRY_CLOSED_IMAGE,
25 MULTIBUTTONENTRY_CLOSED_LABEL
26 } MultiButtonEntry_Closed_Button_Type;
28 typedef enum _Multibuttonentry_View_State
30 MULTIBUTTONENTRY_VIEW_NONE,
31 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
32 MULTIBUTTONENTRY_VIEW_ENTRY,
33 MULTIBUTTONENTRY_VIEW_SHRINK
34 } Multibuttonentry_View_State;
36 typedef struct _Widget_Data Widget_Data;
37 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
39 struct _Multibuttonentry_Item
43 Evas_Coord vw, rw; // vw: visual width, real width
48 typedef struct _Elm_Multibuttonentry_Item_Filter
50 Elm_Multibuttonentry_Item_Filter_Cb callback_func;
52 } Elm_Multibuttonentry_Item_Filter;
60 Evas_Object *guidetext;
61 Evas_Object *end; // used to represent the total number of invisible buttons
63 Evas_Object *rect_for_end;
64 MultiButtonEntry_Closed_Button_Type end_type;
68 Eina_List *filter_list;
70 const char *labeltxt, *guidetexttxt;
73 Multibuttonentry_View_State view_state;
75 Evas_Coord w_box, h_box;
78 Eina_Bool last_btn_select: 1;
79 Elm_Multibuttonentry_Item_Filter_Cb add_callback;
80 void *add_callback_data;
83 static const char *widtype = NULL;
84 static void _del_hook(Evas_Object *obj);
85 static void _theme_hook(Evas_Object *obj);
86 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
87 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
88 static void _sizing_eval(Evas_Object *obj);
89 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
90 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
91 static void _event_init(Evas_Object *obj);
92 static void _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink);
93 static void _view_update(Evas_Object *obj);
94 static void _set_label(Evas_Object *obj, const char *str);
95 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
96 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
97 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
98 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
99 static void _del_button_item(Elm_Multibuttonentry_Item *item);
100 static void _select_button(Evas_Object *obj, Evas_Object *btn);
101 static Elm_Object_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data);
102 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
103 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
104 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
107 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
108 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
109 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
110 static void _view_init(Evas_Object *obj);
111 static void _set_vis_guidetext(Evas_Object *obj);
112 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
113 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
114 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
115 static void _item_text_set_hook(Elm_Object_Item *it,
118 static const char *_item_text_get_hook(const Elm_Object_Item *it,
123 * use evas_object_smart_callback_descriptions_set for smart callbacks.
127 _del_hook(Evas_Object *obj)
129 Widget_Data *wd = elm_widget_data_get(obj);
134 Elm_Multibuttonentry_Item *item;
135 EINA_LIST_FREE(wd->items, item)
137 _del_button_obj(obj, item->button);
144 if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
145 if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
146 if (wd->entry) evas_object_del(wd->entry);
147 if (wd->label) evas_object_del(wd->label);
148 if (wd->guidetext) evas_object_del(wd->guidetext);
149 if (wd->end) evas_object_del(wd->end);
150 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
154 _theme_hook(Evas_Object *obj)
156 Widget_Data *wd = elm_widget_data_get(obj);
158 Elm_Multibuttonentry_Item *item;
162 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
163 if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
164 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
166 EINA_LIST_FOREACH(wd->items, l, item)
169 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
170 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
177 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
179 Widget_Data *wd = elm_widget_data_get(obj);
183 if (elm_widget_focus_get(obj))
187 elm_entry_input_panel_show(wd->entry);
189 else if (((!wd->current) || (!eina_list_count(wd->items))))
191 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
193 elm_entry_input_panel_show(wd->entry);
195 wd->focused = EINA_TRUE;
196 evas_object_smart_callback_call(obj, "focused", NULL);
200 wd->focused = EINA_FALSE;
203 elm_entry_input_panel_hide(wd->entry);
204 evas_object_smart_callback_call(obj, "unfocused", NULL);
209 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
215 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
217 Widget_Data *wd = elm_widget_data_get(obj);
220 edje_object_signal_emit(wd->base, emission, source);
224 _sizing_eval(Evas_Object *obj)
226 Widget_Data *wd = elm_widget_data_get(obj);
227 Evas_Coord minw = -1, minh = -1;
228 Evas_Coord left, right, top, bottom;
231 evas_object_size_hint_min_get(wd->box, &minw, &minh);
232 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
233 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
235 minw += (left + right);
236 minh += (top + bottom);
238 evas_object_size_hint_min_set(obj, minw, minh);
242 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
244 Widget_Data *wd = elm_widget_data_get(data);
246 if (!wd || !wd->base) return;
247 wd->focused = EINA_TRUE;
250 elm_entry_input_panel_show(wd->entry);
252 evas_object_smart_callback_call(data, "clicked", NULL);
256 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
258 Evas_Object *eo = (Evas_Object *)data;
259 Widget_Data *wd = elm_widget_data_get(data);
266 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
268 Widget_Data *wd = elm_widget_data_get(data);
272 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
274 if (wd->h_box < h) evas_object_smart_callback_call(data, "expanded", NULL);
275 else if (wd->h_box > h) evas_object_smart_callback_call(data, "contracted", NULL);
284 _event_init(Evas_Object *obj)
286 Widget_Data *wd = elm_widget_data_get(obj);
288 if (!wd || !wd->base) return;
291 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
292 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
297 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
298 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
303 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
304 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
305 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
306 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
307 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
308 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
309 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
314 _set_vis_guidetext(Evas_Object *obj)
316 Widget_Data *wd = elm_widget_data_get(obj);
319 elm_box_unpack(wd->box, wd->guidetext);
320 elm_box_unpack(wd->box, wd->entry);
321 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
323 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
324 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
326 evas_object_hide(wd->entry);
327 elm_box_pack_end(wd->box, wd->guidetext);
328 evas_object_show(wd->guidetext);
329 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
333 evas_object_hide(wd->guidetext);
334 elm_box_pack_end(wd->box, wd->entry);
335 evas_object_show(wd->entry);
336 if (elm_widget_focus_get(obj) || wd->focused)
338 elm_object_focus_set(wd->entry, EINA_TRUE);
339 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
344 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
346 Widget_Data *wd = elm_widget_data_get(obj);
348 Elm_Multibuttonentry_Item *item;
350 if (!wd || !wd->box) return;
351 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
352 evas_object_hide(wd->entry);
353 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
354 evas_object_hide(wd->guidetext);
355 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
357 evas_object_hide(wd->rect_for_end);
358 evas_object_hide(wd->end);
359 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
362 if (shrink == EINA_TRUE)
364 Evas_Coord w = 0, w_tmp = 0;
365 Evas_Coord box_inner_item_width_padding = 0;
367 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
368 // unpack all items and entry
369 elm_box_unpack_all(wd->box);
370 EINA_LIST_FOREACH(wd->items, l, item)
374 evas_object_hide(item->button);
375 item->visible = EINA_FALSE;
378 // pack buttons only 1line
383 elm_box_pack_end(wd->box, wd->label);
384 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
386 w -= box_inner_item_width_padding;
390 int count = eina_list_count(wd->items);
391 Evas_Coord button_min_width = 0;
392 /* Evas_Coord button_min_height = 0; */
393 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
395 const char *size_str;
396 size_str = edje_object_data_get(wd->end, "closed_button_width");
397 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
399 size_str = edje_object_data_get(wd->end, "closed_button_height");
400 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
404 EINA_LIST_FOREACH(wd->items, l, item)
408 int w_label_count = 0;
411 elm_box_pack_end(wd->box, item->button);
412 evas_object_show(item->button);
413 item->visible = EINA_TRUE;
416 w -= box_inner_item_width_padding;
419 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
423 snprintf(buf, sizeof(buf), "... + %d", count);
424 elm_object_text_set(wd->end, buf);
425 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
428 if (w < 0 || w < w_label_count)
430 elm_box_unpack(wd->box, item->button);
431 evas_object_hide(item->button);
432 item->visible = EINA_FALSE;
435 snprintf(buf, sizeof(buf), "... + %d", count);
436 elm_object_text_set(wd->end, buf);
437 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
439 elm_box_pack_end(wd->box, wd->end);
440 evas_object_show(wd->end);
442 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
443 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)1);
447 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
449 if (w < button_min_width)
452 Evas_Coord closed_height = 0;
453 const char *height_str = edje_object_data_get(wd->base, "closed_height");
455 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
456 elm_box_unpack(wd->box, item->button);
457 evas_object_hide(item->button);
458 item->visible = EINA_FALSE;
461 rectSize = w - button_min_width;
462 if (!wd->rect_for_end)
464 Evas *e = evas_object_evas_get(obj);
465 wd->rect_for_end = evas_object_rectangle_add(e);
466 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
468 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
469 elm_box_pack_end(wd->box, wd->rect_for_end);
470 evas_object_show(wd->rect_for_end);
472 elm_box_pack_end(wd->box, wd->end);
473 evas_object_show(wd->end);
475 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
476 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)0);
485 // unpack all items and entry
486 elm_box_unpack_all(wd->box);
487 EINA_LIST_FOREACH(wd->items, l, item)
491 evas_object_hide(item->button);
492 item->visible = EINA_FALSE;
495 evas_object_hide(wd->end);
497 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
499 // pack buttons only 1line
501 if (wd->label) elm_box_pack_end(wd->box, wd->label);
505 EINA_LIST_FOREACH(wd->items, l, item)
509 elm_box_pack_end(wd->box, item->button);
510 evas_object_show(item->button);
511 item->visible = EINA_TRUE;
515 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
516 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)(long)wd->shrink);
518 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
520 _set_vis_guidetext(obj);
525 _view_update(Evas_Object *obj)
527 Evas_Coord width = 1, height = 1;
528 Widget_Data *wd = elm_widget_data_get(obj);
530 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
535 elm_box_unpack(wd->box, wd->label);
536 elm_box_pack_start(wd->box, wd->label);
537 evas_object_size_hint_min_get(wd->label, &width, &height);
542 Evas_Coord guide_text_width = wd->w_box - width;
543 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
546 // update buttons in shrink mode
547 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
548 _shrink_mode_set(obj, EINA_TRUE);
551 _set_vis_guidetext(obj);
555 _set_label(Evas_Object *obj, const char *str)
557 Widget_Data *wd = elm_widget_data_get(obj);
559 if (!wd || !str) return;
560 eina_stringshare_replace(&wd->labeltxt, str);
563 Evas_Coord width, height, sum_width = 0;
564 evas_object_size_hint_min_set(wd->label, 0, 0);
565 evas_object_resize(wd->label, 0, 0);
566 edje_object_part_text_set(wd->label, "mbe.label", str);
568 if (!strcmp(str, ""))
570 /* FIXME: not work yet */
571 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
572 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
577 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
578 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
582 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
585 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
588 evas_object_size_hint_min_set(wd->label, sum_width, height);
590 evas_object_show(wd->label);
595 _set_guidetext(Evas_Object *obj, const char *str)
597 Widget_Data *wd = elm_widget_data_get(obj);
599 if (!wd || !str) return;
601 eina_stringshare_replace(&wd->guidetexttxt, str);
602 if (wd->guidetext == NULL)
603 wd->guidetext = edje_object_add(evas_object_evas_get(obj));
607 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
608 "guidetext", elm_widget_style_get(obj));
609 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
610 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
612 edje_object_part_text_set(wd->guidetext, "elm.text", str);
618 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
620 Widget_Data *wd = elm_widget_data_get(obj);
621 Elm_Multibuttonentry_Item *item = NULL;
625 item = eina_list_data_get(wd->current);
627 if (item && item->button)
631 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
632 edje_object_signal_emit(item->button, "default", "");
635 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
636 edje_object_signal_emit(item->button, "focused", "");
637 evas_object_smart_callback_call(obj, "item,selected", item);
640 edje_object_signal_emit(item->button, "default", "");
648 _change_current_button(Evas_Object *obj, Evas_Object *btn)
650 Widget_Data *wd = elm_widget_data_get(obj);
652 Elm_Multibuttonentry_Item *item;
656 // change the state of previous button to "default"
657 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
659 // change the current
660 EINA_LIST_FOREACH(wd->items, l, item)
662 if (item->button == btn)
668 // change the state of current button to "focused"
669 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
673 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
675 Widget_Data *wd = elm_widget_data_get(data);
677 Elm_Multibuttonentry_Item *item = NULL;
678 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
680 _select_button(data, obj);
682 if ((wd->current) && ((item = eina_list_data_get(wd->current)) != NULL))
683 evas_object_smart_callback_call(data, "item,clicked", item);
687 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
689 Widget_Data *wd = elm_widget_data_get(obj);
691 if (!wd || !btn) return;
693 evas_object_del(btn);
697 _del_button_item(Elm_Multibuttonentry_Item *item)
700 Elm_Multibuttonentry_Item *_item;
704 Evas_Object *obj = WIDGET(item);
705 wd = elm_widget_data_get(obj);
707 EINA_LIST_FOREACH(wd->items, l, _item)
711 wd->items = eina_list_remove(wd->items, _item);
712 elm_box_unpack(wd->box, _item->button);
714 evas_object_smart_callback_call(obj, "item,deleted", _item);
716 _del_button_obj(obj, _item->button);
718 if (wd->current == l)
723 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
724 _shrink_mode_set(obj, EINA_TRUE);
726 if (!eina_list_count(wd->items))
727 _set_vis_guidetext(obj);
731 _select_button(Evas_Object *obj, Evas_Object *btn)
733 Widget_Data *wd = elm_widget_data_get(obj);
738 _change_current_button(obj, btn);
739 if (elm_widget_focus_get(obj))
741 elm_object_focus_set(wd->entry, EINA_FALSE);
742 evas_object_focus_set(btn, EINA_TRUE);
747 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
748 if (elm_widget_focus_get(obj))
749 elm_object_focus_set(wd->entry, EINA_TRUE);
754 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
757 Evas_Coord w_text, h_btn, padding_outer = 0;
758 Evas_Coord w_btn = 0, button_max_width = 0;
759 const char *size_str;
761 size_str = edje_object_data_get(btn, "button_max_size");
762 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
764 // decide the size of button
765 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
766 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
767 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
768 w_btn = w_text + 2*padding_outer;
771 if (button_max_width < w_btn)
772 vw = button_max_width;
777 evas_object_resize(btn, vw, h_btn);
778 evas_object_size_hint_min_set(btn, vw, h_btn);
780 if (realw) *realw = rw;
781 if (vieww) *vieww = vw;
785 _item_del_pre_hook(Elm_Object_Item *it)
787 _del_button_item((Elm_Multibuttonentry_Item *)it);
791 static Elm_Object_Item*
792 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
794 Elm_Multibuttonentry_Item *item;
795 Elm_Multibuttonentry_Item_Filter *item_filter;
796 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
799 Evas_Coord width = -1, height = -1;
800 char *str_utf8 = NULL;
801 Widget_Data *wd = elm_widget_data_get(obj);
803 if (!wd || !wd->box || !wd->entry) return NULL;
804 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
805 if (!str) return NULL;
807 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
809 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
813 btn = edje_object_add(evas_object_evas_get(obj));
814 str_utf8 = elm_entry_markup_to_utf8(str);
816 //entry is cleared when text is made to button
817 elm_object_text_set(wd->entry, "");
819 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
820 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
821 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
823 evas_object_size_hint_min_set(btn, width, height);
825 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
826 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
827 evas_object_show(btn);
830 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
833 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
834 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
835 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
836 elm_widget_item_data_set(item, data);
838 _resize_button(btn, &rw, &vw);
842 item->visible = EINA_TRUE;
851 case MULTIBUTTONENTRY_POS_START:
852 wd->items = eina_list_prepend(wd->items, item);
853 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
855 elm_widget_sub_object_add(obj, btn);
856 _shrink_mode_set(obj, EINA_TRUE);
861 elm_box_pack_after(wd->box, btn, wd->label);
863 elm_box_pack_start(wd->box, btn);
864 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
865 _set_vis_guidetext(obj);
868 case MULTIBUTTONENTRY_POS_END:
869 wd->items = eina_list_append(wd->items, item);
870 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
872 elm_widget_sub_object_add(obj, btn);
873 evas_object_hide(btn);
877 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
878 _set_vis_guidetext(obj);
880 elm_box_pack_before(wd->box, btn, wd->entry);
882 elm_box_pack_end(wd->box, btn);
885 case MULTIBUTTONENTRY_POS_BEFORE:
887 wd->items = eina_list_prepend_relative(wd->items, item, reference);
889 wd->items = eina_list_append(wd->items, item);
890 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
892 elm_widget_sub_object_add(obj, btn);
893 evas_object_hide(btn);
894 _shrink_mode_set(obj, EINA_TRUE);
899 elm_box_pack_before(wd->box, btn, reference->button);
902 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
903 _set_vis_guidetext(obj);
905 elm_box_pack_before(wd->box, btn, wd->entry);
907 elm_box_pack_end(wd->box, btn);
911 case MULTIBUTTONENTRY_POS_AFTER:
913 wd->items = eina_list_append_relative(wd->items, item, reference);
915 wd->items = eina_list_append(wd->items, item);
916 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
918 elm_widget_sub_object_add(obj, btn);
919 _shrink_mode_set(obj, EINA_TRUE);
924 elm_box_pack_after(wd->box, btn, reference->button);
927 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
928 _set_vis_guidetext(obj);
930 elm_box_pack_before(wd->box, btn, wd->entry);
932 elm_box_pack_end(wd->box, btn);
940 evas_object_smart_callback_call(obj, "item,added", item);
944 return (Elm_Object_Item *)item;
947 static Elm_Multibuttonentry_Item_Filter*
948 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
950 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
951 if (!item_filter) return NULL;
953 item_filter->callback_func= func;
954 item_filter->data = data;
960 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
966 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
968 Widget_Data *wd = elm_widget_data_get(data);
969 Elm_Multibuttonentry_Item *item = NULL;
971 if (!wd || !wd->base || !wd->box) return;
973 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
975 if (wd->last_btn_select)
978 ((strcmp(ev->keyname, "BackSpace") == 0) ||
979 (strcmp(ev->keyname, "Delete") == 0)))
981 item = eina_list_data_get(wd->current);
984 _del_button_item(item);
985 elm_widget_item_free(item);
986 elm_object_focus_set(wd->entry, EINA_TRUE);
989 else if (((!wd->current && (wd->n_str == 0) &&
990 (strcmp(ev->keyname, "BackSpace") == 0)) ||
991 (strcmp(ev->keyname, "Delete") == 0)))
993 item = eina_list_data_get(eina_list_last(wd->items));
995 _select_button(data, item->button);
999 wd->last_btn_select = EINA_TRUE;
1003 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1005 Widget_Data *wd = elm_widget_data_get(data);
1006 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1010 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1011 wd->last_btn_select = EINA_FALSE;
1015 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1017 Widget_Data *wd = elm_widget_data_get(data);
1018 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1021 if (!wd || !wd->base || !wd->box) return;
1023 str = elm_object_text_get(wd->entry);
1025 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1027 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1033 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1035 Widget_Data *wd = elm_widget_data_get(data);
1038 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1039 elm_object_focus_set(wd->entry, EINA_TRUE);
1043 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1045 Widget_Data *wd = elm_widget_data_get(data);
1046 Elm_Multibuttonentry_Item *item = NULL;
1052 item = eina_list_data_get(wd->current);
1053 elm_object_focus_set(wd->entry, EINA_FALSE);
1054 evas_object_focus_set(item->button, EINA_TRUE);
1059 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1061 Widget_Data *wd = elm_widget_data_get(data);
1066 str = elm_object_text_get(wd->entry);
1068 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1072 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1074 Widget_Data *wd = elm_widget_data_get(data);
1079 str = elm_object_text_get(wd->entry);
1080 wd->n_str = strlen(str);
1084 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1086 Evas_Coord en_x, en_y, en_w, en_h;
1088 Widget_Data *wd = elm_widget_data_get(data);
1091 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1094 elm_widget_show_region_set(wd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
1098 _view_init(Evas_Object *obj)
1100 Widget_Data *wd = elm_widget_data_get(obj);
1106 wd->box = elm_box_add(obj);
1107 if (!wd->box) return;
1108 elm_widget_sub_object_add(obj, wd->box);
1109 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1110 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1111 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1115 wd->label = edje_object_add(evas_object_evas_get(obj));
1116 if (!wd->label) return;
1117 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1118 _set_label(obj, "");
1119 elm_widget_sub_object_add(obj, wd->label);
1124 wd->entry = elm_entry_add(obj);
1125 if (!wd->entry) return;
1126 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1127 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1128 elm_object_text_set(wd->entry, "");
1129 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1130 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1131 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1132 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1133 if (wd->box) elm_box_pack_end(wd->box, wd->entry);
1134 evas_object_show(wd->entry);
1135 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1140 const char *end_type;
1142 end_type = edje_object_data_get(wd->base, "closed_button_type");
1143 if (!end_type || !strcmp(end_type, "label"))
1145 wd->end = elm_label_add(obj);
1146 if (!wd->end) return;
1147 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1148 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1152 const char *size_str;
1153 wd->end = edje_object_add(evas_object_evas_get(obj));
1154 if (!wd->end) return;
1155 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1156 Evas_Coord button_min_width = 0;
1157 Evas_Coord button_min_height = 0;
1159 size_str = edje_object_data_get(wd->end, "closed_button_width");
1160 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1161 size_str = edje_object_data_get(wd->end, "closed_button_height");
1162 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1164 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1165 evas_object_size_hint_min_set(wd->end,
1166 button_min_width * _elm_config->scale,
1167 button_min_height * _elm_config->scale);
1168 elm_widget_sub_object_add(obj, wd->end);
1174 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1176 Evas_Coord minw, minh, mnw, mnh, ww;
1177 Evas_Coord w, cw = 0, cmaxh = 0;
1179 Evas_Object_Box_Option *opt;
1182 /* FIXME: need to calc max */
1186 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1187 evas_object_size_hint_min_get(box, &minw, NULL);
1189 EINA_LIST_FOREACH(priv->children, l, opt)
1191 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1192 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1196 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1199 if (mnw != -1 && (w - cw) >= mnw)
1214 if (cmaxh < mnh) cmaxh = mnh;
1219 evas_object_size_hint_min_set(box, minw, minh);
1223 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1225 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1227 Evas_Object_Box_Option *opt;
1228 int local_index = 0;
1231 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1233 EINA_LIST_FOREACH(priv->children, l, opt)
1235 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1236 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1240 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1243 if (mnw != -1 && (w - cw) >= mnw)
1253 if (local_index > obj_index) return cmaxh;
1259 if (cmaxh < mnh) cmaxh = mnh;
1268 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1270 Evas_Coord x, y, w, h, xx, yy;
1273 Evas_Coord minw, minh;
1275 Evas_Object_Box_Option *opt;
1277 _calculate_box_min_size(o, priv);
1279 evas_object_geometry_get(o, &x, &y, &w, &h);
1281 evas_object_size_hint_min_get(o, &minw, &minh);
1282 evas_object_size_hint_align_get(o, &ax, &ay);
1285 x = x + ((w - minw) * (1.0 - ax));
1290 y = y + ((h - minh) * (1.0 - ay));
1297 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1299 EINA_LIST_FOREACH(priv->children, l, opt)
1301 Evas_Coord mnw, mnh, mxw, mxh;
1306 evas_object_size_hint_align_get(obj, &ax, &ay);
1307 evas_object_size_hint_weight_get(obj, &wx, &wy);
1308 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1309 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1311 if (ax == -1.0) {fw = 1; ax = 0.5;}
1312 if (ay == -1.0) {fh = 1; ay = 0.5;}
1313 Evas_Coord ww, hh, ow, oh;
1317 if ((elm_widget_is(obj)) && (!(strcmp(elm_widget_type_get(obj), "entry"))) && (mnw == -1))
1320 if (mnw != -1 && (w - cw) >= mnw)
1327 hh = _calculate_item_max_height(o, priv, obj_index);
1331 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1334 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1343 evas_object_move(obj,
1344 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1345 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1346 evas_object_resize(obj, ow, oh);
1349 if (cmaxh < hh) cmaxh = hh;
1356 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1358 Elm_Multibuttonentry_Item *item;
1359 if (part && strcmp(part, "default")) return;
1361 item = (Elm_Multibuttonentry_Item *)it;
1362 edje_object_part_text_set(item->button, "elm.btn.text", label);
1363 _resize_button(item->button, &item->rw, &item->vw);
1367 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1369 Elm_Multibuttonentry_Item *item;
1370 if (part && strcmp(part, "default")) return NULL;
1371 item = (Elm_Multibuttonentry_Item *)it;
1372 return edje_object_part_text_get(item->button, "elm.btn.text");
1376 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1378 ELM_CHECK_WIDTYPE(obj, widtype);
1379 if (!part || !strcmp(part, "default"))
1381 if (label) _set_label(obj, label);
1382 else _set_label(obj, "");
1384 else if (!strcmp(part, "guide"))
1386 if (label) _set_guidetext(obj, label);
1387 else _set_guidetext(obj, "");
1392 _text_get_hook(const Evas_Object *obj, const char *part)
1394 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1395 Widget_Data *wd = elm_widget_data_get(obj);
1396 if (!wd) return NULL;
1398 if (!part || !strcmp(part, "default"))
1400 return wd->labeltxt;
1402 else if (!strcmp(part, "guide"))
1404 return wd->guidetexttxt;
1410 elm_multibuttonentry_add(Evas_Object *parent)
1416 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1418 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1419 elm_widget_type_set(obj, "multibuttonentry");
1420 elm_widget_sub_object_add(parent, obj);
1421 elm_widget_data_set(obj, wd);
1423 elm_widget_del_hook_set(obj, _del_hook);
1424 elm_widget_theme_hook_set(obj, _theme_hook);
1425 elm_widget_event_hook_set(obj, _event_hook);
1426 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1427 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1428 elm_widget_text_set_hook_set(obj, _text_set_hook);
1429 elm_widget_text_get_hook_set(obj, _text_get_hook);
1431 wd->base = edje_object_add(e);
1432 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1433 elm_widget_resize_object_set(obj, wd->base);
1434 elm_widget_can_focus_set(obj, EINA_TRUE);
1436 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1437 wd->focused = EINA_FALSE;
1438 wd->last_btn_select = EINA_TRUE;
1440 wd->rect_for_end = NULL;
1441 wd->add_callback = NULL;
1442 wd->add_callback_data = NULL;
1451 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1453 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1454 Widget_Data *wd = elm_widget_data_get(obj);
1456 if (!wd) return NULL;
1461 EINA_DEPRECATED EAPI const char *
1462 elm_multibuttonentry_label_get(const Evas_Object *obj)
1464 return _text_get_hook(obj, NULL);
1467 EINA_DEPRECATED EAPI void
1468 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1470 _text_set_hook(obj, NULL, label);
1473 EINA_DEPRECATED EAPI const char *
1474 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1476 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1477 Widget_Data *wd = elm_widget_data_get(obj);
1479 if (!wd) return NULL;
1480 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1484 EINA_DEPRECATED EAPI void
1485 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1487 ELM_CHECK_WIDTYPE(obj, widtype);
1488 Widget_Data *wd = elm_widget_data_get(obj);
1492 _set_guidetext(obj, guidetext);
1495 EINA_DEPRECATED EAPI int
1496 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1498 if (elm_multibuttonentry_expanded_get(obj))
1505 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1507 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1508 Widget_Data *wd = elm_widget_data_get(obj);
1511 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1515 EINA_DEPRECATED EAPI void
1516 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1519 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
1522 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
1526 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1528 ELM_CHECK_WIDTYPE(obj, widtype);
1529 Widget_Data *wd = elm_widget_data_get(obj);
1531 if (!wd || !wd->box ||
1532 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1535 _shrink_mode_set(obj, EINA_FALSE);
1537 _shrink_mode_set(obj, EINA_TRUE);
1541 EAPI Elm_Object_Item *
1542 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1544 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
1547 EAPI Elm_Object_Item *
1548 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1550 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
1553 EAPI Elm_Object_Item *
1554 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
1556 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
1559 EAPI Elm_Object_Item *
1560 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
1562 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
1565 EAPI const Eina_List *
1566 elm_multibuttonentry_items_get(const Evas_Object *obj)
1568 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1569 Widget_Data *wd = elm_widget_data_get(obj);
1570 if (!wd) return NULL;
1574 EAPI Elm_Object_Item *
1575 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1577 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1578 Widget_Data *wd = elm_widget_data_get(obj);
1579 if (!wd) return NULL;
1580 return eina_list_data_get(wd->items);
1583 EAPI Elm_Object_Item *
1584 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1586 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1587 Widget_Data *wd = elm_widget_data_get(obj);
1588 if (!wd) return NULL;
1589 return eina_list_data_get(eina_list_last(wd->items));
1592 EAPI Elm_Object_Item *
1593 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1595 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1596 Widget_Data *wd = elm_widget_data_get(obj);
1597 if (!wd) return NULL;
1598 return eina_list_data_get(wd->current);
1602 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1604 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1605 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
1606 if (selected) _select_button(WIDGET(item), item->button);
1607 else _select_button(WIDGET(item), NULL);
1611 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
1613 //TODO : To be implemented.
1614 if (!it) return EINA_FALSE;
1619 elm_multibuttonentry_clear(Evas_Object *obj)
1621 ELM_CHECK_WIDTYPE(obj, widtype);
1622 Elm_Multibuttonentry_Item *item;
1623 Widget_Data *wd = elm_widget_data_get(obj);
1628 EINA_LIST_FREE(wd->items, item)
1630 elm_box_unpack(wd->box, item->button);
1631 _del_button_obj(obj, item->button);
1641 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1643 elm_object_item_del(it);
1647 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1649 return _item_text_get_hook(it, NULL);
1653 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1655 _item_text_set_hook(it, NULL, str);
1658 EAPI Elm_Object_Item *
1659 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1661 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1664 Elm_Multibuttonentry_Item *_item;
1666 wd = elm_widget_data_get(WIDGET(it));
1667 if (!wd) return NULL;
1669 EINA_LIST_FOREACH(wd->items, l, _item)
1671 if (_item == (Elm_Multibuttonentry_Item *)it)
1673 l = eina_list_prev(l);
1674 if (!l) return NULL;
1675 return eina_list_data_get(l);
1681 EAPI Elm_Object_Item *
1682 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1684 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1687 Elm_Multibuttonentry_Item *_item;
1688 wd = elm_widget_data_get(WIDGET(it));
1689 if (!wd) return NULL;
1691 EINA_LIST_FOREACH(wd->items, l, _item)
1693 if (_item == (Elm_Multibuttonentry_Item *)it)
1695 l = eina_list_next(l);
1696 if (!l) return NULL;
1697 return eina_list_data_get(l);
1704 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1706 return elm_widget_item_data_get(it);
1710 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1712 return elm_widget_item_data_set(it, data);
1716 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1718 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1719 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1722 Widget_Data *wd = elm_widget_data_get(obj);
1725 ELM_CHECK_WIDTYPE(obj, widtype);
1726 EINA_SAFETY_ON_NULL_RETURN(func);
1728 new_item_filter= _filter_new(func, data);
1729 if (!new_item_filter) return;
1731 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1733 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1735 printf("Already Registered this item filter!!!!\n");
1739 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1743 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1745 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1746 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1748 Widget_Data *wd = elm_widget_data_get(obj);
1751 ELM_CHECK_WIDTYPE(obj, widtype);
1752 EINA_SAFETY_ON_NULL_RETURN(func);
1754 new_item_filter = _filter_new(func, data);
1755 if (!new_item_filter) return;
1757 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1759 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1761 printf("Already Registered this item filter!!!!\n");
1765 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1769 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1773 Elm_Multibuttonentry_Item_Filter *item_filter;
1775 wd = elm_widget_data_get(obj);
1777 EINA_SAFETY_ON_NULL_RETURN(func);
1779 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1781 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1783 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1784 _filter_free(item_filter);