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 void _del_hook(Evas_Object *obj);
84 static void _theme_hook(Evas_Object *obj);
85 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
86 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
87 static void _sizing_eval(Evas_Object *obj);
88 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
89 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
90 static void _event_init(Evas_Object *obj);
91 static void _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink);
92 static void _view_update(Evas_Object *obj);
93 static void _set_label(Evas_Object *obj, const char *str);
94 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
95 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
96 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
97 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
98 static void _del_button_item(Elm_Multibuttonentry_Item *item);
99 static void _select_button(Evas_Object *obj, Evas_Object *btn);
100 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);
101 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
102 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
103 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
104 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
106 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
107 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
108 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
109 static void _view_init(Evas_Object *obj);
110 static void _set_vis_guidetext(Evas_Object *obj);
111 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
112 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
113 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
114 static void _item_text_set_hook(Elm_Object_Item *it,
117 static const char *_item_text_get_hook(const Elm_Object_Item *it,
120 static const char *widtype = NULL;
123 static const char SIG_ITEM_SELECTED[] = "item,selected";
124 static const char SIG_ITEM_ADDED[] = "item,added";
125 static const char SIG_ITEM_DELETED[] = "item,deleted";
126 static const char SIG_ITEM_CLICKED[] = "item,clicked";
127 static const char SIG_CLICKED[] = "clicked";
128 static const char SIG_FOCUSED[] = "focused";
129 static const char SIG_UNFOCUSED[] = "unfocused";
130 static const char SIG_EXPANDED[] = "expanded";
131 static const char SIG_CONTRACTED[] = "contracted";
132 static const char SIG_EXPAND_STATE_CHANGED[] = "expand,state,changed";
134 static const Evas_Smart_Cb_Description _signals[] = {
135 {SIG_ITEM_SELECTED, ""},
136 {SIG_ITEM_ADDED, ""},
137 {SIG_ITEM_DELETED, ""},
138 {SIG_ITEM_CLICKED, ""},
143 {SIG_CONTRACTED, ""},
144 {SIG_EXPAND_STATE_CHANGED, ""},
149 _del_hook(Evas_Object *obj)
151 Widget_Data *wd = elm_widget_data_get(obj);
156 Elm_Multibuttonentry_Item *item;
157 EINA_LIST_FREE(wd->items, item)
159 _del_button_obj(obj, item->button);
166 if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
167 if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
168 if (wd->entry) evas_object_del(wd->entry);
169 if (wd->label) evas_object_del(wd->label);
170 if (wd->guidetext) evas_object_del(wd->guidetext);
171 if (wd->end) evas_object_del(wd->end);
172 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
176 _theme_hook(Evas_Object *obj)
178 Widget_Data *wd = elm_widget_data_get(obj);
180 Elm_Multibuttonentry_Item *item;
184 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
185 if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
186 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
188 EINA_LIST_FOREACH(wd->items, l, item)
191 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
192 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
199 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
201 Widget_Data *wd = elm_widget_data_get(obj);
205 if (elm_widget_focus_get(obj))
209 elm_entry_input_panel_show(wd->entry);
211 else if (((!wd->current) || (!eina_list_count(wd->items))))
213 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
215 elm_entry_input_panel_show(wd->entry);
217 wd->focused = EINA_TRUE;
218 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
222 wd->focused = EINA_FALSE;
225 elm_entry_input_panel_hide(wd->entry);
226 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
231 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
237 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
239 Widget_Data *wd = elm_widget_data_get(obj);
242 edje_object_signal_emit(wd->base, emission, source);
246 _sizing_eval(Evas_Object *obj)
248 Widget_Data *wd = elm_widget_data_get(obj);
249 Evas_Coord minw = -1, minh = -1;
250 Evas_Coord left, right, top, bottom;
253 evas_object_size_hint_min_get(wd->box, &minw, &minh);
254 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
255 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
257 minw += (left + right);
258 minh += (top + bottom);
260 evas_object_size_hint_min_set(obj, minw, minh);
264 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
266 Widget_Data *wd = elm_widget_data_get(data);
268 if (!wd || !wd->base) return;
269 wd->focused = EINA_TRUE;
272 elm_entry_input_panel_show(wd->entry);
274 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
278 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
280 Evas_Object *eo = (Evas_Object *)data;
281 Widget_Data *wd = elm_widget_data_get(data);
288 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
290 Widget_Data *wd = elm_widget_data_get(data);
294 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
296 if (wd->h_box < h) evas_object_smart_callback_call(data, SIG_EXPANDED, NULL);
297 else if (wd->h_box > h)
298 evas_object_smart_callback_call(data, SIG_CONTRACTED, NULL);
307 _event_init(Evas_Object *obj)
309 Widget_Data *wd = elm_widget_data_get(obj);
311 if (!wd || !wd->base) return;
314 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
315 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
320 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
321 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
326 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
327 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
328 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
329 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
330 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
331 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
332 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
337 _set_vis_guidetext(Evas_Object *obj)
339 Widget_Data *wd = elm_widget_data_get(obj);
342 elm_box_unpack(wd->box, wd->guidetext);
343 elm_box_unpack(wd->box, wd->entry);
344 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
347 elm_object_focus_set(wd->entry, EINA_FALSE);
349 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
350 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
352 evas_object_hide(wd->entry);
353 elm_box_pack_end(wd->box, wd->guidetext);
354 evas_object_show(wd->guidetext);
355 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
359 evas_object_hide(wd->guidetext);
360 elm_box_pack_end(wd->box, wd->entry);
361 evas_object_show(wd->entry);
362 if (elm_widget_focus_get(obj) || wd->focused)
364 elm_object_focus_set(wd->entry, EINA_TRUE);
365 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
370 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
372 Widget_Data *wd = elm_widget_data_get(obj);
374 Elm_Multibuttonentry_Item *item;
376 if (!wd || !wd->box) return;
377 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
378 evas_object_hide(wd->entry);
379 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
380 evas_object_hide(wd->guidetext);
381 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
383 evas_object_hide(wd->rect_for_end);
384 evas_object_hide(wd->end);
385 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
388 if (shrink == EINA_TRUE)
390 Evas_Coord w = 0, w_tmp = 0;
391 Evas_Coord box_inner_item_width_padding = 0;
393 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
394 // unpack all items and entry
395 elm_box_unpack_all(wd->box);
396 EINA_LIST_FOREACH(wd->items, l, item)
400 evas_object_hide(item->button);
401 item->visible = EINA_FALSE;
404 // pack buttons only 1line
409 elm_box_pack_end(wd->box, wd->label);
410 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
412 w -= box_inner_item_width_padding;
416 int count = eina_list_count(wd->items);
417 Evas_Coord button_min_width = 0;
418 /* Evas_Coord button_min_height = 0; */
419 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
421 const char *size_str;
422 size_str = edje_object_data_get(wd->end, "closed_button_width");
423 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
425 size_str = edje_object_data_get(wd->end, "closed_button_height");
426 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
430 EINA_LIST_FOREACH(wd->items, l, item)
434 int w_label_count = 0;
437 elm_box_pack_end(wd->box, item->button);
438 evas_object_show(item->button);
439 item->visible = EINA_TRUE;
442 w -= box_inner_item_width_padding;
445 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
449 snprintf(buf, sizeof(buf), "... + %d", count);
450 elm_object_text_set(wd->end, buf);
451 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
454 if (w < 0 || w < w_label_count)
456 elm_box_unpack(wd->box, item->button);
457 evas_object_hide(item->button);
458 item->visible = EINA_FALSE;
461 snprintf(buf, sizeof(buf), "... + %d", count);
462 elm_object_text_set(wd->end, buf);
463 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
465 elm_box_pack_end(wd->box, wd->end);
466 evas_object_show(wd->end);
468 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
469 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)1);
473 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
475 if (w < button_min_width)
478 Evas_Coord closed_height = 0;
479 const char *height_str = edje_object_data_get(wd->base, "closed_height");
481 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
482 elm_box_unpack(wd->box, item->button);
483 evas_object_hide(item->button);
484 item->visible = EINA_FALSE;
487 rectSize = w - button_min_width;
488 if (!wd->rect_for_end)
490 Evas *e = evas_object_evas_get(obj);
491 wd->rect_for_end = evas_object_rectangle_add(e);
492 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
494 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
495 elm_box_pack_end(wd->box, wd->rect_for_end);
496 evas_object_show(wd->rect_for_end);
498 elm_box_pack_end(wd->box, wd->end);
499 evas_object_show(wd->end);
501 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
502 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)0);
511 // unpack all items and entry
512 elm_box_unpack_all(wd->box);
513 EINA_LIST_FOREACH(wd->items, l, item)
517 evas_object_hide(item->button);
518 item->visible = EINA_FALSE;
521 evas_object_hide(wd->end);
523 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
525 // pack buttons only 1line
527 if (wd->label) elm_box_pack_end(wd->box, wd->label);
531 EINA_LIST_FOREACH(wd->items, l, item)
535 elm_box_pack_end(wd->box, item->button);
536 evas_object_show(item->button);
537 item->visible = EINA_TRUE;
541 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
542 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED,
543 (void *)(long)wd->shrink);
545 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
547 _set_vis_guidetext(obj);
552 _view_update(Evas_Object *obj)
554 Evas_Coord width = 1, height = 1;
555 Widget_Data *wd = elm_widget_data_get(obj);
557 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
562 elm_box_unpack(wd->box, wd->label);
563 elm_box_pack_start(wd->box, wd->label);
564 evas_object_size_hint_min_get(wd->label, &width, &height);
569 Evas_Coord guide_text_width = wd->w_box - width;
570 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
573 // update buttons in shrink mode
574 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
575 _shrink_mode_set(obj, EINA_TRUE);
578 _set_vis_guidetext(obj);
582 _set_label(Evas_Object *obj, const char *str)
584 Widget_Data *wd = elm_widget_data_get(obj);
586 if (!wd || !str) return;
587 eina_stringshare_replace(&wd->labeltxt, str);
590 Evas_Coord width, height, sum_width = 0;
591 evas_object_size_hint_min_set(wd->label, 0, 0);
592 evas_object_resize(wd->label, 0, 0);
593 edje_object_part_text_set(wd->label, "mbe.label", str);
595 if (!strcmp(str, ""))
597 /* FIXME: not work yet */
598 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
599 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
604 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
605 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
609 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
612 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
615 evas_object_size_hint_min_set(wd->label, sum_width, height);
617 evas_object_show(wd->label);
622 _set_guidetext(Evas_Object *obj, const char *str)
624 Widget_Data *wd = elm_widget_data_get(obj);
626 if (!wd || !str) return;
628 eina_stringshare_replace(&wd->guidetexttxt, str);
629 if (wd->guidetext == NULL)
630 wd->guidetext = edje_object_add(evas_object_evas_get(obj));
634 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
635 "guidetext", elm_widget_style_get(obj));
636 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
637 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
639 edje_object_part_text_set(wd->guidetext, "elm.text", str);
645 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
647 Widget_Data *wd = elm_widget_data_get(obj);
648 Elm_Multibuttonentry_Item *item = NULL;
652 item = eina_list_data_get(wd->current);
654 if (item && item->button)
658 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
659 edje_object_signal_emit(item->button, "default", "");
662 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
663 edje_object_signal_emit(item->button, "focused", "");
664 evas_object_smart_callback_call(obj, SIG_ITEM_SELECTED, item);
667 edje_object_signal_emit(item->button, "default", "");
675 _change_current_button(Evas_Object *obj, Evas_Object *btn)
677 Widget_Data *wd = elm_widget_data_get(obj);
679 Elm_Multibuttonentry_Item *item;
683 // change the state of previous button to "default"
684 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
686 // change the current
687 EINA_LIST_FOREACH(wd->items, l, item)
689 if (item->button == btn)
695 // change the state of current button to "focused"
696 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
700 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
702 Widget_Data *wd = elm_widget_data_get(data);
704 Elm_Multibuttonentry_Item *item = NULL;
705 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
707 _change_current_button(data, obj);
710 if ((item = eina_list_data_get(wd->current)) != NULL)
712 evas_object_smart_callback_call(data, SIG_ITEM_CLICKED, item);
713 _select_button(data, item->button);
718 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
720 Widget_Data *wd = elm_widget_data_get(obj);
722 if (!wd || !btn) return;
724 evas_object_del(btn);
728 _del_button_item(Elm_Multibuttonentry_Item *item)
731 Elm_Multibuttonentry_Item *_item;
735 Evas_Object *obj = WIDGET(item);
736 wd = elm_widget_data_get(obj);
738 EINA_LIST_FOREACH(wd->items, l, _item)
742 wd->items = eina_list_remove(wd->items, _item);
743 elm_box_unpack(wd->box, _item->button);
745 evas_object_smart_callback_call(obj, SIG_ITEM_DELETED, _item);
747 _del_button_obj(obj, _item->button);
749 if (wd->current == l)
754 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
755 _shrink_mode_set(obj, EINA_TRUE);
757 if (!eina_list_count(wd->items))
758 _set_vis_guidetext(obj);
762 _select_button(Evas_Object *obj, Evas_Object *btn)
764 Widget_Data *wd = elm_widget_data_get(obj);
769 _change_current_button(obj, btn);
770 if (elm_widget_focus_get(obj))
772 elm_object_focus_set(wd->entry, EINA_FALSE);
773 evas_object_focus_set(btn, EINA_TRUE);
778 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
779 if (elm_widget_focus_get(obj))
780 elm_object_focus_set(wd->entry, EINA_TRUE);
785 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
788 Evas_Coord w_text, h_btn, padding_outer = 0;
789 Evas_Coord w_btn = 0, button_max_width = 0;
790 const char *size_str;
792 size_str = edje_object_data_get(btn, "button_max_size");
793 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
795 // decide the size of button
796 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
797 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
798 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
799 w_btn = w_text + (2 * padding_outer);
803 if (button_max_width < w_btn)
804 vw = button_max_width;
809 evas_object_resize(btn, vw, h_btn);
810 evas_object_size_hint_min_set(btn, vw, h_btn);
812 if (realw) *realw = rw;
813 if (vieww) *vieww = vw;
817 _item_del_pre_hook(Elm_Object_Item *it)
819 _del_button_item((Elm_Multibuttonentry_Item *)it);
823 static Elm_Object_Item*
824 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
826 Elm_Multibuttonentry_Item *item;
827 Elm_Multibuttonentry_Item_Filter *item_filter;
828 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
831 Evas_Coord width = -1, height = -1;
832 char *str_utf8 = NULL;
833 Widget_Data *wd = elm_widget_data_get(obj);
835 if (!wd || !wd->box || !wd->entry) return NULL;
836 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
837 if (!str) return NULL;
839 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
841 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
845 btn = edje_object_add(evas_object_evas_get(obj));
846 str_utf8 = elm_entry_markup_to_utf8(str);
848 //entry is cleared when text is made to button
849 elm_object_text_set(wd->entry, "");
851 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
852 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
853 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
855 evas_object_size_hint_min_set(btn, width, height);
857 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
858 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
859 evas_object_show(btn);
862 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
865 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
866 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
867 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
868 elm_widget_item_data_set(item, data);
870 _resize_button(btn, &rw, &vw);
874 item->visible = EINA_TRUE;
883 case MULTIBUTTONENTRY_POS_START:
884 wd->items = eina_list_prepend(wd->items, item);
885 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
887 elm_widget_sub_object_add(obj, btn);
888 _shrink_mode_set(obj, EINA_TRUE);
893 elm_box_pack_after(wd->box, btn, wd->label);
895 elm_box_pack_start(wd->box, btn);
896 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
897 _set_vis_guidetext(obj);
900 case MULTIBUTTONENTRY_POS_END:
901 wd->items = eina_list_append(wd->items, item);
902 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
904 elm_widget_sub_object_add(obj, btn);
905 evas_object_hide(btn);
909 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
910 _set_vis_guidetext(obj);
912 elm_box_pack_before(wd->box, btn, wd->entry);
914 elm_box_pack_end(wd->box, btn);
917 case MULTIBUTTONENTRY_POS_BEFORE:
919 wd->items = eina_list_prepend_relative(wd->items, item, reference);
921 wd->items = eina_list_append(wd->items, item);
922 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
924 elm_widget_sub_object_add(obj, btn);
925 evas_object_hide(btn);
926 _shrink_mode_set(obj, EINA_TRUE);
931 elm_box_pack_before(wd->box, btn, reference->button);
934 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
935 _set_vis_guidetext(obj);
937 elm_box_pack_before(wd->box, btn, wd->entry);
939 elm_box_pack_end(wd->box, btn);
943 case MULTIBUTTONENTRY_POS_AFTER:
945 wd->items = eina_list_append_relative(wd->items, item, reference);
947 wd->items = eina_list_append(wd->items, item);
948 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
950 elm_widget_sub_object_add(obj, btn);
951 _shrink_mode_set(obj, EINA_TRUE);
956 elm_box_pack_after(wd->box, btn, reference->button);
959 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
960 _set_vis_guidetext(obj);
962 elm_box_pack_before(wd->box, btn, wd->entry);
964 elm_box_pack_end(wd->box, btn);
972 evas_object_smart_callback_call(obj, SIG_ITEM_ADDED, item);
976 return (Elm_Object_Item *)item;
979 static Elm_Multibuttonentry_Item_Filter*
980 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
982 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
983 if (!item_filter) return NULL;
985 item_filter->callback_func= func;
986 item_filter->data = data;
992 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
998 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1000 Widget_Data *wd = elm_widget_data_get(data);
1001 Elm_Multibuttonentry_Item *item = NULL;
1003 if (!wd || !wd->base || !wd->box) return;
1005 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
1007 if (wd->last_btn_select)
1010 ((strcmp(ev->keyname, "BackSpace") == 0) ||
1011 (strcmp(ev->keyname, "Delete") == 0)))
1013 item = eina_list_data_get(wd->current);
1016 _del_button_item(item);
1017 elm_widget_item_free(item);
1018 elm_object_focus_set(wd->entry, EINA_TRUE);
1021 else if (((!wd->current && (wd->n_str == 0) &&
1022 (strcmp(ev->keyname, "BackSpace") == 0)) ||
1023 (strcmp(ev->keyname, "Delete") == 0)))
1025 item = eina_list_data_get(eina_list_last(wd->items));
1027 _select_button(data, item->button);
1031 wd->last_btn_select = EINA_TRUE;
1035 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1037 Widget_Data *wd = elm_widget_data_get(data);
1038 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1042 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1043 wd->last_btn_select = EINA_FALSE;
1047 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1049 Widget_Data *wd = elm_widget_data_get(data);
1050 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1053 if (!wd || !wd->base || !wd->box) return;
1055 str = elm_object_text_get(wd->entry);
1057 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1059 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1065 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1067 Widget_Data *wd = elm_widget_data_get(data);
1070 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1071 elm_object_focus_set(wd->entry, EINA_TRUE);
1075 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1077 Widget_Data *wd = elm_widget_data_get(data);
1078 Elm_Multibuttonentry_Item *item = NULL;
1084 item = eina_list_data_get(wd->current);
1085 elm_object_focus_set(wd->entry, EINA_FALSE);
1086 evas_object_focus_set(item->button, EINA_TRUE);
1091 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1093 Widget_Data *wd = elm_widget_data_get(data);
1098 str = elm_object_text_get(wd->entry);
1100 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1104 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1106 Widget_Data *wd = elm_widget_data_get(data);
1111 str = elm_object_text_get(wd->entry);
1112 wd->n_str = strlen(str);
1116 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1118 Evas_Coord en_x, en_y, en_w, en_h;
1119 Evas_Coord bx_x, bx_y;
1121 Widget_Data *wd = elm_widget_data_get(data);
1124 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1125 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1128 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
1133 _view_init(Evas_Object *obj)
1135 Widget_Data *wd = elm_widget_data_get(obj);
1141 wd->box = elm_box_add(obj);
1142 if (!wd->box) return;
1143 elm_widget_sub_object_add(obj, wd->box);
1144 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1145 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1146 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1150 wd->label = edje_object_add(evas_object_evas_get(obj));
1151 if (!wd->label) return;
1152 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1153 _set_label(obj, "");
1154 elm_widget_sub_object_add(obj, wd->label);
1159 wd->entry = elm_entry_add(obj);
1160 if (!wd->entry) return;
1161 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1162 elm_object_text_set(wd->entry, "");
1163 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1164 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1165 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1166 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1167 if (wd->box) elm_box_pack_end(wd->box, wd->entry);
1168 evas_object_show(wd->entry);
1169 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1174 const char *end_type;
1176 end_type = edje_object_data_get(wd->base, "closed_button_type");
1177 if (!end_type || !strcmp(end_type, "label"))
1179 wd->end = elm_label_add(obj);
1180 if (!wd->end) return;
1181 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1182 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1186 const char *size_str;
1187 wd->end = edje_object_add(evas_object_evas_get(obj));
1188 if (!wd->end) return;
1189 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1190 Evas_Coord button_min_width = 0;
1191 Evas_Coord button_min_height = 0;
1193 size_str = edje_object_data_get(wd->end, "closed_button_width");
1194 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1195 size_str = edje_object_data_get(wd->end, "closed_button_height");
1196 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1198 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1199 evas_object_size_hint_min_set(wd->end,
1200 button_min_width * _elm_config->scale,
1201 button_min_height * _elm_config->scale);
1202 elm_widget_sub_object_add(obj, wd->end);
1208 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1210 Evas_Coord minw, minh, mnw, mnh, ww;
1211 Evas_Coord w, cw = 0, cmaxh = 0;
1213 Evas_Object_Box_Option *opt;
1216 /* FIXME: need to calc max */
1220 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1221 evas_object_size_hint_min_get(box, &minw, NULL);
1223 EINA_LIST_FOREACH(priv->children, l, opt)
1225 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1226 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1230 if (mnw != -1 && (w - cw) >= mnw)
1245 if (cmaxh < mnh) cmaxh = mnh;
1250 evas_object_size_hint_min_set(box, minw, minh);
1254 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1256 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1258 Evas_Object_Box_Option *opt;
1259 int local_index = 0;
1262 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1264 EINA_LIST_FOREACH(priv->children, l, opt)
1266 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1267 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1271 if (mnw != -1 && (w - cw) >= mnw)
1281 if (local_index > obj_index) return cmaxh;
1287 if (cmaxh < mnh) cmaxh = mnh;
1296 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1298 Evas_Coord x, y, w, h, xx, yy;
1301 Evas_Coord minw, minh;
1303 Evas_Object_Box_Option *opt;
1305 _calculate_box_min_size(o, priv);
1307 evas_object_geometry_get(o, &x, &y, &w, &h);
1309 evas_object_size_hint_min_get(o, &minw, &minh);
1310 evas_object_size_hint_align_get(o, &ax, &ay);
1313 x = x + ((w - minw) * (1.0 - ax));
1318 y = y + ((h - minh) * (1.0 - ay));
1325 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1327 EINA_LIST_FOREACH(priv->children, l, opt)
1329 Evas_Coord mnw, mnh, mxw, mxh;
1334 evas_object_size_hint_align_get(obj, &ax, &ay);
1335 evas_object_size_hint_weight_get(obj, &wx, &wy);
1336 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1337 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1339 if (ax == -1.0) {fw = 1; ax = 0.5;}
1340 if (ay == -1.0) {fh = 1; ay = 0.5;}
1341 Evas_Coord ww, hh, ow, oh;
1345 if (mnw != -1 && (w - cw) >= mnw)
1352 hh = _calculate_item_max_height(o, priv, obj_index);
1356 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1359 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1368 evas_object_move(obj,
1369 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1370 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1371 evas_object_resize(obj, ow, oh);
1374 if (cmaxh < hh) cmaxh = hh;
1381 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1383 Elm_Multibuttonentry_Item *item;
1384 if (part && strcmp(part, "default")) return;
1386 item = (Elm_Multibuttonentry_Item *)it;
1387 edje_object_part_text_set(item->button, "elm.btn.text", label);
1388 _resize_button(item->button, &item->rw, &item->vw);
1392 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1394 Elm_Multibuttonentry_Item *item;
1395 if (part && strcmp(part, "default")) return NULL;
1396 item = (Elm_Multibuttonentry_Item *)it;
1397 return edje_object_part_text_get(item->button, "elm.btn.text");
1401 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1403 ELM_CHECK_WIDTYPE(obj, widtype);
1404 if (!part || !strcmp(part, "default"))
1406 if (label) _set_label(obj, label);
1407 else _set_label(obj, "");
1409 else if (!strcmp(part, "guide"))
1411 if (label) _set_guidetext(obj, label);
1412 else _set_guidetext(obj, "");
1417 _text_get_hook(const Evas_Object *obj, const char *part)
1419 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1420 Widget_Data *wd = elm_widget_data_get(obj);
1421 if (!wd) return NULL;
1423 if (!part || !strcmp(part, "default"))
1425 return wd->labeltxt;
1427 else if (!strcmp(part, "guide"))
1429 return wd->guidetexttxt;
1435 elm_multibuttonentry_add(Evas_Object *parent)
1441 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1443 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1444 elm_widget_type_set(obj, "multibuttonentry");
1445 elm_widget_sub_object_add(parent, obj);
1446 elm_widget_data_set(obj, wd);
1448 elm_widget_del_hook_set(obj, _del_hook);
1449 elm_widget_theme_hook_set(obj, _theme_hook);
1450 elm_widget_event_hook_set(obj, _event_hook);
1451 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1452 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1453 elm_widget_text_set_hook_set(obj, _text_set_hook);
1454 elm_widget_text_get_hook_set(obj, _text_get_hook);
1456 wd->base = edje_object_add(e);
1457 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1458 elm_widget_resize_object_set(obj, wd->base);
1459 elm_widget_can_focus_set(obj, EINA_TRUE);
1461 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1462 wd->focused = EINA_FALSE;
1463 wd->last_btn_select = EINA_TRUE;
1465 wd->rect_for_end = NULL;
1466 wd->add_callback = NULL;
1467 wd->add_callback_data = NULL;
1469 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1478 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1480 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1481 Widget_Data *wd = elm_widget_data_get(obj);
1483 if (!wd) return NULL;
1489 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1491 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1492 Widget_Data *wd = elm_widget_data_get(obj);
1495 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1500 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1502 ELM_CHECK_WIDTYPE(obj, widtype);
1503 Widget_Data *wd = elm_widget_data_get(obj);
1505 if (!wd || !wd->box ||
1506 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1509 _shrink_mode_set(obj, EINA_FALSE);
1511 _shrink_mode_set(obj, EINA_TRUE);
1515 EAPI Elm_Object_Item *
1516 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1518 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
1521 EAPI Elm_Object_Item *
1522 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1524 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
1527 EAPI Elm_Object_Item *
1528 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
1530 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
1533 EAPI Elm_Object_Item *
1534 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
1536 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
1539 EAPI const Eina_List *
1540 elm_multibuttonentry_items_get(const Evas_Object *obj)
1542 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1543 Widget_Data *wd = elm_widget_data_get(obj);
1544 if (!wd) return NULL;
1548 EAPI Elm_Object_Item *
1549 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1551 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1552 Widget_Data *wd = elm_widget_data_get(obj);
1553 if (!wd) return NULL;
1554 return eina_list_data_get(wd->items);
1557 EAPI Elm_Object_Item *
1558 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1560 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1561 Widget_Data *wd = elm_widget_data_get(obj);
1562 if (!wd) return NULL;
1563 return eina_list_data_get(eina_list_last(wd->items));
1566 EAPI Elm_Object_Item *
1567 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1569 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1570 Widget_Data *wd = elm_widget_data_get(obj);
1571 if (!wd) return NULL;
1572 return eina_list_data_get(wd->current);
1576 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1578 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1579 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
1580 if (selected) _select_button(WIDGET(item), item->button);
1581 else _select_button(WIDGET(item), NULL);
1585 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
1587 //TODO : To be implemented.
1588 if (!it) return EINA_FALSE;
1593 elm_multibuttonentry_clear(Evas_Object *obj)
1595 ELM_CHECK_WIDTYPE(obj, widtype);
1596 Elm_Multibuttonentry_Item *item;
1597 Widget_Data *wd = elm_widget_data_get(obj);
1602 EINA_LIST_FREE(wd->items, item)
1604 elm_box_unpack(wd->box, item->button);
1605 _del_button_obj(obj, item->button);
1614 EAPI Elm_Object_Item *
1615 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1617 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1620 Elm_Multibuttonentry_Item *_item;
1622 wd = elm_widget_data_get(WIDGET(it));
1623 if (!wd) return NULL;
1625 EINA_LIST_FOREACH(wd->items, l, _item)
1627 if (_item == (Elm_Multibuttonentry_Item *)it)
1629 l = eina_list_prev(l);
1630 if (!l) return NULL;
1631 return eina_list_data_get(l);
1637 EAPI Elm_Object_Item *
1638 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1640 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1643 Elm_Multibuttonentry_Item *_item;
1644 wd = elm_widget_data_get(WIDGET(it));
1645 if (!wd) return NULL;
1647 EINA_LIST_FOREACH(wd->items, l, _item)
1649 if (_item == (Elm_Multibuttonentry_Item *)it)
1651 l = eina_list_next(l);
1652 if (!l) return NULL;
1653 return eina_list_data_get(l);
1660 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1662 return elm_widget_item_data_get(it);
1666 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1668 return elm_widget_item_data_set(it, data);
1672 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1674 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1675 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1678 Widget_Data *wd = elm_widget_data_get(obj);
1681 ELM_CHECK_WIDTYPE(obj, widtype);
1682 EINA_SAFETY_ON_NULL_RETURN(func);
1684 new_item_filter= _filter_new(func, data);
1685 if (!new_item_filter) return;
1687 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1689 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1691 printf("Already Registered this item filter!!!!\n");
1695 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1699 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1701 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1702 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1704 Widget_Data *wd = elm_widget_data_get(obj);
1707 ELM_CHECK_WIDTYPE(obj, widtype);
1708 EINA_SAFETY_ON_NULL_RETURN(func);
1710 new_item_filter = _filter_new(func, data);
1711 if (!new_item_filter) return;
1713 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1715 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1717 printf("Already Registered this item filter!!!!\n");
1721 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1725 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1729 Elm_Multibuttonentry_Item_Filter *item_filter;
1731 wd = elm_widget_data_get(obj);
1733 EINA_SAFETY_ON_NULL_RETURN(func);
1735 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1737 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1739 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1740 _filter_free(item_filter);