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);
178 _theme_hook(Evas_Object *obj)
180 Widget_Data *wd = elm_widget_data_get(obj);
182 Elm_Multibuttonentry_Item *item;
186 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
187 if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
188 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
190 EINA_LIST_FOREACH(wd->items, l, item)
193 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
194 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
201 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
203 Widget_Data *wd = elm_widget_data_get(obj);
207 if (elm_widget_focus_get(obj))
211 if ((wd->selected_it))
213 elm_entry_input_panel_show(wd->entry);
215 else if (((!wd->selected_it) || (!eina_list_count(wd->items))))
217 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
219 elm_entry_input_panel_show(wd->entry);
222 wd->focused = EINA_TRUE;
223 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
227 wd->focused = EINA_FALSE;
230 elm_entry_input_panel_hide(wd->entry);
231 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
236 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
242 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
244 Widget_Data *wd = elm_widget_data_get(obj);
247 edje_object_signal_emit(wd->base, emission, source);
251 _sizing_eval(Evas_Object *obj)
253 Widget_Data *wd = elm_widget_data_get(obj);
254 Evas_Coord minw = -1, minh = -1;
255 Evas_Coord left, right, top, bottom;
258 evas_object_size_hint_min_get(wd->box, &minw, &minh);
259 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
260 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
262 minw += (left + right);
263 minh += (top + bottom);
265 evas_object_size_hint_min_set(obj, minw, minh);
269 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
271 Widget_Data *wd = elm_widget_data_get(data);
273 if (!wd || !wd->base) return;
274 wd->focused = EINA_TRUE;
279 elm_entry_input_panel_show(wd->entry);
280 elm_object_focus_set(wd->entry, EINA_TRUE);
283 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
287 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
289 Evas_Object *eo = (Evas_Object *)data;
290 Widget_Data *wd = elm_widget_data_get(data);
297 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
299 Widget_Data *wd = elm_widget_data_get(data);
303 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
305 if (wd->h_box < h) evas_object_smart_callback_call(data, SIG_EXPANDED, NULL);
306 else if (wd->h_box > h)
307 evas_object_smart_callback_call(data, SIG_CONTRACTED, NULL);
316 _event_init(Evas_Object *obj)
318 Widget_Data *wd = elm_widget_data_get(obj);
320 if (!wd || !wd->base) return;
323 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
324 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
329 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
330 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
335 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
336 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
337 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
338 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
339 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
340 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
341 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
346 _set_vis_guidetext(Evas_Object *obj)
348 Widget_Data *wd = elm_widget_data_get(obj);
351 elm_box_unpack(wd->box, wd->guidetext);
352 elm_box_unpack(wd->box, wd->entry);
353 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
356 elm_object_focus_set(wd->entry, EINA_FALSE);
358 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
359 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
361 evas_object_hide(wd->entry);
362 elm_box_pack_end(wd->box, wd->guidetext);
363 evas_object_show(wd->guidetext);
364 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
368 evas_object_hide(wd->guidetext);
372 elm_box_pack_end(wd->box, wd->entry);
373 evas_object_show(wd->entry);
374 if (elm_widget_focus_get(obj) || wd->focused)
376 if (!wd->selected_it)
377 elm_object_focus_set(wd->entry, EINA_TRUE);
380 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
385 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
387 Widget_Data *wd = elm_widget_data_get(obj);
389 Elm_Multibuttonentry_Item *item;
391 if (!wd || !wd->box) return;
392 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
393 evas_object_hide(wd->entry);
394 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
395 evas_object_hide(wd->guidetext);
396 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
398 evas_object_hide(wd->rect_for_end);
399 evas_object_hide(wd->end);
400 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
403 if (shrink == EINA_TRUE)
405 Evas_Coord w = 0, w_tmp = 0;
406 Evas_Coord box_inner_item_width_padding = 0;
408 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
409 // unpack all items and entry
410 elm_box_unpack_all(wd->box);
411 EINA_LIST_FOREACH(wd->items, l, item)
415 evas_object_hide(item->button);
416 item->visible = EINA_FALSE;
419 // pack buttons only 1line
424 elm_box_pack_end(wd->box, wd->label);
425 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
427 w -= box_inner_item_width_padding;
431 int count = eina_list_count(wd->items);
432 Evas_Coord button_min_width = 0;
433 /* Evas_Coord button_min_height = 0; */
434 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
436 const char *size_str;
437 size_str = edje_object_data_get(wd->end, "closed_button_width");
438 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
440 size_str = edje_object_data_get(wd->end, "closed_button_height");
441 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
445 EINA_LIST_FOREACH(wd->items, l, item)
449 int w_label_count = 0;
452 elm_box_pack_end(wd->box, item->button);
453 evas_object_show(item->button);
454 item->visible = EINA_TRUE;
457 w -= box_inner_item_width_padding;
460 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
464 snprintf(buf, sizeof(buf), "... + %d", count);
465 elm_object_text_set(wd->end, buf);
466 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
469 if (w < 0 || w < w_label_count)
471 elm_box_unpack(wd->box, item->button);
472 evas_object_hide(item->button);
473 item->visible = EINA_FALSE;
476 snprintf(buf, sizeof(buf), "... + %d", count);
477 elm_object_text_set(wd->end, buf);
478 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
480 elm_box_pack_end(wd->box, wd->end);
481 evas_object_show(wd->end);
483 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
484 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)1);
488 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
490 if (w < button_min_width)
493 Evas_Coord closed_height = 0;
494 const char *height_str = edje_object_data_get(wd->base, "closed_height");
496 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
497 elm_box_unpack(wd->box, item->button);
498 evas_object_hide(item->button);
499 item->visible = EINA_FALSE;
502 rectSize = w - button_min_width;
503 if (!wd->rect_for_end)
505 Evas *e = evas_object_evas_get(obj);
506 wd->rect_for_end = evas_object_rectangle_add(e);
507 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
509 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
510 elm_box_pack_end(wd->box, wd->rect_for_end);
511 evas_object_show(wd->rect_for_end);
513 elm_box_pack_end(wd->box, wd->end);
514 evas_object_show(wd->end);
516 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
517 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED, (void *)0);
526 // unpack all items and entry
527 elm_box_unpack_all(wd->box);
528 EINA_LIST_FOREACH(wd->items, l, item)
532 evas_object_hide(item->button);
533 item->visible = EINA_FALSE;
536 evas_object_hide(wd->end);
538 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
540 // pack buttons only 1line
542 if (wd->label) elm_box_pack_end(wd->box, wd->label);
546 EINA_LIST_FOREACH(wd->items, l, item)
550 elm_box_pack_end(wd->box, item->button);
551 evas_object_show(item->button);
552 item->visible = EINA_TRUE;
556 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
557 evas_object_smart_callback_call(obj, SIG_EXPAND_STATE_CHANGED,
558 (void *)(long)wd->shrink);
560 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
562 _set_vis_guidetext(obj);
567 _view_update(Evas_Object *obj)
569 Evas_Coord width = 1, height = 1;
570 Widget_Data *wd = elm_widget_data_get(obj);
572 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
577 elm_box_unpack(wd->box, wd->label);
578 elm_box_pack_start(wd->box, wd->label);
579 evas_object_size_hint_min_get(wd->label, &width, &height);
584 Evas_Coord guide_text_width = wd->w_box - width;
585 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
588 // update buttons in shrink mode
589 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
590 _shrink_mode_set(obj, EINA_TRUE);
593 _set_vis_guidetext(obj);
597 _set_label(Evas_Object *obj, const char *str)
599 Widget_Data *wd = elm_widget_data_get(obj);
601 if (!wd || !str) return;
602 eina_stringshare_replace(&wd->labeltxt, str);
605 Evas_Coord width, height, sum_width = 0;
606 evas_object_size_hint_min_set(wd->label, 0, 0);
607 evas_object_resize(wd->label, 0, 0);
608 edje_object_part_text_escaped_set(wd->label, "mbe.label", str);
610 if (!strcmp(str, ""))
612 /* FIXME: not work yet */
613 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
614 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
619 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
620 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
624 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
627 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
630 evas_object_size_hint_min_set(wd->label, sum_width, height);
632 evas_object_show(wd->label);
637 _set_guidetext(Evas_Object *obj, const char *str)
639 Widget_Data *wd = elm_widget_data_get(obj);
641 if (!wd || !str) return;
643 eina_stringshare_replace(&wd->guidetexttxt, str);
644 if (wd->guidetext == NULL)
645 wd->guidetext = edje_object_add(evas_object_evas_get(obj));
649 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
650 "guidetext", elm_widget_style_get(obj));
651 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
652 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
654 edje_object_part_text_escaped_set(wd->guidetext, "elm.text", str);
660 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
662 Widget_Data *wd = elm_widget_data_get(obj);
663 Elm_Multibuttonentry_Item *item = NULL;
666 item = (Elm_Multibuttonentry_Item *)wd->selected_it;
668 if (item && item->button)
672 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
673 edje_object_signal_emit(item->button, "default", "");
674 wd->selected_it = NULL;
676 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
677 edje_object_signal_emit(item->button, "focused", "");
678 evas_object_smart_callback_call(obj, SIG_ITEM_SELECTED, item);
681 edje_object_signal_emit(item->button, "default", "");
682 wd->selected_it = NULL;
689 _change_current_button(Evas_Object *obj, Evas_Object *btn)
691 Widget_Data *wd = elm_widget_data_get(obj);
693 Elm_Multibuttonentry_Item *item;
697 // change the state of previous button to "default"
698 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
700 // change the current
701 EINA_LIST_FOREACH(wd->items, l, item)
703 if (item->button == btn)
705 wd->selected_it = (Elm_Object_Item *)item;
709 // change the state of current button to "focused"
710 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
714 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
716 Widget_Data *wd = elm_widget_data_get(data);
718 Elm_Multibuttonentry_Item *item = NULL;
719 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
721 _select_button(data, obj);
724 if ((item = (Elm_Multibuttonentry_Item *)wd->selected_it) != NULL)
726 evas_object_smart_callback_call(data, SIG_ITEM_CLICKED, item);
727 _select_button(data, item->button);
732 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
734 Widget_Data *wd = elm_widget_data_get(obj);
736 if (!wd || !btn) return;
738 evas_object_del(btn);
742 _del_button_item(Elm_Multibuttonentry_Item *item)
745 Elm_Multibuttonentry_Item *_item;
749 Evas_Object *obj = WIDGET(item);
750 wd = elm_widget_data_get(obj);
752 EINA_LIST_FOREACH(wd->items, l, _item)
756 wd->items = eina_list_remove(wd->items, _item);
757 elm_box_unpack(wd->box, _item->button);
759 evas_object_smart_callback_call(obj, SIG_ITEM_DELETED, _item);
761 _del_button_obj(obj, _item->button);
763 if (wd->selected_it == (Elm_Object_Item *)_item)
764 wd->selected_it = NULL;
768 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
769 _shrink_mode_set(obj, EINA_TRUE);
771 if (!eina_list_count(wd->items))
772 _set_vis_guidetext(obj);
776 _select_button(Evas_Object *obj, Evas_Object *btn)
778 Widget_Data *wd = elm_widget_data_get(obj);
783 _change_current_button(obj, btn);
784 if (elm_widget_focus_get(obj))
786 elm_object_focus_set(wd->entry, EINA_FALSE);
787 evas_object_focus_set(btn, EINA_TRUE);
792 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
793 if (elm_widget_focus_get(obj) && wd->editable)
794 elm_object_focus_set(wd->entry, EINA_TRUE);
799 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
802 Evas_Coord w_text, h_btn, padding_outer = 0;
803 Evas_Coord w_btn = 0, button_max_width = 0;
804 const char *size_str;
806 size_str = edje_object_data_get(btn, "button_max_size");
807 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
809 // decide the size of button
810 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
811 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
812 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
813 w_btn = w_text + (2 * padding_outer);
817 if (button_max_width < w_btn)
818 vw = button_max_width;
823 evas_object_resize(btn, vw, h_btn);
824 evas_object_size_hint_min_set(btn, vw, h_btn);
826 if (realw) *realw = rw;
827 if (vieww) *vieww = vw;
831 _item_del_pre_hook(Elm_Object_Item *it)
833 _del_button_item((Elm_Multibuttonentry_Item *)it);
837 static Elm_Object_Item*
838 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
840 Elm_Multibuttonentry_Item *item;
841 Elm_Multibuttonentry_Item_Filter *item_filter;
842 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
845 Evas_Coord width = -1, height = -1;
846 char *str_utf8 = NULL;
847 Widget_Data *wd = elm_widget_data_get(obj);
849 if (!wd || !wd->box || !wd->entry) return NULL;
850 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
851 if (!str) return NULL;
853 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
855 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
859 btn = edje_object_add(evas_object_evas_get(obj));
860 str_utf8 = elm_entry_markup_to_utf8(str);
862 //entry is cleared when text is made to button
863 elm_object_text_set(wd->entry, "");
865 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
866 edje_object_part_text_escaped_set(btn, "elm.btn.text", str_utf8);
867 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
869 evas_object_size_hint_min_set(btn, width, height);
871 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
872 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
873 evas_object_show(btn);
876 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
879 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
880 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
881 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
882 elm_widget_item_data_set(item, data);
884 _resize_button(btn, &rw, &vw);
888 item->visible = EINA_TRUE;
897 case MULTIBUTTONENTRY_POS_START:
898 wd->items = eina_list_prepend(wd->items, item);
899 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
901 elm_widget_sub_object_add(obj, btn);
902 _shrink_mode_set(obj, EINA_TRUE);
907 elm_box_pack_after(wd->box, btn, wd->label);
909 elm_box_pack_start(wd->box, btn);
910 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
911 _set_vis_guidetext(obj);
914 case MULTIBUTTONENTRY_POS_END:
915 wd->items = eina_list_append(wd->items, item);
916 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
918 elm_widget_sub_object_add(obj, btn);
919 evas_object_hide(btn);
923 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
924 _set_vis_guidetext(obj);
925 if (wd->entry && wd->editable)
926 elm_box_pack_before(wd->box, btn, wd->entry);
928 elm_box_pack_end(wd->box, btn);
931 case MULTIBUTTONENTRY_POS_BEFORE:
933 wd->items = eina_list_prepend_relative(wd->items, item, reference);
935 wd->items = eina_list_append(wd->items, item);
936 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
938 elm_widget_sub_object_add(obj, btn);
939 evas_object_hide(btn);
940 _shrink_mode_set(obj, EINA_TRUE);
945 elm_box_pack_before(wd->box, btn, reference->button);
948 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
949 _set_vis_guidetext(obj);
950 if (wd->entry && wd->editable)
951 elm_box_pack_before(wd->box, btn, wd->entry);
953 elm_box_pack_end(wd->box, btn);
957 case MULTIBUTTONENTRY_POS_AFTER:
959 wd->items = eina_list_append_relative(wd->items, item, reference);
961 wd->items = eina_list_append(wd->items, item);
962 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
964 elm_widget_sub_object_add(obj, btn);
965 _shrink_mode_set(obj, EINA_TRUE);
970 elm_box_pack_after(wd->box, btn, reference->button);
973 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
974 _set_vis_guidetext(obj);
975 if (wd->entry && wd->editable)
976 elm_box_pack_before(wd->box, btn, wd->entry);
978 elm_box_pack_end(wd->box, btn);
986 evas_object_smart_callback_call(obj, SIG_ITEM_ADDED, item);
990 return (Elm_Object_Item *)item;
993 static Elm_Multibuttonentry_Item_Filter*
994 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
996 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
997 if (!item_filter) return NULL;
999 item_filter->callback_func= func;
1000 item_filter->data = data;
1006 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
1012 _evas_mbe_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 Elm_Multibuttonentry_Item *item = NULL;
1017 if (!wd || !wd->base || !wd->box) return;
1019 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
1021 if (wd->last_btn_select)
1023 if (wd->selected_it &&
1024 ((strcmp(ev->keyname, "BackSpace") == 0) ||
1025 (strcmp(ev->keyname, "Delete") == 0)))
1027 item = (Elm_Multibuttonentry_Item *)wd->selected_it;
1028 if (item && wd->editable)
1030 _del_button_item(item);
1031 elm_widget_item_free(item);
1032 elm_object_focus_set(wd->entry, EINA_TRUE);
1035 else if (((!wd->selected_it && (wd->n_str == 0) &&
1036 (strcmp(ev->keyname, "BackSpace") == 0)) ||
1037 (strcmp(ev->keyname, "Delete") == 0)))
1039 item = eina_list_data_get(eina_list_last(wd->items));
1041 _select_button(data, item->button);
1045 wd->last_btn_select = EINA_TRUE;
1049 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1051 Widget_Data *wd = elm_widget_data_get(data);
1052 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1056 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1057 wd->last_btn_select = EINA_FALSE;
1061 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1063 Widget_Data *wd = elm_widget_data_get(data);
1064 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1067 if (!wd || !wd->base || !wd->box) return;
1069 str = elm_object_text_get(wd->entry);
1071 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1073 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1079 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1081 Widget_Data *wd = elm_widget_data_get(data);
1084 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1085 elm_object_focus_set(wd->entry, EINA_TRUE);
1089 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1091 Widget_Data *wd = elm_widget_data_get(data);
1092 Elm_Multibuttonentry_Item *item = NULL;
1096 if (wd->selected_it)
1098 item = (Elm_Multibuttonentry_Item *)wd->selected_it;
1099 elm_object_focus_set(wd->entry, EINA_FALSE);
1100 evas_object_focus_set(item->button, EINA_TRUE);
1105 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1107 Widget_Data *wd = elm_widget_data_get(data);
1112 str = elm_object_text_get(wd->entry);
1114 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1118 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1120 Widget_Data *wd = elm_widget_data_get(data);
1125 str = elm_object_text_get(wd->entry);
1126 wd->n_str = strlen(str);
1130 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1132 Evas_Coord en_x, en_y, en_w, en_h;
1134 Widget_Data *wd = elm_widget_data_get(data);
1137 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1140 elm_widget_show_region_set(wd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
1144 _view_init(Evas_Object *obj)
1146 Widget_Data *wd = elm_widget_data_get(obj);
1152 wd->box = elm_box_add(obj);
1153 if (!wd->box) return;
1154 elm_widget_sub_object_add(obj, wd->box);
1155 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1156 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1157 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1161 wd->label = edje_object_add(evas_object_evas_get(obj));
1162 if (!wd->label) return;
1163 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1164 _set_label(obj, "");
1165 elm_widget_sub_object_add(obj, wd->label);
1170 wd->entry = elm_entry_add(obj);
1171 if (!wd->entry) return;
1172 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1173 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1174 elm_object_text_set(wd->entry, "");
1175 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1176 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1177 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1178 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1179 if (wd->box) elm_box_pack_end(wd->box, wd->entry);
1180 evas_object_show(wd->entry);
1181 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1186 const char *end_type;
1188 end_type = edje_object_data_get(wd->base, "closed_button_type");
1189 if (!end_type || !strcmp(end_type, "label"))
1191 wd->end = elm_label_add(obj);
1192 if (!wd->end) return;
1193 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1194 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1198 const char *size_str;
1199 wd->end = edje_object_add(evas_object_evas_get(obj));
1200 if (!wd->end) return;
1201 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1202 Evas_Coord button_min_width = 0;
1203 Evas_Coord button_min_height = 0;
1205 size_str = edje_object_data_get(wd->end, "closed_button_width");
1206 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1207 size_str = edje_object_data_get(wd->end, "closed_button_height");
1208 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1210 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1211 evas_object_size_hint_min_set(wd->end,
1212 button_min_width * _elm_config->scale,
1213 button_min_height * _elm_config->scale);
1214 elm_widget_sub_object_add(obj, wd->end);
1220 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1222 Evas_Coord minw, minh, mnw, mnh, ww;
1223 Evas_Coord w, cw = 0, cmaxh = 0;
1225 Evas_Object_Box_Option *opt;
1228 /* FIXME: need to calc max */
1232 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1233 evas_object_size_hint_min_get(box, &minw, NULL);
1235 EINA_LIST_FOREACH(priv->children, l, opt)
1237 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1238 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1242 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1245 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;
1305 if (cmaxh < mnh) cmaxh = mnh;
1314 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1316 Evas_Coord x, y, w, h, xx, yy;
1319 Evas_Coord minw, minh;
1321 Evas_Object_Box_Option *opt;
1323 _calculate_box_min_size(o, priv);
1325 evas_object_geometry_get(o, &x, &y, &w, &h);
1327 evas_object_size_hint_min_get(o, &minw, &minh);
1328 evas_object_size_hint_align_get(o, &ax, &ay);
1331 x = x + ((w - minw) * (1.0 - ax));
1336 y = y + ((h - minh) * (1.0 - ay));
1343 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1345 EINA_LIST_FOREACH(priv->children, l, opt)
1347 Evas_Coord mnw, mnh, mxw, mxh;
1352 evas_object_size_hint_align_get(obj, &ax, &ay);
1353 evas_object_size_hint_weight_get(obj, &wx, &wy);
1354 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1355 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1357 if (ax == -1.0) {fw = 1; ax = 0.5;}
1358 if (ay == -1.0) {fh = 1; ay = 0.5;}
1359 Evas_Coord ww, hh, ow, oh;
1363 if ((elm_widget_is(obj)) && (!(strcmp(elm_widget_type_get(obj), "entry"))) && (mnw == -1))
1366 if (mnw != -1 && (w - cw) >= mnw)
1373 hh = _calculate_item_max_height(o, priv, obj_index);
1377 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1380 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1389 evas_object_move(obj,
1390 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1391 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1392 evas_object_resize(obj, ow, oh);
1395 if (cmaxh < hh) cmaxh = hh;
1402 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1404 Elm_Multibuttonentry_Item *item;
1405 if (part && strcmp(part, "default")) return;
1407 item = (Elm_Multibuttonentry_Item *)it;
1408 edje_object_part_text_escaped_set(item->button, "elm.btn.text", label);
1409 _resize_button(item->button, &item->rw, &item->vw);
1413 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1415 Elm_Multibuttonentry_Item *item;
1416 if (part && strcmp(part, "default")) return NULL;
1417 item = (Elm_Multibuttonentry_Item *)it;
1418 return edje_object_part_text_get(item->button, "elm.btn.text");
1422 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1424 ELM_CHECK_WIDTYPE(obj, widtype);
1425 if (!part || !strcmp(part, "default"))
1427 if (label) _set_label(obj, label);
1428 else _set_label(obj, "");
1430 else if (!strcmp(part, "guide"))
1432 if (label) _set_guidetext(obj, label);
1433 else _set_guidetext(obj, "");
1438 _text_get_hook(const Evas_Object *obj, const char *part)
1440 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1441 Widget_Data *wd = elm_widget_data_get(obj);
1442 if (!wd) return NULL;
1444 if (!part || !strcmp(part, "default"))
1446 return wd->labeltxt;
1448 else if (!strcmp(part, "guide"))
1450 return wd->guidetexttxt;
1456 elm_multibuttonentry_add(Evas_Object *parent)
1462 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1464 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1465 elm_widget_type_set(obj, "multibuttonentry");
1466 elm_widget_sub_object_add(parent, obj);
1467 elm_widget_data_set(obj, wd);
1469 elm_widget_del_hook_set(obj, _del_hook);
1470 elm_widget_theme_hook_set(obj, _theme_hook);
1471 elm_widget_event_hook_set(obj, _event_hook);
1472 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1473 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1474 elm_widget_text_set_hook_set(obj, _text_set_hook);
1475 elm_widget_text_get_hook_set(obj, _text_get_hook);
1477 wd->base = edje_object_add(e);
1478 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1479 elm_widget_resize_object_set(obj, wd->base);
1480 elm_widget_can_focus_set(obj, EINA_TRUE);
1482 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1483 wd->focused = EINA_FALSE;
1484 wd->last_btn_select = EINA_TRUE;
1486 wd->rect_for_end = NULL;
1487 wd->add_callback = NULL;
1488 wd->add_callback_data = NULL;
1489 wd->editable = EINA_TRUE;
1491 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1500 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1502 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1503 Widget_Data *wd = elm_widget_data_get(obj);
1505 if (!wd) return NULL;
1511 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1513 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1514 Widget_Data *wd = elm_widget_data_get(obj);
1517 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1521 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1523 ELM_CHECK_WIDTYPE(obj, widtype);
1524 Widget_Data *wd = elm_widget_data_get(obj);
1526 if (!wd || !wd->box ||
1527 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1530 _shrink_mode_set(obj, EINA_FALSE);
1532 _shrink_mode_set(obj, EINA_TRUE);
1537 elm_multibuttonentry_editable_set(Evas_Object *obj, Eina_Bool editable)
1539 ELM_CHECK_WIDTYPE(obj, widtype);
1540 Widget_Data *wd = elm_widget_data_get(obj);
1542 if (wd->editable == editable) return;
1543 wd->editable = editable;
1548 evas_object_show(wd->entry);
1551 elm_entry_input_panel_hide(wd->entry);
1552 evas_object_hide(wd->entry);
1558 elm_multibuttonentry_editable_get(const Evas_Object *obj)
1560 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1561 Widget_Data *wd = elm_widget_data_get(obj);
1563 return wd->editable;
1566 EAPI Elm_Object_Item *
1567 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1569 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
1572 EAPI Elm_Object_Item *
1573 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1575 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
1578 EAPI Elm_Object_Item *
1579 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
1581 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
1584 EAPI Elm_Object_Item *
1585 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
1587 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
1590 EAPI const Eina_List *
1591 elm_multibuttonentry_items_get(const Evas_Object *obj)
1593 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1594 Widget_Data *wd = elm_widget_data_get(obj);
1595 if (!wd) return NULL;
1599 EAPI Elm_Object_Item *
1600 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1602 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1603 Widget_Data *wd = elm_widget_data_get(obj);
1604 if (!wd) return NULL;
1605 return eina_list_data_get(wd->items);
1608 EAPI Elm_Object_Item *
1609 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1611 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1612 Widget_Data *wd = elm_widget_data_get(obj);
1613 if (!wd) return NULL;
1614 return eina_list_data_get(eina_list_last(wd->items));
1617 EAPI Elm_Object_Item *
1618 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1620 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1621 Widget_Data *wd = elm_widget_data_get(obj);
1622 if (!wd) return NULL;
1623 return wd->selected_it;
1627 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1629 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1630 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
1631 if (selected) _select_button(WIDGET(item), item->button);
1632 else _select_button(WIDGET(item), NULL);
1636 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
1638 //TODO : To be implemented.
1639 if (!it) return EINA_FALSE;
1644 elm_multibuttonentry_clear(Evas_Object *obj)
1646 ELM_CHECK_WIDTYPE(obj, widtype);
1647 Elm_Multibuttonentry_Item *item;
1648 Widget_Data *wd = elm_widget_data_get(obj);
1653 EINA_LIST_FREE(wd->items, item)
1655 elm_box_unpack(wd->box, item->button);
1656 _del_button_obj(obj, item->button);
1661 wd->selected_it = NULL;
1665 EAPI Elm_Object_Item *
1666 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1668 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1671 Elm_Multibuttonentry_Item *_item;
1673 wd = elm_widget_data_get(WIDGET(it));
1674 if (!wd) return NULL;
1676 EINA_LIST_FOREACH(wd->items, l, _item)
1678 if (_item == (Elm_Multibuttonentry_Item *)it)
1680 l = eina_list_prev(l);
1681 if (!l) return NULL;
1682 return eina_list_data_get(l);
1688 EAPI Elm_Object_Item *
1689 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1691 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1694 Elm_Multibuttonentry_Item *_item;
1695 wd = elm_widget_data_get(WIDGET(it));
1696 if (!wd) return NULL;
1698 EINA_LIST_FOREACH(wd->items, l, _item)
1700 if (_item == (Elm_Multibuttonentry_Item *)it)
1702 l = eina_list_next(l);
1703 if (!l) return NULL;
1704 return eina_list_data_get(l);
1710 EINA_DEPRECATED EAPI void *
1711 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1713 return elm_widget_item_data_get(it);
1716 EINA_DEPRECATED EAPI void
1717 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1719 return elm_widget_item_data_set(it, data);
1723 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1725 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1726 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1729 Widget_Data *wd = elm_widget_data_get(obj);
1732 ELM_CHECK_WIDTYPE(obj, widtype);
1733 EINA_SAFETY_ON_NULL_RETURN(func);
1735 new_item_filter= _filter_new(func, data);
1736 if (!new_item_filter) return;
1738 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1740 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1742 printf("Already Registered this item filter!!!!\n");
1746 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1750 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1752 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1753 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1755 Widget_Data *wd = elm_widget_data_get(obj);
1758 ELM_CHECK_WIDTYPE(obj, widtype);
1759 EINA_SAFETY_ON_NULL_RETURN(func);
1761 new_item_filter = _filter_new(func, data);
1762 if (!new_item_filter) return;
1764 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1766 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1768 printf("Already Registered this item filter!!!!\n");
1772 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1776 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1780 Elm_Multibuttonentry_Item_Filter *item_filter;
1782 wd = elm_widget_data_get(obj);
1784 EINA_SAFETY_ON_NULL_RETURN(func);
1786 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1788 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1790 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1791 _filter_free(item_filter);