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 Ecore_IMF_Context *imf_context;
73 Elm_Multibuttonentry_Item_Verify_Callback add_callback;
74 void *add_callback_data;
77 static const char *widtype = NULL;
78 static void _del_hook(Evas_Object *obj);
79 static void _theme_hook(Evas_Object *obj);
80 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
81 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
82 static void _sizing_eval(Evas_Object *obj);
83 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
84 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
85 static void _event_init(Evas_Object *obj);
86 static void _contracted_state_set(Evas_Object *obj, int contracted);
87 static void _view_update(Evas_Object *obj);
88 static void _set_label(Evas_Object *obj, const char* str);
89 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
90 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
91 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
92 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
93 static void _del_button_item(Elm_Multibuttonentry_Item *item);
94 static void _select_button(Evas_Object *obj, Evas_Object *btn);
95 static Elm_Multibuttonentry_Item* _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data);
96 static void _add_button(Evas_Object *obj, char *str);
97 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
98 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
99 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
100 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
101 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
102 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
103 static void _view_init(Evas_Object *obj);
104 static void _set_vis_guidetext(Evas_Object *obj);
105 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
106 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
107 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
110 _del_hook(Evas_Object *obj)
112 Widget_Data *wd = elm_widget_data_get(obj);
117 Elm_Multibuttonentry_Item *item;
118 EINA_LIST_FREE(wd->items, item)
120 _del_button_obj(obj, item->button);
127 if (wd->entry) evas_object_del (wd->entry);
128 if (wd->label) evas_object_del (wd->label);
129 if (wd->guidetext) evas_object_del (wd->guidetext);
130 if (wd->end) evas_object_del (wd->end);
131 if (wd->rectForEnd) evas_object_del(wd->rectForEnd);
135 _theme_hook(Evas_Object *obj)
137 Widget_Data *wd = elm_widget_data_get(obj);
139 Elm_Multibuttonentry_Item *item;
142 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
143 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
144 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
146 EINA_LIST_FOREACH(wd->items, l, item)
149 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
150 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
157 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
159 Widget_Data *wd = elm_widget_data_get(obj);
163 if (elm_widget_focus_get(obj))
165 if ((wd->imf_context) && (wd->current))
167 ecore_imf_context_input_panel_show(wd->imf_context);
168 evas_object_focus_set(obj, EINA_TRUE);
170 else if ((wd->imf_context) && (!wd->current))
172 ecore_imf_context_input_panel_show(wd->imf_context);
173 elm_object_focus(wd->entry);
178 wd->focused = EINA_FALSE;
180 if (wd->imf_context) ecore_imf_context_input_panel_hide(wd->imf_context);
181 evas_object_smart_callback_call(obj, "unfocused", NULL);
182 evas_object_focus_set(obj, EINA_FALSE);
187 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
194 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
196 Widget_Data *wd = elm_widget_data_get(obj);
198 edje_object_signal_emit(wd->base, emission, source);
202 _sizing_eval(Evas_Object *obj)
204 Widget_Data *wd = elm_widget_data_get(obj);
206 Evas_Coord minw = -1, minh = -1;
207 Evas_Coord left, right, top, bottom;
210 evas_object_size_hint_min_get(wd->box, &minw, &minh);
211 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
212 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
214 minw += (left + right);
215 minh += (top + bottom);
217 evas_object_size_hint_min_set(obj, minw, minh);
221 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
223 Widget_Data *wd = elm_widget_data_get(data);
224 if(!wd || !wd->base) return;
226 wd->focused = EINA_TRUE;
229 if (wd->imf_context) ecore_imf_context_input_panel_show(wd->imf_context);
230 evas_object_smart_callback_call(data, "clicked", NULL);
234 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
236 Evas_Object *eo = (Evas_Object *)data;
237 Widget_Data *wd = elm_widget_data_get(data);
243 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
245 Widget_Data *wd = elm_widget_data_get(data);
249 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
251 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
252 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
261 _event_init(Evas_Object *obj)
263 Widget_Data *wd = elm_widget_data_get(obj);
264 if (!wd || !wd->base) return;
268 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
269 edje_object_signal_callback_add(wd->base, "clicked", "*", _signal_mouse_clicked, obj);
270 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
275 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
276 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
281 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
282 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
283 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
284 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
285 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
290 _set_vis_guidetext(Evas_Object *obj)
292 Widget_Data *wd = elm_widget_data_get(obj);
295 elm_box_unpack(wd->box, wd->guidetext);
296 elm_box_unpack(wd->box, wd->entry);
297 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
299 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
300 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
302 evas_object_hide(wd->entry);
303 elm_box_pack_end(wd->box, wd->guidetext);
304 evas_object_show(wd->guidetext);
305 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
309 evas_object_hide(wd->guidetext);
310 elm_box_pack_end(wd->box, wd->entry);
311 evas_object_show(wd->entry);
312 if (elm_widget_focus_get(obj) || wd->focused)
314 elm_object_focus(wd->entry);
315 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
321 _contracted_state_set(Evas_Object *obj, int contracted)
323 Widget_Data *wd = elm_widget_data_get(obj);
325 Elm_Multibuttonentry_Item *item;
326 if (!wd || !wd->box) return;
328 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
329 evas_object_hide(wd->entry);
330 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
331 evas_object_hide(wd->guidetext);
332 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
334 evas_object_hide(wd->rectForEnd);
335 evas_object_hide(wd->end);
336 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
341 Evas_Coord w=0, w_tmp=0;
342 Evas_Coord box_inner_item_width_padding = 0;
344 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
345 // unpack all items and entry
346 elm_box_unpack_all(wd->box);
347 EINA_LIST_FOREACH(wd->items, l, item)
351 evas_object_hide(item->button);
352 item->visible = EINA_FALSE;
356 // pack buttons only 1line
361 elm_box_pack_end(wd->box, wd->label);
362 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
364 w -= box_inner_item_width_padding;
368 int count = eina_list_count(wd->items);
369 Evas_Coord button_min_width = 0;
370 /* Evas_Coord button_min_height = 0; */
371 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
373 const char *size_str;
374 size_str = edje_object_data_get(wd->end, "closed_button_width");
375 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
377 size_str = edje_object_data_get(wd->end, "closed_button_height");
378 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
382 EINA_LIST_FOREACH(wd->items, l, item)
386 int w_label_count = 0;
387 char buf[MAX_STR] = {0,};
389 elm_box_pack_end(wd->box, item->button);
390 evas_object_show(item->button);
391 item->visible = EINA_TRUE;
394 w -= box_inner_item_width_padding;
397 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
401 snprintf(buf, sizeof(buf), "... + %d", count);
402 elm_object_text_set(wd->end, buf);
403 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
406 if (w < 0 || w < w_label_count)
408 elm_box_unpack(wd->box, item->button);
409 evas_object_hide(item->button);
410 item->visible = EINA_FALSE;
413 snprintf(buf, sizeof(buf), "... + %d", count);
414 elm_object_text_set(wd->end, buf);
415 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
417 elm_box_pack_end(wd->box, wd->end);
418 evas_object_show(wd->end);
420 wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
421 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)1);
425 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
427 if (w < button_min_width)
430 Evas_Coord closed_height = 0;
431 const char *height_str = edje_object_data_get(wd->base, "closed_height");
432 if(height_str) closed_height = (Evas_Coord)atoi(height_str);
433 elm_box_unpack(wd->box, item->button);
434 evas_object_hide(item->button);
435 item->visible = EINA_FALSE;
438 rectSize = w - button_min_width;
441 Evas *e = evas_object_evas_get(obj);
442 wd->rectForEnd = evas_object_rectangle_add(e);
443 evas_object_color_set(wd->rectForEnd, 0, 0, 0, 0);
445 evas_object_size_hint_min_set(wd->rectForEnd, rectSize, closed_height);
446 elm_box_pack_end(wd->box, wd->rectForEnd);
447 evas_object_show(wd->rectForEnd);
449 elm_box_pack_end(wd->box, wd->end);
450 evas_object_show(wd->end);
452 wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
453 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)0);
462 // unpack all items and entry
463 elm_box_unpack_all(wd->box);
464 EINA_LIST_FOREACH(wd->items, l, item)
468 evas_object_hide(item->button);
469 item->visible = EINA_FALSE;
472 evas_object_hide(wd->end);
474 if (wd->rectForEnd) evas_object_hide(wd->rectForEnd);
476 // pack buttons only 1line
478 if (wd->label) elm_box_pack_end(wd->box, wd->label);
482 EINA_LIST_FOREACH(wd->items, l, item)
486 elm_box_pack_end(wd->box, item->button);
487 evas_object_show(item->button);
488 item->visible = EINA_TRUE;
492 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
493 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)wd->contracted);
495 if (wd->view_state != MULTIBUTTONENTRY_VIEW_CONTRACTED)
497 _set_vis_guidetext(obj);
502 _view_update(Evas_Object *obj)
504 Evas_Coord width = 1, height = 1;
505 Widget_Data *wd = elm_widget_data_get(obj);
507 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
512 elm_box_unpack(wd->box, wd->label);
513 elm_box_pack_start(wd->box, wd->label);
514 evas_object_size_hint_min_get(wd->label, &width, &height);
519 Evas_Coord guide_text_width = wd->w_box - width;
520 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
523 // update buttons in contracted mode
524 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
525 _contracted_state_set(obj, 1);
528 _set_vis_guidetext(obj);
532 _set_label(Evas_Object *obj, const char* str)
534 Widget_Data *wd = elm_widget_data_get(obj);
535 if (!wd || !str) return;
539 Evas_Coord width, height, sum_width = 0;
540 evas_object_size_hint_min_set(wd->label, 0, 0);
541 evas_object_resize(wd->label, 0, 0);
542 edje_object_part_text_set(wd->label, "mbe.label", str);
544 if (!strcmp(str, ""))
546 /* FIXME: not work yet */
547 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
548 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
553 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
554 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
557 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
560 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
563 evas_object_size_hint_min_set(wd->label, sum_width, height);
565 evas_object_show(wd->label);
570 _set_guidetext(Evas_Object *obj, const char* str)
572 Widget_Data *wd = elm_widget_data_get(obj);
573 if (!wd || !str) return;
577 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
578 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
579 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
580 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
583 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
588 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
590 Widget_Data *wd = elm_widget_data_get(obj);
591 Elm_Multibuttonentry_Item *item = NULL;
595 item = eina_list_data_get(wd->current);
597 if (item && item->button)
601 case MULTIBUTONENTRY_BUTTON_STATE_DEFAULT:
602 edje_object_signal_emit(item->button, "default", "");
605 case MULTIBUTONENTRY_BUTTON_STATE_SELECTED:
606 edje_object_signal_emit(item->button, "focused", "");
607 evas_object_smart_callback_call(obj, "item,selected", item);
610 edje_object_signal_emit(item->button, "default", "");
618 _change_current_button(Evas_Object *obj, Evas_Object *btn)
620 Widget_Data *wd = elm_widget_data_get(obj);
622 Elm_Multibuttonentry_Item *item;
625 // change the state of previous button to "default"
626 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
628 // change the current
629 EINA_LIST_FOREACH(wd->items, l, item)
631 if (item->button == btn)
638 // chagne the state of current button to "focused"
639 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_SELECTED);
644 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
646 Widget_Data *wd = elm_widget_data_get(data);
648 Elm_Multibuttonentry_Item *item = NULL;
649 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
651 _change_current_button(data, obj);
654 if ((item = eina_list_data_get(wd->current)) != NULL)
656 evas_object_smart_callback_call(data, "item,clicked", item);
657 _select_button(data, item->button);
662 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
664 Widget_Data *wd = elm_widget_data_get(obj);
665 if (!wd || !btn) return;
669 evas_object_del(btn);
673 _del_button_item(Elm_Multibuttonentry_Item *item)
676 Elm_Multibuttonentry_Item *_item;
680 Evas_Object *obj = item->multibuttonentry;
681 wd = elm_widget_data_get(obj);
683 EINA_LIST_FOREACH(wd->items, l, _item)
687 wd->items = eina_list_remove(wd->items, _item);
688 elm_box_unpack(wd->box, _item->button);
690 evas_object_smart_callback_call(obj, "item,deleted", _item);
692 _del_button_obj(obj, _item->button);
695 if (wd->current == l)
700 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
701 _contracted_state_set(obj, 1);
703 if (!eina_list_count(wd->items))
704 _set_vis_guidetext(obj);
708 _select_button(Evas_Object *obj, Evas_Object *btn)
710 Widget_Data *wd = elm_widget_data_get(obj);
715 _change_current_button(obj, btn);
716 if (elm_widget_focus_get(obj))
718 elm_object_unfocus(wd->entry);
719 evas_object_focus_set(btn, EINA_TRUE);
724 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
725 if (elm_widget_focus_get(obj))
726 elm_object_focus(wd->entry);
731 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
734 Evas_Coord w_text, h_btn, padding_outer, padding_inner;
735 Evas_Coord w_btn = 0, button_max_width = 0;
736 const char *size_str;
738 size_str = edje_object_data_get(btn, "button_max_size");
739 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
741 // decide the size of button
742 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
743 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
744 edje_object_part_geometry_get(btn, "left.padding", NULL, NULL, &padding_outer, NULL);
745 edje_object_part_geometry_get(btn, "left.inner.padding", NULL, NULL, &padding_inner, NULL);
746 w_btn = w_text + 2*padding_outer + 2*padding_inner;
749 vw = (button_max_width < w_btn) ? button_max_width : w_btn;
752 evas_object_resize(btn, vw, h_btn);
753 evas_object_size_hint_min_set(btn, vw, h_btn);
755 if(realw) *realw = rw;
756 if(vieww) *vieww = vw;
759 static Elm_Multibuttonentry_Item*
760 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
762 Elm_Multibuttonentry_Item *item;
764 Evas_Coord width, height;
765 char *str_utf8 = NULL;
767 Widget_Data *wd = elm_widget_data_get(obj);
769 if (!wd || !wd->box || !wd->entry) return NULL;
771 if ((wd->add_callback) && !wd->add_callback(obj, str, data, wd->add_callback_data)) return NULL;
773 //entry is cleared when text is made to button
774 elm_entry_entry_set(wd->entry, "");
777 btn = edje_object_add(evas_object_evas_get(obj));
778 str_utf8 = elm_entry_markup_to_utf8(str);
780 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
781 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
782 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
783 evas_object_size_hint_min_set(btn, width, height);
784 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
785 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
786 evas_object_show(btn);
789 item = ELM_NEW(Elm_Multibuttonentry_Item);
793 _resize_button(btn, &rw, &vw);
794 item->multibuttonentry = obj;
799 item->visible = EINA_TRUE;
803 case MULTIBUTONENTRY_POS_START:
804 wd->items = eina_list_prepend(wd->items, item);
805 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
807 elm_widget_sub_object_add(obj, btn);
808 _contracted_state_set(obj, 1);
813 elm_box_pack_after(wd->box, btn, wd->label);
815 elm_box_pack_start(wd->box, btn);
816 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
817 _set_vis_guidetext(obj);
820 case MULTIBUTONENTRY_POS_END:
821 wd->items = eina_list_append(wd->items, item);
822 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
824 elm_widget_sub_object_add(obj, btn);
825 evas_object_hide(btn);
829 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
830 _set_vis_guidetext(obj);
832 elm_box_pack_before(wd->box, btn, wd->entry);
834 elm_box_pack_end(wd->box, btn);
837 case MULTIBUTONENTRY_POS_BEFORE:
839 wd->items = eina_list_prepend_relative(wd->items, item, reference);
841 wd->items = eina_list_append(wd->items, item);
842 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
844 elm_widget_sub_object_add(obj, btn);
845 evas_object_hide(btn);
846 _contracted_state_set(obj, 1);
851 elm_box_pack_before(wd->box, btn, reference->button);
854 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
855 _set_vis_guidetext(obj);
857 elm_box_pack_before(wd->box, btn, wd->entry);
859 elm_box_pack_end(wd->box, btn);
863 case MULTIBUTONENTRY_POS_AFTER:
865 wd->items = eina_list_append_relative(wd->items, item, reference);
867 wd->items = eina_list_append(wd->items, item);
868 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
870 elm_widget_sub_object_add(obj, btn);
871 _contracted_state_set(obj, 1);
876 elm_box_pack_after(wd->box, btn, reference->button);
879 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
880 _set_vis_guidetext(obj);
882 elm_box_pack_before(wd->box, btn, wd->entry);
884 elm_box_pack_end(wd->box, btn);
892 evas_object_smart_callback_call(obj, "item,added", item);
900 _add_button(Evas_Object *obj, char *str)
902 Widget_Data *wd = elm_widget_data_get(obj);
906 _add_button_item(obj, str, MULTIBUTONENTRY_POS_END, NULL, NULL);
910 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
912 Widget_Data *wd = elm_widget_data_get(data);
913 Elm_Multibuttonentry_Item *item = NULL;
915 static char str[MAX_STR];
917 if (!wd || !wd->base || !wd->box) return;
919 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
920 str[MAX_STR - 1] = 0;
922 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
924 if (wd->last_btn_select)
926 if ((wd->current) && ( (strcmp (ev->keyname, "BackSpace") == 0) || (strcmp (ev->keyname, "BackSpace (") == 0)))
928 item = eina_list_data_get(wd->current);
931 _del_button_item(item);
932 elm_object_focus(wd->entry);
935 else if ((((!wd->current) && (wd->n_str == 0) && (strcmp (ev->keyname, "BackSpace") == 0))
936 || (strcmp (ev->keyname, "BackSpace (") == 0)))
938 item = eina_list_data_get(eina_list_last(wd->items));
940 _select_button(data, item->button);
944 wd->last_btn_select = EINA_TRUE;
948 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
950 Widget_Data *wd = elm_widget_data_get(data);
951 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
955 if ( (wd->n_str == 1) && (strcmp (ev->keyname, "BackSpace") == 0 || (strcmp (ev->keyname, "BackSpace (") == 0 )))
956 wd->last_btn_select = EINA_FALSE;
960 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
962 Widget_Data *wd = elm_widget_data_get(data);
963 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
964 static char str[MAX_STR];
966 if (!wd || !wd->base || !wd->box) return;
968 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
969 str[MAX_STR - 1] = 0;
971 if ( (strcmp (str, "") != 0) && (strcmp (ev->keyname, "KP_Enter") == 0 || strcmp (ev->keyname, "Return") == 0 ))
973 _add_button(data, str);
980 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
982 Widget_Data *wd = elm_widget_data_get(data);
985 _change_current_button_state(data, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
989 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
991 Widget_Data *wd = elm_widget_data_get(data);
994 static char str[MAX_STR];
996 strncpy(str,elm_entry_entry_get(wd->entry), MAX_STR);
1000 _add_button(data, str);
1004 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1006 Widget_Data *wd = elm_widget_data_get(data);
1009 static char str[MAX_STR];
1011 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
1012 str[MAX_STR -1] = 0;
1014 wd->n_str = strlen(str);
1018 _view_init(Evas_Object *obj)
1020 Widget_Data *wd = elm_widget_data_get(obj);
1025 if (! (wd->box = elm_box_add (obj))) return;
1026 elm_widget_sub_object_add(obj, wd->box);
1027 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1028 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1029 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1034 if (!(wd->label = edje_object_add(evas_object_evas_get(obj)))) return;
1035 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1036 _set_label(obj, "");
1037 elm_widget_sub_object_add(obj, wd->label);
1042 if (! (wd->entry = elm_entry_add (obj))) return;
1043 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1044 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1045 elm_entry_entry_set(wd->entry, "");
1046 elm_entry_cursor_end_set(wd->entry);
1047 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1048 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1049 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1050 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1051 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1052 evas_object_show(wd->entry);
1053 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1054 wd->imf_context = elm_entry_imf_context_get(wd->entry);
1059 const char *end_type = edje_object_data_get(wd->base, "closed_button_type");
1060 if (!end_type || !strcmp(end_type, "label"))
1062 if (! (wd->end = elm_label_add (obj))) return;
1063 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1064 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1068 const char *size_str;
1069 if (!(wd->end = edje_object_add(evas_object_evas_get(obj)))) return;
1070 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1071 Evas_Coord button_min_width = 0;
1072 Evas_Coord button_min_height = 0;
1074 size_str = edje_object_data_get(wd->end, "closed_button_width");
1075 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
1076 size_str = edje_object_data_get(wd->end, "closed_button_height");
1077 if(size_str) button_min_height = (Evas_Coord)atoi(size_str);
1079 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1080 evas_object_size_hint_min_set(wd->end, button_min_width, button_min_height);
1081 elm_widget_sub_object_add(obj, wd->end);
1087 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1089 Evas_Coord minw, minh, maxw, maxh, mnw, mnh, ww;
1090 Evas_Coord w, cw = 0, cmaxh = 0;
1092 Evas_Object_Box_Option *opt;
1095 /* FIXME: need to calc max */
1101 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1102 evas_object_size_hint_min_get(box, &minw, NULL);
1104 EINA_LIST_FOREACH(priv->children, l, opt)
1106 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1107 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1111 if (mnw != -1 && (w - cw) >= mnw)
1126 if (cmaxh < mnh) cmaxh = mnh;
1131 evas_object_size_hint_min_set(box, minw, minh);
1135 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1137 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1139 Evas_Object_Box_Option *opt;
1143 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1145 EINA_LIST_FOREACH(priv->children, l, opt)
1147 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1148 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1152 if (mnw != -1 && (w - cw) >= mnw)
1162 if (index > obj_index) return cmaxh;
1168 if (cmaxh < mnh) cmaxh = mnh;
1177 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1179 Evas_Coord x, y, w, h, xx, yy;
1182 Evas_Coord minw, minh, wdif, hdif;
1185 Evas_Object_Box_Option *opt;
1187 _calculate_box_min_size(o, priv);
1189 evas_object_geometry_get(o, &x, &y, &w, &h);
1191 evas_object_size_hint_min_get(o, &minw, &minh);
1192 evas_object_size_hint_align_get(o, &ax, &ay);
1193 count = eina_list_count(priv->children);
1196 x = x + ((w - minw) * (1.0 - ax));
1201 y = y + ((h - minh) * (1.0 - ay));
1210 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1212 EINA_LIST_FOREACH(priv->children, l, opt)
1214 Evas_Coord mnw, mnh, mxw, mxh;
1219 evas_object_size_hint_align_get(obj, &ax, &ay);
1220 evas_object_size_hint_weight_get(obj, &wx, &wy);
1221 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1222 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1225 if (ax == -1.0) {fw = 1; ax = 0.5;}
1226 if (ay == -1.0) {fh = 1; ay = 0.5;}
1227 if (wx > 0.0) xw = 1;
1228 if (wy > 0.0) xh = 1;
1229 Evas_Coord ww, hh, ow, oh;
1233 if (mnw != -1 && (w - cw) >= mnw)
1240 hh = _calculate_item_max_height(o, priv, obj_index);
1244 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1247 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1256 evas_object_move(obj,
1257 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1258 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1259 evas_object_resize(obj, ow, oh);
1262 if (cmaxh < hh) cmaxh = hh;
1269 * Add a new multibuttonentry to the parent
1271 * @param parent The parent object
1272 * @return The new object or NULL if it cannot be created
1274 * @ingroup Multibuttonentry
1277 elm_multibuttonentry_add(Evas_Object *parent)
1282 if (!parent) return NULL;
1284 wd = ELM_NEW(Widget_Data);
1285 e = evas_object_evas_get(parent);
1286 if (!e) return NULL;
1287 obj = elm_widget_add(e);
1288 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1289 elm_widget_type_set(obj, "multibuttonentry");
1290 elm_widget_sub_object_add(parent, obj);
1291 elm_widget_data_set(obj, wd);
1293 elm_widget_del_hook_set(obj, _del_hook);
1294 elm_widget_theme_hook_set(obj, _theme_hook);
1295 elm_widget_event_hook_set(obj, _event_hook);
1296 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1297 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1299 wd->base = edje_object_add(e);
1300 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1301 elm_widget_resize_object_set(obj, wd->base);
1302 elm_widget_can_focus_set(obj,EINA_TRUE);
1304 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1305 wd->focused = EINA_FALSE;
1306 wd->last_btn_select = EINA_TRUE;
1308 wd->rectForEnd = NULL;
1309 wd->imf_context = NULL;
1310 wd->add_callback = NULL;
1311 wd->add_callback_data = NULL;
1320 * Get the entry of the multibuttonentry object
1322 * @param obj The multibuttonentry object
1323 * @return The entry object, or NULL if none
1325 * @ingroup Multibuttonentry
1328 elm_multibuttonentry_entry_get(Evas_Object *obj)
1330 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1331 Widget_Data *wd = elm_widget_data_get(obj);
1332 if (!wd) return NULL;
1340 * @param obj The multibuttonentry object
1341 * @return The label, or NULL if none
1343 * @ingroup Multibuttonentry
1346 elm_multibuttonentry_label_get(Evas_Object *obj)
1348 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1349 Widget_Data *wd = elm_widget_data_get(obj);
1350 if (!wd) return NULL;
1351 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1358 * @param obj The multibuttonentry object
1359 * @param label The text label string
1361 * @ingroup Multibuttonentry
1364 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1366 ELM_CHECK_WIDTYPE(obj, widtype);
1367 Widget_Data *wd = elm_widget_data_get(obj);
1370 _set_label(obj, label);
1372 _set_label(obj, "");
1376 * Get the guide text
1378 * @param obj The multibuttonentry object
1379 * @return The guide text, or NULL if none
1381 * @ingroup Multibuttonentry
1384 elm_multibuttonentry_guide_text_get(Evas_Object *obj)
1386 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1387 Widget_Data *wd = elm_widget_data_get(obj);
1388 if (!wd) return NULL;
1389 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1394 * Set the guide text
1396 * @param obj The multibuttonentry object
1397 * @param label The guide text string
1399 * @ingroup Multibuttonentry
1402 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1404 ELM_CHECK_WIDTYPE(obj, widtype);
1405 Widget_Data *wd = elm_widget_data_get(obj);
1408 _set_guidetext(obj, guidetext);
1410 _set_guidetext(obj, "");
1415 * Get the value of contracted state.
1417 * @param obj The multibuttonentry object
1418 * @param the value of contracted state.
1420 * @ingroup Multibuttonentry
1423 elm_multibuttonentry_contracted_state_get(Evas_Object *obj)
1425 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1426 Widget_Data *wd = elm_widget_data_get(obj);
1428 return wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED ? 1 : 0;
1432 * Set/Unset the multibuttonentry to contracted state of single line
1434 * @param obj The multibuttonentry object
1435 * @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.
1437 * @ingroup Multibuttonentry
1440 elm_multibuttonentry_contracted_state_set(Evas_Object *obj, int contracted)
1442 ELM_CHECK_WIDTYPE(obj, widtype);
1443 Widget_Data *wd = elm_widget_data_get(obj);
1444 if (!wd || !wd->box ||
1445 ((wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) ? 1 : 0) == contracted) return;
1446 _contracted_state_set(obj, contracted);
1450 * Prepend a new item to the multibuttonentry
1452 * @param obj The multibuttonentry object
1453 * @param label The label of new item
1454 * @param data The ponter to the data to be attached
1455 * @return A handle to the item added or NULL if not possible
1457 * @ingroup Multibuttonentry
1459 EAPI Elm_Multibuttonentry_Item *
1460 elm_multibuttonentry_item_add_start(Evas_Object *obj, const char *label, void *data)
1462 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1463 Widget_Data *wd = elm_widget_data_get(obj);
1464 Elm_Multibuttonentry_Item *item;
1465 if (!wd || !label) return NULL;
1466 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_START, NULL, data);
1471 * Append a new item to the multibuttonentry
1473 * @param obj The multibuttonentry object
1474 * @param label The label of new item
1475 * @param data The ponter to the data to be attached
1476 * @return A handle to the item added or NULL if not possible
1478 * @ingroup Multibuttonentry
1480 EAPI Elm_Multibuttonentry_Item *
1481 elm_multibuttonentry_item_add_end(Evas_Object *obj, const char *label, void *data)
1483 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1484 Widget_Data *wd = elm_widget_data_get(obj);
1485 Elm_Multibuttonentry_Item *item;
1486 if (!wd || !label) return NULL;
1487 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_END, NULL, data);
1492 * Add a new item to the multibuttonentry before the indicated object
1495 * @param obj The multibuttonentry object
1496 * @param label The label of new item
1497 * @param before The item before which to add it
1498 * @param data The ponter to the data to be attached
1499 * @return A handle to the item added or NULL if not possible
1501 * @ingroup Multibuttonentry
1503 EAPI Elm_Multibuttonentry_Item *
1504 elm_multibuttonentry_item_add_before(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *before, void *data)
1506 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1507 Widget_Data *wd = elm_widget_data_get(obj);
1508 Elm_Multibuttonentry_Item *item;
1509 if (!wd || !label) return NULL;
1510 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_BEFORE, before, data);
1515 * Add a new item to the multibuttonentry after the indicated object
1517 * @param obj The multibuttonentry object
1518 * @param label The label of new item
1519 * @param after The item after which to add it
1520 * @param data The ponter to the data to be attached
1521 * @return A handle to the item added or NULL if not possible
1523 * @ingroup Multibuttonentry
1525 EAPI Elm_Multibuttonentry_Item *
1526 elm_multibuttonentry_item_add_after(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *after, void *data)
1528 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1529 Widget_Data *wd = elm_widget_data_get(obj);
1530 Elm_Multibuttonentry_Item *item;
1531 if (!wd || !label) return NULL;
1532 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_AFTER, after, data);
1537 * Get a list of items in the multibuttonentry
1539 * @param obj The multibuttonentry object
1540 * @return The list of items, or NULL if none
1542 * @ingroup Multibuttonentry
1544 EAPI const Eina_List *
1545 elm_multibuttonentry_items_get(Evas_Object *obj)
1547 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1548 Widget_Data *wd = elm_widget_data_get(obj);
1549 if (!wd) return NULL;
1554 * Get the first item in the multibuttonentry
1556 * @param obj The multibuttonentry object
1557 * @return The first item, or NULL if none
1559 * @ingroup Multibuttonentry
1561 EAPI Elm_Multibuttonentry_Item *
1562 elm_multibuttonentry_item_first_get(Evas_Object *obj)
1564 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1565 Widget_Data *wd = elm_widget_data_get(obj);
1566 if (!wd || !wd->items) return NULL;
1567 return eina_list_data_get(wd->items);
1571 * Get the last item in the multibuttonentry
1573 * @param obj The multibuttonentry object
1574 * @return The last item, or NULL if none
1576 * @ingroup Multibuttonentry
1578 EAPI Elm_Multibuttonentry_Item *
1579 elm_multibuttonentry_item_last_get(Evas_Object *obj)
1581 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1582 Widget_Data *wd = elm_widget_data_get(obj);
1583 if (!wd || !wd->items) return NULL;
1584 return eina_list_data_get(eina_list_last(wd->items));
1588 * Get the selected item in the multibuttonentry
1590 * @param obj The multibuttonentry object
1591 * @return The selected item, or NULL if none
1593 * @ingroup Multibuttonentry
1595 EAPI Elm_Multibuttonentry_Item *
1596 elm_multibuttonentry_item_selected_get(Evas_Object *obj)
1598 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1599 Widget_Data *wd = elm_widget_data_get(obj);
1600 if (!wd || !wd->current) return NULL;
1601 return eina_list_data_get(wd->current);
1605 * Set the selected state of an item
1607 * @param item The item
1609 * @ingroup Multibuttonentry
1612 elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item)
1616 Elm_Multibuttonentry_Item *_item;
1619 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1620 wd = elm_widget_data_get(item->multibuttonentry);
1623 EINA_LIST_FOREACH(wd->items, l, _item)
1626 _select_button(item->multibuttonentry, item->button);
1631 * unselect all of items.
1633 * @param obj The multibuttonentry object
1635 * @ingroup Multibuttonentry
1638 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1640 ELM_CHECK_WIDTYPE(obj, widtype);
1641 Widget_Data *wd = elm_widget_data_get(obj);
1644 _select_button(obj, NULL);
1648 * Remove all items in the multibuttonentry.
1650 * @param obj The multibuttonentry object
1652 * @ingroup Multibuttonentry
1655 elm_multibuttonentry_items_del(Evas_Object *obj)
1657 ELM_CHECK_WIDTYPE(obj, widtype);
1658 Widget_Data *wd = elm_widget_data_get(obj);
1663 Elm_Multibuttonentry_Item *item;
1664 EINA_LIST_FREE(wd->items, item)
1666 elm_box_unpack(wd->box, item->button);
1667 _del_button_obj(obj, item->button);
1677 * Delete a given item
1679 * @param item The item
1681 * @ingroup Multibuttonentry
1684 elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
1687 _del_button_item(item);
1691 * Get the label of a given item
1693 * @param item The item
1694 * @return The label of a given item, or NULL if none
1696 * @ingroup Multibuttonentry
1699 elm_multibuttonentry_item_label_get(Elm_Multibuttonentry_Item *item)
1703 Elm_Multibuttonentry_Item *_item;
1704 if (!item) return NULL;
1705 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1706 wd = elm_widget_data_get(item->multibuttonentry);
1707 if (!wd || !wd->items) return NULL;
1709 EINA_LIST_FOREACH(wd->items, l, _item)
1712 return edje_object_part_text_get(_item->button, "elm.btn.text");
1719 * Set the label of a given item
1721 * @param item The item
1722 * @param label The text label string
1724 * @ingroup Multibuttonentry
1727 elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
1731 Elm_Multibuttonentry_Item *_item;
1732 if (!item || !str) return;
1733 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1734 wd = elm_widget_data_get(item->multibuttonentry);
1735 if (!wd || !wd->items) return;
1737 EINA_LIST_FOREACH(wd->items, l, _item)
1740 edje_object_part_text_set(_item->button, "elm.btn.text", str);
1741 _resize_button(_item->button, &_item->rw, &_item->vw);
1747 * Get the previous item in the multibuttonentry
1749 * @param item The item
1750 * @return The item before the item @p item
1752 * @ingroup Multibuttonentry
1754 EAPI Elm_Multibuttonentry_Item *
1755 elm_multibuttonentry_item_prev(Elm_Multibuttonentry_Item *item)
1759 Elm_Multibuttonentry_Item *_item;
1760 if (!item) return NULL;
1761 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1762 wd = elm_widget_data_get(item->multibuttonentry);
1763 if (!wd || !wd->items) return NULL;
1765 EINA_LIST_FOREACH(wd->items, l, _item)
1768 l = eina_list_prev(l);
1769 if (!l) return NULL;
1770 return eina_list_data_get(l);
1776 * Get the next item in the multibuttonentry
1778 * @param item The item
1779 * @return The item after the item @p item
1781 * @ingroup Multibuttonentry
1783 EAPI Elm_Multibuttonentry_Item *
1784 elm_multibuttonentry_item_next(Elm_Multibuttonentry_Item *item)
1788 Elm_Multibuttonentry_Item *_item;
1789 if (!item) return NULL;
1790 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1791 wd = elm_widget_data_get(item->multibuttonentry);
1792 if (!wd || !wd->items) return NULL;
1794 EINA_LIST_FOREACH(wd->items, l, _item)
1797 l = eina_list_next(l);
1798 if (!l) return NULL;
1799 return eina_list_data_get(l);
1805 * Get private data of item
1807 * @param item The item
1808 * @return The data pointer stored, or NULL if none was stored
1810 * @ingroup Multibuttonentry
1813 elm_multibuttonentry_item_data_get(Elm_Multibuttonentry_Item *item)
1815 if (!item) return NULL;
1820 * Set private data of item
1822 * @param item The item
1823 * @param data The ponter to the data to be attached
1825 * @ingroup Multibuttonentry
1828 elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
1835 * Set the multibuttonentry item_verify_callback function
1837 * @param obj The multibuttonentry object
1838 * @param func The function pointer to be called, it it's NULL, callback function will be deleted.
1839 * @param data user data to be passed to the callback function
1841 * @ingroup Multibuttonentry
1844 elm_multibuttonentry_item_verify_callback_set(Evas_Object *obj, Elm_Multibuttonentry_Item_Verify_Callback func, void *data)
1846 ELM_CHECK_WIDTYPE(obj, widtype);
1847 Widget_Data *wd = elm_widget_data_get(obj);
1850 wd->add_callback = func;
1851 wd->add_callback_data = data;