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_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, 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,
121 // XXX: use evas_object_smart_callback_descriptions_set for smart callbacks.
124 _del_hook(Evas_Object *obj)
126 Widget_Data *wd = elm_widget_data_get(obj);
131 Elm_Multibuttonentry_Item *item;
132 EINA_LIST_FREE(wd->items, item)
134 _del_button_obj(obj, item->button);
141 if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
142 if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
143 if (wd->entry) evas_object_del(wd->entry);
144 if (wd->label) evas_object_del(wd->label);
145 if (wd->guidetext) evas_object_del(wd->guidetext);
146 if (wd->end) evas_object_del(wd->end);
147 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
151 _theme_hook(Evas_Object *obj)
153 Widget_Data *wd = elm_widget_data_get(obj);
155 Elm_Multibuttonentry_Item *item;
159 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
160 if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
161 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
163 EINA_LIST_FOREACH(wd->items, l, item)
166 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
167 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
174 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
176 Widget_Data *wd = elm_widget_data_get(obj);
180 if (elm_widget_focus_get(obj))
184 elm_entry_input_panel_show(wd->entry);
186 else if (((!wd->current) || (!eina_list_count(wd->items))))
188 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
190 elm_entry_input_panel_show(wd->entry);
192 wd->focused = EINA_TRUE;
193 evas_object_smart_callback_call(obj, "focused", NULL);
197 wd->focused = EINA_FALSE;
200 elm_entry_input_panel_hide(wd->entry);
201 evas_object_smart_callback_call(obj, "unfocused", NULL);
206 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
212 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
214 Widget_Data *wd = elm_widget_data_get(obj);
217 edje_object_signal_emit(wd->base, emission, source);
221 _sizing_eval(Evas_Object *obj)
223 Widget_Data *wd = elm_widget_data_get(obj);
224 Evas_Coord minw = -1, minh = -1;
225 Evas_Coord left, right, top, bottom;
228 evas_object_size_hint_min_get(wd->box, &minw, &minh);
229 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
230 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
232 minw += (left + right);
233 minh += (top + bottom);
235 evas_object_size_hint_min_set(obj, minw, minh);
239 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
241 Widget_Data *wd = elm_widget_data_get(data);
243 if (!wd || !wd->base) return;
244 wd->focused = EINA_TRUE;
247 elm_entry_input_panel_show(wd->entry);
249 evas_object_smart_callback_call(data, "clicked", NULL);
253 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
255 Evas_Object *eo = (Evas_Object *)data;
256 Widget_Data *wd = elm_widget_data_get(data);
263 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
265 Widget_Data *wd = elm_widget_data_get(data);
269 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
271 if (wd->h_box < h) evas_object_smart_callback_call(data, "expanded", NULL);
272 else if (wd->h_box > h) evas_object_smart_callback_call(data, "contracted", NULL);
281 _event_init(Evas_Object *obj)
283 Widget_Data *wd = elm_widget_data_get(obj);
285 if (!wd || !wd->base) return;
288 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
289 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
294 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
295 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
300 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
301 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
302 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
303 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
304 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
305 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
306 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
311 _set_vis_guidetext(Evas_Object *obj)
313 Widget_Data *wd = elm_widget_data_get(obj);
316 elm_box_unpack(wd->box, wd->guidetext);
317 elm_box_unpack(wd->box, wd->entry);
318 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
320 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
321 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
323 evas_object_hide(wd->entry);
324 elm_box_pack_end(wd->box, wd->guidetext);
325 evas_object_show(wd->guidetext);
326 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
330 evas_object_hide(wd->guidetext);
331 elm_box_pack_end(wd->box, wd->entry);
332 evas_object_show(wd->entry);
333 if (elm_widget_focus_get(obj) || wd->focused)
335 elm_object_focus_set(wd->entry, EINA_TRUE);
336 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
341 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
343 Widget_Data *wd = elm_widget_data_get(obj);
345 Elm_Multibuttonentry_Item *item;
347 if (!wd || !wd->box) return;
348 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
349 evas_object_hide(wd->entry);
350 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
351 evas_object_hide(wd->guidetext);
352 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
354 evas_object_hide(wd->rect_for_end);
355 evas_object_hide(wd->end);
356 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
359 if (shrink == EINA_TRUE)
361 Evas_Coord w = 0, w_tmp = 0;
362 Evas_Coord box_inner_item_width_padding = 0;
364 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
365 // unpack all items and entry
366 elm_box_unpack_all(wd->box);
367 EINA_LIST_FOREACH(wd->items, l, item)
371 evas_object_hide(item->button);
372 item->visible = EINA_FALSE;
375 // pack buttons only 1line
380 elm_box_pack_end(wd->box, wd->label);
381 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
383 w -= box_inner_item_width_padding;
387 int count = eina_list_count(wd->items);
388 Evas_Coord button_min_width = 0;
389 /* Evas_Coord button_min_height = 0; */
390 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
392 const char *size_str;
393 size_str = edje_object_data_get(wd->end, "closed_button_width");
394 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
396 size_str = edje_object_data_get(wd->end, "closed_button_height");
397 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
401 EINA_LIST_FOREACH(wd->items, l, item)
405 int w_label_count = 0;
408 elm_box_pack_end(wd->box, item->button);
409 evas_object_show(item->button);
410 item->visible = EINA_TRUE;
413 w -= box_inner_item_width_padding;
416 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
420 snprintf(buf, sizeof(buf), "... + %d", count);
421 elm_object_text_set(wd->end, buf);
422 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
425 if (w < 0 || w < w_label_count)
427 elm_box_unpack(wd->box, item->button);
428 evas_object_hide(item->button);
429 item->visible = EINA_FALSE;
432 snprintf(buf, sizeof(buf), "... + %d", count);
433 elm_object_text_set(wd->end, buf);
434 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
436 elm_box_pack_end(wd->box, wd->end);
437 evas_object_show(wd->end);
439 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
440 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
444 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
446 if (w < button_min_width)
449 Evas_Coord closed_height = 0;
450 const char *height_str = edje_object_data_get(wd->base, "closed_height");
452 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
453 elm_box_unpack(wd->box, item->button);
454 evas_object_hide(item->button);
455 item->visible = EINA_FALSE;
458 rectSize = w - button_min_width;
459 if (!wd->rect_for_end)
461 Evas *e = evas_object_evas_get(obj);
462 wd->rect_for_end = evas_object_rectangle_add(e);
463 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
465 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
466 elm_box_pack_end(wd->box, wd->rect_for_end);
467 evas_object_show(wd->rect_for_end);
469 elm_box_pack_end(wd->box, wd->end);
470 evas_object_show(wd->end);
472 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
473 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
482 // unpack all items and entry
483 elm_box_unpack_all(wd->box);
484 EINA_LIST_FOREACH(wd->items, l, item)
488 evas_object_hide(item->button);
489 item->visible = EINA_FALSE;
492 evas_object_hide(wd->end);
494 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
496 // pack buttons only 1line
498 if (wd->label) elm_box_pack_end(wd->box, wd->label);
502 EINA_LIST_FOREACH(wd->items, l, item)
506 elm_box_pack_end(wd->box, item->button);
507 evas_object_show(item->button);
508 item->visible = EINA_TRUE;
512 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
513 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)(long)wd->shrink);
515 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
517 _set_vis_guidetext(obj);
522 _view_update(Evas_Object *obj)
524 Evas_Coord width = 1, height = 1;
525 Widget_Data *wd = elm_widget_data_get(obj);
527 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
532 elm_box_unpack(wd->box, wd->label);
533 elm_box_pack_start(wd->box, wd->label);
534 evas_object_size_hint_min_get(wd->label, &width, &height);
539 Evas_Coord guide_text_width = wd->w_box - width;
540 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
543 // update buttons in shrink mode
544 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
545 _shrink_mode_set(obj, EINA_TRUE);
548 _set_vis_guidetext(obj);
552 _set_label(Evas_Object *obj, const char *str)
554 Widget_Data *wd = elm_widget_data_get(obj);
556 if (!wd || !str) return;
557 eina_stringshare_replace(&wd->labeltxt, str);
560 Evas_Coord width, height, sum_width = 0;
561 evas_object_size_hint_min_set(wd->label, 0, 0);
562 evas_object_resize(wd->label, 0, 0);
563 edje_object_part_text_set(wd->label, "mbe.label", str);
565 if (!strcmp(str, ""))
567 /* FIXME: not work yet */
568 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
569 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
574 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
575 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
579 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
582 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
585 evas_object_size_hint_min_set(wd->label, sum_width, height);
587 evas_object_show(wd->label);
592 _set_guidetext(Evas_Object *obj, const char *str)
594 Widget_Data *wd = elm_widget_data_get(obj);
596 if (!wd || !str) return;
598 eina_stringshare_replace(&wd->guidetexttxt, str);
599 if (wd->guidetext == NULL)
600 wd->guidetext = edje_object_add(evas_object_evas_get(obj));
604 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
605 "guidetext", elm_widget_style_get(obj));
606 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
607 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
609 edje_object_part_text_set(wd->guidetext, "elm.text", str);
615 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
617 Widget_Data *wd = elm_widget_data_get(obj);
618 Elm_Multibuttonentry_Item *item = NULL;
622 item = eina_list_data_get(wd->current);
624 if (item && item->button)
628 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
629 edje_object_signal_emit(item->button, "default", "");
632 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
633 edje_object_signal_emit(item->button, "focused", "");
634 evas_object_smart_callback_call(obj, "item,selected", item);
637 edje_object_signal_emit(item->button, "default", "");
645 _change_current_button(Evas_Object *obj, Evas_Object *btn)
647 Widget_Data *wd = elm_widget_data_get(obj);
649 Elm_Multibuttonentry_Item *item;
653 // change the state of previous button to "default"
654 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
656 // change the current
657 EINA_LIST_FOREACH(wd->items, l, item)
659 if (item->button == btn)
665 // change the state of current button to "focused"
666 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
670 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
672 Widget_Data *wd = elm_widget_data_get(data);
674 Elm_Multibuttonentry_Item *item = NULL;
675 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
677 _change_current_button(data, obj);
680 if ((item = eina_list_data_get(wd->current)) != NULL)
682 evas_object_smart_callback_call(data, "item,clicked", item);
683 _select_button(data, item->button);
688 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
690 Widget_Data *wd = elm_widget_data_get(obj);
692 if (!wd || !btn) return;
694 evas_object_del(btn);
698 _del_button_item(Elm_Multibuttonentry_Item *item)
701 Elm_Multibuttonentry_Item *_item;
705 Evas_Object *obj = WIDGET(item);
706 wd = elm_widget_data_get(obj);
708 EINA_LIST_FOREACH(wd->items, l, _item)
712 wd->items = eina_list_remove(wd->items, _item);
713 elm_box_unpack(wd->box, _item->button);
715 evas_object_smart_callback_call(obj, "item,deleted", _item);
717 _del_button_obj(obj, _item->button);
719 if (wd->current == l)
724 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
725 _shrink_mode_set(obj, EINA_TRUE);
727 if (!eina_list_count(wd->items))
728 _set_vis_guidetext(obj);
732 _select_button(Evas_Object *obj, Evas_Object *btn)
734 Widget_Data *wd = elm_widget_data_get(obj);
739 _change_current_button(obj, btn);
740 if (elm_widget_focus_get(obj))
742 elm_object_focus_set(wd->entry, EINA_FALSE);
743 evas_object_focus_set(btn, EINA_TRUE);
748 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
749 if (elm_widget_focus_get(obj))
750 elm_object_focus_set(wd->entry, EINA_TRUE);
755 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
758 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
759 Evas_Coord w_btn = 0, button_max_width = 0;
760 const char *size_str;
762 size_str = edje_object_data_get(btn, "button_max_size");
763 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
765 // decide the size of button
766 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
767 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
768 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
769 w_btn = w_text + 2*padding_outer + 2*padding_inner;
773 if (button_max_width < w_btn)
774 vw = button_max_width;
779 evas_object_resize(btn, vw, h_btn);
780 evas_object_size_hint_min_set(btn, vw, h_btn);
782 if (realw) *realw = rw;
783 if (vieww) *vieww = vw;
787 _item_del_pre_hook(Elm_Object_Item *it)
789 _del_button_item((Elm_Multibuttonentry_Item *)it);
793 static Elm_Object_Item*
794 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, void *data)
796 Elm_Multibuttonentry_Item *item;
797 Elm_Multibuttonentry_Item_Filter *item_filter;
798 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
801 Evas_Coord width = -1, height = -1;
802 char *str_utf8 = NULL;
803 Widget_Data *wd = elm_widget_data_get(obj);
805 if (!wd || !wd->box || !wd->entry) return NULL;
806 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
807 if (!str) return NULL;
809 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
811 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
815 btn = edje_object_add(evas_object_evas_get(obj));
816 str_utf8 = elm_entry_markup_to_utf8(str);
818 //entry is cleared when text is made to button
819 elm_object_text_set(wd->entry, "");
821 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
822 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
823 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
825 evas_object_size_hint_min_set(btn, width, height);
827 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
828 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
829 evas_object_show(btn);
832 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
835 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
836 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
837 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
838 elm_widget_item_data_set(item, data);
840 _resize_button(btn, &rw, &vw);
844 item->visible = EINA_TRUE;
848 case MULTIBUTTONENTRY_POS_START:
849 wd->items = eina_list_prepend(wd->items, item);
850 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
852 elm_widget_sub_object_add(obj, btn);
853 _shrink_mode_set(obj, EINA_TRUE);
858 elm_box_pack_after(wd->box, btn, wd->label);
860 elm_box_pack_start(wd->box, btn);
861 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
862 _set_vis_guidetext(obj);
865 case MULTIBUTTONENTRY_POS_END:
866 wd->items = eina_list_append(wd->items, item);
867 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
869 elm_widget_sub_object_add(obj, btn);
870 evas_object_hide(btn);
874 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
875 _set_vis_guidetext(obj);
877 elm_box_pack_before(wd->box, btn, wd->entry);
879 elm_box_pack_end(wd->box, btn);
882 case MULTIBUTTONENTRY_POS_BEFORE:
884 wd->items = eina_list_prepend_relative(wd->items, item, reference);
886 wd->items = eina_list_append(wd->items, item);
887 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
889 elm_widget_sub_object_add(obj, btn);
890 evas_object_hide(btn);
891 _shrink_mode_set(obj, EINA_TRUE);
896 elm_box_pack_before(wd->box, btn, reference->button);
899 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
900 _set_vis_guidetext(obj);
902 elm_box_pack_before(wd->box, btn, wd->entry);
904 elm_box_pack_end(wd->box, btn);
908 case MULTIBUTTONENTRY_POS_AFTER:
910 wd->items = eina_list_append_relative(wd->items, item, reference);
912 wd->items = eina_list_append(wd->items, item);
913 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
915 elm_widget_sub_object_add(obj, btn);
916 _shrink_mode_set(obj, EINA_TRUE);
921 elm_box_pack_after(wd->box, btn, reference->button);
924 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
925 _set_vis_guidetext(obj);
927 elm_box_pack_before(wd->box, btn, wd->entry);
929 elm_box_pack_end(wd->box, btn);
937 evas_object_smart_callback_call(obj, "item,added", item);
941 return (Elm_Object_Item *)item;
944 static Elm_Multibuttonentry_Item_Filter*
945 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
947 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
948 if (!item_filter) return NULL;
950 item_filter->callback_func= func;
951 item_filter->data = data;
957 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
963 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
965 Widget_Data *wd = elm_widget_data_get(data);
966 Elm_Multibuttonentry_Item *item = NULL;
968 if (!wd || !wd->base || !wd->box) return;
970 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
972 if (wd->last_btn_select)
975 ((strcmp(ev->keyname, "BackSpace") == 0) ||
976 (strcmp(ev->keyname, "Delete") == 0)))
978 item = eina_list_data_get(wd->current);
981 _del_button_item(item);
982 elm_widget_item_free(item);
983 elm_object_focus_set(wd->entry, EINA_TRUE);
986 else if (((!wd->current && (wd->n_str == 0) &&
987 (strcmp(ev->keyname, "BackSpace") == 0)) ||
988 (strcmp(ev->keyname, "Delete") == 0)))
990 item = eina_list_data_get(eina_list_last(wd->items));
992 _select_button(data, item->button);
996 wd->last_btn_select = EINA_TRUE;
1000 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1002 Widget_Data *wd = elm_widget_data_get(data);
1003 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1007 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1008 wd->last_btn_select = EINA_FALSE;
1012 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1014 Widget_Data *wd = elm_widget_data_get(data);
1015 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1018 if (!wd || !wd->base || !wd->box) return;
1020 str = elm_object_text_get(wd->entry);
1022 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1024 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
1030 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1032 Widget_Data *wd = elm_widget_data_get(data);
1035 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1036 elm_object_focus_set(wd->entry, EINA_TRUE);
1040 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1042 Widget_Data *wd = elm_widget_data_get(data);
1043 Elm_Multibuttonentry_Item *item = NULL;
1049 item = eina_list_data_get(wd->current);
1050 elm_object_focus_set(wd->entry, EINA_FALSE);
1051 evas_object_focus_set(item->button, EINA_TRUE);
1056 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1058 Widget_Data *wd = elm_widget_data_get(data);
1063 str = elm_object_text_get(wd->entry);
1065 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
1069 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1071 Widget_Data *wd = elm_widget_data_get(data);
1076 str = elm_object_text_get(wd->entry);
1077 wd->n_str = strlen(str);
1081 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1083 Evas_Coord en_x, en_y, en_w, en_h;
1084 Evas_Coord bx_x, bx_y;
1086 Widget_Data *wd = elm_widget_data_get(data);
1089 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1090 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1093 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
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_single_line_set(wd->entry, EINA_TRUE);
1127 elm_object_text_set(wd->entry, "");
1128 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1129 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1130 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1131 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1132 if (wd->box) elm_box_pack_end(wd->box, wd->entry);
1133 evas_object_show(wd->entry);
1134 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1139 const char *end_type;
1141 end_type = edje_object_data_get(wd->base, "closed_button_type");
1142 if (!end_type || !strcmp(end_type, "label"))
1144 wd->end = elm_label_add(obj);
1145 if (!wd->end) return;
1146 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1147 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1151 const char *size_str;
1152 wd->end = edje_object_add(evas_object_evas_get(obj));
1153 if (!wd->end) return;
1154 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1155 Evas_Coord button_min_width = 0;
1156 Evas_Coord button_min_height = 0;
1158 size_str = edje_object_data_get(wd->end, "closed_button_width");
1159 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1160 size_str = edje_object_data_get(wd->end, "closed_button_height");
1161 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1163 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1164 evas_object_size_hint_min_set(wd->end,
1165 button_min_width * _elm_config->scale,
1166 button_min_height * _elm_config->scale);
1167 elm_widget_sub_object_add(obj, wd->end);
1173 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1175 Evas_Coord minw, minh, mnw, mnh, ww;
1176 Evas_Coord w, cw = 0, cmaxh = 0;
1178 Evas_Object_Box_Option *opt;
1181 /* FIXME: need to calc max */
1185 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1186 evas_object_size_hint_min_get(box, &minw, NULL);
1188 EINA_LIST_FOREACH(priv->children, l, opt)
1190 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1191 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1195 if (mnw != -1 && (w - cw) >= mnw)
1210 if (cmaxh < mnh) cmaxh = mnh;
1215 evas_object_size_hint_min_set(box, minw, minh);
1219 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1221 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1223 Evas_Object_Box_Option *opt;
1227 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1229 EINA_LIST_FOREACH(priv->children, l, opt)
1231 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1232 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1236 if (mnw != -1 && (w - cw) >= mnw)
1246 if (index > obj_index) return cmaxh;
1252 if (cmaxh < mnh) cmaxh = mnh;
1261 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1263 Evas_Coord x, y, w, h, xx, yy;
1266 Evas_Coord minw, minh;
1268 Evas_Object_Box_Option *opt;
1270 _calculate_box_min_size(o, priv);
1272 evas_object_geometry_get(o, &x, &y, &w, &h);
1274 evas_object_size_hint_min_get(o, &minw, &minh);
1275 evas_object_size_hint_align_get(o, &ax, &ay);
1278 x = x + ((w - minw) * (1.0 - ax));
1283 y = y + ((h - minh) * (1.0 - ay));
1290 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1292 EINA_LIST_FOREACH(priv->children, l, opt)
1294 Evas_Coord mnw, mnh, mxw, mxh;
1299 evas_object_size_hint_align_get(obj, &ax, &ay);
1300 evas_object_size_hint_weight_get(obj, &wx, &wy);
1301 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1302 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1304 if (ax == -1.0) {fw = 1; ax = 0.5;}
1305 if (ay == -1.0) {fh = 1; ay = 0.5;}
1306 Evas_Coord ww, hh, ow, oh;
1310 if (mnw != -1 && (w - cw) >= mnw)
1317 hh = _calculate_item_max_height(o, priv, obj_index);
1321 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1324 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1333 evas_object_move(obj,
1334 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1335 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1336 evas_object_resize(obj, ow, oh);
1339 if (cmaxh < hh) cmaxh = hh;
1346 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1348 Elm_Multibuttonentry_Item *item;
1349 if (part && strcmp(part, "default")) return;
1351 item = (Elm_Multibuttonentry_Item *)it;
1352 edje_object_part_text_set(item->button, "elm.btn.text", label);
1353 _resize_button(item->button, &item->rw, &item->vw);
1357 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1359 Elm_Multibuttonentry_Item *item;
1360 if (part && strcmp(part, "default")) return NULL;
1361 item = (Elm_Multibuttonentry_Item *)it;
1362 return edje_object_part_text_get(item->button, "elm.btn.text");
1366 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1368 ELM_CHECK_WIDTYPE(obj, widtype);
1369 if (!part || !strcmp(part, "default"))
1371 if (label) _set_label(obj, label);
1372 else _set_label(obj, "");
1374 else if (!strcmp(part, "guide"))
1376 if (label) _set_guidetext(obj, label);
1377 else _set_guidetext(obj, "");
1382 _text_get_hook(const Evas_Object *obj, const char *part)
1384 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1385 Widget_Data *wd = elm_widget_data_get(obj);
1386 if (!wd) return NULL;
1388 if (!part || !strcmp(part, "default"))
1390 return wd->labeltxt;
1392 else if (!strcmp(part, "guide"))
1394 return wd->guidetexttxt;
1400 elm_multibuttonentry_add(Evas_Object *parent)
1406 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1408 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1409 elm_widget_type_set(obj, "multibuttonentry");
1410 elm_widget_sub_object_add(parent, obj);
1411 elm_widget_data_set(obj, wd);
1413 elm_widget_del_hook_set(obj, _del_hook);
1414 elm_widget_theme_hook_set(obj, _theme_hook);
1415 elm_widget_event_hook_set(obj, _event_hook);
1416 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1417 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1418 elm_widget_text_set_hook_set(obj, _text_set_hook);
1419 elm_widget_text_get_hook_set(obj, _text_get_hook);
1421 wd->base = edje_object_add(e);
1422 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1423 elm_widget_resize_object_set(obj, wd->base);
1424 elm_widget_can_focus_set(obj, EINA_TRUE);
1426 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1427 wd->focused = EINA_FALSE;
1428 wd->last_btn_select = EINA_TRUE;
1430 wd->rect_for_end = NULL;
1431 wd->add_callback = NULL;
1432 wd->add_callback_data = NULL;
1441 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1443 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1444 Widget_Data *wd = elm_widget_data_get(obj);
1446 if (!wd) return NULL;
1451 EINA_DEPRECATED EAPI const char *
1452 elm_multibuttonentry_label_get(const Evas_Object *obj)
1454 return _text_get_hook(obj, NULL);
1457 EINA_DEPRECATED EAPI void
1458 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1460 _text_set_hook(obj, NULL, label);
1463 EINA_DEPRECATED EAPI const char *
1464 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1466 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1467 Widget_Data *wd = elm_widget_data_get(obj);
1469 if (!wd) return NULL;
1470 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1474 EINA_DEPRECATED EAPI void
1475 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1477 ELM_CHECK_WIDTYPE(obj, widtype);
1478 Widget_Data *wd = elm_widget_data_get(obj);
1482 _set_guidetext(obj, guidetext);
1485 EINA_DEPRECATED EAPI int
1486 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1488 if (elm_multibuttonentry_expanded_get(obj))
1495 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1497 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1498 Widget_Data *wd = elm_widget_data_get(obj);
1501 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1505 EINA_DEPRECATED EAPI void
1506 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1509 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
1512 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
1516 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1518 ELM_CHECK_WIDTYPE(obj, widtype);
1519 Widget_Data *wd = elm_widget_data_get(obj);
1521 if (!wd || !wd->box ||
1522 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1525 _shrink_mode_set(obj, EINA_FALSE);
1527 _shrink_mode_set(obj, EINA_TRUE);
1531 EAPI Elm_Object_Item *
1532 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1534 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1537 EAPI Elm_Object_Item *
1538 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1540 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1543 EAPI Elm_Object_Item *
1544 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1546 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, data);
1549 EAPI Elm_Object_Item *
1550 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
1552 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, data);
1555 EAPI const Eina_List *
1556 elm_multibuttonentry_items_get(const Evas_Object *obj)
1558 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1559 Widget_Data *wd = elm_widget_data_get(obj);
1560 if (!wd) return NULL;
1564 EAPI Elm_Object_Item *
1565 elm_multibuttonentry_first_item_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;
1570 return eina_list_data_get(wd->items);
1573 EAPI Elm_Object_Item *
1574 elm_multibuttonentry_last_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(eina_list_last(wd->items));
1582 EAPI Elm_Object_Item *
1583 elm_multibuttonentry_selected_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(wd->current);
1592 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1594 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1595 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
1596 if (selected) _select_button(WIDGET(item), item->button);
1597 else _select_button(WIDGET(item), NULL);
1601 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
1603 //TODO : To be implemented.
1604 if (!it) return EINA_FALSE;
1609 elm_multibuttonentry_clear(Evas_Object *obj)
1611 ELM_CHECK_WIDTYPE(obj, widtype);
1612 Elm_Multibuttonentry_Item *item;
1613 Widget_Data *wd = elm_widget_data_get(obj);
1618 EINA_LIST_FREE(wd->items, item)
1620 elm_box_unpack(wd->box, item->button);
1621 _del_button_obj(obj, item->button);
1631 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1633 elm_object_item_del(it);
1637 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1639 return _item_text_get_hook(it, NULL);
1643 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1645 _item_text_set_hook(it, NULL, str);
1648 EAPI Elm_Object_Item *
1649 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1651 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1654 Elm_Multibuttonentry_Item *_item;
1656 wd = elm_widget_data_get(WIDGET(it));
1657 if (!wd) return NULL;
1659 EINA_LIST_FOREACH(wd->items, l, _item)
1661 if (_item == (Elm_Multibuttonentry_Item *)it)
1663 l = eina_list_prev(l);
1664 if (!l) return NULL;
1665 return eina_list_data_get(l);
1671 EAPI Elm_Object_Item *
1672 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1674 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1677 Elm_Multibuttonentry_Item *_item;
1678 wd = elm_widget_data_get(WIDGET(it));
1679 if (!wd) return NULL;
1681 EINA_LIST_FOREACH(wd->items, l, _item)
1683 if (_item == (Elm_Multibuttonentry_Item *)it)
1685 l = eina_list_next(l);
1686 if (!l) return NULL;
1687 return eina_list_data_get(l);
1694 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1696 return elm_widget_item_data_get(it);
1700 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1702 return elm_widget_item_data_set(it, data);
1706 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1708 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1709 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1712 Widget_Data *wd = elm_widget_data_get(obj);
1715 ELM_CHECK_WIDTYPE(obj, widtype);
1716 EINA_SAFETY_ON_NULL_RETURN(func);
1718 new_item_filter= _filter_new(func, data);
1719 if (!new_item_filter) return;
1721 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1723 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1725 printf("Already Registered this item filter!!!!\n");
1729 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1733 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1735 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1736 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1738 Widget_Data *wd = elm_widget_data_get(obj);
1741 ELM_CHECK_WIDTYPE(obj, widtype);
1742 EINA_SAFETY_ON_NULL_RETURN(func);
1744 new_item_filter = _filter_new(func, data);
1745 if (!new_item_filter) return;
1747 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1749 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1751 printf("Already Registered this item filter!!!!\n");
1755 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1759 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1763 Elm_Multibuttonentry_Item_Filter *item_filter;
1765 wd = elm_widget_data_get(obj);
1767 EINA_SAFETY_ON_NULL_RETURN(func);
1769 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1771 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1773 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1774 _filter_free(item_filter);