1 #include <Elementary.h>
7 typedef enum _Multibuttonentry_Pos
9 MULTIBUTTONENTRY_POS_START,
10 MULTIBUTTONENTRY_POS_END,
11 MULTIBUTTONENTRY_POS_BEFORE,
12 MULTIBUTTONENTRY_POS_AFTER,
13 MULTIBUTTONENTRY_POS_NUM
14 } Multibuttonentry_Pos;
16 typedef enum _Multibuttonentry_Button_State
18 MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
19 MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
20 MULTIBUTTONENTRY_BUTTON_STATE_NUM
21 } Multibuttonentry_Button_State;
23 typedef enum _MultiButtonEntry_Closed_Button_Type
25 MULTIBUTTONENTRY_CLOSED_IMAGE,
26 MULTIBUTTONENTRY_CLOSED_LABEL
27 } MultiButtonEntry_Closed_Button_Type;
29 typedef enum _Multibuttonentry_View_State
31 MULTIBUTTONENTRY_VIEW_NONE,
32 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
33 MULTIBUTTONENTRY_VIEW_ENTRY,
34 MULTIBUTTONENTRY_VIEW_SHRINK
35 } Multibuttonentry_View_State;
37 typedef struct _Widget_Data Widget_Data;
38 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
40 struct _Multibuttonentry_Item
44 Evas_Coord vw, rw; // vw: visual width, real width
48 typedef struct _Elm_Multibuttonentry_Item_Filter
50 Elm_Multibuttonentry_Item_Filter_callback callback_func;
52 } Elm_Multibuttonentry_Item_Filter;
60 Evas_Object *guidetext;
61 Evas_Object *end; // used to represent the total number of invisible buttons
63 Evas_Object *rect_for_end;
64 MultiButtonEntry_Closed_Button_Type end_type;
68 Eina_List *filter_list;
71 Multibuttonentry_View_State view_state;
73 Evas_Coord w_box, h_box;
76 Eina_Bool last_btn_select: 1;
77 Elm_Multibuttonentry_Item_Filter_callback add_callback;
78 void *add_callback_data;
81 static const char *widtype = NULL;
82 static void _del_hook(Evas_Object *obj);
83 static void _theme_hook(Evas_Object *obj);
84 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
85 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
86 static void _sizing_eval(Evas_Object *obj);
87 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
88 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
89 static void _event_init(Evas_Object *obj);
90 static void _shrink_mode_set(Evas_Object *obj, int shrink);
91 static void _view_update(Evas_Object *obj);
92 static void _set_label(Evas_Object *obj, const char *str);
93 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
94 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
95 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
96 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
97 static void _del_button_item(Elm_Multibuttonentry_Item *item);
98 static void _select_button(Evas_Object *obj, Evas_Object *btn);
99 static Elm_Multibuttonentry_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos,
100 const Elm_Multibuttonentry_Item *reference, void *data);
101 static void _add_button(Evas_Object *obj, const char *str);
102 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
103 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
104 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
107 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
108 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
109 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
110 static void _view_init(Evas_Object *obj);
111 static void _set_vis_guidetext(Evas_Object *obj);
112 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
113 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
114 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
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 _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);
175 if (elm_widget_focus_get(obj))
177 wd->focused = EINA_TRUE;
178 evas_object_smart_callback_call(obj, "focused", NULL);
182 wd->focused = EINA_FALSE;
183 evas_object_smart_callback_call(obj, "unfocused", NULL);
190 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
196 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
198 Widget_Data *wd = elm_widget_data_get(obj);
201 edje_object_signal_emit(wd->base, emission, source);
205 _sizing_eval(Evas_Object *obj)
207 Widget_Data *wd = elm_widget_data_get(obj);
208 Evas_Coord minw = -1, minh = -1;
209 Evas_Coord left, right, top, bottom;
212 evas_object_size_hint_min_get(wd->box, &minw, &minh);
213 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
214 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
216 minw += (left + right);
217 minh += (top + bottom);
219 evas_object_size_hint_min_set(obj, minw, minh);
223 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
225 Widget_Data *wd = elm_widget_data_get(data);
227 if (!wd || !wd->base) return;
228 wd->focused = EINA_TRUE;
231 evas_object_smart_callback_call(data, "clicked", NULL);
235 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
237 Evas_Object *eo = (Evas_Object *)data;
238 Widget_Data *wd = elm_widget_data_get(data);
245 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
247 Widget_Data *wd = elm_widget_data_get(data);
251 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
253 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
254 else if (wd->h_box > h) evas_object_smart_callback_call (data, "shrank", NULL);
263 _event_init(Evas_Object *obj)
265 Widget_Data *wd = elm_widget_data_get(obj);
267 if (!wd || !wd->base) return;
270 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
271 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
276 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
277 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
282 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
283 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
284 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
285 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
286 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
287 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
288 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
293 _set_vis_guidetext(Evas_Object *obj)
295 Widget_Data *wd = elm_widget_data_get(obj);
298 elm_box_unpack(wd->box, wd->guidetext);
299 elm_box_unpack(wd->box, wd->entry);
300 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
302 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
303 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
305 evas_object_hide(wd->entry);
306 elm_box_pack_end(wd->box, wd->guidetext);
307 evas_object_show(wd->guidetext);
308 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
312 evas_object_hide(wd->guidetext);
313 elm_box_pack_end(wd->box, wd->entry);
314 evas_object_show(wd->entry);
315 if (elm_widget_focus_get(obj) || wd->focused)
317 elm_object_focus_set(wd->entry, EINA_TRUE);
318 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
323 _shrink_mode_set(Evas_Object *obj, int shrink)
325 Widget_Data *wd = elm_widget_data_get(obj);
327 Elm_Multibuttonentry_Item *item;
329 if (!wd || !wd->box) return;
330 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
331 evas_object_hide(wd->entry);
332 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
333 evas_object_hide(wd->guidetext);
334 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
336 evas_object_hide(wd->rect_for_end);
337 evas_object_hide(wd->end);
338 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
343 Evas_Coord w=0, w_tmp=0;
344 Evas_Coord box_inner_item_width_padding = 0;
346 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
347 // unpack all items and entry
348 elm_box_unpack_all(wd->box);
349 EINA_LIST_FOREACH(wd->items, l, item)
353 evas_object_hide(item->button);
354 item->visible = EINA_FALSE;
357 // pack buttons only 1line
362 elm_box_pack_end(wd->box, wd->label);
363 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
365 w -= box_inner_item_width_padding;
369 int count = eina_list_count(wd->items);
370 Evas_Coord button_min_width = 0;
371 /* Evas_Coord button_min_height = 0; */
372 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
374 const char *size_str;
375 size_str = edje_object_data_get(wd->end, "closed_button_width");
376 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
378 size_str = edje_object_data_get(wd->end, "closed_button_height");
379 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
383 EINA_LIST_FOREACH(wd->items, l, item)
387 int w_label_count = 0;
390 elm_box_pack_end(wd->box, item->button);
391 evas_object_show(item->button);
392 item->visible = EINA_TRUE;
395 w -= box_inner_item_width_padding;
398 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
402 snprintf(buf, sizeof(buf), "... + %d", count);
403 elm_object_text_set(wd->end, buf);
404 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
407 if (w < 0 || w < w_label_count)
409 elm_box_unpack(wd->box, item->button);
410 evas_object_hide(item->button);
411 item->visible = EINA_FALSE;
414 snprintf(buf, sizeof(buf), "... + %d", count);
415 elm_object_text_set(wd->end, buf);
416 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
418 elm_box_pack_end(wd->box, wd->end);
419 evas_object_show(wd->end);
421 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
422 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
426 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
428 if (w < button_min_width)
431 Evas_Coord closed_height = 0;
432 const char *height_str = edje_object_data_get(wd->base, "closed_height");
434 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
435 elm_box_unpack(wd->box, item->button);
436 evas_object_hide(item->button);
437 item->visible = EINA_FALSE;
440 rectSize = w - button_min_width;
441 if (!wd->rect_for_end)
443 Evas *e = evas_object_evas_get(obj);
444 wd->rect_for_end= evas_object_rectangle_add(e);
445 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
447 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get() );
448 elm_box_pack_end(wd->box, wd->rect_for_end);
449 evas_object_show(wd->rect_for_end);
451 elm_box_pack_end(wd->box, wd->end);
452 evas_object_show(wd->end);
454 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
455 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
464 // unpack all items and entry
465 elm_box_unpack_all(wd->box);
466 EINA_LIST_FOREACH(wd->items, l, item)
470 evas_object_hide(item->button);
471 item->visible = EINA_FALSE;
474 evas_object_hide(wd->end);
476 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
478 // pack buttons only 1line
480 if (wd->label) elm_box_pack_end(wd->box, wd->label);
484 EINA_LIST_FOREACH(wd->items, l, item)
488 elm_box_pack_end(wd->box, item->button);
489 evas_object_show(item->button);
490 item->visible = EINA_TRUE;
494 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
495 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)wd->shrink);
497 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
499 _set_vis_guidetext(obj);
504 _view_update(Evas_Object *obj)
506 Evas_Coord width = 1, height = 1;
507 Widget_Data *wd = elm_widget_data_get(obj);
509 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
514 elm_box_unpack(wd->box, wd->label);
515 elm_box_pack_start(wd->box, wd->label);
516 evas_object_size_hint_min_get(wd->label, &width, &height);
521 Evas_Coord guide_text_width = wd->w_box - width;
522 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
525 // update buttons in shrink mode
526 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
527 _shrink_mode_set(obj, 1);
530 _set_vis_guidetext(obj);
534 _set_label(Evas_Object *obj, const char* str)
536 Widget_Data *wd = elm_widget_data_get(obj);
538 if (!wd || !str) return;
541 Evas_Coord width, height, sum_width = 0;
542 evas_object_size_hint_min_set(wd->label, 0, 0);
543 evas_object_resize(wd->label, 0, 0);
544 edje_object_part_text_set(wd->label, "mbe.label", str);
546 if (!strcmp(str, ""))
548 /* FIXME: not work yet */
549 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
550 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
555 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
556 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
560 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
563 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
566 evas_object_size_hint_min_set(wd->label, sum_width, height);
568 evas_object_show(wd->label);
573 _set_guidetext(Evas_Object *obj, const char* str)
575 Widget_Data *wd = elm_widget_data_get(obj);
577 if (!wd || !str) return;
580 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
581 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
582 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
583 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
586 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
591 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
593 Widget_Data *wd = elm_widget_data_get(obj);
594 Elm_Multibuttonentry_Item *item = NULL;
598 item = eina_list_data_get(wd->current);
600 if (item && item->button)
604 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
605 edje_object_signal_emit(item->button, "default", "");
608 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
609 edje_object_signal_emit(item->button, "focused", "");
610 evas_object_smart_callback_call(obj, "item,selected", item);
613 edje_object_signal_emit(item->button, "default", "");
621 _change_current_button(Evas_Object *obj, Evas_Object *btn)
623 Widget_Data *wd = elm_widget_data_get(obj);
625 Elm_Multibuttonentry_Item *item;
629 // change the state of previous button to "default"
630 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
632 // change the current
633 EINA_LIST_FOREACH(wd->items, l, item)
635 if (item->button == btn)
641 // change the state of current button to "focused"
642 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
646 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
648 Widget_Data *wd = elm_widget_data_get(data);
650 Elm_Multibuttonentry_Item *item = NULL;
651 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
653 _change_current_button(data, obj);
656 if ((item = eina_list_data_get(wd->current)) != NULL)
658 evas_object_smart_callback_call(data, "item,clicked", item);
659 _select_button(data, item->button);
664 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
666 Widget_Data *wd = elm_widget_data_get(obj);
668 if (!wd || !btn) return;
670 evas_object_del(btn);
674 _del_button_item(Elm_Multibuttonentry_Item *item)
677 Elm_Multibuttonentry_Item *_item;
681 Evas_Object *obj = WIDGET(item);
682 wd = elm_widget_data_get(obj);
684 EINA_LIST_FOREACH(wd->items, l, _item)
688 wd->items = eina_list_remove(wd->items, _item);
689 elm_box_unpack(wd->box, _item->button);
691 evas_object_smart_callback_call(obj, "item,deleted", _item);
693 _del_button_obj(obj, _item->button);
696 if (wd->current == l)
701 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
702 _shrink_mode_set(obj, 1);
704 if (!eina_list_count(wd->items))
705 _set_vis_guidetext(obj);
709 _select_button(Evas_Object *obj, Evas_Object *btn)
711 Widget_Data *wd = elm_widget_data_get(obj);
716 _change_current_button(obj, btn);
717 if (elm_widget_focus_get(obj))
719 elm_object_focus_set(wd->entry, EINA_FALSE);
720 evas_object_focus_set(btn, EINA_TRUE);
725 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
726 if (elm_widget_focus_get(obj))
727 elm_object_focus_set(wd->entry, EINA_TRUE);
732 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
735 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
736 Evas_Coord w_btn = 0, button_max_width = 0;
737 const char *size_str;
739 size_str = edje_object_data_get(btn, "button_max_size");
740 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
742 // decide the size of button
743 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
744 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
745 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
746 w_btn = w_text + 2*padding_outer + 2*padding_inner;
750 if (button_max_width < w_btn)
751 vw = button_max_width;
756 evas_object_resize(btn, vw, h_btn);
757 evas_object_size_hint_min_set(btn, vw, h_btn);
759 if (realw) *realw = rw;
760 if (vieww) *vieww = vw;
763 static Elm_Multibuttonentry_Item*
764 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
766 Elm_Multibuttonentry_Item *item;
767 Elm_Multibuttonentry_Item_Filter *item_filter;
770 Evas_Coord width = -1, height = -1;
771 char *str_utf8 = NULL;
772 Widget_Data *wd = elm_widget_data_get(obj);
774 if (!wd || !wd->box || !wd->entry) return NULL;
776 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
778 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
782 btn = edje_object_add(evas_object_evas_get(obj));
783 str_utf8 = elm_entry_markup_to_utf8(str);
785 //entry is cleared when text is made to button
786 elm_object_text_set(wd->entry, "");
788 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
789 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
790 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
792 evas_object_size_hint_min_set(btn, width, height);
794 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
795 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
796 evas_object_show(btn);
799 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
802 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
803 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
804 elm_widget_item_data_set(item, data);
806 _resize_button(btn, &rw, &vw);
810 item->visible = EINA_TRUE;
814 case MULTIBUTTONENTRY_POS_START:
815 wd->items = eina_list_prepend(wd->items, item);
816 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
818 elm_widget_sub_object_add(obj, btn);
819 _shrink_mode_set(obj, 1);
824 elm_box_pack_after(wd->box, btn, wd->label);
826 elm_box_pack_start(wd->box, btn);
827 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
828 _set_vis_guidetext(obj);
831 case MULTIBUTTONENTRY_POS_END:
832 wd->items = eina_list_append(wd->items, item);
833 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
835 elm_widget_sub_object_add(obj, btn);
836 evas_object_hide(btn);
840 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
841 _set_vis_guidetext(obj);
843 elm_box_pack_before(wd->box, btn, wd->entry);
845 elm_box_pack_end(wd->box, btn);
848 case MULTIBUTTONENTRY_POS_BEFORE:
850 wd->items = eina_list_prepend_relative(wd->items, item, reference);
852 wd->items = eina_list_append(wd->items, item);
853 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
855 elm_widget_sub_object_add(obj, btn);
856 evas_object_hide(btn);
857 _shrink_mode_set(obj, 1);
862 elm_box_pack_before(wd->box, btn, reference->button);
865 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
866 _set_vis_guidetext(obj);
868 elm_box_pack_before(wd->box, btn, wd->entry);
870 elm_box_pack_end(wd->box, btn);
874 case MULTIBUTTONENTRY_POS_AFTER:
876 wd->items = eina_list_append_relative(wd->items, item, reference);
878 wd->items = eina_list_append(wd->items, item);
879 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
881 elm_widget_sub_object_add(obj, btn);
882 _shrink_mode_set(obj, 1);
887 elm_box_pack_after(wd->box, btn, reference->button);
890 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
891 _set_vis_guidetext(obj);
893 elm_box_pack_before(wd->box, btn, wd->entry);
895 elm_box_pack_end(wd->box, btn);
903 evas_object_smart_callback_call(obj, "item,added", item);
911 _add_button(Evas_Object *obj, const char *str)
913 Widget_Data *wd = elm_widget_data_get(obj);
916 _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
919 static Elm_Multibuttonentry_Item_Filter*
920 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
922 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
923 if (!item_filter) return NULL;
925 item_filter->callback_func= func;
926 item_filter->data = data;
932 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
938 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
940 Widget_Data *wd = elm_widget_data_get(data);
941 Elm_Multibuttonentry_Item *item = NULL;
943 if (!wd || !wd->base || !wd->box) return;
945 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
947 if (wd->last_btn_select)
950 ((strcmp(ev->keyname, "BackSpace") == 0) ||
951 (strcmp(ev->keyname, "BackSpace (") == 0)))
953 item = eina_list_data_get(wd->current);
956 _del_button_item(item);
957 elm_object_focus_set(wd->entry, EINA_TRUE);
960 else if (((!wd->current && (wd->n_str == 0) &&
961 (strcmp(ev->keyname, "BackSpace") == 0)) ||
962 (strcmp(ev->keyname, "BackSpace (") == 0)))
964 item = eina_list_data_get(eina_list_last(wd->items));
966 _select_button(data, item->button);
970 wd->last_btn_select = EINA_TRUE;
974 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
976 Widget_Data *wd = elm_widget_data_get(data);
977 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
981 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
982 wd->last_btn_select = EINA_FALSE;
986 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
988 Widget_Data *wd = elm_widget_data_get(data);
989 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
992 if (!wd || !wd->base || !wd->box) return;
994 str = elm_object_text_get(wd->entry);
996 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
998 _add_button(data, str);
1004 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1006 Widget_Data *wd = elm_widget_data_get(data);
1009 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1010 elm_object_focus_set(wd->entry, EINA_TRUE);
1014 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1016 Widget_Data *wd = elm_widget_data_get(data);
1017 Elm_Multibuttonentry_Item *item = NULL;
1023 item = eina_list_data_get(wd->current);
1024 elm_object_focus_set(wd->entry, EINA_FALSE);
1025 evas_object_focus_set(item->button, EINA_TRUE);
1030 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1032 Widget_Data *wd = elm_widget_data_get(data);
1037 str = elm_object_text_get(wd->entry);
1039 _add_button(data, str);
1043 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1045 Widget_Data *wd = elm_widget_data_get(data);
1050 str = elm_object_text_get(wd->entry);
1051 wd->n_str = strlen(str);
1055 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1057 Evas_Coord en_x, en_y, en_w, en_h;
1058 Evas_Coord bx_x, bx_y;
1060 Widget_Data *wd = elm_widget_data_get(data);
1063 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1064 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1066 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w, en_h, EINA_TRUE);
1070 _view_init(Evas_Object *obj)
1072 Widget_Data *wd = elm_widget_data_get(obj);
1078 wd->box = elm_box_add (obj);
1079 if (!wd->box) return;
1080 elm_widget_sub_object_add(obj, wd->box);
1081 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1082 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1083 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1087 wd->label = edje_object_add(evas_object_evas_get(obj));
1088 if (!wd->label) return;
1089 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1090 _set_label(obj, "");
1091 elm_widget_sub_object_add(obj, wd->label);
1096 wd->entry = elm_entry_add (obj);
1097 if (!wd->entry) return;
1098 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1099 elm_object_text_set(wd->entry, "");
1100 elm_entry_cursor_end_set(wd->entry);
1101 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1102 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1103 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1104 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1105 evas_object_show(wd->entry);
1106 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1111 const char *end_type;
1113 end_type = edje_object_data_get(wd->base, "closed_button_type");
1114 if (!end_type || !strcmp(end_type, "label"))
1116 wd->end = elm_label_add (obj);
1117 if (!wd->end) return;
1118 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1119 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1123 const char *size_str;
1124 wd->end = edje_object_add(evas_object_evas_get(obj));
1125 if (!wd->end) return;
1126 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1127 Evas_Coord button_min_width = 0;
1128 Evas_Coord button_min_height = 0;
1130 size_str = edje_object_data_get(wd->end, "closed_button_width");
1131 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1132 size_str = edje_object_data_get(wd->end, "closed_button_height");
1133 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1135 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1136 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1137 elm_widget_sub_object_add(obj, wd->end);
1143 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1145 Evas_Coord minw, minh, mnw, mnh, ww;
1146 Evas_Coord w, cw = 0, cmaxh = 0;
1148 Evas_Object_Box_Option *opt;
1151 /* FIXME: need to calc max */
1155 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1156 evas_object_size_hint_min_get(box, &minw, NULL);
1158 EINA_LIST_FOREACH(priv->children, l, opt)
1160 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1161 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1165 if (mnw != -1 && (w - cw) >= mnw)
1180 if (cmaxh < mnh) cmaxh = mnh;
1185 evas_object_size_hint_min_set(box, minw, minh);
1189 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1191 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1193 Evas_Object_Box_Option *opt;
1197 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1199 EINA_LIST_FOREACH(priv->children, l, opt)
1201 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1202 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1206 if (mnw != -1 && (w - cw) >= mnw)
1216 if (index > obj_index) return cmaxh;
1222 if (cmaxh < mnh) cmaxh = mnh;
1231 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1233 Evas_Coord x, y, w, h, xx, yy;
1236 Evas_Coord minw, minh;
1238 Evas_Object_Box_Option *opt;
1240 _calculate_box_min_size(o, priv);
1242 evas_object_geometry_get(o, &x, &y, &w, &h);
1244 evas_object_size_hint_min_get(o, &minw, &minh);
1245 evas_object_size_hint_align_get(o, &ax, &ay);
1248 x = x + ((w - minw) * (1.0 - ax));
1253 y = y + ((h - minh) * (1.0 - ay));
1260 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1262 EINA_LIST_FOREACH(priv->children, l, opt)
1264 Evas_Coord mnw, mnh, mxw, mxh;
1269 evas_object_size_hint_align_get(obj, &ax, &ay);
1270 evas_object_size_hint_weight_get(obj, &wx, &wy);
1271 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1272 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1274 if (ax == -1.0) {fw = 1; ax = 0.5;}
1275 if (ay == -1.0) {fh = 1; ay = 0.5;}
1276 Evas_Coord ww, hh, ow, oh;
1280 if (mnw != -1 && (w - cw) >= mnw)
1287 hh = _calculate_item_max_height(o, priv, obj_index);
1291 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1294 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1303 evas_object_move(obj,
1304 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1305 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1306 evas_object_resize(obj, ow, oh);
1309 if (cmaxh < hh) cmaxh = hh;
1316 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1318 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1320 Elm_Multibuttonentry_Item *item;
1321 if (part && strcmp(part, "default")) return;
1323 item = (Elm_Multibuttonentry_Item *) it;
1324 edje_object_part_text_set(item->button, "elm.btn.text", label);
1325 _resize_button(item->button, &item->rw, &item->vw);
1329 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1331 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1332 Elm_Multibuttonentry_Item *item;
1333 if (part && strcmp(part, "default")) return NULL;
1334 item = (Elm_Multibuttonentry_Item *) it;
1335 return edje_object_part_text_get(item->button, "elm.btn.text");
1339 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1341 ELM_CHECK_WIDTYPE(obj, widtype);
1342 if (part && strcmp(part, "default")) return;
1343 if (label) _set_label(obj, label);
1344 else _set_label(obj, "");
1348 _text_get_hook(const Evas_Object *obj, const char *part)
1350 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1352 if (part && strcmp(part, "default")) return NULL;
1353 wd = elm_widget_data_get(obj);
1354 if (!wd) return NULL;
1355 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1360 elm_multibuttonentry_add(Evas_Object *parent)
1366 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1368 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1369 elm_widget_type_set(obj, "multibuttonentry");
1370 elm_widget_sub_object_add(parent, obj);
1371 elm_widget_data_set(obj, wd);
1373 elm_widget_del_hook_set(obj, _del_hook);
1374 elm_widget_theme_hook_set(obj, _theme_hook);
1375 elm_widget_event_hook_set(obj, _event_hook);
1376 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1377 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1378 elm_widget_text_set_hook_set(obj, _text_set_hook);
1379 elm_widget_text_get_hook_set(obj, _text_get_hook);
1381 wd->base = edje_object_add(e);
1382 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1383 elm_widget_resize_object_set(obj, wd->base);
1384 elm_widget_can_focus_set(obj, EINA_TRUE);
1386 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1387 wd->focused = EINA_FALSE;
1388 wd->last_btn_select = EINA_TRUE;
1390 wd->rect_for_end= NULL;
1391 wd->add_callback = NULL;
1392 wd->add_callback_data = NULL;
1401 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1403 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1404 Widget_Data *wd = elm_widget_data_get(obj);
1406 if (!wd) return NULL;
1412 elm_multibuttonentry_label_get(const Evas_Object *obj)
1414 return _text_get_hook(obj, NULL);
1418 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1420 _text_set_hook(obj, NULL, label);
1424 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1426 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1427 Widget_Data *wd = elm_widget_data_get(obj);
1429 if (!wd) return NULL;
1430 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1435 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1437 ELM_CHECK_WIDTYPE(obj, widtype);
1438 Widget_Data *wd = elm_widget_data_get(obj);
1442 _set_guidetext(obj, guidetext);
1444 _set_guidetext(obj, "");
1448 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1450 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1451 Widget_Data *wd = elm_widget_data_get(obj);
1454 return wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? 1 : 0;
1458 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1460 ELM_CHECK_WIDTYPE(obj, widtype);
1461 Widget_Data *wd = elm_widget_data_get(obj);
1463 if (!wd || !wd->box ||
1464 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? 1 : 0) == shrink) return;
1465 _shrink_mode_set(obj, shrink);
1468 EAPI Elm_Object_Item *
1469 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1471 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1472 Elm_Multibuttonentry_Item *item;
1473 if (!label) return NULL;
1474 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1475 return (Elm_Object_Item *) item;
1478 EAPI Elm_Object_Item *
1479 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1481 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1482 Elm_Multibuttonentry_Item *item;
1483 if (!label) return NULL;
1484 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1485 return (Elm_Object_Item *) item;
1488 EAPI Elm_Object_Item *
1489 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1491 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1492 Elm_Multibuttonentry_Item *item;
1493 if (!label) return NULL;
1494 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE,
1495 (Elm_Multibuttonentry_Item *) before, data);
1496 return (Elm_Object_Item *) item;
1499 EAPI Elm_Object_Item *
1500 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
1502 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1503 Elm_Multibuttonentry_Item *item;
1504 if (!label) return NULL;
1505 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER,
1506 (Elm_Multibuttonentry_Item *) after, data);
1507 return (Elm_Object_Item *) item;
1510 EAPI const Eina_List *
1511 elm_multibuttonentry_items_get(const Evas_Object *obj)
1513 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1514 Widget_Data *wd = elm_widget_data_get(obj);
1515 if (!wd) return NULL;
1519 EAPI Elm_Object_Item *
1520 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1522 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1523 Widget_Data *wd = elm_widget_data_get(obj);
1524 if (!wd) return NULL;
1525 return eina_list_data_get(wd->items);
1528 EAPI Elm_Object_Item *
1529 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1531 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1532 Widget_Data *wd = elm_widget_data_get(obj);
1533 if (!wd) return NULL;
1534 return eina_list_data_get(eina_list_last(wd->items));
1537 EAPI Elm_Object_Item *
1538 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1540 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1541 Widget_Data *wd = elm_widget_data_get(obj);
1542 if (!wd) return NULL;
1543 return eina_list_data_get(wd->current);
1547 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
1549 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1550 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1551 if (selected) _select_button(WIDGET(item), item->button);
1552 else _select_button(WIDGET(item), NULL);
1556 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1558 ELM_CHECK_WIDTYPE(obj, widtype);
1559 Widget_Data *wd = elm_widget_data_get(obj);
1561 _select_button(obj, NULL);
1565 elm_multibuttonentry_clear(Evas_Object *obj)
1567 ELM_CHECK_WIDTYPE(obj, widtype);
1568 Elm_Multibuttonentry_Item *item;
1569 Widget_Data *wd = elm_widget_data_get(obj);
1574 EINA_LIST_FREE(wd->items, item)
1576 elm_box_unpack(wd->box, item->button);
1577 _del_button_obj(obj, item->button);
1587 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1589 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1590 _del_button_item((Elm_Multibuttonentry_Item *) it);
1594 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1596 return _item_text_get_hook(it, NULL);
1600 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1602 _item_text_set_hook(it, NULL, str);
1605 EAPI Elm_Object_Item *
1606 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1608 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1611 Elm_Multibuttonentry_Item *_item;
1613 wd = elm_widget_data_get(WIDGET(it));
1614 if (!wd) return NULL;
1616 EINA_LIST_FOREACH(wd->items, l, _item)
1618 if (_item == (Elm_Multibuttonentry_Item *) it)
1620 l = eina_list_prev(l);
1621 if (!l) return NULL;
1622 return eina_list_data_get(l);
1628 EAPI Elm_Object_Item *
1629 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1631 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1634 Elm_Multibuttonentry_Item *_item;
1635 wd = elm_widget_data_get(WIDGET(it));
1636 if (!wd) return NULL;
1638 EINA_LIST_FOREACH(wd->items, l, _item)
1640 if (_item == (Elm_Multibuttonentry_Item *) it)
1642 l = eina_list_next(l);
1643 if (!l) return NULL;
1644 return eina_list_data_get(l);
1651 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1653 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1654 return elm_widget_item_data_get(it);
1658 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1660 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1661 return elm_widget_item_data_set(it, data);
1665 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1667 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1668 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1671 Widget_Data *wd = elm_widget_data_get(obj);
1674 ELM_CHECK_WIDTYPE(obj, widtype);
1675 EINA_SAFETY_ON_NULL_RETURN(func);
1677 new_item_filter= _filter_new(func, data);
1678 if (!new_item_filter) return;
1680 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1682 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1684 printf("Already Registered this item filter!!!!\n");
1688 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1692 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1694 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1695 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1697 Widget_Data *wd = elm_widget_data_get(obj);
1700 ELM_CHECK_WIDTYPE(obj, widtype);
1701 EINA_SAFETY_ON_NULL_RETURN(func);
1703 new_item_filter = _filter_new(func, data);
1704 if (!new_item_filter) return;
1706 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1708 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1710 printf("Already Registered this item filter!!!!\n");
1714 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1718 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1722 Elm_Multibuttonentry_Item_Filter *item_filter;
1724 wd = elm_widget_data_get(obj);
1726 EINA_SAFETY_ON_NULL_RETURN(func);
1728 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1730 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1732 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1733 _filter_free(item_filter);