1 #include <Elementary.h>
7 typedef enum _Multibuttonentry_Pos
9 MULTIBUTTONENTRY_POS_START,
10 MULTIBUTTONENTRY_POS_END,
11 MULTIBUTTONENTRY_POS_BEFORE,
12 MULTIBUTTONENTRY_POS_AFTER,
13 MULTIBUTTONENTRY_POS_NUM
14 } Multibuttonentry_Pos;
16 typedef enum _Multibuttonentry_Button_State
18 MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
19 MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
20 MULTIBUTTONENTRY_BUTTON_STATE_NUM
21 } Multibuttonentry_Button_State;
23 typedef enum _MultiButtonEntry_Closed_Button_Type
25 MULTIBUTTONENTRY_CLOSED_IMAGE,
26 MULTIBUTTONENTRY_CLOSED_LABEL
27 } MultiButtonEntry_Closed_Button_Type;
29 typedef enum _Multibuttonentry_View_State
31 MULTIBUTTONENTRY_VIEW_NONE,
32 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
33 MULTIBUTTONENTRY_VIEW_ENTRY,
34 MULTIBUTTONENTRY_VIEW_SHRINK
35 } Multibuttonentry_View_State;
37 typedef struct _Widget_Data Widget_Data;
38 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
40 struct _Multibuttonentry_Item
44 Evas_Coord vw, rw; // vw: visual width, real width
48 typedef struct _Elm_Multibuttonentry_Item_Filter
50 Elm_Multibuttonentry_Item_Filter_callback callback_func;
52 } Elm_Multibuttonentry_Item_Filter;
60 Evas_Object *guidetext;
61 Evas_Object *end; // used to represent the total number of invisible buttons
63 Evas_Object *rect_for_end;
64 MultiButtonEntry_Closed_Button_Type end_type;
68 Eina_List *filter_list;
71 Multibuttonentry_View_State view_state;
73 Evas_Coord w_box, h_box;
76 Eina_Bool last_btn_select: 1;
78 Elm_Multibuttonentry_Item_Filter_callback add_callback;
79 void *add_callback_data;
82 static const char *widtype = NULL;
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, int 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_Multibuttonentry_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos,
101 const Elm_Multibuttonentry_Item *reference, void *data);
102 static void _add_button(Evas_Object *obj, const char *str);
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,
123 _del_hook(Evas_Object *obj)
125 Widget_Data *wd = elm_widget_data_get(obj);
130 Elm_Multibuttonentry_Item *item;
131 EINA_LIST_FREE(wd->items, item)
133 _del_button_obj(obj, item->button);
140 if (wd->entry) evas_object_del (wd->entry);
141 if (wd->label) evas_object_del (wd->label);
142 if (wd->guidetext) evas_object_del (wd->guidetext);
143 if (wd->end) evas_object_del (wd->end);
144 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
148 _theme_hook(Evas_Object *obj)
150 Widget_Data *wd = elm_widget_data_get(obj);
152 Elm_Multibuttonentry_Item *item;
156 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
157 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
158 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
160 EINA_LIST_FOREACH(wd->items, l, item)
163 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
164 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
171 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
173 Widget_Data *wd = elm_widget_data_get(obj);
177 if (elm_widget_focus_get(obj))
181 elm_entry_input_panel_show(wd->entry);
183 else if (((!wd->current) || (!eina_list_count(wd->items))))
185 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
187 elm_entry_input_panel_show(wd->entry);
189 wd->focused = EINA_TRUE;
190 evas_object_smart_callback_call(obj, "focused", NULL);
194 wd->focused = EINA_FALSE;
197 elm_entry_input_panel_hide(wd->entry);
198 evas_object_smart_callback_call(obj, "unfocused", NULL);
203 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
209 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
211 Widget_Data *wd = elm_widget_data_get(obj);
214 edje_object_signal_emit(wd->base, emission, source);
218 _sizing_eval(Evas_Object *obj)
220 Widget_Data *wd = elm_widget_data_get(obj);
221 Evas_Coord minw = -1, minh = -1;
222 Evas_Coord left, right, top, bottom;
225 evas_object_size_hint_min_get(wd->box, &minw, &minh);
226 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
227 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
229 minw += (left + right);
230 minh += (top + bottom);
232 evas_object_size_hint_min_set(obj, minw, minh);
236 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
238 Widget_Data *wd = elm_widget_data_get(data);
240 if (!wd || !wd->base) return;
241 wd->focused = EINA_TRUE;
244 elm_entry_input_panel_show(wd->entry);
246 evas_object_smart_callback_call(data, "clicked", NULL);
250 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
252 Evas_Object *eo = (Evas_Object *)data;
253 Widget_Data *wd = elm_widget_data_get(data);
260 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
262 Widget_Data *wd = elm_widget_data_get(data);
266 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
268 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
269 else if (wd->h_box > h) evas_object_smart_callback_call (data, "shrank", NULL);
278 _event_init(Evas_Object *obj)
280 Widget_Data *wd = elm_widget_data_get(obj);
282 if (!wd || !wd->base) return;
285 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
286 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
291 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
292 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
297 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
298 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
299 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
300 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
301 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
302 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
303 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
308 _set_vis_guidetext(Evas_Object *obj)
310 Widget_Data *wd = elm_widget_data_get(obj);
313 elm_box_unpack(wd->box, wd->guidetext);
314 elm_box_unpack(wd->box, wd->entry);
315 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
317 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
318 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
320 evas_object_hide(wd->entry);
321 elm_box_pack_end(wd->box, wd->guidetext);
322 evas_object_show(wd->guidetext);
323 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
327 evas_object_hide(wd->guidetext);
330 elm_box_pack_end(wd->box, wd->entry);
331 evas_object_show(wd->entry);
333 if (elm_widget_focus_get(obj) || wd->focused)
335 elm_object_focus_set(wd->entry, EINA_TRUE);
336 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
341 _shrink_mode_set(Evas_Object *obj, int shrink)
343 Widget_Data *wd = elm_widget_data_get(obj);
345 Elm_Multibuttonentry_Item *item;
347 if (!wd || !wd->box) return;
348 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
349 evas_object_hide(wd->entry);
350 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
351 evas_object_hide(wd->guidetext);
352 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
354 evas_object_hide(wd->rect_for_end);
355 evas_object_hide(wd->end);
356 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
361 Evas_Coord w=0, w_tmp=0;
362 Evas_Coord box_inner_item_width_padding = 0;
364 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
365 // unpack all items and entry
366 elm_box_unpack_all(wd->box);
367 EINA_LIST_FOREACH(wd->items, l, item)
371 evas_object_hide(item->button);
372 item->visible = EINA_FALSE;
375 // pack buttons only 1line
380 elm_box_pack_end(wd->box, wd->label);
381 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
383 w -= box_inner_item_width_padding;
387 int count = eina_list_count(wd->items);
388 Evas_Coord button_min_width = 0;
389 /* Evas_Coord button_min_height = 0; */
390 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
392 const char *size_str;
393 size_str = edje_object_data_get(wd->end, "closed_button_width");
394 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
396 size_str = edje_object_data_get(wd->end, "closed_button_height");
397 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
401 EINA_LIST_FOREACH(wd->items, l, item)
405 int w_label_count = 0;
408 elm_box_pack_end(wd->box, item->button);
409 evas_object_show(item->button);
410 item->visible = EINA_TRUE;
413 w -= box_inner_item_width_padding;
416 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
420 snprintf(buf, sizeof(buf), "... + %d", count);
421 elm_object_text_set(wd->end, buf);
422 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
425 if (w < 0 || w < w_label_count)
427 elm_box_unpack(wd->box, item->button);
428 evas_object_hide(item->button);
429 item->visible = EINA_FALSE;
432 snprintf(buf, sizeof(buf), "... + %d", count);
433 elm_object_text_set(wd->end, buf);
434 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
436 elm_box_pack_end(wd->box, wd->end);
437 evas_object_show(wd->end);
439 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
440 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
444 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
446 if (w < button_min_width)
449 Evas_Coord closed_height = 0;
450 const char *height_str = edje_object_data_get(wd->base, "closed_height");
452 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
453 elm_box_unpack(wd->box, item->button);
454 evas_object_hide(item->button);
455 item->visible = EINA_FALSE;
458 rectSize = w - button_min_width;
459 if (!wd->rect_for_end)
461 Evas *e = evas_object_evas_get(obj);
462 wd->rect_for_end = evas_object_rectangle_add(e);
463 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
465 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get());
466 elm_box_pack_end(wd->box, wd->rect_for_end);
467 evas_object_show(wd->rect_for_end);
469 elm_box_pack_end(wd->box, wd->end);
470 evas_object_show(wd->end);
472 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
473 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
482 // unpack all items and entry
483 elm_box_unpack_all(wd->box);
484 EINA_LIST_FOREACH(wd->items, l, item)
488 evas_object_hide(item->button);
489 item->visible = EINA_FALSE;
492 evas_object_hide(wd->end);
494 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
496 // pack buttons only 1line
498 if (wd->label) elm_box_pack_end(wd->box, wd->label);
502 EINA_LIST_FOREACH(wd->items, l, item)
506 elm_box_pack_end(wd->box, item->button);
507 evas_object_show(item->button);
508 item->visible = EINA_TRUE;
512 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
513 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)wd->shrink);
515 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
517 _set_vis_guidetext(obj);
522 _view_update(Evas_Object *obj)
524 Evas_Coord width = 1, height = 1;
525 Widget_Data *wd = elm_widget_data_get(obj);
527 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
532 elm_box_unpack(wd->box, wd->label);
533 elm_box_pack_start(wd->box, wd->label);
534 evas_object_size_hint_min_get(wd->label, &width, &height);
539 Evas_Coord guide_text_width = wd->w_box - width;
540 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
543 // update buttons in shrink mode
544 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
545 _shrink_mode_set(obj, 1);
548 _set_vis_guidetext(obj);
552 _set_label(Evas_Object *obj, const char* str)
554 Widget_Data *wd = elm_widget_data_get(obj);
556 if (!wd || !str) return;
559 Evas_Coord width, height, sum_width = 0;
560 evas_object_size_hint_min_set(wd->label, 0, 0);
561 evas_object_resize(wd->label, 0, 0);
562 edje_object_part_text_set(wd->label, "mbe.label", str);
564 if (!strcmp(str, ""))
566 /* FIXME: not work yet */
567 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
568 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
573 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
574 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
578 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
581 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
584 evas_object_size_hint_min_set(wd->label, sum_width, height);
586 evas_object_show(wd->label);
591 _set_guidetext(Evas_Object *obj, const char* str)
593 Widget_Data *wd = elm_widget_data_get(obj);
595 if (!wd || !str) return;
598 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
599 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
600 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
601 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
604 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
609 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
611 Widget_Data *wd = elm_widget_data_get(obj);
612 Elm_Multibuttonentry_Item *item = NULL;
616 item = eina_list_data_get(wd->current);
618 if (item && item->button)
622 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
623 edje_object_signal_emit(item->button, "default", "");
626 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
627 edje_object_signal_emit(item->button, "focused", "");
628 evas_object_smart_callback_call(obj, "item,selected", item);
631 edje_object_signal_emit(item->button, "default", "");
639 _change_current_button(Evas_Object *obj, Evas_Object *btn)
641 Widget_Data *wd = elm_widget_data_get(obj);
643 Elm_Multibuttonentry_Item *item;
647 // change the state of previous button to "default"
648 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
650 // change the current
651 EINA_LIST_FOREACH(wd->items, l, item)
653 if (item->button == btn)
659 // change the state of current button to "focused"
660 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
664 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
666 Widget_Data *wd = elm_widget_data_get(data);
668 Elm_Multibuttonentry_Item *item = NULL;
669 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
671 _select_button(data, obj);
673 if ((wd->current) && ((item = eina_list_data_get(wd->current)) != NULL))
674 evas_object_smart_callback_call(data, "item,clicked", item);
678 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
680 Widget_Data *wd = elm_widget_data_get(obj);
682 if (!wd || !btn) return;
684 evas_object_del(btn);
688 _del_button_item(Elm_Multibuttonentry_Item *item)
691 Elm_Multibuttonentry_Item *_item;
695 Evas_Object *obj = WIDGET(item);
696 wd = elm_widget_data_get(obj);
698 EINA_LIST_FOREACH(wd->items, l, _item)
702 wd->items = eina_list_remove(wd->items, _item);
703 elm_box_unpack(wd->box, _item->button);
705 evas_object_smart_callback_call(obj, "item,deleted", _item);
707 _del_button_obj(obj, _item->button);
709 if (wd->current == l)
714 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
715 _shrink_mode_set(obj, 1);
717 if (!eina_list_count(wd->items))
718 _set_vis_guidetext(obj);
722 _select_button(Evas_Object *obj, Evas_Object *btn)
724 Widget_Data *wd = elm_widget_data_get(obj);
729 _change_current_button(obj, btn);
730 if (elm_widget_focus_get(obj))
732 elm_object_focus_set(wd->entry, EINA_FALSE);
733 evas_object_focus_set(btn, EINA_TRUE);
738 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
739 if (elm_widget_focus_get(obj))
740 elm_object_focus_set(wd->entry, EINA_TRUE);
745 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
748 Evas_Coord w_text, h_btn, padding_outer = 0;
749 Evas_Coord w_btn = 0, button_max_width = 0;
750 const char *size_str;
752 size_str = edje_object_data_get(btn, "button_max_size");
753 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
755 // decide the size of button
756 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
757 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
758 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
759 w_btn = w_text + 2*padding_outer;
763 if (button_max_width < w_btn)
764 vw = button_max_width;
769 evas_object_resize(btn, vw, h_btn);
770 evas_object_size_hint_min_set(btn, vw, h_btn);
772 if (realw) *realw = rw;
773 if (vieww) *vieww = vw;
777 _item_del_pre_hook(Elm_Object_Item *it)
779 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
780 _del_button_item((Elm_Multibuttonentry_Item *) it);
784 static Elm_Multibuttonentry_Item*
785 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
787 Elm_Multibuttonentry_Item *item;
788 Elm_Multibuttonentry_Item_Filter *item_filter;
791 Evas_Coord width = -1, height = -1;
792 char *str_utf8 = NULL;
794 Widget_Data *wd = elm_widget_data_get(obj);
796 if (!wd || !wd->box || !wd->entry) return NULL;
798 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
800 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
804 btn = edje_object_add(evas_object_evas_get(obj));
805 str_utf8 = elm_entry_markup_to_utf8(str);
807 //entry is cleared when text is made to button
808 elm_object_text_set(wd->entry, "");
810 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
811 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
812 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
814 evas_object_size_hint_min_set(btn, width, height);
816 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
817 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
818 evas_object_show(btn);
821 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
824 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
825 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
826 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
827 elm_widget_item_data_set(item, data);
829 _resize_button(btn, &rw, &vw);
833 item->visible = EINA_TRUE;
837 case MULTIBUTTONENTRY_POS_START:
838 wd->items = eina_list_prepend(wd->items, item);
839 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
841 elm_widget_sub_object_add(obj, btn);
842 _shrink_mode_set(obj, 1);
847 elm_box_pack_after(wd->box, btn, wd->label);
849 elm_box_pack_start(wd->box, btn);
850 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
851 _set_vis_guidetext(obj);
854 case MULTIBUTTONENTRY_POS_END:
855 wd->items = eina_list_append(wd->items, item);
856 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
858 elm_widget_sub_object_add(obj, btn);
859 evas_object_hide(btn);
863 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
864 _set_vis_guidetext(obj);
868 elm_box_pack_before(wd->box, btn, wd->entry);
870 elm_box_pack_end(wd->box, btn);
873 elm_box_pack_end(wd->box, btn);
876 case MULTIBUTTONENTRY_POS_BEFORE:
878 wd->items = eina_list_prepend_relative(wd->items, item, reference);
880 wd->items = eina_list_append(wd->items, item);
881 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
883 elm_widget_sub_object_add(obj, btn);
884 evas_object_hide(btn);
885 _shrink_mode_set(obj, 1);
890 elm_box_pack_before(wd->box, btn, reference->button);
893 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
894 _set_vis_guidetext(obj);
898 elm_box_pack_before(wd->box, btn, wd->entry);
900 elm_box_pack_end(wd->box, btn);
903 elm_box_pack_end(wd->box, btn);
907 case MULTIBUTTONENTRY_POS_AFTER:
909 wd->items = eina_list_append_relative(wd->items, item, reference);
911 wd->items = eina_list_append(wd->items, item);
912 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
914 elm_widget_sub_object_add(obj, btn);
915 _shrink_mode_set(obj, 1);
920 elm_box_pack_after(wd->box, btn, reference->button);
923 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
924 _set_vis_guidetext(obj);
928 elm_box_pack_before(wd->box, btn, wd->entry);
930 elm_box_pack_end(wd->box, btn);
933 elm_box_pack_end(wd->box, btn);
941 evas_object_smart_callback_call(obj, "item,added", item);
949 _add_button(Evas_Object *obj, const char *str)
951 Widget_Data *wd = elm_widget_data_get(obj);
954 _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
957 static Elm_Multibuttonentry_Item_Filter*
958 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
960 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
961 if (!item_filter) return NULL;
963 item_filter->callback_func= func;
964 item_filter->data = data;
970 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
976 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
978 Widget_Data *wd = elm_widget_data_get(data);
979 Elm_Multibuttonentry_Item *item = NULL;
981 if (!wd || !wd->base || !wd->box) return;
983 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
985 if (wd->last_btn_select)
988 ((strcmp(ev->keyname, "BackSpace") == 0) ||
989 (strcmp(ev->keyname, "BackSpace (") == 0)))
991 item = eina_list_data_get(wd->current);
994 _del_button_item(item);
995 elm_widget_item_free(item);
996 elm_object_focus_set(wd->entry, EINA_TRUE);
999 else if (((!wd->current && (wd->n_str == 0) &&
1000 (strcmp(ev->keyname, "BackSpace") == 0)) ||
1001 (strcmp(ev->keyname, "BackSpace (") == 0)))
1003 item = eina_list_data_get(eina_list_last(wd->items));
1005 _select_button(data, item->button);
1009 wd->last_btn_select = EINA_TRUE;
1013 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1015 Widget_Data *wd = elm_widget_data_get(data);
1016 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1020 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
1021 wd->last_btn_select = EINA_FALSE;
1025 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1027 Widget_Data *wd = elm_widget_data_get(data);
1028 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1031 if (!wd || !wd->base || !wd->box) return;
1033 str = elm_object_text_get(wd->entry);
1035 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1037 _add_button(data, str);
1043 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1045 Widget_Data *wd = elm_widget_data_get(data);
1048 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1049 elm_object_focus_set(wd->entry, EINA_TRUE);
1053 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1055 Widget_Data *wd = elm_widget_data_get(data);
1056 Elm_Multibuttonentry_Item *item = NULL;
1062 item = eina_list_data_get(wd->current);
1063 elm_object_focus_set(wd->entry, EINA_FALSE);
1064 evas_object_focus_set(item->button, EINA_TRUE);
1069 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1071 Widget_Data *wd = elm_widget_data_get(data);
1076 str = elm_object_text_get(wd->entry);
1078 _add_button(data, str);
1082 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1084 Widget_Data *wd = elm_widget_data_get(data);
1089 str = elm_object_text_get(wd->entry);
1090 wd->n_str = strlen(str);
1094 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1096 Evas_Coord en_x, en_y, en_w, en_h;
1098 Widget_Data *wd = elm_widget_data_get(data);
1101 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1104 elm_widget_show_region_set(wd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
1108 _view_init(Evas_Object *obj)
1110 Widget_Data *wd = elm_widget_data_get(obj);
1116 wd->box = elm_box_add (obj);
1117 if (!wd->box) return;
1118 elm_widget_sub_object_add(obj, wd->box);
1119 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1120 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1121 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1125 wd->label = edje_object_add(evas_object_evas_get(obj));
1126 if (!wd->label) return;
1127 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1128 _set_label(obj, "");
1129 elm_widget_sub_object_add(obj, wd->label);
1134 wd->entry = elm_entry_add (obj);
1135 if (!wd->entry) return;
1136 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1137 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1138 elm_object_text_set(wd->entry, "");
1139 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1140 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1141 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1142 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1143 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1144 evas_object_show(wd->entry);
1145 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1150 const char *end_type;
1152 end_type = edje_object_data_get(wd->base, "closed_button_type");
1153 if (!end_type || !strcmp(end_type, "label"))
1155 wd->end = elm_label_add (obj);
1156 if (!wd->end) return;
1157 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1158 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1162 const char *size_str;
1163 wd->end = edje_object_add(evas_object_evas_get(obj));
1164 if (!wd->end) return;
1165 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1166 Evas_Coord button_min_width = 0;
1167 Evas_Coord button_min_height = 0;
1169 size_str = edje_object_data_get(wd->end, "closed_button_width");
1170 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1171 size_str = edje_object_data_get(wd->end, "closed_button_height");
1172 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1174 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1175 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1176 elm_widget_sub_object_add(obj, wd->end);
1182 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1184 Evas_Coord minw, minh, mnw, mnh, ww;
1185 Evas_Coord w, cw = 0, cmaxh = 0;
1187 Evas_Object_Box_Option *opt;
1190 /* FIXME: need to calc max */
1194 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1195 evas_object_size_hint_min_get(box, &minw, NULL);
1197 EINA_LIST_FOREACH(priv->children, l, opt)
1199 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1200 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1204 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1207 if (mnw != -1 && (w - cw) >= mnw)
1222 if (cmaxh < mnh) cmaxh = mnh;
1227 evas_object_size_hint_min_set(box, minw, minh);
1231 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1233 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1235 Evas_Object_Box_Option *opt;
1239 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1241 EINA_LIST_FOREACH(priv->children, l, opt)
1243 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1244 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1248 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1251 if (mnw != -1 && (w - cw) >= mnw)
1261 if (index > obj_index) return cmaxh;
1267 if (cmaxh < mnh) cmaxh = mnh;
1276 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1278 Evas_Coord x, y, w, h, xx, yy;
1281 Evas_Coord minw, minh;
1283 Evas_Object_Box_Option *opt;
1285 _calculate_box_min_size(o, priv);
1287 evas_object_geometry_get(o, &x, &y, &w, &h);
1289 evas_object_size_hint_min_get(o, &minw, &minh);
1290 evas_object_size_hint_align_get(o, &ax, &ay);
1293 x = x + ((w - minw) * (1.0 - ax));
1298 y = y + ((h - minh) * (1.0 - ay));
1305 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1307 EINA_LIST_FOREACH(priv->children, l, opt)
1309 Evas_Coord mnw, mnh, mxw, mxh;
1314 evas_object_size_hint_align_get(obj, &ax, &ay);
1315 evas_object_size_hint_weight_get(obj, &wx, &wy);
1316 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1317 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1319 if (ax == -1.0) {fw = 1; ax = 0.5;}
1320 if (ay == -1.0) {fh = 1; ay = 0.5;}
1321 Evas_Coord ww, hh, ow, oh;
1325 if ((elm_widget_is(obj)) && (!(strcmp(elm_widget_type_get(obj), "entry"))) && (mnw == -1))
1328 if (mnw != -1 && (w - cw) >= mnw)
1335 hh = _calculate_item_max_height(o, priv, obj_index);
1339 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1342 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1351 evas_object_move(obj,
1352 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1353 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1354 evas_object_resize(obj, ow, oh);
1357 if (cmaxh < hh) cmaxh = hh;
1364 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1366 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1368 Elm_Multibuttonentry_Item *item;
1369 if (part && strcmp(part, "default")) return;
1371 item = (Elm_Multibuttonentry_Item *) it;
1372 edje_object_part_text_set(item->button, "elm.btn.text", label);
1373 _resize_button(item->button, &item->rw, &item->vw);
1377 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1379 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1380 Elm_Multibuttonentry_Item *item;
1381 if (part && strcmp(part, "default")) return NULL;
1382 item = (Elm_Multibuttonentry_Item *) it;
1383 return edje_object_part_text_get(item->button, "elm.btn.text");
1387 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1389 ELM_CHECK_WIDTYPE(obj, widtype);
1390 if (part && strcmp(part, "default")) return;
1391 if (label) _set_label(obj, label);
1392 else _set_label(obj, "");
1396 _text_get_hook(const Evas_Object *obj, const char *part)
1398 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1400 if (part && strcmp(part, "default")) return NULL;
1401 wd = elm_widget_data_get(obj);
1402 if (!wd) return NULL;
1403 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1408 elm_multibuttonentry_add(Evas_Object *parent)
1414 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1416 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1417 elm_widget_type_set(obj, "multibuttonentry");
1418 elm_widget_sub_object_add(parent, obj);
1419 elm_widget_data_set(obj, wd);
1421 elm_widget_del_hook_set(obj, _del_hook);
1422 elm_widget_theme_hook_set(obj, _theme_hook);
1423 elm_widget_event_hook_set(obj, _event_hook);
1424 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1425 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1426 elm_widget_text_set_hook_set(obj, _text_set_hook);
1427 elm_widget_text_get_hook_set(obj, _text_get_hook);
1429 wd->base = edje_object_add(e);
1430 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1431 elm_widget_resize_object_set(obj, wd->base);
1432 elm_widget_can_focus_set(obj, EINA_TRUE);
1434 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1435 wd->focused = EINA_FALSE;
1436 wd->last_btn_select = EINA_TRUE;
1438 wd->rect_for_end= NULL;
1439 wd->add_callback = NULL;
1440 wd->add_callback_data = NULL;
1449 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1451 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1452 Widget_Data *wd = elm_widget_data_get(obj);
1454 if (!wd) return NULL;
1460 elm_multibuttonentry_label_get(const Evas_Object *obj)
1462 return _text_get_hook(obj, NULL);
1466 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1468 _text_set_hook(obj, NULL, label);
1472 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1474 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1475 Widget_Data *wd = elm_widget_data_get(obj);
1477 if (!wd) return NULL;
1478 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1483 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1485 ELM_CHECK_WIDTYPE(obj, widtype);
1486 Widget_Data *wd = elm_widget_data_get(obj);
1490 _set_guidetext(obj, guidetext);
1492 _set_guidetext(obj, "");
1496 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1498 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1499 Widget_Data *wd = elm_widget_data_get(obj);
1502 return wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? 1 : 0;
1506 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1508 ELM_CHECK_WIDTYPE(obj, widtype);
1509 Widget_Data *wd = elm_widget_data_get(obj);
1511 if (!wd || !wd->box ||
1512 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? 1 : 0) == shrink) return;
1513 _shrink_mode_set(obj, shrink);
1516 EAPI Elm_Object_Item *
1517 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1519 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1520 Elm_Multibuttonentry_Item *item;
1521 if (!label) return NULL;
1522 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1523 return (Elm_Object_Item *) item;
1526 EAPI Elm_Object_Item *
1527 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1529 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1530 Elm_Multibuttonentry_Item *item;
1531 if (!label) return NULL;
1532 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1533 return (Elm_Object_Item *) item;
1536 EAPI Elm_Object_Item *
1537 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1539 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1540 Elm_Multibuttonentry_Item *item;
1541 if (!label) return NULL;
1542 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE,
1543 (Elm_Multibuttonentry_Item *) before, data);
1544 return (Elm_Object_Item *) item;
1547 EAPI Elm_Object_Item *
1548 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
1550 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1551 Elm_Multibuttonentry_Item *item;
1552 if (!label) return NULL;
1553 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER,
1554 (Elm_Multibuttonentry_Item *) after, data);
1555 return (Elm_Object_Item *) item;
1558 EAPI const Eina_List *
1559 elm_multibuttonentry_items_get(const Evas_Object *obj)
1561 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1562 Widget_Data *wd = elm_widget_data_get(obj);
1563 if (!wd) return NULL;
1567 EAPI Elm_Object_Item *
1568 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1570 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1571 Widget_Data *wd = elm_widget_data_get(obj);
1572 if (!wd) return NULL;
1573 return eina_list_data_get(wd->items);
1576 EAPI Elm_Object_Item *
1577 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1579 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1580 Widget_Data *wd = elm_widget_data_get(obj);
1581 if (!wd) return NULL;
1582 return eina_list_data_get(eina_list_last(wd->items));
1585 EAPI Elm_Object_Item *
1586 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1588 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1589 Widget_Data *wd = elm_widget_data_get(obj);
1590 if (!wd) return NULL;
1591 return eina_list_data_get(wd->current);
1595 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
1597 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1598 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1599 if (selected) _select_button(WIDGET(item), item->button);
1600 else _select_button(WIDGET(item), NULL);
1604 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1606 ELM_CHECK_WIDTYPE(obj, widtype);
1607 Widget_Data *wd = elm_widget_data_get(obj);
1609 _select_button(obj, NULL);
1613 elm_multibuttonentry_clear(Evas_Object *obj)
1615 ELM_CHECK_WIDTYPE(obj, widtype);
1616 Elm_Multibuttonentry_Item *item;
1617 Widget_Data *wd = elm_widget_data_get(obj);
1622 EINA_LIST_FREE(wd->items, item)
1624 elm_box_unpack(wd->box, item->button);
1625 _del_button_obj(obj, item->button);
1635 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1637 elm_object_item_del(it);
1641 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1643 return _item_text_get_hook(it, NULL);
1647 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1649 _item_text_set_hook(it, NULL, str);
1652 EAPI Elm_Object_Item *
1653 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1655 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1658 Elm_Multibuttonentry_Item *_item;
1660 wd = elm_widget_data_get(WIDGET(it));
1661 if (!wd) return NULL;
1663 EINA_LIST_FOREACH(wd->items, l, _item)
1665 if (_item == (Elm_Multibuttonentry_Item *) it)
1667 l = eina_list_prev(l);
1668 if (!l) return NULL;
1669 return eina_list_data_get(l);
1675 EAPI Elm_Object_Item *
1676 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1678 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1681 Elm_Multibuttonentry_Item *_item;
1682 wd = elm_widget_data_get(WIDGET(it));
1683 if (!wd) return NULL;
1685 EINA_LIST_FOREACH(wd->items, l, _item)
1687 if (_item == (Elm_Multibuttonentry_Item *) it)
1689 l = eina_list_next(l);
1690 if (!l) return NULL;
1691 return eina_list_data_get(l);
1698 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1700 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1701 return elm_widget_item_data_get(it);
1705 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1707 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1708 return elm_widget_item_data_set(it, data);
1712 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1714 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1715 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1718 Widget_Data *wd = elm_widget_data_get(obj);
1721 ELM_CHECK_WIDTYPE(obj, widtype);
1722 EINA_SAFETY_ON_NULL_RETURN(func);
1724 new_item_filter= _filter_new(func, data);
1725 if (!new_item_filter) return;
1727 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1729 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1731 printf("Already Registered this item filter!!!!\n");
1735 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1739 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1741 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1742 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1744 Widget_Data *wd = elm_widget_data_get(obj);
1747 ELM_CHECK_WIDTYPE(obj, widtype);
1748 EINA_SAFETY_ON_NULL_RETURN(func);
1750 new_item_filter = _filter_new(func, data);
1751 if (!new_item_filter) return;
1753 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1755 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1757 printf("Already Registered this item filter!!!!\n");
1761 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1765 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1769 Elm_Multibuttonentry_Item_Filter *item_filter;
1771 wd = elm_widget_data_get(obj);
1773 EINA_SAFETY_ON_NULL_RETURN(func);
1775 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1777 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1779 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1780 _filter_free(item_filter);
1787 elm_multibuttonentry_view_mode(Evas_Object *obj, Eina_Bool view_mode)
1789 ELM_CHECK_WIDTYPE(obj, widtype);
1790 Widget_Data *wd = elm_widget_data_get(obj);
1791 wd->view_mode = view_mode;
1795 elm_box_unpack(wd->box, wd->entry);
1796 evas_object_hide(wd->entry);