1 #include <Elementary.h>
5 * @defgroup Multibuttonentry Multibuttonentry
8 * This is a Multibuttonentry.
12 #define MIN_W_ENTRY 20
14 typedef enum _Multibuttonentry_Pos
16 MULTIBUTONENTRY_POS_START,
17 MULTIBUTONENTRY_POS_END,
18 MULTIBUTONENTRY_POS_BEFORE,
19 MULTIBUTONENTRY_POS_AFTER,
20 MULTIBUTONENTRY_POS_NUM
21 } Multibuttonentry_Pos;
23 typedef enum _Multibuttonentry_Button_State
25 MULTIBUTONENTRY_BUTTON_STATE_DEFAULT,
26 MULTIBUTONENTRY_BUTTON_STATE_SELECTED,
27 MULTIBUTONENTRY_BUTTON_STATE_NUM
28 } Multibuttonentry_Button_State;
30 typedef enum _MultiButtonEntry_Closed_Button_Type {
31 MULTIBUTTONENTRY_CLOSED_IMAGE,
32 MULTIBUTTONENTRY_CLOSED_LABEL
33 } MultiButtonEntry_Closed_Button_Type;
35 typedef enum _Multibuttonentry_View_State
37 MULTIBUTTONENTRY_VIEW_NONE,
38 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
39 MULTIBUTTONENTRY_VIEW_ENTRY,
40 MULTIBUTTONENTRY_VIEW_CONTRACTED
41 } Multibuttonentry_View_State;
43 struct _Multibuttonentry_Item {
44 Evas_Object *multibuttonentry;
47 Evas_Coord vw, rw; // vw: visual width, real width
51 typedef struct _Widget_Data Widget_Data;
57 Evas_Object *guidetext;
58 Evas_Object *end; // used to represent the total number of invisible buttons
60 Evas_Object *rectForEnd;
61 MultiButtonEntry_Closed_Button_Type end_type;
66 Multibuttonentry_View_State view_state;
68 Evas_Coord w_box, h_box;
71 Eina_Bool last_btn_select: 1;
72 Elm_Multibuttonentry_Item_Verify_Callback add_callback;
73 void *add_callback_data;
76 static const char *widtype = NULL;
77 static void _del_hook(Evas_Object *obj);
78 static void _theme_hook(Evas_Object *obj);
79 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
80 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
81 static void _sizing_eval(Evas_Object *obj);
82 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
83 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
84 static void _event_init(Evas_Object *obj);
85 static void _contracted_state_set(Evas_Object *obj, int contracted);
86 static void _view_update(Evas_Object *obj);
87 static void _set_label(Evas_Object *obj, const char* str);
88 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
89 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
90 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
91 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
92 static void _del_button_item(Elm_Multibuttonentry_Item *item);
93 static void _select_button(Evas_Object *obj, Evas_Object *btn);
94 static Elm_Multibuttonentry_Item* _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data);
95 static void _add_button(Evas_Object *obj, char *str);
96 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
97 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
98 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
99 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
100 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
101 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
102 static void _view_init(Evas_Object *obj);
103 static void _set_vis_guidetext(Evas_Object *obj);
104 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
105 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
106 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
109 _del_hook(Evas_Object *obj)
111 Widget_Data *wd = elm_widget_data_get(obj);
116 Elm_Multibuttonentry_Item *item;
117 EINA_LIST_FREE(wd->items, item)
119 _del_button_obj(obj, item->button);
126 if (wd->entry) evas_object_del (wd->entry);
127 if (wd->label) evas_object_del (wd->label);
128 if (wd->guidetext) evas_object_del (wd->guidetext);
129 if (wd->end) evas_object_del (wd->end);
130 if (wd->rectForEnd) evas_object_del(wd->rectForEnd);
134 _theme_hook(Evas_Object *obj)
136 Widget_Data *wd = elm_widget_data_get(obj);
138 Elm_Multibuttonentry_Item *item;
141 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
142 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
143 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
145 EINA_LIST_FOREACH(wd->items, l, item)
148 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
149 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
156 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
158 Widget_Data *wd = elm_widget_data_get(obj);
162 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(wd->entry);
164 if (elm_widget_focus_get(obj))
166 if ((imf_context) && (wd->current))
168 ecore_imf_context_input_panel_show(imf_context);
169 evas_object_focus_set(obj, EINA_TRUE);
171 else if ((imf_context) && (!wd->current) || (!eina_list_count(wd->items)))
174 ecore_imf_context_input_panel_show(imf_context);
179 wd->focused = EINA_FALSE;
181 if (imf_context) ecore_imf_context_input_panel_hide(imf_context);
182 evas_object_smart_callback_call(obj, "unfocused", NULL);
183 evas_object_focus_set(obj, EINA_FALSE);
188 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
195 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
197 Widget_Data *wd = elm_widget_data_get(obj);
199 edje_object_signal_emit(wd->base, emission, source);
203 _sizing_eval(Evas_Object *obj)
205 Widget_Data *wd = elm_widget_data_get(obj);
207 Evas_Coord minw = -1, minh = -1;
208 Evas_Coord left, right, top, bottom;
211 evas_object_size_hint_min_get(wd->box, &minw, &minh);
212 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
213 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
215 minw += (left + right);
216 minh += (top + bottom);
218 evas_object_size_hint_min_set(obj, minw, minh);
222 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
224 Widget_Data *wd = elm_widget_data_get(data);
225 if(!wd || !wd->base) return;
227 wd->focused = EINA_TRUE;
230 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(wd->entry);
232 if (imf_context) ecore_imf_context_input_panel_show(imf_context);
233 evas_object_smart_callback_call(data, "clicked", NULL);
237 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
239 Evas_Object *eo = (Evas_Object *)data;
240 Widget_Data *wd = elm_widget_data_get(data);
246 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
248 Widget_Data *wd = elm_widget_data_get(data);
252 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
254 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
255 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
264 _event_init(Evas_Object *obj)
266 Widget_Data *wd = elm_widget_data_get(obj);
267 if (!wd || !wd->base) return;
271 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
272 edje_object_signal_callback_add(wd->base, "clicked", "*", _signal_mouse_clicked, obj);
273 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
278 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
279 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
284 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
285 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
286 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
287 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
288 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
293 _set_vis_guidetext(Evas_Object *obj)
295 Widget_Data *wd = elm_widget_data_get(obj);
298 elm_box_unpack(wd->box, wd->guidetext);
299 elm_box_unpack(wd->box, wd->entry);
300 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
302 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
303 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
305 evas_object_hide(wd->entry);
306 elm_box_pack_end(wd->box, wd->guidetext);
307 evas_object_show(wd->guidetext);
308 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
312 evas_object_hide(wd->guidetext);
313 elm_box_pack_end(wd->box, wd->entry);
314 evas_object_show(wd->entry);
315 if (elm_widget_focus_get(obj) || wd->focused)
317 elm_object_focus(wd->entry);
318 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
324 _contracted_state_set(Evas_Object *obj, int contracted)
326 Widget_Data *wd = elm_widget_data_get(obj);
328 Elm_Multibuttonentry_Item *item;
329 if (!wd || !wd->box) return;
331 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
332 evas_object_hide(wd->entry);
333 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
334 evas_object_hide(wd->guidetext);
335 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
337 evas_object_hide(wd->rectForEnd);
338 evas_object_hide(wd->end);
339 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
344 Evas_Coord w=0, w_tmp=0;
345 Evas_Coord box_inner_item_width_padding = 0;
347 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
348 // unpack all items and entry
349 elm_box_unpack_all(wd->box);
350 EINA_LIST_FOREACH(wd->items, l, item)
354 evas_object_hide(item->button);
355 item->visible = EINA_FALSE;
359 // pack buttons only 1line
364 elm_box_pack_end(wd->box, wd->label);
365 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
367 w -= box_inner_item_width_padding;
371 int count = eina_list_count(wd->items);
372 Evas_Coord button_min_width = 0;
373 /* Evas_Coord button_min_height = 0; */
374 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
376 const char *size_str;
377 size_str = edje_object_data_get(wd->end, "closed_button_width");
378 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
380 size_str = edje_object_data_get(wd->end, "closed_button_height");
381 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
385 EINA_LIST_FOREACH(wd->items, l, item)
389 int w_label_count = 0;
390 char buf[MAX_STR] = {0,};
392 elm_box_pack_end(wd->box, item->button);
393 evas_object_show(item->button);
394 item->visible = EINA_TRUE;
397 w -= box_inner_item_width_padding;
400 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
404 snprintf(buf, sizeof(buf), "... + %d", count);
405 elm_object_text_set(wd->end, buf);
406 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
409 if (w < 0 || w < w_label_count)
411 elm_box_unpack(wd->box, item->button);
412 evas_object_hide(item->button);
413 item->visible = EINA_FALSE;
416 snprintf(buf, sizeof(buf), "... + %d", count);
417 elm_object_text_set(wd->end, buf);
418 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
420 elm_box_pack_end(wd->box, wd->end);
421 evas_object_show(wd->end);
423 wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
424 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)1);
428 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
430 if (w < button_min_width)
433 Evas_Coord closed_height = 0;
434 const char *height_str = edje_object_data_get(wd->base, "closed_height");
435 if(height_str) closed_height = (Evas_Coord)atoi(height_str);
436 elm_box_unpack(wd->box, item->button);
437 evas_object_hide(item->button);
438 item->visible = EINA_FALSE;
441 rectSize = w - button_min_width;
444 Evas *e = evas_object_evas_get(obj);
445 wd->rectForEnd = evas_object_rectangle_add(e);
446 evas_object_color_set(wd->rectForEnd, 0, 0, 0, 0);
448 evas_object_size_hint_min_set(wd->rectForEnd, rectSize, closed_height);
449 elm_box_pack_end(wd->box, wd->rectForEnd);
450 evas_object_show(wd->rectForEnd);
452 elm_box_pack_end(wd->box, wd->end);
453 evas_object_show(wd->end);
455 wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
456 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)0);
465 // unpack all items and entry
466 elm_box_unpack_all(wd->box);
467 EINA_LIST_FOREACH(wd->items, l, item)
471 evas_object_hide(item->button);
472 item->visible = EINA_FALSE;
475 evas_object_hide(wd->end);
477 if (wd->rectForEnd) evas_object_hide(wd->rectForEnd);
479 // pack buttons only 1line
481 if (wd->label) elm_box_pack_end(wd->box, wd->label);
485 EINA_LIST_FOREACH(wd->items, l, item)
489 elm_box_pack_end(wd->box, item->button);
490 evas_object_show(item->button);
491 item->visible = EINA_TRUE;
495 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
496 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)wd->contracted);
498 if (wd->view_state != MULTIBUTTONENTRY_VIEW_CONTRACTED)
500 _set_vis_guidetext(obj);
505 _view_update(Evas_Object *obj)
507 Evas_Coord width = 1, height = 1;
508 Widget_Data *wd = elm_widget_data_get(obj);
510 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
515 elm_box_unpack(wd->box, wd->label);
516 elm_box_pack_start(wd->box, wd->label);
517 evas_object_size_hint_min_get(wd->label, &width, &height);
522 Evas_Coord guide_text_width = wd->w_box - width;
523 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
526 // update buttons in contracted mode
527 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
528 _contracted_state_set(obj, 1);
531 _set_vis_guidetext(obj);
535 _set_label(Evas_Object *obj, const char* str)
537 Widget_Data *wd = elm_widget_data_get(obj);
538 if (!wd || !str) return;
542 Evas_Coord width, height, sum_width = 0;
543 evas_object_size_hint_min_set(wd->label, 0, 0);
544 evas_object_resize(wd->label, 0, 0);
545 edje_object_part_text_set(wd->label, "mbe.label", str);
547 if (!strcmp(str, ""))
549 /* FIXME: not work yet */
550 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
551 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
556 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
557 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
560 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
563 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
566 evas_object_size_hint_min_set(wd->label, sum_width, height);
568 evas_object_show(wd->label);
573 _set_guidetext(Evas_Object *obj, const char* str)
575 Widget_Data *wd = elm_widget_data_get(obj);
576 if (!wd || !str) return;
580 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
581 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
582 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
583 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
586 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
591 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
593 Widget_Data *wd = elm_widget_data_get(obj);
594 Elm_Multibuttonentry_Item *item = NULL;
598 item = eina_list_data_get(wd->current);
600 if (item && item->button)
604 case MULTIBUTONENTRY_BUTTON_STATE_DEFAULT:
605 edje_object_signal_emit(item->button, "default", "");
608 case MULTIBUTONENTRY_BUTTON_STATE_SELECTED:
609 edje_object_signal_emit(item->button, "focused", "");
610 evas_object_smart_callback_call(obj, "item,selected", item);
613 edje_object_signal_emit(item->button, "default", "");
621 _change_current_button(Evas_Object *obj, Evas_Object *btn)
623 Widget_Data *wd = elm_widget_data_get(obj);
625 Elm_Multibuttonentry_Item *item;
628 // change the state of previous button to "default"
629 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
631 // change the current
632 EINA_LIST_FOREACH(wd->items, l, item)
634 if (item->button == btn)
641 // chagne the state of current button to "focused"
642 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_SELECTED);
647 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
649 Widget_Data *wd = elm_widget_data_get(data);
651 Elm_Multibuttonentry_Item *item = NULL;
652 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
654 _change_current_button(data, obj);
657 if ((item = eina_list_data_get(wd->current)) != NULL)
659 evas_object_smart_callback_call(data, "item,clicked", item);
660 _select_button(data, item->button);
665 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
667 Widget_Data *wd = elm_widget_data_get(obj);
668 if (!wd || !btn) return;
672 evas_object_del(btn);
676 _del_button_item(Elm_Multibuttonentry_Item *item)
679 Elm_Multibuttonentry_Item *_item;
683 Evas_Object *obj = item->multibuttonentry;
684 wd = elm_widget_data_get(obj);
686 EINA_LIST_FOREACH(wd->items, l, _item)
690 wd->items = eina_list_remove(wd->items, _item);
691 elm_box_unpack(wd->box, _item->button);
693 evas_object_smart_callback_call(obj, "item,deleted", _item);
695 _del_button_obj(obj, _item->button);
698 if (wd->current == l)
703 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
704 _contracted_state_set(obj, 1);
706 if (!eina_list_count(wd->items))
707 _set_vis_guidetext(obj);
711 _select_button(Evas_Object *obj, Evas_Object *btn)
713 Widget_Data *wd = elm_widget_data_get(obj);
718 _change_current_button(obj, btn);
719 if (elm_widget_focus_get(obj))
721 elm_object_unfocus(wd->entry);
722 evas_object_focus_set(btn, EINA_TRUE);
727 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
728 if (elm_widget_focus_get(obj))
729 elm_object_focus(wd->entry);
734 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
737 Evas_Coord w_text, h_btn, padding_outer, padding_inner;
738 Evas_Coord w_btn = 0, button_max_width = 0;
739 const char *size_str;
740 const char *ellipsis = "<ellipsis=1.0>";
742 size_str = edje_object_data_get(btn, "button_max_size");
743 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
745 const char *button_text = edje_object_part_text_get(btn, "elm.btn.text");
747 // decide the size of button
748 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
749 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
750 edje_object_part_geometry_get(btn, "left.padding", NULL, NULL, &padding_outer, NULL);
751 edje_object_part_geometry_get(btn, "left.inner.padding", NULL, NULL, &padding_inner, NULL);
752 w_btn = w_text + 2*padding_outer + 2*padding_inner;
756 if (button_max_width < w_btn)
758 vw = button_max_width;
759 edje_object_part_text_set(btn, "elm.btn.text", ellipsis);
760 edje_object_part_text_append(btn, "elm.btn.text", button_text);
766 evas_object_resize(btn, vw, h_btn);
767 evas_object_size_hint_min_set(btn, vw, h_btn);
769 if(realw) *realw = rw;
770 if(vieww) *vieww = vw;
773 static Elm_Multibuttonentry_Item*
774 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
776 Elm_Multibuttonentry_Item *item;
778 Evas_Coord width, height;
779 char *str_utf8 = NULL;
781 Widget_Data *wd = elm_widget_data_get(obj);
783 if (!wd || !wd->box || !wd->entry) return NULL;
785 if ((wd->add_callback) && !wd->add_callback(obj, str, data, wd->add_callback_data)) return NULL;
787 //entry is cleared when text is made to button
788 elm_entry_entry_set(wd->entry, "");
791 btn = edje_object_add(evas_object_evas_get(obj));
792 str_utf8 = elm_entry_markup_to_utf8(str);
794 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
795 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
796 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
797 evas_object_size_hint_min_set(btn, width, height);
798 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
799 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
800 evas_object_show(btn);
803 item = ELM_NEW(Elm_Multibuttonentry_Item);
807 _resize_button(btn, &rw, &vw);
808 item->multibuttonentry = obj;
813 item->visible = EINA_TRUE;
817 case MULTIBUTONENTRY_POS_START:
818 wd->items = eina_list_prepend(wd->items, item);
819 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
821 elm_widget_sub_object_add(obj, btn);
822 _contracted_state_set(obj, 1);
827 elm_box_pack_after(wd->box, btn, wd->label);
829 elm_box_pack_start(wd->box, btn);
830 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
831 _set_vis_guidetext(obj);
834 case MULTIBUTONENTRY_POS_END:
835 wd->items = eina_list_append(wd->items, item);
836 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
838 elm_widget_sub_object_add(obj, btn);
839 evas_object_hide(btn);
843 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
844 _set_vis_guidetext(obj);
846 elm_box_pack_before(wd->box, btn, wd->entry);
848 elm_box_pack_end(wd->box, btn);
851 case MULTIBUTONENTRY_POS_BEFORE:
853 wd->items = eina_list_prepend_relative(wd->items, item, reference);
855 wd->items = eina_list_append(wd->items, item);
856 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
858 elm_widget_sub_object_add(obj, btn);
859 evas_object_hide(btn);
860 _contracted_state_set(obj, 1);
865 elm_box_pack_before(wd->box, btn, reference->button);
868 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
869 _set_vis_guidetext(obj);
871 elm_box_pack_before(wd->box, btn, wd->entry);
873 elm_box_pack_end(wd->box, btn);
877 case MULTIBUTONENTRY_POS_AFTER:
879 wd->items = eina_list_append_relative(wd->items, item, reference);
881 wd->items = eina_list_append(wd->items, item);
882 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
884 elm_widget_sub_object_add(obj, btn);
885 _contracted_state_set(obj, 1);
890 elm_box_pack_after(wd->box, btn, reference->button);
893 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
894 _set_vis_guidetext(obj);
896 elm_box_pack_before(wd->box, btn, wd->entry);
898 elm_box_pack_end(wd->box, btn);
906 evas_object_smart_callback_call(obj, "item,added", item);
914 _add_button(Evas_Object *obj, char *str)
916 Widget_Data *wd = elm_widget_data_get(obj);
920 _add_button_item(obj, str, MULTIBUTONENTRY_POS_END, NULL, NULL);
924 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
926 Widget_Data *wd = elm_widget_data_get(data);
927 Elm_Multibuttonentry_Item *item = NULL;
929 static char str[MAX_STR];
931 if (!wd || !wd->base || !wd->box) return;
933 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
934 str[MAX_STR - 1] = 0;
936 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
938 if (wd->last_btn_select)
940 if ((wd->current) && ( (strcmp (ev->keyname, "BackSpace") == 0) || (strcmp (ev->keyname, "BackSpace (") == 0)))
942 item = eina_list_data_get(wd->current);
945 _del_button_item(item);
946 elm_object_focus(wd->entry);
949 else if ((((!wd->current) && (wd->n_str == 0) && (strcmp (ev->keyname, "BackSpace") == 0))
950 || (strcmp (ev->keyname, "BackSpace (") == 0)))
952 item = eina_list_data_get(eina_list_last(wd->items));
954 _select_button(data, item->button);
958 wd->last_btn_select = EINA_TRUE;
962 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
964 Widget_Data *wd = elm_widget_data_get(data);
965 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
969 if ( (wd->n_str == 1) && (strcmp (ev->keyname, "BackSpace") == 0 || (strcmp (ev->keyname, "BackSpace (") == 0 )))
970 wd->last_btn_select = EINA_FALSE;
974 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
976 Widget_Data *wd = elm_widget_data_get(data);
977 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
978 static char str[MAX_STR];
980 if (!wd || !wd->base || !wd->box) return;
982 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
983 str[MAX_STR - 1] = 0;
985 if ( (strcmp (str, "") != 0) && (strcmp (ev->keyname, "KP_Enter") == 0 || strcmp (ev->keyname, "Return") == 0 ))
987 _add_button(data, str);
994 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
996 Widget_Data *wd = elm_widget_data_get(data);
999 _change_current_button_state(data, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
1003 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1005 Widget_Data *wd = elm_widget_data_get(data);
1008 static char str[MAX_STR];
1010 strncpy(str,elm_entry_entry_get(wd->entry), MAX_STR);
1011 str[MAX_STR -1] = 0;
1014 _add_button(data, str);
1018 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1020 Widget_Data *wd = elm_widget_data_get(data);
1023 static char str[MAX_STR];
1025 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
1026 str[MAX_STR -1] = 0;
1028 wd->n_str = strlen(str);
1032 _view_init(Evas_Object *obj)
1034 Widget_Data *wd = elm_widget_data_get(obj);
1039 if (! (wd->box = elm_box_add (obj))) return;
1040 elm_widget_sub_object_add(obj, wd->box);
1041 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1042 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1043 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1048 if (!(wd->label = edje_object_add(evas_object_evas_get(obj)))) return;
1049 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1050 _set_label(obj, "");
1051 elm_widget_sub_object_add(obj, wd->label);
1056 if (! (wd->entry = elm_entry_add (obj))) return;
1057 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1058 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1059 elm_entry_entry_set(wd->entry, "");
1060 elm_entry_cursor_end_set(wd->entry);
1061 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1062 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1063 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1064 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1065 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1066 evas_object_show(wd->entry);
1067 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1072 const char *end_type = edje_object_data_get(wd->base, "closed_button_type");
1073 if (!end_type || !strcmp(end_type, "label"))
1075 if (! (wd->end = elm_label_add (obj))) return;
1076 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1077 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1081 const char *size_str;
1082 if (!(wd->end = edje_object_add(evas_object_evas_get(obj)))) return;
1083 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1084 Evas_Coord button_min_width = 0;
1085 Evas_Coord button_min_height = 0;
1087 size_str = edje_object_data_get(wd->end, "closed_button_width");
1088 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
1089 size_str = edje_object_data_get(wd->end, "closed_button_height");
1090 if(size_str) button_min_height = (Evas_Coord)atoi(size_str);
1092 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1093 evas_object_size_hint_min_set(wd->end, button_min_width, button_min_height);
1094 elm_widget_sub_object_add(obj, wd->end);
1100 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1102 Evas_Coord minw, minh, maxw, maxh, mnw, mnh, ww;
1103 Evas_Coord w, cw = 0, cmaxh = 0;
1105 Evas_Object_Box_Option *opt;
1108 /* FIXME: need to calc max */
1114 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1115 evas_object_size_hint_min_get(box, &minw, NULL);
1117 EINA_LIST_FOREACH(priv->children, l, opt)
1119 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1120 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1124 if (mnw != -1 && (w - cw) >= mnw)
1139 if (cmaxh < mnh) cmaxh = mnh;
1144 evas_object_size_hint_min_set(box, minw, minh);
1148 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1150 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1152 Evas_Object_Box_Option *opt;
1156 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1158 EINA_LIST_FOREACH(priv->children, l, opt)
1160 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1161 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1165 if (mnw != -1 && (w - cw) >= mnw)
1175 if (index > obj_index) return cmaxh;
1181 if (cmaxh < mnh) cmaxh = mnh;
1190 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1192 Evas_Coord x, y, w, h, xx, yy;
1195 Evas_Coord minw, minh, wdif, hdif;
1198 Evas_Object_Box_Option *opt;
1200 _calculate_box_min_size(o, priv);
1202 evas_object_geometry_get(o, &x, &y, &w, &h);
1204 evas_object_size_hint_min_get(o, &minw, &minh);
1205 evas_object_size_hint_align_get(o, &ax, &ay);
1206 count = eina_list_count(priv->children);
1209 x = x + ((w - minw) * (1.0 - ax));
1214 y = y + ((h - minh) * (1.0 - ay));
1223 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1225 EINA_LIST_FOREACH(priv->children, l, opt)
1227 Evas_Coord mnw, mnh, mxw, mxh;
1232 evas_object_size_hint_align_get(obj, &ax, &ay);
1233 evas_object_size_hint_weight_get(obj, &wx, &wy);
1234 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1235 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1238 if (ax == -1.0) {fw = 1; ax = 0.5;}
1239 if (ay == -1.0) {fh = 1; ay = 0.5;}
1240 if (wx > 0.0) xw = 1;
1241 if (wy > 0.0) xh = 1;
1242 Evas_Coord ww, hh, ow, oh;
1246 if (mnw != -1 && (w - cw) >= mnw)
1253 hh = _calculate_item_max_height(o, priv, obj_index);
1257 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1260 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1269 evas_object_move(obj,
1270 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1271 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1272 evas_object_resize(obj, ow, oh);
1275 if (cmaxh < hh) cmaxh = hh;
1282 * Add a new multibuttonentry to the parent
1284 * @param parent The parent object
1285 * @return The new object or NULL if it cannot be created
1287 * @ingroup Multibuttonentry
1290 elm_multibuttonentry_add(Evas_Object *parent)
1295 if (!parent) return NULL;
1297 wd = ELM_NEW(Widget_Data);
1298 e = evas_object_evas_get(parent);
1299 if (!e) return NULL;
1300 obj = elm_widget_add(e);
1301 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1302 elm_widget_type_set(obj, "multibuttonentry");
1303 elm_widget_sub_object_add(parent, obj);
1304 elm_widget_data_set(obj, wd);
1306 elm_widget_del_hook_set(obj, _del_hook);
1307 elm_widget_theme_hook_set(obj, _theme_hook);
1308 elm_widget_event_hook_set(obj, _event_hook);
1309 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1310 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1312 wd->base = edje_object_add(e);
1313 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1314 elm_widget_resize_object_set(obj, wd->base);
1315 elm_widget_can_focus_set(obj,EINA_TRUE);
1317 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1318 wd->focused = EINA_FALSE;
1319 wd->last_btn_select = EINA_TRUE;
1321 wd->rectForEnd = NULL;
1322 wd->add_callback = NULL;
1323 wd->add_callback_data = NULL;
1332 * Get the entry of the multibuttonentry object
1334 * @param obj The multibuttonentry object
1335 * @return The entry object, or NULL if none
1337 * @ingroup Multibuttonentry
1340 elm_multibuttonentry_entry_get(Evas_Object *obj)
1342 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1343 Widget_Data *wd = elm_widget_data_get(obj);
1344 if (!wd) return NULL;
1352 * @param obj The multibuttonentry object
1353 * @return The label, or NULL if none
1355 * @ingroup Multibuttonentry
1358 elm_multibuttonentry_label_get(Evas_Object *obj)
1360 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1361 Widget_Data *wd = elm_widget_data_get(obj);
1362 if (!wd) return NULL;
1363 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1370 * @param obj The multibuttonentry object
1371 * @param label The text label string
1373 * @ingroup Multibuttonentry
1376 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1378 ELM_CHECK_WIDTYPE(obj, widtype);
1379 Widget_Data *wd = elm_widget_data_get(obj);
1382 _set_label(obj, label);
1384 _set_label(obj, "");
1388 * Get the guide text
1390 * @param obj The multibuttonentry object
1391 * @return The guide text, or NULL if none
1393 * @ingroup Multibuttonentry
1396 elm_multibuttonentry_guide_text_get(Evas_Object *obj)
1398 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1399 Widget_Data *wd = elm_widget_data_get(obj);
1400 if (!wd) return NULL;
1401 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1406 * Set the guide text
1408 * @param obj The multibuttonentry object
1409 * @param label The guide text string
1411 * @ingroup Multibuttonentry
1414 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1416 ELM_CHECK_WIDTYPE(obj, widtype);
1417 Widget_Data *wd = elm_widget_data_get(obj);
1420 _set_guidetext(obj, guidetext);
1422 _set_guidetext(obj, "");
1427 * Get the value of contracted state.
1429 * @param obj The multibuttonentry object
1430 * @param the value of contracted state.
1432 * @ingroup Multibuttonentry
1435 elm_multibuttonentry_contracted_state_get(Evas_Object *obj)
1437 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1438 Widget_Data *wd = elm_widget_data_get(obj);
1440 return wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED ? 1 : 0;
1444 * Set/Unset the multibuttonentry to contracted state of single line
1446 * @param obj The multibuttonentry object
1447 * @param the value of contracted state. set this to 1 to set the multibuttonentry to contracted state of single line. set this to 0 to unset the contracted state.
1449 * @ingroup Multibuttonentry
1452 elm_multibuttonentry_contracted_state_set(Evas_Object *obj, int contracted)
1454 ELM_CHECK_WIDTYPE(obj, widtype);
1455 Widget_Data *wd = elm_widget_data_get(obj);
1456 if (!wd || !wd->box ||
1457 ((wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) ? 1 : 0) == contracted) return;
1458 _contracted_state_set(obj, contracted);
1462 * Prepend a new item to the multibuttonentry
1464 * @param obj The multibuttonentry object
1465 * @param label The label of new item
1466 * @param data The ponter to the data to be attached
1467 * @return A handle to the item added or NULL if not possible
1469 * @ingroup Multibuttonentry
1471 EAPI Elm_Multibuttonentry_Item *
1472 elm_multibuttonentry_item_add_start(Evas_Object *obj, const char *label, void *data)
1474 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1475 Widget_Data *wd = elm_widget_data_get(obj);
1476 Elm_Multibuttonentry_Item *item;
1477 if (!wd || !label) return NULL;
1478 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_START, NULL, data);
1483 * Append a new item to the multibuttonentry
1485 * @param obj The multibuttonentry object
1486 * @param label The label of new item
1487 * @param data The ponter to the data to be attached
1488 * @return A handle to the item added or NULL if not possible
1490 * @ingroup Multibuttonentry
1492 EAPI Elm_Multibuttonentry_Item *
1493 elm_multibuttonentry_item_add_end(Evas_Object *obj, const char *label, void *data)
1495 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1496 Widget_Data *wd = elm_widget_data_get(obj);
1497 Elm_Multibuttonentry_Item *item;
1498 if (!wd || !label) return NULL;
1499 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_END, NULL, data);
1504 * Add a new item to the multibuttonentry before the indicated object
1507 * @param obj The multibuttonentry object
1508 * @param label The label of new item
1509 * @param before The item before which to add it
1510 * @param data The ponter to the data to be attached
1511 * @return A handle to the item added or NULL if not possible
1513 * @ingroup Multibuttonentry
1515 EAPI Elm_Multibuttonentry_Item *
1516 elm_multibuttonentry_item_add_before(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *before, void *data)
1518 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1519 Widget_Data *wd = elm_widget_data_get(obj);
1520 Elm_Multibuttonentry_Item *item;
1521 if (!wd || !label) return NULL;
1522 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_BEFORE, before, data);
1527 * Add a new item to the multibuttonentry after the indicated object
1529 * @param obj The multibuttonentry object
1530 * @param label The label of new item
1531 * @param after The item after which to add it
1532 * @param data The ponter to the data to be attached
1533 * @return A handle to the item added or NULL if not possible
1535 * @ingroup Multibuttonentry
1537 EAPI Elm_Multibuttonentry_Item *
1538 elm_multibuttonentry_item_add_after(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *after, void *data)
1540 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1541 Widget_Data *wd = elm_widget_data_get(obj);
1542 Elm_Multibuttonentry_Item *item;
1543 if (!wd || !label) return NULL;
1544 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_AFTER, after, data);
1549 * Get a list of items in the multibuttonentry
1551 * @param obj The multibuttonentry object
1552 * @return The list of items, or NULL if none
1554 * @ingroup Multibuttonentry
1556 EAPI const Eina_List *
1557 elm_multibuttonentry_items_get(Evas_Object *obj)
1559 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1560 Widget_Data *wd = elm_widget_data_get(obj);
1561 if (!wd) return NULL;
1566 * Get the first item in the multibuttonentry
1568 * @param obj The multibuttonentry object
1569 * @return The first item, or NULL if none
1571 * @ingroup Multibuttonentry
1573 EAPI Elm_Multibuttonentry_Item *
1574 elm_multibuttonentry_item_first_get(Evas_Object *obj)
1576 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1577 Widget_Data *wd = elm_widget_data_get(obj);
1578 if (!wd || !wd->items) return NULL;
1579 return eina_list_data_get(wd->items);
1583 * Get the last item in the multibuttonentry
1585 * @param obj The multibuttonentry object
1586 * @return The last item, or NULL if none
1588 * @ingroup Multibuttonentry
1590 EAPI Elm_Multibuttonentry_Item *
1591 elm_multibuttonentry_item_last_get(Evas_Object *obj)
1593 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1594 Widget_Data *wd = elm_widget_data_get(obj);
1595 if (!wd || !wd->items) return NULL;
1596 return eina_list_data_get(eina_list_last(wd->items));
1600 * Get the selected item in the multibuttonentry
1602 * @param obj The multibuttonentry object
1603 * @return The selected item, or NULL if none
1605 * @ingroup Multibuttonentry
1607 EAPI Elm_Multibuttonentry_Item *
1608 elm_multibuttonentry_item_selected_get(Evas_Object *obj)
1610 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1611 Widget_Data *wd = elm_widget_data_get(obj);
1612 if (!wd || !wd->current) return NULL;
1613 return eina_list_data_get(wd->current);
1617 * Set the selected state of an item
1619 * @param item The item
1621 * @ingroup Multibuttonentry
1624 elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item)
1628 Elm_Multibuttonentry_Item *_item;
1631 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1632 wd = elm_widget_data_get(item->multibuttonentry);
1635 EINA_LIST_FOREACH(wd->items, l, _item)
1638 _select_button(item->multibuttonentry, item->button);
1643 * unselect all of items.
1645 * @param obj The multibuttonentry object
1647 * @ingroup Multibuttonentry
1650 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1652 ELM_CHECK_WIDTYPE(obj, widtype);
1653 Widget_Data *wd = elm_widget_data_get(obj);
1656 _select_button(obj, NULL);
1660 * Remove all items in the multibuttonentry.
1662 * @param obj The multibuttonentry object
1664 * @ingroup Multibuttonentry
1667 elm_multibuttonentry_items_del(Evas_Object *obj)
1669 ELM_CHECK_WIDTYPE(obj, widtype);
1670 Widget_Data *wd = elm_widget_data_get(obj);
1675 Elm_Multibuttonentry_Item *item;
1676 EINA_LIST_FREE(wd->items, item)
1678 elm_box_unpack(wd->box, item->button);
1679 _del_button_obj(obj, item->button);
1689 * Delete a given item
1691 * @param item The item
1693 * @ingroup Multibuttonentry
1696 elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
1699 _del_button_item(item);
1703 * Get the label of a given item
1705 * @param item The item
1706 * @return The label of a given item, or NULL if none
1708 * @ingroup Multibuttonentry
1711 elm_multibuttonentry_item_label_get(Elm_Multibuttonentry_Item *item)
1715 Elm_Multibuttonentry_Item *_item;
1716 if (!item) return NULL;
1717 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1718 wd = elm_widget_data_get(item->multibuttonentry);
1719 if (!wd || !wd->items) return NULL;
1721 EINA_LIST_FOREACH(wd->items, l, _item)
1724 return edje_object_part_text_get(_item->button, "elm.btn.text");
1731 * Set the label of a given item
1733 * @param item The item
1734 * @param label The text label string
1736 * @ingroup Multibuttonentry
1739 elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
1743 Elm_Multibuttonentry_Item *_item;
1744 if (!item || !str) return;
1745 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1746 wd = elm_widget_data_get(item->multibuttonentry);
1747 if (!wd || !wd->items) return;
1749 EINA_LIST_FOREACH(wd->items, l, _item)
1752 edje_object_part_text_set(_item->button, "elm.btn.text", str);
1753 _resize_button(_item->button, &_item->rw, &_item->vw);
1759 * Get the previous item in the multibuttonentry
1761 * @param item The item
1762 * @return The item before the item @p item
1764 * @ingroup Multibuttonentry
1766 EAPI Elm_Multibuttonentry_Item *
1767 elm_multibuttonentry_item_prev(Elm_Multibuttonentry_Item *item)
1771 Elm_Multibuttonentry_Item *_item;
1772 if (!item) return NULL;
1773 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1774 wd = elm_widget_data_get(item->multibuttonentry);
1775 if (!wd || !wd->items) return NULL;
1777 EINA_LIST_FOREACH(wd->items, l, _item)
1780 l = eina_list_prev(l);
1781 if (!l) return NULL;
1782 return eina_list_data_get(l);
1788 * Get the next item in the multibuttonentry
1790 * @param item The item
1791 * @return The item after the item @p item
1793 * @ingroup Multibuttonentry
1795 EAPI Elm_Multibuttonentry_Item *
1796 elm_multibuttonentry_item_next(Elm_Multibuttonentry_Item *item)
1800 Elm_Multibuttonentry_Item *_item;
1801 if (!item) return NULL;
1802 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1803 wd = elm_widget_data_get(item->multibuttonentry);
1804 if (!wd || !wd->items) return NULL;
1806 EINA_LIST_FOREACH(wd->items, l, _item)
1809 l = eina_list_next(l);
1810 if (!l) return NULL;
1811 return eina_list_data_get(l);
1817 * Get private data of item
1819 * @param item The item
1820 * @return The data pointer stored, or NULL if none was stored
1822 * @ingroup Multibuttonentry
1825 elm_multibuttonentry_item_data_get(Elm_Multibuttonentry_Item *item)
1827 if (!item) return NULL;
1832 * Set private data of item
1834 * @param item The item
1835 * @param data The ponter to the data to be attached
1837 * @ingroup Multibuttonentry
1840 elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
1847 * Set the multibuttonentry item_verify_callback function
1849 * @param obj The multibuttonentry object
1850 * @param func The function pointer to be called, it it's NULL, callback function will be deleted.
1851 * @param data user data to be passed to the callback function
1853 * @ingroup Multibuttonentry
1856 elm_multibuttonentry_item_verify_callback_set(Evas_Object *obj, Elm_Multibuttonentry_Item_Verify_Callback func, void *data)
1858 ELM_CHECK_WIDTYPE(obj, widtype);
1859 Widget_Data *wd = elm_widget_data_get(obj);
1862 wd->add_callback = func;
1863 wd->add_callback_data = data;