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 _del_button(Evas_Object *obj);
95 static void _select_button(Evas_Object *obj, Evas_Object *btn);
96 static Elm_Multibuttonentry_Item* _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data);
97 static void _add_button(Evas_Object *obj, char *str);
98 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
99 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
100 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
101 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
102 static void _entry_focus_in_cb(void *data, Evas *e, __UNUSED__ void *event_info);
103 static void _entry_focus_out_cb(void *data, Evas *e, __UNUSED__ void *event_info);
104 static void _view_init(Evas_Object *obj);
105 static void _set_vis_guidetext(Evas_Object *obj);
106 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
107 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
108 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
111 _del_hook(Evas_Object *obj)
113 Widget_Data *wd = elm_widget_data_get(obj);
118 Elm_Multibuttonentry_Item *item;
119 EINA_LIST_FREE(wd->items, item)
121 _del_button_obj(obj, item->button);
128 if (wd->entry) evas_object_del (wd->entry);
129 if (wd->label) evas_object_del (wd->label);
130 if (wd->guidetext) evas_object_del (wd->guidetext);
131 if (wd->end) evas_object_del (wd->end);
132 if (wd->rectForEnd) evas_object_del(wd->rectForEnd);
136 _theme_hook(Evas_Object *obj)
138 Widget_Data *wd = elm_widget_data_get(obj);
140 Elm_Multibuttonentry_Item *item;
143 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
144 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
145 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
147 EINA_LIST_FOREACH(wd->items, l, item)
150 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
151 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
158 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
160 Widget_Data *wd = elm_widget_data_get(obj);
164 if (elm_widget_focus_get(obj))
166 if (wd->imf_context) ecore_imf_context_input_panel_show(wd->imf_context);
167 evas_object_focus_set(obj, EINA_TRUE);
171 wd->focused = EINA_FALSE;
173 evas_object_smart_callback_call(obj, "unfocused", NULL);
174 if (wd->imf_context) ecore_imf_context_input_panel_hide(wd->imf_context);
175 evas_object_focus_set(obj, EINA_FALSE);
180 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
187 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
189 Widget_Data *wd = elm_widget_data_get(obj);
191 edje_object_signal_emit(wd->base, emission, source);
195 _sizing_eval(Evas_Object *obj)
197 Widget_Data *wd = elm_widget_data_get(obj);
198 Evas_Coord minw = -1, minh = -1;
199 Evas_Coord left, right, top, bottom;
202 evas_object_size_hint_min_get(wd->box, &minw, &minh);
203 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
204 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
206 minw += (left + right);
207 minh += (top + bottom);
209 evas_object_size_hint_min_set(obj, minw, minh);
213 _signal_mouse_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
215 Widget_Data *wd = elm_widget_data_get(data);
216 if(!wd || !wd->base) return;
218 wd->focused = EINA_TRUE;
221 if (wd->imf_context) ecore_imf_context_input_panel_show(wd->imf_context);
222 evas_object_smart_callback_call(data, "clicked", NULL);
226 _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event)
228 Evas_Object *eo = (Evas_Object *)data;
229 Widget_Data *wd = elm_widget_data_get(data);
235 _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event)
237 Widget_Data *wd = elm_widget_data_get(data);
241 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
243 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
244 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
254 _event_init(Evas_Object *obj)
256 Widget_Data *wd = elm_widget_data_get(obj);
257 if (!wd || !wd->base) return;
261 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
262 edje_object_signal_callback_add(wd->base, "clicked", "*", _signal_mouse_clicked, obj);
263 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
268 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
269 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
274 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
275 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
276 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
277 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
278 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
283 _set_vis_guidetext(Evas_Object *obj)
285 Widget_Data *wd = elm_widget_data_get(obj);
287 elm_box_unpack(wd->box, wd->guidetext);
288 elm_box_unpack(wd->box, wd->entry);
289 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
291 if (wd && !eina_list_count(wd->items) && wd->guidetext
292 && !elm_widget_focus_get(obj) && !wd->focused)
294 evas_object_hide(wd->entry);
295 elm_box_pack_end(wd->box, wd->guidetext);
296 evas_object_show(wd->guidetext);
297 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
301 evas_object_hide(wd->guidetext);
302 elm_box_pack_end(wd->box, wd->entry);
303 evas_object_show(wd->entry);
304 if (elm_widget_focus_get(obj) || wd->focused)
306 elm_object_focus(wd->entry);
307 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
313 _contracted_state_set(Evas_Object *obj, int contracted)
315 Widget_Data *wd = elm_widget_data_get(obj);
317 Elm_Multibuttonentry_Item *item;
318 if (!wd || !wd->box) return;
320 elm_scrolled_entry_entry_set(wd->entry, "");
322 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
323 evas_object_hide(wd->entry);
324 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
325 evas_object_hide(wd->guidetext);
326 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
328 evas_object_hide(wd->rectForEnd);
329 evas_object_hide(wd->end);
330 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
335 Evas_Coord w=0, w_tmp=0;
336 Evas_Coord box_inner_item_width_padding = 0;
338 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
339 // unpack all items and entry
340 elm_box_unpack_all(wd->box);
341 EINA_LIST_FOREACH(wd->items, l, item)
345 evas_object_hide(item->button);
346 item->visible = EINA_FALSE;
350 // pack buttons only 1line
355 elm_box_pack_end(wd->box, wd->label);
356 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
358 w -= box_inner_item_width_padding;
362 int count = eina_list_count(wd->items);
363 Evas_Coord button_min_width = 0;
364 /* Evas_Coord button_min_height = 0; */
365 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
367 const char *size_str;
368 size_str = edje_object_data_get(wd->end, "closed_button_width");
369 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
371 size_str = edje_object_data_get(wd->end, "closed_button_height");
372 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
376 EINA_LIST_FOREACH(wd->items, l, item)
380 int w_label_count = 0;
381 char buf[MAX_STR] = {0,};
383 elm_box_pack_end(wd->box, item->button);
384 evas_object_show(item->button);
385 item->visible = EINA_TRUE;
388 w -= box_inner_item_width_padding;
391 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
395 snprintf(buf, sizeof(buf), "... + %d", count);
396 elm_label_label_set(wd->end, buf);
397 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
400 if (w < 0 || w < w_label_count)
402 elm_box_unpack(wd->box, item->button);
403 evas_object_hide(item->button);
404 item->visible = EINA_FALSE;
407 snprintf(buf, sizeof(buf), "... + %d", count);
408 elm_label_label_set(wd->end, buf);
409 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
411 elm_box_pack_end(wd->box, wd->end);
412 evas_object_show(wd->end);
414 wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
415 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)1);
419 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
421 if (w < button_min_width)
424 Evas_Coord closed_height = 0;
425 const char *height_str = edje_object_data_get(wd->base, "closed_height");
426 if(height_str) closed_height = (Evas_Coord)atoi(height_str);
427 elm_box_unpack(wd->box, item->button);
428 evas_object_hide(item->button);
429 item->visible = EINA_FALSE;
432 rectSize = w - button_min_width;
435 Evas *e = evas_object_evas_get(obj);
436 wd->rectForEnd = evas_object_rectangle_add(e);
437 evas_object_color_set(wd->rectForEnd, 0, 0, 0, 0);
439 evas_object_size_hint_min_set(wd->rectForEnd, rectSize, closed_height);
440 elm_box_pack_end(wd->box, wd->rectForEnd);
441 evas_object_show(wd->rectForEnd);
443 elm_box_pack_end(wd->box, wd->end);
444 evas_object_show(wd->end);
446 wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
447 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)0);
456 // unpack all items and entry
457 elm_box_unpack_all(wd->box);
458 EINA_LIST_FOREACH(wd->items, l, item)
462 evas_object_hide(item->button);
463 item->visible = EINA_FALSE;
466 evas_object_hide(wd->end);
468 if (wd->rectForEnd) evas_object_hide(wd->rectForEnd);
470 // pack buttons only 1line
472 if (wd->label) elm_box_pack_end(wd->box, wd->label);
476 EINA_LIST_FOREACH(wd->items, l, item)
480 elm_box_pack_end(wd->box, item->button);
481 evas_object_show(item->button);
482 item->visible = EINA_TRUE;
486 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
487 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)wd->contracted);
489 if (wd->view_state != MULTIBUTTONENTRY_VIEW_CONTRACTED)
491 _set_vis_guidetext(obj);
496 _view_update(Evas_Object *obj)
498 Evas_Coord width = 1, height = 1;
499 Widget_Data *wd = elm_widget_data_get(obj);
501 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
506 elm_box_unpack(wd->box, wd->label);
507 elm_box_pack_start(wd->box, wd->label);
508 evas_object_size_hint_min_get(wd->label, &width, &height);
513 Evas_Coord guide_text_width = wd->w_box - width;
514 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
517 // update buttons in contracted mode
518 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
519 _contracted_state_set(obj, 1);
522 _set_vis_guidetext(obj);
526 _set_label(Evas_Object *obj, const char* str)
528 Widget_Data *wd = elm_widget_data_get(obj);
529 if (!wd || !str) return;
533 Evas_Coord width, height, sum_width = 0;
534 evas_object_size_hint_min_set(wd->label, 0, 0);
535 evas_object_resize(wd->label, 0, 0);
536 edje_object_part_text_set(wd->label, "mbe.label", str);
538 if (!strcmp(str, ""))
540 /* FIXME: not work yet */
541 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
542 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
547 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
548 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
551 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
554 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
557 evas_object_size_hint_min_set(wd->label, sum_width, height);
559 evas_object_show(wd->label);
564 _set_guidetext(Evas_Object *obj, const char* str)
566 Widget_Data *wd = elm_widget_data_get(obj);
567 if (!wd || !str) return;
571 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
572 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
573 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
574 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
577 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
582 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
584 Widget_Data *wd = elm_widget_data_get(obj);
585 Elm_Multibuttonentry_Item *item = NULL;
589 item = eina_list_data_get(wd->current);
591 if (item && item->button)
595 case MULTIBUTONENTRY_BUTTON_STATE_DEFAULT:
596 edje_object_signal_emit(item->button, "default", "");
599 case MULTIBUTONENTRY_BUTTON_STATE_SELECTED:
600 edje_object_signal_emit(item->button, "focused", "");
601 evas_object_smart_callback_call(obj, "item,selected", item);
604 edje_object_signal_emit(item->button, "default", "");
612 _change_current_button(Evas_Object *obj, Evas_Object *btn)
614 Widget_Data *wd = elm_widget_data_get(obj);
616 Elm_Multibuttonentry_Item *item;
619 // change the state of previous button to "default"
620 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
622 // change the current
623 EINA_LIST_FOREACH(wd->items, l, item)
625 if (item->button == btn)
632 // chagne the state of current button to "focused"
633 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_SELECTED);
638 _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
640 Widget_Data *wd = elm_widget_data_get(data);
642 Elm_Multibuttonentry_Item *item = NULL;
643 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
645 _change_current_button(data, obj);
648 if ((item = eina_list_data_get(wd->current)) != NULL)
650 evas_object_smart_callback_call(data, "item,clicked", item);
651 _select_button(data, item->button);
656 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
658 Widget_Data *wd = elm_widget_data_get(obj);
659 if (!wd || !btn) return;
663 evas_object_del(btn);
667 _del_button_item(Elm_Multibuttonentry_Item *item)
670 Elm_Multibuttonentry_Item *_item;
674 Evas_Object *obj = item->multibuttonentry;
675 wd = elm_widget_data_get(obj);
677 EINA_LIST_FOREACH(wd->items, l, _item)
681 wd->items = eina_list_remove(wd->items, _item);
682 elm_box_unpack(wd->box, _item->button);
684 evas_object_smart_callback_call(obj, "item,deleted", _item);
686 _del_button_obj(obj, _item->button);
689 if (wd->current == l)
694 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
695 _contracted_state_set(obj, 1);
697 if (!eina_list_count(wd->items))
698 _set_vis_guidetext(obj);
702 _select_button(Evas_Object *obj, Evas_Object *btn)
704 Widget_Data *wd = elm_widget_data_get(obj);
705 Elm_Multibuttonentry_Item *item;
711 _change_current_button(obj, btn);
712 if (elm_widget_focus_get(obj))
714 elm_object_unfocus(wd->entry);
715 evas_object_focus_set(btn, EINA_TRUE);
720 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
721 if (elm_widget_focus_get(obj))
722 elm_object_focus(wd->entry);
727 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
730 Evas_Coord w_text, h_btn, padding_outer, padding_inner;
731 Evas_Coord w_btn = 0, button_max_width = 0;
732 const char *size_str;
734 size_str = edje_object_data_get(btn, "button_max_size");
735 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
737 // decide the size of button
738 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
739 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
740 edje_object_part_geometry_get(btn, "left.padding", NULL, NULL, &padding_outer, NULL);
741 edje_object_part_geometry_get(btn, "left.inner.padding", NULL, NULL, &padding_inner, NULL);
742 w_btn = w_text + 2*padding_outer + 2*padding_inner;
745 vw = (button_max_width < w_btn) ? button_max_width : w_btn;
748 evas_object_resize(btn, vw, h_btn);
749 evas_object_size_hint_min_set(btn, vw, h_btn);
751 if(realw) *realw = rw;
752 if(vieww) *vieww = vw;
755 static Elm_Multibuttonentry_Item*
756 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
758 Elm_Multibuttonentry_Item *item;
760 Evas_Coord width, height;
761 const char *str_utf8 = NULL;
763 Widget_Data *wd = elm_widget_data_get(obj);
765 if (!wd || !wd->box || !wd->entry) return NULL;
767 if ((wd->add_callback) && !wd->add_callback(obj, str, data, wd->add_callback_data)) return NULL;
770 btn = edje_object_add(evas_object_evas_get(obj));
771 str_utf8 = elm_entry_markup_to_utf8(str);
773 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
774 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
775 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
776 evas_object_size_hint_min_set(btn, width, height);
777 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
778 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
779 evas_object_show(btn);
782 item = ELM_NEW(Elm_Multibuttonentry_Item);
786 _resize_button(btn, &rw, &vw);
787 item->multibuttonentry = obj;
792 item->visible = EINA_TRUE;
796 case MULTIBUTONENTRY_POS_START:
797 wd->items = eina_list_prepend(wd->items, item);
798 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
800 elm_widget_sub_object_add(obj, btn);
801 _contracted_state_set(obj, 1);
806 elm_box_pack_after(wd->box, btn, wd->label);
808 elm_box_pack_start(wd->box, btn);
809 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
810 _set_vis_guidetext(obj);
813 case MULTIBUTONENTRY_POS_END:
814 wd->items = eina_list_append(wd->items, item);
815 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
817 elm_widget_sub_object_add(obj, btn);
818 evas_object_hide(btn);
822 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
823 _set_vis_guidetext(obj);
825 elm_box_pack_before(wd->box, btn, wd->entry);
827 elm_box_pack_end(wd->box, btn);
830 case MULTIBUTONENTRY_POS_BEFORE:
832 wd->items = eina_list_prepend_relative(wd->items, item, reference);
834 wd->items = eina_list_append(wd->items, item);
835 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
837 elm_widget_sub_object_add(obj, btn);
838 evas_object_hide(btn);
839 _contracted_state_set(obj, 1);
844 elm_box_pack_before(wd->box, btn, reference->button);
847 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
848 _set_vis_guidetext(obj);
850 elm_box_pack_before(wd->box, btn, wd->entry);
852 elm_box_pack_end(wd->box, btn);
856 case MULTIBUTONENTRY_POS_AFTER:
858 wd->items = eina_list_append_relative(wd->items, item, reference);
860 wd->items = eina_list_append(wd->items, item);
861 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
863 elm_widget_sub_object_add(obj, btn);
864 _contracted_state_set(obj, 1);
869 elm_box_pack_after(wd->box, btn, reference->button);
872 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
873 _set_vis_guidetext(obj);
875 elm_box_pack_before(wd->box, btn, wd->entry);
877 elm_box_pack_end(wd->box, btn);
885 evas_object_smart_callback_call(obj, "item,added", item);
893 _add_button(Evas_Object *obj, char *str)
895 Widget_Data *wd = elm_widget_data_get(obj);
899 elm_scrolled_entry_entry_set(wd->entry, "");
902 _add_button_item(obj, str, MULTIBUTONENTRY_POS_END, NULL, NULL);
906 _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
908 Widget_Data *wd = elm_widget_data_get(data);
909 Elm_Multibuttonentry_Item *item = NULL;
911 static char str[MAX_STR];
913 if (!wd || !wd->base || !wd->box) return;
915 strncpy(str, elm_scrolled_entry_entry_get(wd->entry), MAX_STR);
916 str[MAX_STR - 1] = 0;
918 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
920 if (wd->last_btn_select)
922 if ((wd->current) && ( (strcmp (ev->keyname, "BackSpace") == 0) || (strcmp (ev->keyname, "BackSpace (") == 0)))
924 item = eina_list_data_get(wd->current);
927 _del_button_item(item);
928 elm_object_focus(wd->entry);
931 else if (((!wd->current) && (wd->n_str == 0) && (strcmp (ev->keyname, "BackSpace") == 0) || (strcmp (ev->keyname, "BackSpace (") == 0)))
933 item = eina_list_data_get(eina_list_last(wd->items));
935 _select_button(data, item->button);
939 wd->last_btn_select = EINA_TRUE;
943 _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
945 Widget_Data *wd = elm_widget_data_get(data);
946 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
950 if ( (wd->n_str == 1) && (strcmp (ev->keyname, "BackSpace") == 0 || (strcmp (ev->keyname, "BackSpace (") == 0 )))
951 wd->last_btn_select = EINA_FALSE;
955 _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
957 Widget_Data *wd = elm_widget_data_get(data);
958 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
959 static char str[MAX_STR];
961 if (!wd || !wd->base || !wd->box) return;
963 strncpy(str, elm_scrolled_entry_entry_get(wd->entry), MAX_STR);
964 str[MAX_STR - 1] = 0;
966 if ( (strcmp (str, "") != 0) && (strcmp (ev->keyname, "KP_Enter") == 0 || strcmp (ev->keyname, "Return") == 0 ))
968 _add_button(data, str);
975 _entry_focus_in_cb(void *data, Evas *e, __UNUSED__ void *event_info)
977 Widget_Data *wd = elm_widget_data_get(data);
980 _change_current_button_state(data, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
984 _entry_focus_out_cb(void *data, Evas *e, __UNUSED__ void *event_info)
986 Widget_Data *wd = elm_widget_data_get(data);
989 static char str[MAX_STR];
991 strncpy(str,elm_scrolled_entry_entry_get(wd->entry), MAX_STR);
995 _add_button(data, str);
999 _entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
1001 Widget_Data *wd = elm_widget_data_get(data);
1004 static char str[MAX_STR];
1006 strncpy(str, elm_scrolled_entry_entry_get(wd->entry), MAX_STR);
1007 str[MAX_STR -1] = 0;
1009 wd->n_str = strlen(str);
1013 _view_init(Evas_Object *obj)
1015 Widget_Data *wd = elm_widget_data_get(obj);
1020 if (! (wd->box = elm_box_add (obj))) return;
1021 elm_widget_sub_object_add(obj, wd->box);
1022 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1023 elm_box_homogenous_set(wd->box, EINA_FALSE);
1024 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1029 if (!(wd->label = edje_object_add(evas_object_evas_get(obj)))) return;
1030 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1031 _set_label(obj, "");
1032 elm_widget_sub_object_add(obj, wd->label);
1037 if (! (wd->entry = elm_scrolled_entry_add (obj))) return;
1038 elm_scrolled_entry_single_line_set(wd->entry, EINA_TRUE);
1039 elm_scrolled_entry_entry_set(wd->entry, "");
1040 elm_scrolled_entry_cursor_end_set(wd->entry);
1041 elm_scrolled_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1042 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1043 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1044 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1045 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1046 evas_object_show(wd->entry);
1047 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1048 wd->imf_context = elm_scrolled_entry_imf_context_get(wd->entry);
1053 const char *end_type = edje_object_data_get(wd->base, "closed_button_type");
1054 if (!end_type || !strcmp(end_type, "label"))
1056 if (! (wd->end = elm_label_add (obj))) return;
1057 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1058 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1062 const char *size_str;
1063 if (!(wd->end = edje_object_add(evas_object_evas_get(obj)))) return;
1064 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1065 Evas_Coord button_min_width = 0;
1066 Evas_Coord button_min_height = 0;
1068 size_str = edje_object_data_get(wd->end, "closed_button_width");
1069 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
1070 size_str = edje_object_data_get(wd->end, "closed_button_height");
1071 if(size_str) button_min_height = (Evas_Coord)atoi(size_str);
1073 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1074 evas_object_size_hint_min_set(wd->end, button_min_width, button_min_height);
1075 elm_widget_sub_object_add(obj, wd->end);
1081 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1083 Evas_Coord minw, minh, maxw, maxh, mnw, mnh, ww;
1084 Evas_Coord w, cw = 0, cmaxh = 0;
1086 Evas_Object_Box_Option *opt;
1089 /* FIXME: need to calc max */
1095 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1096 evas_object_size_hint_min_get(box, &minw, NULL);
1098 EINA_LIST_FOREACH(priv->children, l, opt)
1100 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1101 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1105 if (mnw != -1 && (w - cw) >= mnw)
1120 if (cmaxh < mnh) cmaxh = mnh;
1125 evas_object_size_hint_min_set(box, minw, minh);
1129 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1131 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1133 Evas_Object_Box_Option *opt;
1137 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1139 EINA_LIST_FOREACH(priv->children, l, opt)
1141 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1142 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1146 if (mnw != -1 && (w - cw) >= mnw)
1156 if (index > obj_index) return cmaxh;
1162 if (cmaxh < mnh) cmaxh = mnh;
1171 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
1173 Evas_Coord x, y, w, h, xx, yy;
1176 Evas_Coord minw, minh, wdif, hdif;
1179 Evas_Object_Box_Option *opt;
1181 _calculate_box_min_size(o, priv);
1183 evas_object_geometry_get(o, &x, &y, &w, &h);
1185 evas_object_size_hint_min_get(o, &minw, &minh);
1186 evas_object_size_hint_align_get(o, &ax, &ay);
1187 count = eina_list_count(priv->children);
1190 x = x + ((w - minw) * (1.0 - ax));
1195 y = y + ((h - minh) * (1.0 - ay));
1204 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1206 EINA_LIST_FOREACH(priv->children, l, opt)
1208 Evas_Coord mnw, mnh, mxw, mxh;
1213 evas_object_size_hint_align_get(obj, &ax, &ay);
1214 evas_object_size_hint_weight_get(obj, &wx, &wy);
1215 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1216 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1219 if (ax == -1.0) {fw = 1; ax = 0.5;}
1220 if (ay == -1.0) {fh = 1; ay = 0.5;}
1221 if (wx > 0.0) xw = 1;
1222 if (wy > 0.0) xh = 1;
1223 Evas_Coord ww, hh, ow, oh;
1227 if (mnw != -1 && (w - cw) >= mnw)
1234 hh = _calculate_item_max_height(o, priv, obj_index);
1238 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1241 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1250 evas_object_move(obj,
1251 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1252 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1253 evas_object_resize(obj, ow, oh);
1256 if (cmaxh < hh) cmaxh = hh;
1263 * Add a new multibuttonentry to the parent
1265 * @param parent The parent object
1266 * @return The new object or NULL if it cannot be created
1268 * @ingroup Multibuttonentry
1271 elm_multibuttonentry_add(Evas_Object *parent)
1276 if (!parent) return NULL;
1278 wd = ELM_NEW(Widget_Data);
1279 e = evas_object_evas_get(parent);
1280 if (!e) return NULL;
1281 obj = elm_widget_add(e);
1282 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1283 elm_widget_type_set(obj, "multibuttonentry");
1284 elm_widget_sub_object_add(parent, obj);
1285 elm_widget_data_set(obj, wd);
1287 elm_widget_del_hook_set(obj, _del_hook);
1288 elm_widget_theme_hook_set(obj, _theme_hook);
1289 elm_widget_event_hook_set(obj, _event_hook);
1290 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1291 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1293 wd->base = edje_object_add(e);
1294 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1295 elm_widget_resize_object_set(obj, wd->base);
1296 elm_widget_can_focus_set(obj,EINA_TRUE);
1298 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1299 wd->focused = EINA_FALSE;
1300 wd->last_btn_select = EINA_TRUE;
1302 wd->rectForEnd = NULL;
1303 wd->imf_context = NULL;
1304 wd->add_callback = NULL;
1305 wd->add_callback_data = NULL;
1314 * Get the entry of the multibuttonentry object
1316 * @param obj The multibuttonentry object
1317 * @return The entry object, or NULL if none
1319 * @ingroup Multibuttonentry
1322 elm_multibuttonentry_entry_get(Evas_Object *obj)
1324 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1325 Widget_Data *wd = elm_widget_data_get(obj);
1326 if (!wd) return NULL;
1334 * @param obj The multibuttonentry object
1335 * @return The label, or NULL if none
1337 * @ingroup Multibuttonentry
1340 elm_multibuttonentry_label_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;
1345 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1352 * @param obj The multibuttonentry object
1353 * @param label The text label string
1355 * @ingroup Multibuttonentry
1358 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1360 ELM_CHECK_WIDTYPE(obj, widtype);
1361 Widget_Data *wd = elm_widget_data_get(obj);
1364 _set_label(obj, label);
1366 _set_label(obj, "");
1370 * Get the guide text
1372 * @param obj The multibuttonentry object
1373 * @return The guide text, or NULL if none
1375 * @ingroup Multibuttonentry
1378 elm_multibuttonentry_guide_text_get(Evas_Object *obj)
1380 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1381 Widget_Data *wd = elm_widget_data_get(obj);
1382 if (!wd) return NULL;
1383 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1388 * Set the guide text
1390 * @param obj The multibuttonentry object
1391 * @param label The guide text string
1393 * @ingroup Multibuttonentry
1396 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1398 ELM_CHECK_WIDTYPE(obj, widtype);
1399 Widget_Data *wd = elm_widget_data_get(obj);
1402 _set_guidetext(obj, guidetext);
1404 _set_guidetext(obj, "");
1409 * Get the value of contracted state.
1411 * @param obj The multibuttonentry object
1412 * @param the value of contracted state.
1414 * @ingroup Multibuttonentry
1417 elm_multibuttonentry_contracted_state_get(Evas_Object *obj)
1419 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1420 Widget_Data *wd = elm_widget_data_get(obj);
1422 return wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED ? 1 : 0;
1426 * Set/Unset the multibuttonentry to contracted state of single line
1428 * @param obj The multibuttonentry object
1429 * @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.
1431 * @ingroup Multibuttonentry
1434 elm_multibuttonentry_contracted_state_set(Evas_Object *obj, int contracted)
1436 ELM_CHECK_WIDTYPE(obj, widtype);
1437 Widget_Data *wd = elm_widget_data_get(obj);
1438 if (!wd || !wd->box ||
1439 ((wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) ? 1 : 0) == contracted) return;
1440 _contracted_state_set(obj, contracted);
1444 * Prepend a new item to the multibuttonentry
1446 * @param obj The multibuttonentry object
1447 * @param label The label of new item
1448 * @param data The ponter to the data to be attached
1449 * @return A handle to the item added or NULL if not possible
1451 * @ingroup Multibuttonentry
1453 EAPI Elm_Multibuttonentry_Item *
1454 elm_multibuttonentry_item_add_start(Evas_Object *obj, const char *label, void *data)
1456 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1457 Widget_Data *wd = elm_widget_data_get(obj);
1458 Elm_Multibuttonentry_Item *item;
1459 if (!wd || !label) return NULL;
1460 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_START, NULL, data);
1465 * Append a new item to the multibuttonentry
1467 * @param obj The multibuttonentry object
1468 * @param label The label of new item
1469 * @param data The ponter to the data to be attached
1470 * @return A handle to the item added or NULL if not possible
1472 * @ingroup Multibuttonentry
1474 EAPI Elm_Multibuttonentry_Item *
1475 elm_multibuttonentry_item_add_end(Evas_Object *obj, const char *label, void *data)
1477 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1478 Widget_Data *wd = elm_widget_data_get(obj);
1479 Elm_Multibuttonentry_Item *item;
1480 if (!wd || !label) return NULL;
1481 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_END, NULL, data);
1486 * Add a new item to the multibuttonentry before the indicated object
1489 * @param obj The multibuttonentry object
1490 * @param label The label of new item
1491 * @param before The item before which to add it
1492 * @param data The ponter to the data to be attached
1493 * @return A handle to the item added or NULL if not possible
1495 * @ingroup Multibuttonentry
1497 EAPI Elm_Multibuttonentry_Item *
1498 elm_multibuttonentry_item_add_before(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *before, void *data)
1500 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1501 Widget_Data *wd = elm_widget_data_get(obj);
1502 Elm_Multibuttonentry_Item *item;
1503 if (!wd || !label) return NULL;
1504 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_BEFORE, before, data);
1509 * Add a new item to the multibuttonentry after the indicated object
1511 * @param obj The multibuttonentry object
1512 * @param label The label of new item
1513 * @param after The item after which to add it
1514 * @param data The ponter to the data to be attached
1515 * @return A handle to the item added or NULL if not possible
1517 * @ingroup Multibuttonentry
1519 EAPI Elm_Multibuttonentry_Item *
1520 elm_multibuttonentry_item_add_after(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *after, void *data)
1522 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1523 Widget_Data *wd = elm_widget_data_get(obj);
1524 Elm_Multibuttonentry_Item *item;
1525 if (!wd || !label) return NULL;
1526 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_AFTER, after, data);
1531 * Get a list of items in the multibuttonentry
1533 * @param obj The multibuttonentry object
1534 * @return The list of items, or NULL if none
1536 * @ingroup Multibuttonentry
1538 EAPI const Eina_List *
1539 elm_multibuttonentry_items_get(Evas_Object *obj)
1541 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1542 Widget_Data *wd = elm_widget_data_get(obj);
1543 if (!wd) return NULL;
1548 * Get the first item in the multibuttonentry
1550 * @param obj The multibuttonentry object
1551 * @return The first item, or NULL if none
1553 * @ingroup Multibuttonentry
1555 EAPI Elm_Multibuttonentry_Item *
1556 elm_multibuttonentry_item_first_get(Evas_Object *obj)
1558 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1559 Widget_Data *wd = elm_widget_data_get(obj);
1560 if (!wd || !wd->items) return NULL;
1561 return eina_list_data_get(wd->items);
1565 * Get the last item in the multibuttonentry
1567 * @param obj The multibuttonentry object
1568 * @return The last item, or NULL if none
1570 * @ingroup Multibuttonentry
1572 EAPI Elm_Multibuttonentry_Item *
1573 elm_multibuttonentry_item_last_get(Evas_Object *obj)
1575 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1576 Widget_Data *wd = elm_widget_data_get(obj);
1577 if (!wd || !wd->items) return NULL;
1578 return eina_list_data_get(eina_list_last(wd->items));
1582 * Get the selected item in the multibuttonentry
1584 * @param obj The multibuttonentry object
1585 * @return The selected item, or NULL if none
1587 * @ingroup Multibuttonentry
1589 EAPI Elm_Multibuttonentry_Item *
1590 elm_multibuttonentry_item_selected_get(Evas_Object *obj)
1592 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1593 Widget_Data *wd = elm_widget_data_get(obj);
1594 if (!wd || !wd->current) return NULL;
1595 return eina_list_data_get(wd->current);
1599 * Set the selected state of an item
1601 * @param item The item
1603 * @ingroup Multibuttonentry
1606 elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item)
1610 Elm_Multibuttonentry_Item *_item;
1613 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1614 wd = elm_widget_data_get(item->multibuttonentry);
1617 EINA_LIST_FOREACH(wd->items, l, _item)
1620 _select_button(item->multibuttonentry, item->button);
1625 * unselect all of items.
1627 * @param obj The multibuttonentry object
1629 * @ingroup Multibuttonentry
1632 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1634 ELM_CHECK_WIDTYPE(obj, widtype);
1635 Widget_Data *wd = elm_widget_data_get(obj);
1638 _select_button(obj, NULL);
1642 * Remove all items in the multibuttonentry.
1644 * @param obj The multibuttonentry object
1646 * @ingroup Multibuttonentry
1649 elm_multibuttonentry_items_del(Evas_Object *obj)
1651 ELM_CHECK_WIDTYPE(obj, widtype);
1652 Widget_Data *wd = elm_widget_data_get(obj);
1657 Elm_Multibuttonentry_Item *item;
1658 EINA_LIST_FREE(wd->items, item)
1660 elm_box_unpack(wd->box, item->button);
1661 _del_button_obj(obj, item->button);
1671 * Delete a given item
1673 * @param item The item
1675 * @ingroup Multibuttonentry
1678 elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
1681 _del_button_item(item);
1685 * Get the label of a given item
1687 * @param item The item
1688 * @return The label of a given item, or NULL if none
1690 * @ingroup Multibuttonentry
1693 elm_multibuttonentry_item_label_get(Elm_Multibuttonentry_Item *item)
1697 Elm_Multibuttonentry_Item *_item;
1698 if (!item) return NULL;
1699 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1700 wd = elm_widget_data_get(item->multibuttonentry);
1701 if (!wd || !wd->items) return NULL;
1703 EINA_LIST_FOREACH(wd->items, l, _item)
1706 return edje_object_part_text_get(_item->button, "elm.btn.text");
1713 * Set the label of a given item
1715 * @param item The item
1716 * @param label The text label string
1718 * @ingroup Multibuttonentry
1721 elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
1725 Elm_Multibuttonentry_Item *_item;
1726 if (!item || !str) return;
1727 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1728 wd = elm_widget_data_get(item->multibuttonentry);
1729 if (!wd || !wd->items) return;
1731 EINA_LIST_FOREACH(wd->items, l, _item)
1734 edje_object_part_text_set(_item->button, "elm.btn.text", str);
1735 _resize_button(_item->button, &_item->rw, &_item->vw);
1741 * Get the previous item in the multibuttonentry
1743 * @param item The item
1744 * @return The item before the item @p item
1746 * @ingroup Multibuttonentry
1748 EAPI Elm_Multibuttonentry_Item *
1749 elm_multibuttonentry_item_prev(Elm_Multibuttonentry_Item *item)
1753 Elm_Multibuttonentry_Item *_item;
1754 if (!item) return NULL;
1755 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1756 wd = elm_widget_data_get(item->multibuttonentry);
1757 if (!wd || !wd->items) return NULL;
1759 EINA_LIST_FOREACH(wd->items, l, _item)
1762 l = eina_list_prev(l);
1763 if (!l) return NULL;
1764 return eina_list_data_get(l);
1770 * Get the next item in the multibuttonentry
1772 * @param item The item
1773 * @return The item after the item @p item
1775 * @ingroup Multibuttonentry
1777 EAPI Elm_Multibuttonentry_Item *
1778 elm_multibuttonentry_item_next(Elm_Multibuttonentry_Item *item)
1782 Elm_Multibuttonentry_Item *_item;
1783 if (!item) return NULL;
1784 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1785 wd = elm_widget_data_get(item->multibuttonentry);
1786 if (!wd || !wd->items) return NULL;
1788 EINA_LIST_FOREACH(wd->items, l, _item)
1791 l = eina_list_next(l);
1792 if (!l) return NULL;
1793 return eina_list_data_get(l);
1799 * Get private data of item
1801 * @param item The item
1802 * @return The data pointer stored, or NULL if none was stored
1804 * @ingroup Multibuttonentry
1807 elm_multibuttonentry_item_data_get(Elm_Multibuttonentry_Item *item)
1809 if (!item) return NULL;
1814 * Set private data of item
1816 * @param item The item
1817 * @param data The ponter to the data to be attached
1819 * @ingroup Multibuttonentry
1822 elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
1829 * Set the multibuttonentry item_verify_callback function
1831 * @param obj The multibuttonentry object
1832 * @param func The function pointer to be called, it it's NULL, callback function will be deleted.
1833 * @param data user data to be passed to the callback function
1835 * @ingroup Multibuttonentry
1838 elm_multibuttonentry_item_verify_callback_set(Evas_Object *obj, Elm_Multibuttonentry_Item_Verify_Callback func, void *data)
1840 ELM_CHECK_WIDTYPE(obj, widtype);
1841 Widget_Data *wd = elm_widget_data_get(obj);
1844 wd->add_callback = func;
1845 wd->add_callback_data = data;