1 #include <Elementary.h>
5 #define MIN_W_ENTRY 160
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;
67 Eina_List *filter_list;
68 Elm_Object_Item *selected_it; /* selected item */
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;
85 static void _del_hook(Evas_Object *obj);
86 static void _theme_hook(Evas_Object *obj);
87 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
88 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
89 static void _sizing_eval(Evas_Object *obj);
90 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
91 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
92 static void _event_init(Evas_Object *obj);
93 static void _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink);
94 static void _view_update(Evas_Object *obj);
95 static void _set_label(Evas_Object *obj, const char *str);
96 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
97 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
98 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
99 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
100 static void _del_button_item(Elm_Multibuttonentry_Item *item);
101 static void _select_button(Evas_Object *obj, Evas_Object *btn);
102 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);
103 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
104 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
105 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
107 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
108 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
109 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
110 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
111 static void _view_init(Evas_Object *obj);
112 static void _set_vis_guidetext(Evas_Object *obj);
113 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
114 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
115 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
116 static void _item_text_set_hook(Elm_Object_Item *it,
119 static const char *_item_text_get_hook(const Elm_Object_Item *it,
122 static const char *widtype = NULL;
125 static const char SIG_ITEM_SELECTED[] = "item,selected";
126 static const char SIG_ITEM_ADDED[] = "item,added";
127 static const char SIG_ITEM_DELETED[] = "item,deleted";
128 static const char SIG_ITEM_CLICKED[] = "item,clicked";
129 static const char SIG_CLICKED[] = "clicked";
130 static const char SIG_FOCUSED[] = "focused";
131 static const char SIG_UNFOCUSED[] = "unfocused";
132 static const char SIG_EXPANDED[] = "expanded";
133 static const char SIG_CONTRACTED[] = "contracted";
134 static const char SIG_EXPAND_STATE_CHANGED[] = "expand,state,changed";
136 static const Evas_Smart_Cb_Description _signals[] = {
137 {SIG_ITEM_SELECTED, ""},
138 {SIG_ITEM_ADDED, ""},
139 {SIG_ITEM_DELETED, ""},
140 {SIG_ITEM_CLICKED, ""},
145 {SIG_CONTRACTED, ""},
146 {SIG_EXPAND_STATE_CHANGED, ""},
151 _del_hook(Evas_Object *obj)
153 Widget_Data *wd = elm_widget_data_get(obj);
158 Elm_Multibuttonentry_Item *item;
159 EINA_LIST_FREE(wd->items, item)
161 _del_button_obj(obj, item->button);
166 wd->selected_it = NULL;
168 if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
169 if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
170 if (wd->entry) evas_object_del(wd->entry);
171 if (wd->label) evas_object_del(wd->label);
172 if (wd->guidetext) evas_object_del(wd->guidetext);
173 if (wd->end) evas_object_del(wd->end);
174 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
179 _theme_hook(Evas_Object *obj)
181 Widget_Data *wd = elm_widget_data_get(obj);
183 Elm_Multibuttonentry_Item *item;
187 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
188 if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
189 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
191 EINA_LIST_FOREACH(wd->items, l, item)
194 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
195 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
202 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
204 Widget_Data *wd = elm_widget_data_get(obj);
208 if (elm_widget_focus_get(obj))
212 if ((wd->selected_it))
214 elm_entry_input_panel_show(wd->entry);
216 else if (((!wd->selected_it) || (!eina_list_count(wd->items))))
218 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
220 elm_entry_input_panel_show(wd->entry);
223 wd->focused = EINA_TRUE;
224 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
228 wd->focused = EINA_FALSE;
231 elm_entry_input_panel_hide(wd->entry);
232 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
237 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
243 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
245 Widget_Data *wd = elm_widget_data_get(obj);
248 edje_object_signal_emit(wd->base, emission, source);
252 _sizing_eval(Evas_Object *obj)
254 Widget_Data *wd = elm_widget_data_get(obj);
255 Evas_Coord minw = -1, minh = -1;
256 Evas_Coord left, right, top, bottom;
259 evas_object_size_hint_min_get(wd->box, &minw, &minh);
260 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
261 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
263 minw += (left + right);
264 minh += (top + bottom);
266 evas_object_size_hint_min_set(obj, minw, minh);
270 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
272 Widget_Data *wd = elm_widget_data_get(data);
274 if (!wd || !wd->base) return;
275 wd->focused = EINA_TRUE;
280 elm_entry_input_panel_show(wd->entry);
281 elm_object_focus_set(wd->entry, EINA_TRUE);
284 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
288 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
290 Evas_Object *eo = (Evas_Object *)data;
291 Widget_Data *wd = elm_widget_data_get(data);
298 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
300 Widget_Data *wd = elm_widget_data_get(data);
304 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
306 if (wd->h_box < h) evas_object_smart_callback_call(data, SIG_EXPANDED, NULL);
307 else if (wd->h_box > h)
308 evas_object_smart_callback_call(data, SIG_CONTRACTED, NULL);
317 _event_init(Evas_Object *obj)
319 Widget_Data *wd = elm_widget_data_get(obj);
321 if (!wd || !wd->base) return;
324 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
325 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
330 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
331 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
336 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
337 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
338 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
339 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
340 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
341 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
342 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
347 _set_vis_guidetext(Evas_Object *obj)
349 Widget_Data *wd = elm_widget_data_get(obj);
352 elm_box_unpack(wd->box, wd->guidetext);
353 elm_box_unpack(wd->box, wd->entry);
354 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
357 elm_object_focus_set(wd->entry, EINA_FALSE);
359 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
360 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
362 evas_object_hide(wd->entry);
363 elm_box_pack_end(wd->box, wd->guidetext);
364 evas_object_show(wd->guidetext);
365 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
369 evas_object_hide(wd->guidetext);
373 elm_box_pack_end(wd->box, wd->entry);
374 evas_object_show(wd->entry);
375 if (elm_widget_focus_get(obj) || wd->focused)
377 if (!wd->selected_it)
378 elm_object_focus_set(wd->entry, EINA_TRUE);
381 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
386 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
388 Widget_Data *wd = elm_widget_data_get(obj);
390 Elm_Multibuttonentry_Item *item;
392 if (!wd || !wd->box) return;
393 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
394 evas_object_hide(wd->entry);
395 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
396 evas_object_hide(wd->guidetext);
397 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
399 evas_object_hide(wd->rect_for_end);
400 evas_object_hide(wd->end);
401 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
404 if (shrink == EINA_TRUE)
406 Evas_Coord w = 0, w_tmp = 0;
407 Evas_Coord box_inner_item_width_padding = 0;
409 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
410 // unpack all items and entry
411 elm_box_unpack_all(wd->box);
412 EINA_LIST_FOREACH(wd->items, l, item)
416 evas_object_hide(item->button);
417 item->visible = EINA_FALSE;
420 // pack buttons only 1line
425 elm_box_pack_end(wd->box, wd->label);
426 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
428 w -= box_inner_item_width_padding;
432 int count = eina_list_count(wd->items);
433 Evas_Coord button_min_width = 0;
434 /* Evas_Coord button_min_height = 0; */
435 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
437 const char *size_str;
438 size_str = edje_object_data_get(wd->end, "closed_button_width");
439 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
441 size_str = edje_object_data_get(wd->end, "closed_button_height");
442 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
446 EINA_LIST_FOREACH(wd->items, l, item)
450 int w_label_count = 0;
453 elm_box_pack_end(wd->box, item->button);
454 evas_object_show(item->button);
455 item->visible = EINA_TRUE;
458 w -= box_inner_item_width_padding;
461 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
465 snprintf(buf, sizeof(buf), "... + %d", count);
466 elm_object_text_set(wd->end, buf);
467 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
470 if (w < 0 || w < w_label_count)
472 elm_box_unpack(wd->box, item->button);
473 evas_object_hide(item->button);
474 item->visible = EINA_FALSE;
477 snprintf(buf, sizeof(buf), "... + %d", count);
478 elm_object_text_set(wd->end, buf);
479 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
481 elm_box_pack_end(wd->box, wd->end);
482 evas_object_show(wd->end);
484 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
485 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)1);
489 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
491 if (w < button_min_width)
494 Evas_Coord closed_height = 0;
495 const char *height_str = edje_object_data_get(wd->base, "closed_height");
497 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
498 elm_box_unpack(wd->box, item->button);
499 evas_object_hide(item->button);
500 item->visible = EINA_FALSE;
503 rectSize = w - button_min_width;
504 if (!wd->rect_for_end)
506 Evas *e = evas_object_evas_get(obj);
507 wd->rect_for_end = evas_object_rectangle_add(e);
508 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
510 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
511 elm_box_pack_end(wd->box, wd->rect_for_end);
512 evas_object_show(wd->rect_for_end);
514 elm_box_pack_end(wd->box, wd->end);
515 evas_object_show(wd->end);
517 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
518 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)0);
527 // unpack all items and entry
528 elm_box_unpack_all(wd->box);
529 EINA_LIST_FOREACH(wd->items, l, item)
533 evas_object_hide(item->button);
534 item->visible = EINA_FALSE;
537 evas_object_hide(wd->end);
539 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
541 // pack buttons only 1line
543 if (wd->label) elm_box_pack_end(wd->box, wd->label);
547 EINA_LIST_FOREACH(wd->items, l, item)
551 elm_box_pack_end(wd->box, item->button);
552 evas_object_show(item->button);
553 item->visible = EINA_TRUE;
557 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
558 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED,
559 (void *)(long)wd->shrink);
561 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
563 _set_vis_guidetext(obj);
568 _view_update(Evas_Object *obj)
570 Evas_Coord width = 1, height = 1;
571 Widget_Data *wd = elm_widget_data_get(obj);
573 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
578 elm_box_unpack(wd->box, wd->label);
579 elm_box_pack_start(wd->box, wd->label);
580 evas_object_size_hint_min_get(wd->label, &width, &height);
585 Evas_Coord guide_text_width = wd->w_box - width;
586 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
589 // update buttons in shrink mode
590 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
591 _shrink_mode_set(obj, EINA_TRUE);
594 _set_vis_guidetext(obj);
598 _set_label(Evas_Object *obj, const char *str)
600 Widget_Data *wd = elm_widget_data_get(obj);
602 if (!wd || !str) return;
603 eina_stringshare_replace(&wd->labeltxt, str);
606 Evas_Coord width, height, sum_width = 0;
607 evas_object_size_hint_min_set(wd->label, 0, 0);
608 evas_object_resize(wd->label, 0, 0);
609 edje_object_part_text_escaped_set(wd->label, "mbe.label", str);
611 if (!strcmp(str, ""))
613 /* FIXME: not work yet */
614 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
615 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
620 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
621 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
625 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
628 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
631 evas_object_size_hint_min_set(wd->label, sum_width, height);
633 evas_object_show(wd->label);
638 _set_guidetext(Evas_Object *obj, const char *str)
640 Widget_Data *wd = elm_widget_data_get(obj);
642 if (!wd || !str) return;
644 eina_stringshare_replace(&wd->guidetexttxt, str);
645 if (wd->guidetext == NULL)
646 wd->guidetext = edje_object_add(evas_object_evas_get(obj));
650 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
651 "guidetext", elm_widget_style_get(obj));
652 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
653 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
655 edje_object_part_text_escaped_set(wd->guidetext, "elm.text", str);
661 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
663 Widget_Data *wd = elm_widget_data_get(obj);
664 Elm_Multibuttonentry_Item *item = NULL;
667 item = (Elm_Multibuttonentry_Item *)wd->selected_it;
669 if (item && item->button)
673 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
674 edje_object_signal_emit(item->button, "default", "");
675 wd->selected_it = NULL;
677 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
678 edje_object_signal_emit(item->button, "focused", "");
679 evas_object_smart_callback_call(obj, SIG_ITEM_SELECTED, item);
682 edje_object_signal_emit(item->button, "default", "");
683 wd->selected_it = NULL;
690 _change_current_button(Evas_Object *obj, Evas_Object *btn)
692 Widget_Data *wd = elm_widget_data_get(obj);
694 Elm_Multibuttonentry_Item *item;
698 // change the state of previous button to "default"
699 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
701 // change the current
702 EINA_LIST_FOREACH(wd->items, l, item)
704 if (item->button == btn)
706 wd->selected_it = (Elm_Object_Item *)item;
710 // change the state of current button to "focused"
711 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
715 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
717 Widget_Data *wd = elm_widget_data_get(data);
719 Elm_Multibuttonentry_Item *item = NULL;
720 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
722 _select_button(data, obj);
725 if ((item = (Elm_Multibuttonentry_Item *)wd->selected_it) != NULL)
727 evas_object_smart_callback_call(data, SIG_ITEM_CLICKED, item);
728 _select_button(data, item->button);
733 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
735 Widget_Data *wd = elm_widget_data_get(obj);
737 if (!wd || !btn) return;
739 evas_object_del(btn);
743 _del_button_item(Elm_Multibuttonentry_Item *item)
746 Elm_Multibuttonentry_Item *_item;
750 Evas_Object *obj = WIDGET(item);
751 wd = elm_widget_data_get(obj);
753 EINA_LIST_FOREACH(wd->items, l, _item)
757 wd->items = eina_list_remove(wd->items, _item);
758 elm_box_unpack(wd->box, _item->button);
760 evas_object_smart_callback_call(obj, SIG_ITEM_DELETED, _item);
762 _del_button_obj(obj, _item->button);
764 if (wd->selected_it == (Elm_Object_Item *)_item)
765 wd->selected_it = NULL;
769 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
770 _shrink_mode_set(obj, EINA_TRUE);
772 if (!eina_list_count(wd->items))
773 _set_vis_guidetext(obj);
777 _select_button(Evas_Object *obj, Evas_Object *btn)
779 Widget_Data *wd = elm_widget_data_get(obj);
784 _change_current_button(obj, btn);
785 if (elm_widget_focus_get(obj))
787 elm_object_focus_set(wd->entry, EINA_FALSE);
788 evas_object_focus_set(btn, EINA_TRUE);
793 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
794 if (elm_widget_focus_get(obj) && wd->editable)
795 elm_object_focus_set(wd->entry, EINA_TRUE);
800 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
803 Evas_Coord w_text, h_btn, padding_outer = 0;
804 Evas_Coord w_btn = 0, button_max_width = 0;
805 const char *size_str;
807 size_str = edje_object_data_get(btn, "button_max_size");
808 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
810 // decide the size of button
811 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
812 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
813 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
814 w_btn = w_text + (2 * padding_outer);
818 if (button_max_width < w_btn)
819 vw = button_max_width;
824 evas_object_resize(btn, vw, h_btn);
825 evas_object_size_hint_min_set(btn, vw, h_btn);
827 if (realw) *realw = rw;
828 if (vieww) *vieww = vw;
832 _item_del_pre_hook(Elm_Object_Item *it)
834 _del_button_item((Elm_Multibuttonentry_Item *)it);
838 static Elm_Object_Item*
839 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
841 Elm_Multibuttonentry_Item *item;
842 Elm_Multibuttonentry_Item_Filter *item_filter;
843 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
846 Evas_Coord width = -1, height = -1;
847 char *str_utf8 = NULL;
848 Widget_Data *wd = elm_widget_data_get(obj);
850 if (!wd || !wd->box || !wd->entry) return NULL;
851 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
852 if (!str) return NULL;
854 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
856 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
860 btn = edje_object_add(evas_object_evas_get(obj));
861 str_utf8 = elm_entry_markup_to_utf8(str);
863 //entry is cleared when text is made to button
864 elm_object_text_set(wd->entry, "");
866 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
867 edje_object_part_text_escaped_set(btn, "elm.btn.text", str_utf8);
868 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
870 evas_object_size_hint_min_set(btn, width, height);
872 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
873 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
874 evas_object_show(btn);
877 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
880 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
881 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
882 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
883 elm_widget_item_data_set(item, data);
885 _resize_button(btn, &rw, &vw);
889 item->visible = EINA_TRUE;
898 case MULTIBUTTONENTRY_POS_START:
899 wd->items = eina_list_prepend(wd->items, item);
900 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
902 elm_widget_sub_object_add(obj, btn);
903 _shrink_mode_set(obj, EINA_TRUE);
908 elm_box_pack_after(wd->box, btn, wd->label);
910 elm_box_pack_start(wd->box, btn);
911 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
912 _set_vis_guidetext(obj);
915 case MULTIBUTTONENTRY_POS_END:
916 wd->items = eina_list_append(wd->items, item);
917 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
919 elm_widget_sub_object_add(obj, btn);
920 evas_object_hide(btn);
924 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
925 _set_vis_guidetext(obj);
926 if (wd->entry && wd->editable)
927 elm_box_pack_before(wd->box, btn, wd->entry);
929 elm_box_pack_end(wd->box, btn);
932 case MULTIBUTTONENTRY_POS_BEFORE:
934 wd->items = eina_list_prepend_relative(wd->items, item, reference);
936 wd->items = eina_list_append(wd->items, item);
937 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
939 elm_widget_sub_object_add(obj, btn);
940 evas_object_hide(btn);
941 _shrink_mode_set(obj, EINA_TRUE);
946 elm_box_pack_before(wd->box, btn, reference->button);
949 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
950 _set_vis_guidetext(obj);
951 if (wd->entry && wd->editable)
952 elm_box_pack_before(wd->box, btn, wd->entry);
954 elm_box_pack_end(wd->box, btn);
958 case MULTIBUTTONENTRY_POS_AFTER:
960 wd->items = eina_list_append_relative(wd->items, item, reference);
962 wd->items = eina_list_append(wd->items, item);
963 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
965 elm_widget_sub_object_add(obj, btn);
966 _shrink_mode_set(obj, EINA_TRUE);
971 elm_box_pack_after(wd->box, btn, reference->button);
974 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
975 _set_vis_guidetext(obj);
976 if (wd->entry && wd->editable)
977 elm_box_pack_before(wd->box, btn, wd->entry);
979 elm_box_pack_end(wd->box, btn);
987 evas_object_smart_callback_call(obj, SIG_ITEM_ADDED, item);
991 return (Elm_Object_Item *)item;
994 static Elm_Multibuttonentry_Item_Filter*
995 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
997 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
998 if (!item_filter) return NULL;
1000 item_filter->callback_func= func;
1001 item_filter->data = data;
1007 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
1013 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1015 Widget_Data *wd = elm_widget_data_get(data);
1016 Elm_Multibuttonentry_Item *item = NULL;
1018 if (!wd || !wd->base || !wd->box) return;
1020 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
1022 if (wd->last_btn_select)
1024 if (wd->selected_it &&
1025 ((strcmp(ev->keyname, "BackSpace") == 0) ||
1026 (strcmp(ev->keyname, "Delete") == 0)))
1028 item = (Elm_Multibuttonentry_Item *)wd->selected_it;
1029 if (item && wd->editable)
1031 _del_button_item(item);
1032 elm_widget_item_free(item);
1033 elm_object_focus_set(wd->entry, EINA_TRUE);
1036 else if (((!wd->selected_it && (wd->n_str == 0) &&
1037 (strcmp(ev->keyname, "BackSpace") == 0)) ||
1038 (strcmp(ev->keyname, "Delete") == 0)))
1040 item = eina_list_data_get(eina_list_last(wd->items));
1042 _select_button(data, item->button);
1046 wd->last_btn_select = EINA_TRUE;
1050 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1052 Widget_Data *wd = elm_widget_data_get(data);
1053 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1057 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1058 wd->last_btn_select = EINA_FALSE;
1062 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1064 Widget_Data *wd = elm_widget_data_get(data);
1065 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1068 if (!wd || !wd->base || !wd->box) return;
1070 str = elm_object_text_get(wd->entry);
1072 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1074 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1080 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1082 Widget_Data *wd = elm_widget_data_get(data);
1085 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1086 elm_object_focus_set(wd->entry, EINA_TRUE);
1090 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1092 Widget_Data *wd = elm_widget_data_get(data);
1093 Elm_Multibuttonentry_Item *item = NULL;
1097 if (wd->selected_it)
1099 item = (Elm_Multibuttonentry_Item *)wd->selected_it;
1100 elm_object_focus_set(wd->entry, EINA_FALSE);
1101 evas_object_focus_set(item->button, EINA_TRUE);
1106 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1108 Widget_Data *wd = elm_widget_data_get(data);
1113 str = elm_object_text_get(wd->entry);
1115 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1119 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1121 Widget_Data *wd = elm_widget_data_get(data);
1126 str = elm_object_text_get(wd->entry);
1127 wd->n_str = strlen(str);
1131 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1133 Evas_Coord en_x, en_y, en_w, en_h;
1135 Widget_Data *wd = elm_widget_data_get(data);
1138 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1141 elm_widget_show_region_set(wd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
1145 _view_init(Evas_Object *obj)
1147 Widget_Data *wd = elm_widget_data_get(obj);
1153 wd->box = elm_box_add(obj);
1154 if (!wd->box) return;
1155 elm_widget_sub_object_add(obj, wd->box);
1156 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1157 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1158 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1162 wd->label = edje_object_add(evas_object_evas_get(obj));
1163 if (!wd->label) return;
1164 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1165 _set_label(obj, "");
1166 elm_widget_sub_object_add(obj, wd->label);
1171 wd->entry = elm_entry_add(obj);
1172 if (!wd->entry) return;
1173 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1174 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1175 elm_object_text_set(wd->entry, "");
1176 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1177 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1178 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1179 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1180 if (wd->box) elm_box_pack_end(wd->box, wd->entry);
1181 evas_object_show(wd->entry);
1182 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1187 const char *end_type;
1189 end_type = edje_object_data_get(wd->base, "closed_button_type");
1190 if (!end_type || !strcmp(end_type, "label"))
1192 wd->end = elm_label_add(obj);
1193 if (!wd->end) return;
1194 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1195 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1199 const char *size_str;
1200 wd->end = edje_object_add(evas_object_evas_get(obj));
1201 if (!wd->end) return;
1202 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1203 Evas_Coord button_min_width = 0;
1204 Evas_Coord button_min_height = 0;
1206 size_str = edje_object_data_get(wd->end, "closed_button_width");
1207 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1208 size_str = edje_object_data_get(wd->end, "closed_button_height");
1209 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1211 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1212 evas_object_size_hint_min_set(wd->end,
1213 button_min_width * _elm_config->scale,
1214 button_min_height * _elm_config->scale);
1215 elm_widget_sub_object_add(obj, wd->end);
1221 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1223 Evas_Coord minw, minh, mnw, mnh, ww;
1224 Evas_Coord w, cw = 0, cmaxh = 0;
1226 Evas_Object_Box_Option *opt;
1229 /* FIXME: need to calc max */
1233 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1234 evas_object_size_hint_min_get(box, &minw, NULL);
1236 EINA_LIST_FOREACH(priv->children, l, opt)
1238 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1239 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1243 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1246 if (mnw != -1 && (w - cw) >= mnw)
1260 if (cmaxh < mnh) cmaxh = mnh;
1265 evas_object_size_hint_min_set(box, minw, minh);
1269 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1271 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1273 Evas_Object_Box_Option *opt;
1274 int local_index = 0;
1277 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1279 EINA_LIST_FOREACH(priv->children, l, opt)
1281 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1282 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1286 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1289 if (mnw != -1 && (w - cw) >= mnw)
1299 if (local_index > obj_index) return cmaxh;
1304 if (cmaxh < mnh) cmaxh = mnh;
1313 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1315 Evas_Coord x, y, w, h, xx, yy;
1318 Evas_Coord minw, minh;
1320 Evas_Object_Box_Option *opt;
1322 _calculate_box_min_size(o, priv);
1324 evas_object_geometry_get(o, &x, &y, &w, &h);
1326 evas_object_size_hint_min_get(o, &minw, &minh);
1327 evas_object_size_hint_align_get(o, &ax, &ay);
1330 x = x + ((w - minw) * (1.0 - ax));
1335 y = y + ((h - minh) * (1.0 - ay));
1342 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1344 EINA_LIST_FOREACH(priv->children, l, opt)
1346 Evas_Coord mnw, mnh, mxw, mxh;
1351 evas_object_size_hint_align_get(obj, &ax, &ay);
1352 evas_object_size_hint_weight_get(obj, &wx, &wy);
1353 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1354 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1356 if (ax == -1.0) {fw = 1; ax = 0.5;}
1357 if (ay == -1.0) {fh = 1; ay = 0.5;}
1358 Evas_Coord ww, hh, ow, oh;
1362 if ((elm_widget_is(obj)) && (!(strcmp(elm_widget_type_get(obj), "entry"))) && (mnw == -1))
1365 if (mnw != -1 && (w - cw) >= mnw)
1372 hh = _calculate_item_max_height(o, priv, obj_index);
1376 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1379 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1387 evas_object_move(obj,
1388 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1389 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1390 evas_object_resize(obj, ow, oh);
1393 if (cmaxh < hh) cmaxh = hh;
1400 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1402 Elm_Multibuttonentry_Item *item;
1403 if (part && strcmp(part, "default")) return;
1405 item = (Elm_Multibuttonentry_Item *)it;
1406 edje_object_part_text_escaped_set(item->button, "elm.btn.text", label);
1407 _resize_button(item->button, &item->rw, &item->vw);
1411 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1413 Elm_Multibuttonentry_Item *item;
1414 if (part && strcmp(part, "default")) return NULL;
1415 item = (Elm_Multibuttonentry_Item *)it;
1416 return edje_object_part_text_get(item->button, "elm.btn.text");
1420 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1422 ELM_CHECK_WIDTYPE(obj, widtype);
1423 if (!part || !strcmp(part, "default"))
1425 if (label) _set_label(obj, label);
1426 else _set_label(obj, "");
1428 else if (!strcmp(part, "guide"))
1430 if (label) _set_guidetext(obj, label);
1431 else _set_guidetext(obj, "");
1436 _text_get_hook(const Evas_Object *obj, const char *part)
1438 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1439 Widget_Data *wd = elm_widget_data_get(obj);
1440 if (!wd) return NULL;
1442 if (!part || !strcmp(part, "default"))
1444 return wd->labeltxt;
1446 else if (!strcmp(part, "guide"))
1448 return wd->guidetexttxt;
1454 elm_multibuttonentry_add(Evas_Object *parent)
1460 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1462 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1463 elm_widget_type_set(obj, "multibuttonentry");
1464 elm_widget_sub_object_add(parent, obj);
1465 elm_widget_data_set(obj, wd);
1467 elm_widget_del_hook_set(obj, _del_hook);
1468 elm_widget_theme_hook_set(obj, _theme_hook);
1469 elm_widget_event_hook_set(obj, _event_hook);
1470 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1471 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1472 elm_widget_text_set_hook_set(obj, _text_set_hook);
1473 elm_widget_text_get_hook_set(obj, _text_get_hook);
1475 wd->base = edje_object_add(e);
1476 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1477 elm_widget_resize_object_set(obj, wd->base);
1478 elm_widget_can_focus_set(obj, EINA_TRUE);
1480 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1481 wd->focused = EINA_FALSE;
1482 wd->last_btn_select = EINA_TRUE;
1484 wd->rect_for_end = NULL;
1485 wd->add_callback = NULL;
1486 wd->add_callback_data = NULL;
1487 wd->editable = EINA_TRUE;
1489 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1498 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1500 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1501 Widget_Data *wd = elm_widget_data_get(obj);
1503 if (!wd) return NULL;
1509 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1511 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1512 Widget_Data *wd = elm_widget_data_get(obj);
1515 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1519 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1521 ELM_CHECK_WIDTYPE(obj, widtype);
1522 Widget_Data *wd = elm_widget_data_get(obj);
1524 if (!wd || !wd->box ||
1525 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1528 _shrink_mode_set(obj, EINA_FALSE);
1530 _shrink_mode_set(obj, EINA_TRUE);
1535 elm_multibuttonentry_editable_set(Evas_Object *obj, Eina_Bool editable)
1537 ELM_CHECK_WIDTYPE(obj, widtype);
1538 Widget_Data *wd = elm_widget_data_get(obj);
1540 if (wd->editable == editable) return;
1541 wd->editable = editable;
1546 evas_object_show(wd->entry);
1549 elm_entry_input_panel_hide(wd->entry);
1550 evas_object_hide(wd->entry);
1556 elm_multibuttonentry_editable_get(const Evas_Object *obj)
1558 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1559 Widget_Data *wd = elm_widget_data_get(obj);
1561 return wd->editable;
1564 EAPI Elm_Object_Item *
1565 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1567 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
1570 EAPI Elm_Object_Item *
1571 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1573 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
1576 EAPI Elm_Object_Item *
1577 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
1579 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
1582 EAPI Elm_Object_Item *
1583 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
1585 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
1588 EAPI const Eina_List *
1589 elm_multibuttonentry_items_get(const Evas_Object *obj)
1591 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1592 Widget_Data *wd = elm_widget_data_get(obj);
1593 if (!wd) return NULL;
1597 EAPI Elm_Object_Item *
1598 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1600 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1601 Widget_Data *wd = elm_widget_data_get(obj);
1602 if (!wd) return NULL;
1603 return eina_list_data_get(wd->items);
1606 EAPI Elm_Object_Item *
1607 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1609 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1610 Widget_Data *wd = elm_widget_data_get(obj);
1611 if (!wd) return NULL;
1612 return eina_list_data_get(eina_list_last(wd->items));
1615 EAPI Elm_Object_Item *
1616 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1618 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1619 Widget_Data *wd = elm_widget_data_get(obj);
1620 if (!wd) return NULL;
1621 return wd->selected_it;
1625 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1627 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1628 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
1629 if (selected) _select_button(WIDGET(item), item->button);
1630 else _select_button(WIDGET(item), NULL);
1634 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
1636 //TODO : To be implemented.
1637 if (!it) return EINA_FALSE;
1642 elm_multibuttonentry_clear(Evas_Object *obj)
1644 ELM_CHECK_WIDTYPE(obj, widtype);
1645 Elm_Multibuttonentry_Item *item;
1646 Widget_Data *wd = elm_widget_data_get(obj);
1651 EINA_LIST_FREE(wd->items, item)
1653 elm_box_unpack(wd->box, item->button);
1654 _del_button_obj(obj, item->button);
1659 wd->selected_it = NULL;
1663 EAPI Elm_Object_Item *
1664 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1666 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1669 Elm_Multibuttonentry_Item *_item;
1671 wd = elm_widget_data_get(WIDGET(it));
1672 if (!wd) return NULL;
1674 EINA_LIST_FOREACH(wd->items, l, _item)
1676 if (_item == (Elm_Multibuttonentry_Item *)it)
1678 l = eina_list_prev(l);
1679 if (!l) return NULL;
1680 return eina_list_data_get(l);
1686 EAPI Elm_Object_Item *
1687 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1689 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1692 Elm_Multibuttonentry_Item *_item;
1693 wd = elm_widget_data_get(WIDGET(it));
1694 if (!wd) return NULL;
1696 EINA_LIST_FOREACH(wd->items, l, _item)
1698 if (_item == (Elm_Multibuttonentry_Item *)it)
1700 l = eina_list_next(l);
1701 if (!l) return NULL;
1702 return eina_list_data_get(l);
1708 EINA_DEPRECATED EAPI void *
1709 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1711 return elm_widget_item_data_get(it);
1714 EINA_DEPRECATED EAPI void
1715 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1717 return elm_widget_item_data_set(it, data);
1721 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1723 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1724 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1727 Widget_Data *wd = elm_widget_data_get(obj);
1730 ELM_CHECK_WIDTYPE(obj, widtype);
1731 EINA_SAFETY_ON_NULL_RETURN(func);
1733 new_item_filter= _filter_new(func, data);
1734 if (!new_item_filter) return;
1736 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1738 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1740 printf("Already Registered this item filter!!!!\n");
1744 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1748 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1750 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1751 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1753 Widget_Data *wd = elm_widget_data_get(obj);
1756 ELM_CHECK_WIDTYPE(obj, widtype);
1757 EINA_SAFETY_ON_NULL_RETURN(func);
1759 new_item_filter = _filter_new(func, data);
1760 if (!new_item_filter) return;
1762 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1764 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1766 printf("Already Registered this item filter!!!!\n");
1770 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1774 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1778 Elm_Multibuttonentry_Item_Filter *item_filter;
1780 wd = elm_widget_data_get(obj);
1782 EINA_SAFETY_ON_NULL_RETURN(func);
1784 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1786 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1788 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1789 _filter_free(item_filter);