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 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
103 static void _entry_resized_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
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 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(wd->entry);
166 if (elm_widget_focus_get(obj))
168 if ((imf_context) && (wd->current))
170 ecore_imf_context_input_panel_show(imf_context);
172 else if ((imf_context) && ((!wd->current) || (!eina_list_count(wd->items))))
175 ecore_imf_context_input_panel_show(imf_context);
177 wd->focused = EINA_TRUE;
178 evas_object_smart_callback_call(obj, "focused", NULL);
182 wd->focused = EINA_FALSE;
184 if (imf_context) ecore_imf_context_input_panel_hide(imf_context);
185 evas_object_smart_callback_call(obj, "unfocused", NULL);
190 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
197 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
199 Widget_Data *wd = elm_widget_data_get(obj);
201 edje_object_signal_emit(wd->base, emission, source);
205 _sizing_eval(Evas_Object *obj)
207 Widget_Data *wd = elm_widget_data_get(obj);
209 Evas_Coord minw = -1, minh = -1;
210 Evas_Coord left, right, top, bottom;
213 evas_object_size_hint_min_get(wd->box, &minw, &minh);
214 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
215 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
217 minw += (left + right);
218 minh += (top + bottom);
220 evas_object_size_hint_min_set(obj, minw, minh);
224 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
226 Widget_Data *wd = elm_widget_data_get(data);
227 if(!wd || !wd->base) return;
229 wd->focused = EINA_TRUE;
232 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(wd->entry);
234 if (imf_context) ecore_imf_context_input_panel_show(imf_context);
235 evas_object_smart_callback_call(data, "clicked", NULL);
239 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
241 Evas_Object *eo = (Evas_Object *)data;
242 Widget_Data *wd = elm_widget_data_get(data);
248 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
250 Widget_Data *wd = elm_widget_data_get(data);
254 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
256 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
257 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
266 _event_init(Evas_Object *obj)
268 Widget_Data *wd = elm_widget_data_get(obj);
269 if (!wd || !wd->base) return;
273 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
274 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
279 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
280 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
285 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
286 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
287 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
288 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
289 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
290 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
291 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
296 _set_vis_guidetext(Evas_Object *obj)
298 Widget_Data *wd = elm_widget_data_get(obj);
301 elm_box_unpack(wd->box, wd->guidetext);
302 elm_box_unpack(wd->box, wd->entry);
303 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
305 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
306 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
308 evas_object_hide(wd->entry);
309 elm_box_pack_end(wd->box, wd->guidetext);
310 evas_object_show(wd->guidetext);
311 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
315 evas_object_hide(wd->guidetext);
316 elm_box_pack_end(wd->box, wd->entry);
317 evas_object_show(wd->entry);
318 if (elm_widget_focus_get(obj) || wd->focused)
320 elm_object_focus(wd->entry);
321 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
327 _contracted_state_set(Evas_Object *obj, int contracted)
329 Widget_Data *wd = elm_widget_data_get(obj);
331 Elm_Multibuttonentry_Item *item;
332 if (!wd || !wd->box) return;
334 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
335 evas_object_hide(wd->entry);
336 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
337 evas_object_hide(wd->guidetext);
338 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
340 evas_object_hide(wd->rectForEnd);
341 evas_object_hide(wd->end);
342 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
347 Evas_Coord w=0, w_tmp=0;
348 Evas_Coord box_inner_item_width_padding = 0;
350 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
351 // unpack all items and entry
352 elm_box_unpack_all(wd->box);
353 EINA_LIST_FOREACH(wd->items, l, item)
357 evas_object_hide(item->button);
358 item->visible = EINA_FALSE;
362 // pack buttons only 1line
367 elm_box_pack_end(wd->box, wd->label);
368 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
370 w -= box_inner_item_width_padding;
374 int count = eina_list_count(wd->items);
375 Evas_Coord button_min_width = 0;
376 /* Evas_Coord button_min_height = 0; */
377 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
379 const char *size_str;
380 size_str = edje_object_data_get(wd->end, "closed_button_width");
381 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
383 size_str = edje_object_data_get(wd->end, "closed_button_height");
384 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
388 EINA_LIST_FOREACH(wd->items, l, item)
392 int w_label_count = 0;
393 char buf[MAX_STR] = {0,};
395 elm_box_pack_end(wd->box, item->button);
396 evas_object_show(item->button);
397 item->visible = EINA_TRUE;
400 w -= box_inner_item_width_padding;
403 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
407 snprintf(buf, sizeof(buf), "... + %d", count);
408 elm_object_text_set(wd->end, buf);
409 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
412 if (w < 0 || w < w_label_count)
414 elm_box_unpack(wd->box, item->button);
415 evas_object_hide(item->button);
416 item->visible = EINA_FALSE;
419 snprintf(buf, sizeof(buf), "... + %d", count);
420 elm_object_text_set(wd->end, buf);
421 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
423 elm_box_pack_end(wd->box, wd->end);
424 evas_object_show(wd->end);
426 wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
427 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)1);
431 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
433 if (w < button_min_width)
436 Evas_Coord closed_height = 0;
437 const char *height_str = edje_object_data_get(wd->base, "closed_height");
438 if(height_str) closed_height = (Evas_Coord)atoi(height_str);
439 elm_box_unpack(wd->box, item->button);
440 evas_object_hide(item->button);
441 item->visible = EINA_FALSE;
444 rectSize = w - button_min_width;
447 Evas *e = evas_object_evas_get(obj);
448 wd->rectForEnd = evas_object_rectangle_add(e);
449 evas_object_color_set(wd->rectForEnd, 0, 0, 0, 0);
451 evas_object_size_hint_min_set(wd->rectForEnd, rectSize, closed_height * elm_scale_get());
452 elm_box_pack_end(wd->box, wd->rectForEnd);
453 evas_object_show(wd->rectForEnd);
455 elm_box_pack_end(wd->box, wd->end);
456 evas_object_show(wd->end);
458 wd->view_state = MULTIBUTTONENTRY_VIEW_CONTRACTED;
459 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)0);
468 // unpack all items and entry
469 elm_box_unpack_all(wd->box);
470 EINA_LIST_FOREACH(wd->items, l, item)
474 evas_object_hide(item->button);
475 item->visible = EINA_FALSE;
478 evas_object_hide(wd->end);
480 if (wd->rectForEnd) evas_object_hide(wd->rectForEnd);
482 // pack buttons only 1line
484 if (wd->label) elm_box_pack_end(wd->box, wd->label);
488 EINA_LIST_FOREACH(wd->items, l, item)
492 elm_box_pack_end(wd->box, item->button);
493 evas_object_show(item->button);
494 item->visible = EINA_TRUE;
498 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
499 evas_object_smart_callback_call(obj, "contracted,state,changed", (void *)wd->contracted);
501 if (wd->view_state != MULTIBUTTONENTRY_VIEW_CONTRACTED)
503 _set_vis_guidetext(obj);
508 _view_update(Evas_Object *obj)
510 Evas_Coord width = 1, height = 1;
511 Widget_Data *wd = elm_widget_data_get(obj);
513 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
518 elm_box_unpack(wd->box, wd->label);
519 elm_box_pack_start(wd->box, wd->label);
520 evas_object_size_hint_min_get(wd->label, &width, &height);
525 Evas_Coord guide_text_width = wd->w_box - width;
526 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
529 // update buttons in contracted mode
530 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
531 _contracted_state_set(obj, 1);
534 _set_vis_guidetext(obj);
538 _set_label(Evas_Object *obj, const char* str)
540 Widget_Data *wd = elm_widget_data_get(obj);
541 if (!wd || !str) return;
545 Evas_Coord width, height, sum_width = 0;
546 evas_object_size_hint_min_set(wd->label, 0, 0);
547 evas_object_resize(wd->label, 0, 0);
548 edje_object_part_text_set(wd->label, "mbe.label", str);
550 if (!strcmp(str, ""))
552 /* FIXME: not work yet */
553 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
554 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
559 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
560 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
563 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
566 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
569 evas_object_size_hint_min_set(wd->label, sum_width, height);
571 evas_object_show(wd->label);
576 _set_guidetext(Evas_Object *obj, const char* str)
578 Widget_Data *wd = elm_widget_data_get(obj);
579 if (!wd || !str) return;
583 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
584 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
585 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
586 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
589 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
594 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
596 Widget_Data *wd = elm_widget_data_get(obj);
597 Elm_Multibuttonentry_Item *item = NULL;
601 item = eina_list_data_get(wd->current);
603 if (item && item->button)
607 case MULTIBUTONENTRY_BUTTON_STATE_DEFAULT:
608 edje_object_signal_emit(item->button, "default", "");
611 case MULTIBUTONENTRY_BUTTON_STATE_SELECTED:
612 edje_object_signal_emit(item->button, "focused", "");
613 evas_object_smart_callback_call(obj, "item,selected", item);
616 edje_object_signal_emit(item->button, "default", "");
624 _change_current_button(Evas_Object *obj, Evas_Object *btn)
626 Widget_Data *wd = elm_widget_data_get(obj);
628 Elm_Multibuttonentry_Item *item;
631 // change the state of previous button to "default"
632 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
634 // change the current
635 EINA_LIST_FOREACH(wd->items, l, item)
637 if (item->button == btn)
644 // chagne the state of current button to "focused"
645 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_SELECTED);
650 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
652 Widget_Data *wd = elm_widget_data_get(data);
654 Elm_Multibuttonentry_Item *item = NULL;
655 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) return;
657 _change_current_button(data, obj);
660 if ((item = eina_list_data_get(wd->current)) != NULL)
662 evas_object_smart_callback_call(data, "item,clicked", item);
663 _select_button(data, item->button);
668 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
670 Widget_Data *wd = elm_widget_data_get(obj);
671 if (!wd || !btn) return;
675 evas_object_del(btn);
679 _del_button_item(Elm_Multibuttonentry_Item *item)
682 Elm_Multibuttonentry_Item *_item;
686 Evas_Object *obj = item->multibuttonentry;
687 wd = elm_widget_data_get(obj);
689 EINA_LIST_FOREACH(wd->items, l, _item)
693 wd->items = eina_list_remove(wd->items, _item);
694 elm_box_unpack(wd->box, _item->button);
696 evas_object_smart_callback_call(obj, "item,deleted", _item);
698 _del_button_obj(obj, _item->button);
701 if (wd->current == l)
706 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
707 _contracted_state_set(obj, 1);
709 if (!eina_list_count(wd->items))
710 _set_vis_guidetext(obj);
714 _select_button(Evas_Object *obj, Evas_Object *btn)
716 Widget_Data *wd = elm_widget_data_get(obj);
721 _change_current_button(obj, btn);
722 if (elm_widget_focus_get(obj))
724 elm_object_unfocus(wd->entry);
725 evas_object_focus_set(btn, EINA_TRUE);
730 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
731 if (elm_widget_focus_get(obj))
732 elm_object_focus(wd->entry);
737 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
740 Evas_Coord w_text, h_btn, padding_outer, padding_inner;
741 Evas_Coord w_btn = 0, button_max_width = 0;
742 const char *size_str;
743 const char *ellipsis = "<ellipsis=1.0>";
745 size_str = edje_object_data_get(btn, "button_max_size");
746 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
748 const char *button_text = edje_object_part_text_get(btn, "elm.btn.text");
750 // decide the size of button
751 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
752 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
753 edje_object_part_geometry_get(btn, "left.padding", NULL, NULL, &padding_outer, NULL);
754 edje_object_part_geometry_get(btn, "left.inner.padding", NULL, NULL, &padding_inner, NULL);
755 w_btn = w_text + 2*padding_outer + 2*padding_inner;
759 if (button_max_width < w_btn)
761 vw = button_max_width;
762 edje_object_part_text_set(btn, "elm.btn.text", ellipsis);
763 edje_object_part_text_append(btn, "elm.btn.text", button_text);
769 evas_object_resize(btn, vw, h_btn);
770 evas_object_size_hint_min_set(btn, vw, h_btn);
772 if(realw) *realw = rw;
773 if(vieww) *vieww = vw;
776 static Elm_Multibuttonentry_Item*
777 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
779 Elm_Multibuttonentry_Item *item;
781 Evas_Coord width, height;
782 char *str_utf8 = NULL;
784 Widget_Data *wd = elm_widget_data_get(obj);
786 if (!wd || !wd->box || !wd->entry) return NULL;
788 if ((wd->add_callback) && !wd->add_callback(obj, str, data, wd->add_callback_data)) return NULL;
790 //entry is cleared when text is made to button
791 elm_entry_entry_set(wd->entry, "");
793 // initialize entry size to be called entry's EVAS_CALLBACK_RESIZE even entry size's doesn't changed
794 evas_object_resize(wd->entry, 0, 0);
797 btn = edje_object_add(evas_object_evas_get(obj));
798 str_utf8 = elm_entry_markup_to_utf8(str);
800 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
801 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
802 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
803 evas_object_size_hint_min_set(btn, width, height);
804 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
805 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
806 evas_object_show(btn);
809 item = ELM_NEW(Elm_Multibuttonentry_Item);
813 _resize_button(btn, &rw, &vw);
814 item->multibuttonentry = obj;
819 item->visible = EINA_TRUE;
823 case MULTIBUTONENTRY_POS_START:
824 wd->items = eina_list_prepend(wd->items, item);
825 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
827 elm_widget_sub_object_add(obj, btn);
828 _contracted_state_set(obj, 1);
833 elm_box_pack_after(wd->box, btn, wd->label);
835 elm_box_pack_start(wd->box, btn);
836 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
837 _set_vis_guidetext(obj);
840 case MULTIBUTONENTRY_POS_END:
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);
849 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
850 _set_vis_guidetext(obj);
852 elm_box_pack_before(wd->box, btn, wd->entry);
854 elm_box_pack_end(wd->box, btn);
857 case MULTIBUTONENTRY_POS_BEFORE:
859 wd->items = eina_list_prepend_relative(wd->items, item, reference);
861 wd->items = eina_list_append(wd->items, item);
862 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
864 elm_widget_sub_object_add(obj, btn);
865 evas_object_hide(btn);
866 _contracted_state_set(obj, 1);
871 elm_box_pack_before(wd->box, btn, reference->button);
874 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
875 _set_vis_guidetext(obj);
877 elm_box_pack_before(wd->box, btn, wd->entry);
879 elm_box_pack_end(wd->box, btn);
883 case MULTIBUTONENTRY_POS_AFTER:
885 wd->items = eina_list_append_relative(wd->items, item, reference);
887 wd->items = eina_list_append(wd->items, item);
888 if (wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED)
890 elm_widget_sub_object_add(obj, btn);
891 _contracted_state_set(obj, 1);
896 elm_box_pack_after(wd->box, btn, reference->button);
899 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
900 _set_vis_guidetext(obj);
902 elm_box_pack_before(wd->box, btn, wd->entry);
904 elm_box_pack_end(wd->box, btn);
912 evas_object_smart_callback_call(obj, "item,added", item);
919 _add_button(Evas_Object *obj, char *str)
921 Widget_Data *wd = elm_widget_data_get(obj);
925 _add_button_item(obj, str, MULTIBUTONENTRY_POS_END, NULL, NULL);
929 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
931 Widget_Data *wd = elm_widget_data_get(data);
932 Elm_Multibuttonentry_Item *item = NULL;
934 static char str[MAX_STR];
936 if (!wd || !wd->base || !wd->box) return;
938 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
939 str[MAX_STR - 1] = 0;
941 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
943 if (wd->last_btn_select)
945 if ((wd->current) && ( (strcmp (ev->keyname, "BackSpace") == 0) || (strcmp (ev->keyname, "BackSpace (") == 0)))
947 item = eina_list_data_get(wd->current);
950 _del_button_item(item);
951 elm_object_focus(wd->entry);
954 else if ((((!wd->current) && (wd->n_str == 0) && (strcmp (ev->keyname, "BackSpace") == 0))
955 || (strcmp (ev->keyname, "BackSpace (") == 0)))
957 item = eina_list_data_get(eina_list_last(wd->items));
959 _select_button(data, item->button);
963 wd->last_btn_select = EINA_TRUE;
967 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
969 Widget_Data *wd = elm_widget_data_get(data);
970 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
974 if ( (wd->n_str == 1) && (strcmp (ev->keyname, "BackSpace") == 0 || (strcmp (ev->keyname, "BackSpace (") == 0 )))
975 wd->last_btn_select = EINA_FALSE;
979 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
981 Widget_Data *wd = elm_widget_data_get(data);
982 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
983 static char str[MAX_STR];
985 if (!wd || !wd->base || !wd->box) return;
987 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
988 str[MAX_STR - 1] = 0;
990 if ( (strcmp (str, "") != 0) && (strcmp (ev->keyname, "KP_Enter") == 0 || strcmp (ev->keyname, "Return") == 0 ))
992 _add_button(data, str);
999 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1001 Widget_Data *wd = elm_widget_data_get(data);
1004 _change_current_button_state(data, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
1005 elm_object_focus(wd->entry);
1009 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1011 Widget_Data *wd = elm_widget_data_get(data);
1012 Elm_Multibuttonentry_Item *item = NULL;
1017 item = eina_list_data_get(wd->current);
1018 elm_object_unfocus(wd->entry);
1019 evas_object_focus_set(item->button, EINA_TRUE);
1024 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1026 Widget_Data *wd = elm_widget_data_get(data);
1029 static char str[MAX_STR];
1031 strncpy(str,elm_entry_entry_get(wd->entry), MAX_STR);
1032 str[MAX_STR -1] = 0;
1035 _add_button(data, str);
1039 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1041 Widget_Data *wd = elm_widget_data_get(data);
1044 static char str[MAX_STR];
1046 strncpy(str, elm_entry_entry_get(wd->entry), MAX_STR);
1047 str[MAX_STR -1] = 0;
1049 wd->n_str = strlen(str);
1053 _entry_resized_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1055 Evas_Coord en_x, en_y, en_w, en_h;
1056 Evas_Coord bx_x, bx_y;
1058 Widget_Data *wd = elm_widget_data_get(data);
1061 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1062 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1064 // should be reconsidered appropriate location to use the function as below.
1065 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w, en_h, EINA_TRUE);
1069 _view_init(Evas_Object *obj)
1071 Widget_Data *wd = elm_widget_data_get(obj);
1076 if (! (wd->box = elm_box_add (obj))) return;
1077 elm_widget_sub_object_add(obj, wd->box);
1078 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1079 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1080 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1085 if (!(wd->label = edje_object_add(evas_object_evas_get(obj)))) return;
1086 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1087 _set_label(obj, "");
1088 elm_widget_sub_object_add(obj, wd->label);
1093 if (! (wd->entry = elm_entry_add (obj))) return;
1094 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1095 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1096 elm_entry_entry_set(wd->entry, "");
1097 elm_entry_cursor_end_set(wd->entry);
1098 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1099 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1100 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1101 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1102 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1103 evas_object_show(wd->entry);
1104 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1109 const char *end_type = edje_object_data_get(wd->base, "closed_button_type");
1110 if (!end_type || !strcmp(end_type, "label"))
1112 if (! (wd->end = elm_label_add (obj))) return;
1113 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1114 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1118 const char *size_str;
1119 if (!(wd->end = edje_object_add(evas_object_evas_get(obj)))) return;
1120 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1121 Evas_Coord button_min_width = 0;
1122 Evas_Coord button_min_height = 0;
1124 size_str = edje_object_data_get(wd->end, "closed_button_width");
1125 if(size_str) button_min_width = (Evas_Coord)atoi(size_str);
1126 size_str = edje_object_data_get(wd->end, "closed_button_height");
1127 if(size_str) button_min_height = (Evas_Coord)atoi(size_str);
1129 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1130 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1131 elm_widget_sub_object_add(obj, wd->end);
1137 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1139 Evas_Coord minw, minh, maxw, maxh, mnw, mnh, ww;
1140 Evas_Coord w, cw = 0, cmaxh = 0;
1142 Evas_Object_Box_Option *opt;
1145 /* FIXME: need to calc max */
1151 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1152 evas_object_size_hint_min_get(box, &minw, NULL);
1154 EINA_LIST_FOREACH(priv->children, l, opt)
1156 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1157 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1161 if (mnw != -1 && (w - cw) >= mnw)
1176 if (cmaxh < mnh) cmaxh = mnh;
1181 evas_object_size_hint_min_set(box, minw, minh);
1185 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1187 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1189 Evas_Object_Box_Option *opt;
1193 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1195 EINA_LIST_FOREACH(priv->children, l, opt)
1197 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1198 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1202 if (mnw != -1 && (w - cw) >= mnw)
1212 if (index > obj_index) return cmaxh;
1218 if (cmaxh < mnh) cmaxh = mnh;
1227 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1229 Evas_Coord x, y, w, h, xx, yy;
1232 Evas_Coord minw, minh, wdif, hdif;
1235 Evas_Object_Box_Option *opt;
1237 _calculate_box_min_size(o, priv);
1239 evas_object_geometry_get(o, &x, &y, &w, &h);
1241 evas_object_size_hint_min_get(o, &minw, &minh);
1242 evas_object_size_hint_align_get(o, &ax, &ay);
1243 count = eina_list_count(priv->children);
1246 x = x + ((w - minw) * (1.0 - ax));
1251 y = y + ((h - minh) * (1.0 - ay));
1260 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1262 EINA_LIST_FOREACH(priv->children, l, opt)
1264 Evas_Coord mnw, mnh, mxw, mxh;
1269 evas_object_size_hint_align_get(obj, &ax, &ay);
1270 evas_object_size_hint_weight_get(obj, &wx, &wy);
1271 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1272 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1275 if (ax == -1.0) {fw = 1; ax = 0.5;}
1276 if (ay == -1.0) {fh = 1; ay = 0.5;}
1277 if (wx > 0.0) xw = 1;
1278 if (wy > 0.0) xh = 1;
1279 Evas_Coord ww, hh, ow, oh;
1283 if (mnw != -1 && (w - cw) >= mnw)
1290 hh = _calculate_item_max_height(o, priv, obj_index);
1294 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1297 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1306 evas_object_move(obj,
1307 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1308 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1309 evas_object_resize(obj, ow, oh);
1312 if (cmaxh < hh) cmaxh = hh;
1319 * Add a new multibuttonentry to the parent
1321 * @param parent The parent object
1322 * @return The new object or NULL if it cannot be created
1324 * @ingroup Multibuttonentry
1327 elm_multibuttonentry_add(Evas_Object *parent)
1333 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1335 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1336 elm_widget_type_set(obj, "multibuttonentry");
1337 elm_widget_sub_object_add(parent, obj);
1338 elm_widget_data_set(obj, wd);
1340 elm_widget_del_hook_set(obj, _del_hook);
1341 elm_widget_theme_hook_set(obj, _theme_hook);
1342 elm_widget_event_hook_set(obj, _event_hook);
1343 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1344 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1346 wd->base = edje_object_add(e);
1347 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1348 elm_widget_resize_object_set(obj, wd->base);
1349 elm_widget_can_focus_set(obj,EINA_TRUE);
1351 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1352 wd->focused = EINA_FALSE;
1353 wd->last_btn_select = EINA_TRUE;
1355 wd->rectForEnd = NULL;
1356 wd->add_callback = NULL;
1357 wd->add_callback_data = NULL;
1366 * Get the entry of the multibuttonentry object
1368 * @param obj The multibuttonentry object
1369 * @return The entry object, or NULL if none
1371 * @ingroup Multibuttonentry
1374 elm_multibuttonentry_entry_get(Evas_Object *obj)
1376 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1377 Widget_Data *wd = elm_widget_data_get(obj);
1378 if (!wd) return NULL;
1386 * @param obj The multibuttonentry object
1387 * @return The label, or NULL if none
1389 * @ingroup Multibuttonentry
1392 elm_multibuttonentry_label_get(Evas_Object *obj)
1394 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1395 Widget_Data *wd = elm_widget_data_get(obj);
1396 if (!wd) return NULL;
1397 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1404 * @param obj The multibuttonentry object
1405 * @param label The text label string
1407 * @ingroup Multibuttonentry
1410 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1412 ELM_CHECK_WIDTYPE(obj, widtype);
1413 Widget_Data *wd = elm_widget_data_get(obj);
1416 _set_label(obj, label);
1418 _set_label(obj, "");
1422 * Get the guide text
1424 * @param obj The multibuttonentry object
1425 * @return The guide text, or NULL if none
1427 * @ingroup Multibuttonentry
1430 elm_multibuttonentry_guide_text_get(Evas_Object *obj)
1432 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1433 Widget_Data *wd = elm_widget_data_get(obj);
1434 if (!wd) return NULL;
1435 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1440 * Set the guide text
1442 * @param obj The multibuttonentry object
1443 * @param label The guide text string
1445 * @ingroup Multibuttonentry
1448 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1450 ELM_CHECK_WIDTYPE(obj, widtype);
1451 Widget_Data *wd = elm_widget_data_get(obj);
1454 _set_guidetext(obj, guidetext);
1456 _set_guidetext(obj, "");
1461 * Get the value of contracted state.
1463 * @param obj The multibuttonentry object
1464 * @param the value of contracted state.
1466 * @ingroup Multibuttonentry
1469 elm_multibuttonentry_contracted_state_get(Evas_Object *obj)
1471 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1472 Widget_Data *wd = elm_widget_data_get(obj);
1474 return wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED ? 1 : 0;
1478 * Set/Unset the multibuttonentry to contracted state of single line
1480 * @param obj The multibuttonentry object
1481 * @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.
1483 * @ingroup Multibuttonentry
1486 elm_multibuttonentry_contracted_state_set(Evas_Object *obj, int contracted)
1488 ELM_CHECK_WIDTYPE(obj, widtype);
1489 Widget_Data *wd = elm_widget_data_get(obj);
1490 if (!wd || !wd->box ||
1491 ((wd->view_state == MULTIBUTTONENTRY_VIEW_CONTRACTED) ? 1 : 0) == contracted) return;
1492 _contracted_state_set(obj, contracted);
1496 * Prepend a new item to the multibuttonentry
1498 * @param obj The multibuttonentry object
1499 * @param label The label of new item
1500 * @param data The ponter to the data to be attached
1501 * @return A handle to the item added or NULL if not possible
1503 * @ingroup Multibuttonentry
1505 EAPI Elm_Multibuttonentry_Item *
1506 elm_multibuttonentry_item_add_start(Evas_Object *obj, const char *label, void *data)
1508 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1509 Widget_Data *wd = elm_widget_data_get(obj);
1510 Elm_Multibuttonentry_Item *item;
1511 if (!wd || !label) return NULL;
1512 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_START, NULL, data);
1517 * Append a new item to the multibuttonentry
1519 * @param obj The multibuttonentry object
1520 * @param label The label of new item
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_end(Evas_Object *obj, const char *label, 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_END, NULL, data);
1538 * Add a new item to the multibuttonentry before the indicated object
1541 * @param obj The multibuttonentry object
1542 * @param label The label of new item
1543 * @param before The item before which to add it
1544 * @param data The ponter to the data to be attached
1545 * @return A handle to the item added or NULL if not possible
1547 * @ingroup Multibuttonentry
1549 EAPI Elm_Multibuttonentry_Item *
1550 elm_multibuttonentry_item_add_before(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *before, void *data)
1552 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1553 Widget_Data *wd = elm_widget_data_get(obj);
1554 Elm_Multibuttonentry_Item *item;
1555 if (!wd || !label) return NULL;
1556 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_BEFORE, before, data);
1561 * Add a new item to the multibuttonentry after the indicated object
1563 * @param obj The multibuttonentry object
1564 * @param label The label of new item
1565 * @param after The item after which to add it
1566 * @param data The ponter to the data to be attached
1567 * @return A handle to the item added or NULL if not possible
1569 * @ingroup Multibuttonentry
1571 EAPI Elm_Multibuttonentry_Item *
1572 elm_multibuttonentry_item_add_after(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *after, void *data)
1574 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1575 Widget_Data *wd = elm_widget_data_get(obj);
1576 Elm_Multibuttonentry_Item *item;
1577 if (!wd || !label) return NULL;
1578 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_AFTER, after, data);
1583 * Get a list of items in the multibuttonentry
1585 * @param obj The multibuttonentry object
1586 * @return The list of items, or NULL if none
1588 * @ingroup Multibuttonentry
1590 EAPI const Eina_List *
1591 elm_multibuttonentry_items_get(Evas_Object *obj)
1593 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1594 Widget_Data *wd = elm_widget_data_get(obj);
1595 if (!wd) return NULL;
1600 * Get the first item in the multibuttonentry
1602 * @param obj The multibuttonentry object
1603 * @return The first item, or NULL if none
1605 * @ingroup Multibuttonentry
1607 EAPI Elm_Multibuttonentry_Item *
1608 elm_multibuttonentry_item_first_get(Evas_Object *obj)
1610 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1611 Widget_Data *wd = elm_widget_data_get(obj);
1612 if (!wd || !wd->items) return NULL;
1613 return eina_list_data_get(wd->items);
1617 * Get the last item in the multibuttonentry
1619 * @param obj The multibuttonentry object
1620 * @return The last item, or NULL if none
1622 * @ingroup Multibuttonentry
1624 EAPI Elm_Multibuttonentry_Item *
1625 elm_multibuttonentry_item_last_get(Evas_Object *obj)
1627 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1628 Widget_Data *wd = elm_widget_data_get(obj);
1629 if (!wd || !wd->items) return NULL;
1630 return eina_list_data_get(eina_list_last(wd->items));
1634 * Get the selected item in the multibuttonentry
1636 * @param obj The multibuttonentry object
1637 * @return The selected item, or NULL if none
1639 * @ingroup Multibuttonentry
1641 EAPI Elm_Multibuttonentry_Item *
1642 elm_multibuttonentry_item_selected_get(Evas_Object *obj)
1644 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1645 Widget_Data *wd = elm_widget_data_get(obj);
1646 if (!wd || !wd->current) return NULL;
1647 return eina_list_data_get(wd->current);
1651 * Set the selected state of an item
1653 * @param item The item
1655 * @ingroup Multibuttonentry
1658 elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item)
1662 Elm_Multibuttonentry_Item *_item;
1665 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1666 wd = elm_widget_data_get(item->multibuttonentry);
1669 EINA_LIST_FOREACH(wd->items, l, _item)
1672 _select_button(item->multibuttonentry, item->button);
1677 * unselect all of items.
1679 * @param obj The multibuttonentry object
1681 * @ingroup Multibuttonentry
1684 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1686 ELM_CHECK_WIDTYPE(obj, widtype);
1687 Widget_Data *wd = elm_widget_data_get(obj);
1690 _select_button(obj, NULL);
1694 * Remove all items in the multibuttonentry.
1696 * @param obj The multibuttonentry object
1698 * @ingroup Multibuttonentry
1701 elm_multibuttonentry_items_del(Evas_Object *obj)
1703 ELM_CHECK_WIDTYPE(obj, widtype);
1704 Widget_Data *wd = elm_widget_data_get(obj);
1709 Elm_Multibuttonentry_Item *item;
1710 EINA_LIST_FREE(wd->items, item)
1712 elm_box_unpack(wd->box, item->button);
1713 _del_button_obj(obj, item->button);
1723 * Delete a given item
1725 * @param item The item
1727 * @ingroup Multibuttonentry
1730 elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
1733 _del_button_item(item);
1737 * Get the label of a given item
1739 * @param item The item
1740 * @return The label of a given item, or NULL if none
1742 * @ingroup Multibuttonentry
1745 elm_multibuttonentry_item_label_get(Elm_Multibuttonentry_Item *item)
1749 Elm_Multibuttonentry_Item *_item;
1750 if (!item) return NULL;
1751 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1752 wd = elm_widget_data_get(item->multibuttonentry);
1753 if (!wd || !wd->items) return NULL;
1755 EINA_LIST_FOREACH(wd->items, l, _item)
1758 return edje_object_part_text_get(_item->button, "elm.btn.text");
1765 * Set the label of a given item
1767 * @param item The item
1768 * @param label The text label string
1770 * @ingroup Multibuttonentry
1773 elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
1777 Elm_Multibuttonentry_Item *_item;
1778 if (!item || !str) return;
1779 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
1780 wd = elm_widget_data_get(item->multibuttonentry);
1781 if (!wd || !wd->items) return;
1783 EINA_LIST_FOREACH(wd->items, l, _item)
1786 edje_object_part_text_set(_item->button, "elm.btn.text", str);
1787 _resize_button(_item->button, &_item->rw, &_item->vw);
1793 * Get the previous item in the multibuttonentry
1795 * @param item The item
1796 * @return The item before the item @p item
1798 * @ingroup Multibuttonentry
1800 EAPI Elm_Multibuttonentry_Item *
1801 elm_multibuttonentry_item_prev(Elm_Multibuttonentry_Item *item)
1805 Elm_Multibuttonentry_Item *_item;
1806 if (!item) return NULL;
1807 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1808 wd = elm_widget_data_get(item->multibuttonentry);
1809 if (!wd || !wd->items) return NULL;
1811 EINA_LIST_FOREACH(wd->items, l, _item)
1814 l = eina_list_prev(l);
1815 if (!l) return NULL;
1816 return eina_list_data_get(l);
1822 * Get the next item in the multibuttonentry
1824 * @param item The item
1825 * @return The item after the item @p item
1827 * @ingroup Multibuttonentry
1829 EAPI Elm_Multibuttonentry_Item *
1830 elm_multibuttonentry_item_next(Elm_Multibuttonentry_Item *item)
1834 Elm_Multibuttonentry_Item *_item;
1835 if (!item) return NULL;
1836 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
1837 wd = elm_widget_data_get(item->multibuttonentry);
1838 if (!wd || !wd->items) return NULL;
1840 EINA_LIST_FOREACH(wd->items, l, _item)
1843 l = eina_list_next(l);
1844 if (!l) return NULL;
1845 return eina_list_data_get(l);
1851 * Get private data of item
1853 * @param item The item
1854 * @return The data pointer stored, or NULL if none was stored
1856 * @ingroup Multibuttonentry
1859 elm_multibuttonentry_item_data_get(Elm_Multibuttonentry_Item *item)
1861 if (!item) return NULL;
1866 * Set private data of item
1868 * @param item The item
1869 * @param data The ponter to the data to be attached
1871 * @ingroup Multibuttonentry
1874 elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
1881 * Set the multibuttonentry item_verify_callback function
1883 * @param obj The multibuttonentry object
1884 * @param func The function pointer to be called, it it's NULL, callback function will be deleted.
1885 * @param data user data to be passed to the callback function
1887 * @ingroup Multibuttonentry
1890 elm_multibuttonentry_item_verify_callback_set(Evas_Object *obj, Elm_Multibuttonentry_Item_Verify_Callback func, void *data)
1892 ELM_CHECK_WIDTYPE(obj, widtype);
1893 Widget_Data *wd = elm_widget_data_get(obj);
1896 wd->add_callback = func;
1897 wd->add_callback_data = data;