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))
173 ecore_imf_context_input_panel_show(imf_context);
174 elm_object_focus(wd->entry);
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;
741 size_str = edje_object_data_get(btn, "button_max_size");
742 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
744 // decide the size of button
745 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
746 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
747 edje_object_part_geometry_get(btn, "left.padding", NULL, NULL, &padding_outer, NULL);
748 edje_object_part_geometry_get(btn, "left.inner.padding", NULL, NULL, &padding_inner, NULL);
749 w_btn = w_text + 2*padding_outer + 2*padding_inner;
752 vw = (button_max_width < w_btn) ? button_max_width : w_btn;
755 evas_object_resize(btn, vw, h_btn);
756 evas_object_size_hint_min_set(btn, vw, h_btn);
758 if(realw) *realw = rw;
759 if(vieww) *vieww = vw;
762 static Elm_Multibuttonentry_Item*
763 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
765 Elm_Multibuttonentry_Item *item;
767 Evas_Coord width, height;
768 char *str_utf8 = NULL;
770 Widget_Data *wd = elm_widget_data_get(obj);
772 if (!wd || !wd->box || !wd->entry) return NULL;
774 if ((wd->add_callback) && !wd->add_callback(obj, str, data, wd->add_callback_data)) return NULL;
776 //entry is cleared when text is made to button
777 elm_entry_entry_set(wd->entry, "");
780 btn = edje_object_add(evas_object_evas_get(obj));
781 str_utf8 = elm_entry_markup_to_utf8(str);
783 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
784 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
785 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
786 evas_object_size_hint_min_set(btn, width, height);
787 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
788 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
789 evas_object_show(btn);
792 item = ELM_NEW(Elm_Multibuttonentry_Item);
796 _resize_button(btn, &rw, &vw);
797 item->multibuttonentry = obj;
802 item->visible = EINA_TRUE;
806 case MULTIBUTONENTRY_POS_START:
807 wd->items = eina_list_prepend(wd->items, item);
808 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
810 elm_widget_sub_object_add(obj, btn);
811 _contracted_state_set(obj, 1);
816 elm_box_pack_after(wd->box, btn, wd->label);
818 elm_box_pack_start(wd->box, btn);
819 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
820 _set_vis_guidetext(obj);
823 case MULTIBUTONENTRY_POS_END:
824 wd->items = eina_list_append(wd->items, item);
825 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
827 elm_widget_sub_object_add(obj, btn);
828 evas_object_hide(btn);
832 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
833 _set_vis_guidetext(obj);
835 elm_box_pack_before(wd->box, btn, wd->entry);
837 elm_box_pack_end(wd->box, btn);
840 case MULTIBUTONENTRY_POS_BEFORE:
842 wd->items = eina_list_prepend_relative(wd->items, item, reference);
844 wd->items = eina_list_append(wd->items, item);
845 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
847 elm_widget_sub_object_add(obj, btn);
848 evas_object_hide(btn);
849 _contracted_state_set(obj, 1);
854 elm_box_pack_before(wd->box, btn, reference->button);
857 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
858 _set_vis_guidetext(obj);
860 elm_box_pack_before(wd->box, btn, wd->entry);
862 elm_box_pack_end(wd->box, btn);
866 case MULTIBUTONENTRY_POS_AFTER:
868 wd->items = eina_list_append_relative(wd->items, item, reference);
870 wd->items = eina_list_append(wd->items, item);
871 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
873 elm_widget_sub_object_add(obj, btn);
874 _contracted_state_set(obj, 1);
879 elm_box_pack_after(wd->box, btn, reference->button);
882 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
883 _set_vis_guidetext(obj);
885 elm_box_pack_before(wd->box, btn, wd->entry);
887 elm_box_pack_end(wd->box, btn);
895 evas_object_smart_callback_call(obj, "item,added", item);
903 _add_button(Evas_Object *obj, char *str)
905 Widget_Data *wd = elm_widget_data_get(obj);
909 _add_button_item(obj, str, MULTIBUTONENTRY_POS_END, NULL, NULL);
913 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
915 Widget_Data *wd = elm_widget_data_get(data);
916 Elm_Multibuttonentry_Item *item = NULL;
918 static char str[MAX_STR];
920 if (!wd || !wd->base || !wd->box) return;
922 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
923 str[MAX_STR - 1] = 0;
925 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
927 if (wd->last_btn_select)
929 if ((wd->current) && ( (strcmp (ev->keyname, "BackSpace") == 0) || (strcmp (ev->keyname, "BackSpace (") == 0)))
931 item = eina_list_data_get(wd->current);
934 _del_button_item(item);
935 elm_object_focus(wd->entry);
938 else if ((((!wd->current) && (wd->n_str == 0) && (strcmp (ev->keyname, "BackSpace") == 0))
939 || (strcmp (ev->keyname, "BackSpace (") == 0)))
941 item = eina_list_data_get(eina_list_last(wd->items));
943 _select_button(data, item->button);
947 wd->last_btn_select = EINA_TRUE;
951 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
953 Widget_Data *wd = elm_widget_data_get(data);
954 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
958 if ( (wd->n_str == 1) && (strcmp (ev->keyname, "BackSpace") == 0 || (strcmp (ev->keyname, "BackSpace (") == 0 )))
959 wd->last_btn_select = EINA_FALSE;
963 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
965 Widget_Data *wd = elm_widget_data_get(data);
966 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
967 static char str[MAX_STR];
969 if (!wd || !wd->base || !wd->box) return;
971 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
972 str[MAX_STR - 1] = 0;
974 if ( (strcmp (str, "") != 0) && (strcmp (ev->keyname, "KP_Enter") == 0 || strcmp (ev->keyname, "Return") == 0 ))
976 _add_button(data, str);
983 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
985 Widget_Data *wd = elm_widget_data_get(data);
988 _change_current_button_state(data, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
992 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
994 Widget_Data *wd = elm_widget_data_get(data);
997 static char str[MAX_STR];
999 strncpy(str,elm_entry_entry_get(wd->entry), MAX_STR);
1000 str[MAX_STR -1] = 0;
1003 _add_button(data, str);
1007 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1009 Widget_Data *wd = elm_widget_data_get(data);
1012 static char str[MAX_STR];
1014 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
1015 str[MAX_STR -1] = 0;
1017 wd->n_str = strlen(str);
1021 _view_init(Evas_Object *obj)
1023 Widget_Data *wd = elm_widget_data_get(obj);
1028 if (! (wd->box = elm_box_add (obj))) return;
1029 elm_widget_sub_object_add(obj, wd->box);
1030 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1031 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1032 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1037 if (!(wd->label = edje_object_add(evas_object_evas_get(obj)))) return;
1038 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1039 _set_label(obj, "");
1040 elm_widget_sub_object_add(obj, wd->label);
1045 if (! (wd->entry = elm_entry_add (obj))) return;
1046 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1047 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1048 elm_entry_entry_set(wd->entry, "");
1049 elm_entry_cursor_end_set(wd->entry);
1050 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1051 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1052 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1053 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1054 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1055 evas_object_show(wd->entry);
1056 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1061 const char *end_type = edje_object_data_get(wd->base, "closed_button_type");
1062 if (!end_type || !strcmp(end_type, "label"))
1064 if (! (wd->end = elm_label_add (obj))) return;
1065 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1066 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1070 const char *size_str;
1071 if (!(wd->end = edje_object_add(evas_object_evas_get(obj)))) return;
1072 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1073 Evas_Coord button_min_width = 0;
1074 Evas_Coord button_min_height = 0;
1076 size_str = edje_object_data_get(wd->end, "closed_button_width");
1077 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
1078 size_str = edje_object_data_get(wd->end, "closed_button_height");
1079 if(size_str) button_min_height = (Evas_Coord)atoi(size_str);
1081 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1082 evas_object_size_hint_min_set(wd->end, button_min_width, button_min_height);
1083 elm_widget_sub_object_add(obj, wd->end);
1089 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1091 Evas_Coord minw, minh, maxw, maxh, mnw, mnh, ww;
1092 Evas_Coord w, cw = 0, cmaxh = 0;
1094 Evas_Object_Box_Option *opt;
1097 /* FIXME: need to calc max */
1103 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1104 evas_object_size_hint_min_get(box, &minw, NULL);
1106 EINA_LIST_FOREACH(priv->children, l, opt)
1108 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1109 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1113 if (mnw != -1 && (w - cw) >= mnw)
1128 if (cmaxh < mnh) cmaxh = mnh;
1133 evas_object_size_hint_min_set(box, minw, minh);
1137 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1139 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1141 Evas_Object_Box_Option *opt;
1145 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1147 EINA_LIST_FOREACH(priv->children, l, opt)
1149 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1150 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1154 if (mnw != -1 && (w - cw) >= mnw)
1164 if (index > obj_index) return cmaxh;
1170 if (cmaxh < mnh) cmaxh = mnh;
1179 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1181 Evas_Coord x, y, w, h, xx, yy;
1184 Evas_Coord minw, minh, wdif, hdif;
1187 Evas_Object_Box_Option *opt;
1189 _calculate_box_min_size(o, priv);
1191 evas_object_geometry_get(o, &x, &y, &w, &h);
1193 evas_object_size_hint_min_get(o, &minw, &minh);
1194 evas_object_size_hint_align_get(o, &ax, &ay);
1195 count = eina_list_count(priv->children);
1198 x = x + ((w - minw) * (1.0 - ax));
1203 y = y + ((h - minh) * (1.0 - ay));
1212 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1214 EINA_LIST_FOREACH(priv->children, l, opt)
1216 Evas_Coord mnw, mnh, mxw, mxh;
1221 evas_object_size_hint_align_get(obj, &ax, &ay);
1222 evas_object_size_hint_weight_get(obj, &wx, &wy);
1223 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1224 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1227 if (ax == -1.0) {fw = 1; ax = 0.5;}
1228 if (ay == -1.0) {fh = 1; ay = 0.5;}
1229 if (wx > 0.0) xw = 1;
1230 if (wy > 0.0) xh = 1;
1231 Evas_Coord ww, hh, ow, oh;
1235 if (mnw != -1 && (w - cw) >= mnw)
1242 hh = _calculate_item_max_height(o, priv, obj_index);
1246 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1249 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1258 evas_object_move(obj,
1259 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1260 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1261 evas_object_resize(obj, ow, oh);
1264 if (cmaxh < hh) cmaxh = hh;
1271 * Add a new multibuttonentry to the parent
1273 * @param parent The parent object
1274 * @return The new object or NULL if it cannot be created
1276 * @ingroup Multibuttonentry
1279 elm_multibuttonentry_add(Evas_Object *parent)
1284 if (!parent) return NULL;
1286 wd = ELM_NEW(Widget_Data);
1287 e = evas_object_evas_get(parent);
1288 if (!e) return NULL;
1289 obj = elm_widget_add(e);
1290 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1291 elm_widget_type_set(obj, "multibuttonentry");
1292 elm_widget_sub_object_add(parent, obj);
1293 elm_widget_data_set(obj, wd);
1295 elm_widget_del_hook_set(obj, _del_hook);
1296 elm_widget_theme_hook_set(obj, _theme_hook);
1297 elm_widget_event_hook_set(obj, _event_hook);
1298 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1299 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1301 wd->base = edje_object_add(e);
1302 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1303 elm_widget_resize_object_set(obj, wd->base);
1304 elm_widget_can_focus_set(obj,EINA_TRUE);
1306 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1307 wd->focused = EINA_FALSE;
1308 wd->last_btn_select = EINA_TRUE;
1310 wd->rectForEnd = NULL;
1311 wd->add_callback = NULL;
1312 wd->add_callback_data = NULL;
1321 * Get the entry of the multibuttonentry object
1323 * @param obj The multibuttonentry object
1324 * @return The entry object, or NULL if none
1326 * @ingroup Multibuttonentry
1329 elm_multibuttonentry_entry_get(Evas_Object *obj)
1331 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1332 Widget_Data *wd = elm_widget_data_get(obj);
1333 if (!wd) return NULL;
1341 * @param obj The multibuttonentry object
1342 * @return The label, or NULL if none
1344 * @ingroup Multibuttonentry
1347 elm_multibuttonentry_label_get(Evas_Object *obj)
1349 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1350 Widget_Data *wd = elm_widget_data_get(obj);
1351 if (!wd) return NULL;
1352 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1359 * @param obj The multibuttonentry object
1360 * @param label The text label string
1362 * @ingroup Multibuttonentry
1365 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1367 ELM_CHECK_WIDTYPE(obj, widtype);
1368 Widget_Data *wd = elm_widget_data_get(obj);
1371 _set_label(obj, label);
1373 _set_label(obj, "");
1377 * Get the guide text
1379 * @param obj The multibuttonentry object
1380 * @return The guide text, or NULL if none
1382 * @ingroup Multibuttonentry
1385 elm_multibuttonentry_guide_text_get(Evas_Object *obj)
1387 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1388 Widget_Data *wd = elm_widget_data_get(obj);
1389 if (!wd) return NULL;
1390 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1395 * Set the guide text
1397 * @param obj The multibuttonentry object
1398 * @param label The guide text string
1400 * @ingroup Multibuttonentry
1403 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1405 ELM_CHECK_WIDTYPE(obj, widtype);
1406 Widget_Data *wd = elm_widget_data_get(obj);
1409 _set_guidetext(obj, guidetext);
1411 _set_guidetext(obj, "");
1416 * Get the value of contracted state.
1418 * @param obj The multibuttonentry object
1419 * @param the value of contracted state.
1421 * @ingroup Multibuttonentry
1424 elm_multibuttonentry_contracted_state_get(Evas_Object *obj)
1426 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1427 Widget_Data *wd = elm_widget_data_get(obj);
1429 return wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED ? 1 : 0;
1433 * Set/Unset the multibuttonentry to contracted state of single line
1435 * @param obj The multibuttonentry object
1436 * @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.
1438 * @ingroup Multibuttonentry
1441 elm_multibuttonentry_contracted_state_set(Evas_Object *obj, int contracted)
1443 ELM_CHECK_WIDTYPE(obj, widtype);
1444 Widget_Data *wd = elm_widget_data_get(obj);
1445 if (!wd || !wd->box ||
1446 ((wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) ? 1 : 0) == contracted) return;
1447 _contracted_state_set(obj, contracted);
1451 * Prepend a new item to the multibuttonentry
1453 * @param obj The multibuttonentry object
1454 * @param label The label of new item
1455 * @param data The ponter to the data to be attached
1456 * @return A handle to the item added or NULL if not possible
1458 * @ingroup Multibuttonentry
1460 EAPI Elm_Multibuttonentry_Item *
1461 elm_multibuttonentry_item_add_start(Evas_Object *obj, const char *label, void *data)
1463 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1464 Widget_Data *wd = elm_widget_data_get(obj);
1465 Elm_Multibuttonentry_Item *item;
1466 if (!wd || !label) return NULL;
1467 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_START, NULL, data);
1472 * Append a new item to the multibuttonentry
1474 * @param obj The multibuttonentry object
1475 * @param label The label of new item
1476 * @param data The ponter to the data to be attached
1477 * @return A handle to the item added or NULL if not possible
1479 * @ingroup Multibuttonentry
1481 EAPI Elm_Multibuttonentry_Item *
1482 elm_multibuttonentry_item_add_end(Evas_Object *obj, const char *label, void *data)
1484 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1485 Widget_Data *wd = elm_widget_data_get(obj);
1486 Elm_Multibuttonentry_Item *item;
1487 if (!wd || !label) return NULL;
1488 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_END, NULL, data);
1493 * Add a new item to the multibuttonentry before the indicated object
1496 * @param obj The multibuttonentry object
1497 * @param label The label of new item
1498 * @param before The item before which to add it
1499 * @param data The ponter to the data to be attached
1500 * @return A handle to the item added or NULL if not possible
1502 * @ingroup Multibuttonentry
1504 EAPI Elm_Multibuttonentry_Item *
1505 elm_multibuttonentry_item_add_before(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *before, void *data)
1507 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1508 Widget_Data *wd = elm_widget_data_get(obj);
1509 Elm_Multibuttonentry_Item *item;
1510 if (!wd || !label) return NULL;
1511 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_BEFORE, before, data);
1516 * Add a new item to the multibuttonentry after the indicated object
1518 * @param obj The multibuttonentry object
1519 * @param label The label of new item
1520 * @param after The item after which to add it
1521 * @param data The ponter to the data to be attached
1522 * @return A handle to the item added or NULL if not possible
1524 * @ingroup Multibuttonentry
1526 EAPI Elm_Multibuttonentry_Item *
1527 elm_multibuttonentry_item_add_after(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *after, void *data)
1529 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1530 Widget_Data *wd = elm_widget_data_get(obj);
1531 Elm_Multibuttonentry_Item *item;
1532 if (!wd || !label) return NULL;
1533 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_AFTER, after, data);
1538 * Get a list of items in the multibuttonentry
1540 * @param obj The multibuttonentry object
1541 * @return The list of items, or NULL if none
1543 * @ingroup Multibuttonentry
1545 EAPI const Eina_List *
1546 elm_multibuttonentry_items_get(Evas_Object *obj)
1548 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1549 Widget_Data *wd = elm_widget_data_get(obj);
1550 if (!wd) return NULL;
1555 * Get the first item in the multibuttonentry
1557 * @param obj The multibuttonentry object
1558 * @return The first item, or NULL if none
1560 * @ingroup Multibuttonentry
1562 EAPI Elm_Multibuttonentry_Item *
1563 elm_multibuttonentry_item_first_get(Evas_Object *obj)
1565 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1566 Widget_Data *wd = elm_widget_data_get(obj);
1567 if (!wd || !wd->items) return NULL;
1568 return eina_list_data_get(wd->items);
1572 * Get the last item in the multibuttonentry
1574 * @param obj The multibuttonentry object
1575 * @return The last item, or NULL if none
1577 * @ingroup Multibuttonentry
1579 EAPI Elm_Multibuttonentry_Item *
1580 elm_multibuttonentry_item_last_get(Evas_Object *obj)
1582 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1583 Widget_Data *wd = elm_widget_data_get(obj);
1584 if (!wd || !wd->items) return NULL;
1585 return eina_list_data_get(eina_list_last(wd->items));
1589 * Get the selected item in the multibuttonentry
1591 * @param obj The multibuttonentry object
1592 * @return The selected item, or NULL if none
1594 * @ingroup Multibuttonentry
1596 EAPI Elm_Multibuttonentry_Item *
1597 elm_multibuttonentry_item_selected_get(Evas_Object *obj)
1599 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1600 Widget_Data *wd = elm_widget_data_get(obj);
1601 if (!wd || !wd->current) return NULL;
1602 return eina_list_data_get(wd->current);
1606 * Set the selected state of an item
1608 * @param item The item
1610 * @ingroup Multibuttonentry
1613 elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item)
1617 Elm_Multibuttonentry_Item *_item;
1620 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1621 wd = elm_widget_data_get(item->multibuttonentry);
1624 EINA_LIST_FOREACH(wd->items, l, _item)
1627 _select_button(item->multibuttonentry, item->button);
1632 * unselect all of items.
1634 * @param obj The multibuttonentry object
1636 * @ingroup Multibuttonentry
1639 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1641 ELM_CHECK_WIDTYPE(obj, widtype);
1642 Widget_Data *wd = elm_widget_data_get(obj);
1645 _select_button(obj, NULL);
1649 * Remove all items in the multibuttonentry.
1651 * @param obj The multibuttonentry object
1653 * @ingroup Multibuttonentry
1656 elm_multibuttonentry_items_del(Evas_Object *obj)
1658 ELM_CHECK_WIDTYPE(obj, widtype);
1659 Widget_Data *wd = elm_widget_data_get(obj);
1664 Elm_Multibuttonentry_Item *item;
1665 EINA_LIST_FREE(wd->items, item)
1667 elm_box_unpack(wd->box, item->button);
1668 _del_button_obj(obj, item->button);
1678 * Delete a given item
1680 * @param item The item
1682 * @ingroup Multibuttonentry
1685 elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
1688 _del_button_item(item);
1692 * Get the label of a given item
1694 * @param item The item
1695 * @return The label of a given item, or NULL if none
1697 * @ingroup Multibuttonentry
1700 elm_multibuttonentry_item_label_get(Elm_Multibuttonentry_Item *item)
1704 Elm_Multibuttonentry_Item *_item;
1705 if (!item) return NULL;
1706 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1707 wd = elm_widget_data_get(item->multibuttonentry);
1708 if (!wd || !wd->items) return NULL;
1710 EINA_LIST_FOREACH(wd->items, l, _item)
1713 return edje_object_part_text_get(_item->button, "elm.btn.text");
1720 * Set the label of a given item
1722 * @param item The item
1723 * @param label The text label string
1725 * @ingroup Multibuttonentry
1728 elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
1732 Elm_Multibuttonentry_Item *_item;
1733 if (!item || !str) return;
1734 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1735 wd = elm_widget_data_get(item->multibuttonentry);
1736 if (!wd || !wd->items) return;
1738 EINA_LIST_FOREACH(wd->items, l, _item)
1741 edje_object_part_text_set(_item->button, "elm.btn.text", str);
1742 _resize_button(_item->button, &_item->rw, &_item->vw);
1748 * Get the previous item in the multibuttonentry
1750 * @param item The item
1751 * @return The item before the item @p item
1753 * @ingroup Multibuttonentry
1755 EAPI Elm_Multibuttonentry_Item *
1756 elm_multibuttonentry_item_prev(Elm_Multibuttonentry_Item *item)
1760 Elm_Multibuttonentry_Item *_item;
1761 if (!item) return NULL;
1762 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1763 wd = elm_widget_data_get(item->multibuttonentry);
1764 if (!wd || !wd->items) return NULL;
1766 EINA_LIST_FOREACH(wd->items, l, _item)
1769 l = eina_list_prev(l);
1770 if (!l) return NULL;
1771 return eina_list_data_get(l);
1777 * Get the next item in the multibuttonentry
1779 * @param item The item
1780 * @return The item after the item @p item
1782 * @ingroup Multibuttonentry
1784 EAPI Elm_Multibuttonentry_Item *
1785 elm_multibuttonentry_item_next(Elm_Multibuttonentry_Item *item)
1789 Elm_Multibuttonentry_Item *_item;
1790 if (!item) return NULL;
1791 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1792 wd = elm_widget_data_get(item->multibuttonentry);
1793 if (!wd || !wd->items) return NULL;
1795 EINA_LIST_FOREACH(wd->items, l, _item)
1798 l = eina_list_next(l);
1799 if (!l) return NULL;
1800 return eina_list_data_get(l);
1806 * Get private data of item
1808 * @param item The item
1809 * @return The data pointer stored, or NULL if none was stored
1811 * @ingroup Multibuttonentry
1814 elm_multibuttonentry_item_data_get(Elm_Multibuttonentry_Item *item)
1816 if (!item) return NULL;
1821 * Set private data of item
1823 * @param item The item
1824 * @param data The ponter to the data to be attached
1826 * @ingroup Multibuttonentry
1829 elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
1836 * Set the multibuttonentry item_verify_callback function
1838 * @param obj The multibuttonentry object
1839 * @param func The function pointer to be called, it it's NULL, callback function will be deleted.
1840 * @param data user data to be passed to the callback function
1842 * @ingroup Multibuttonentry
1845 elm_multibuttonentry_item_verify_callback_set(Evas_Object *obj, Elm_Multibuttonentry_Item_Verify_Callback func, void *data)
1847 ELM_CHECK_WIDTYPE(obj, widtype);
1848 Widget_Data *wd = elm_widget_data_get(obj);
1851 wd->add_callback = func;
1852 wd->add_callback_data = data;