1 #include <Elementary.h>
7 typedef enum _Multibuttonentry_Pos
9 MULTIBUTTONENTRY_POS_START,
10 MULTIBUTTONENTRY_POS_END,
11 MULTIBUTTONENTRY_POS_BEFORE,
12 MULTIBUTTONENTRY_POS_AFTER,
13 MULTIBUTTONENTRY_POS_NUM
14 } Multibuttonentry_Pos;
16 typedef enum _Multibuttonentry_Button_State
18 MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
19 MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
20 MULTIBUTTONENTRY_BUTTON_STATE_NUM
21 } Multibuttonentry_Button_State;
23 typedef enum _MultiButtonEntry_Closed_Button_Type
25 MULTIBUTTONENTRY_CLOSED_IMAGE,
26 MULTIBUTTONENTRY_CLOSED_LABEL
27 } MultiButtonEntry_Closed_Button_Type;
29 typedef enum _Multibuttonentry_View_State
31 MULTIBUTTONENTRY_VIEW_NONE,
32 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
33 MULTIBUTTONENTRY_VIEW_ENTRY,
34 MULTIBUTTONENTRY_VIEW_SHRINK
35 } Multibuttonentry_View_State;
37 typedef struct _Widget_Data Widget_Data;
38 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
40 struct _Multibuttonentry_Item
44 Evas_Coord vw, rw; // vw: visual width, real width
48 typedef struct _Elm_Multibuttonentry_Item_Filter
50 Elm_Multibuttonentry_Item_Filter_callback callback_func;
52 } Elm_Multibuttonentry_Item_Filter;
60 Evas_Object *guidetext;
61 Evas_Object *end; // used to represent the total number of invisible buttons
63 Evas_Object *rect_for_end;
64 MultiButtonEntry_Closed_Button_Type end_type;
68 Eina_List *filter_list;
71 Multibuttonentry_View_State view_state;
73 Evas_Coord w_box, h_box;
76 Eina_Bool last_btn_select: 1;
78 Elm_Multibuttonentry_Item_Filter_callback add_callback;
79 void *add_callback_data;
82 static const char *widtype = NULL;
83 static void _del_hook(Evas_Object *obj);
84 static void _theme_hook(Evas_Object *obj);
85 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
86 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
87 static void _sizing_eval(Evas_Object *obj);
88 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
89 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
90 static void _event_init(Evas_Object *obj);
91 static void _shrink_mode_set(Evas_Object *obj, int shrink);
92 static void _view_update(Evas_Object *obj);
93 static void _set_label(Evas_Object *obj, const char *str);
94 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
95 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
96 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
97 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
98 static void _del_button_item(Elm_Multibuttonentry_Item *item);
99 static void _select_button(Evas_Object *obj, Evas_Object *btn);
100 static Elm_Multibuttonentry_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos,
101 const Elm_Multibuttonentry_Item *reference, void *data);
102 static void _add_button(Evas_Object *obj, const char *str);
103 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
104 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
105 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
107 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
108 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
109 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
110 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
111 static void _view_init(Evas_Object *obj);
112 static void _set_vis_guidetext(Evas_Object *obj);
113 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
114 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
115 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
116 static void _item_text_set_hook(Elm_Object_Item *it,
119 static const char * _item_text_get_hook(const Elm_Object_Item *it,
123 _del_hook(Evas_Object *obj)
125 Widget_Data *wd = elm_widget_data_get(obj);
130 Elm_Multibuttonentry_Item *item;
131 EINA_LIST_FREE(wd->items, item)
133 _del_button_obj(obj, item->button);
140 if (wd->entry) evas_object_del (wd->entry);
141 if (wd->label) evas_object_del (wd->label);
142 if (wd->guidetext) evas_object_del (wd->guidetext);
143 if (wd->end) evas_object_del (wd->end);
144 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
148 _theme_hook(Evas_Object *obj)
150 Widget_Data *wd = elm_widget_data_get(obj);
152 Elm_Multibuttonentry_Item *item;
156 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
157 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
158 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
160 EINA_LIST_FOREACH(wd->items, l, item)
163 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
164 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
171 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
173 Widget_Data *wd = elm_widget_data_get(obj);
177 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(wd->entry);
179 if (elm_widget_focus_get(obj))
181 if ((imf_context) && (wd->current))
183 ecore_imf_context_input_panel_show(imf_context);
185 else if ((imf_context) && ((!wd->current) || (!eina_list_count(wd->items))))
187 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
189 ecore_imf_context_input_panel_show(imf_context);
191 wd->focused = EINA_TRUE;
192 evas_object_smart_callback_call(obj, "focused", NULL);
196 wd->focused = EINA_FALSE;
198 if (imf_context) ecore_imf_context_input_panel_hide(imf_context);
199 evas_object_smart_callback_call(obj, "unfocused", NULL);
204 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
210 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
212 Widget_Data *wd = elm_widget_data_get(obj);
215 edje_object_signal_emit(wd->base, emission, source);
219 _sizing_eval(Evas_Object *obj)
221 Widget_Data *wd = elm_widget_data_get(obj);
222 Evas_Coord minw = -1, minh = -1;
223 Evas_Coord left, right, top, bottom;
226 evas_object_size_hint_min_get(wd->box, &minw, &minh);
227 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
228 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
230 minw += (left + right);
231 minh += (top + bottom);
233 evas_object_size_hint_min_set(obj, minw, minh);
237 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
239 Widget_Data *wd = elm_widget_data_get(data);
241 if (!wd || !wd->base) return;
242 wd->focused = EINA_TRUE;
245 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(wd->entry);
247 if (imf_context) ecore_imf_context_input_panel_show(imf_context);
248 evas_object_smart_callback_call(data, "clicked", NULL);
252 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
254 Evas_Object *eo = (Evas_Object *)data;
255 Widget_Data *wd = elm_widget_data_get(data);
262 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
264 Widget_Data *wd = elm_widget_data_get(data);
268 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
270 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
271 else if (wd->h_box > h) evas_object_smart_callback_call (data, "shrank", NULL);
280 _event_init(Evas_Object *obj)
282 Widget_Data *wd = elm_widget_data_get(obj);
284 if (!wd || !wd->base) return;
287 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
288 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
293 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
294 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
299 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
300 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
301 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
302 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
303 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
304 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
305 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
310 _set_vis_guidetext(Evas_Object *obj)
312 Widget_Data *wd = elm_widget_data_get(obj);
315 elm_box_unpack(wd->box, wd->guidetext);
316 elm_box_unpack(wd->box, wd->entry);
317 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
319 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
320 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
322 evas_object_hide(wd->entry);
323 elm_box_pack_end(wd->box, wd->guidetext);
324 evas_object_show(wd->guidetext);
325 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
329 evas_object_hide(wd->guidetext);
332 elm_box_pack_end(wd->box, wd->entry);
333 evas_object_show(wd->entry);
335 if (elm_widget_focus_get(obj) || wd->focused)
337 elm_object_focus_set(wd->entry, EINA_TRUE);
338 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
343 _shrink_mode_set(Evas_Object *obj, int shrink)
345 Widget_Data *wd = elm_widget_data_get(obj);
347 Elm_Multibuttonentry_Item *item;
349 if (!wd || !wd->box) return;
350 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
351 evas_object_hide(wd->entry);
352 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
353 evas_object_hide(wd->guidetext);
354 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
356 evas_object_hide(wd->rect_for_end);
357 evas_object_hide(wd->end);
358 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
363 Evas_Coord w=0, w_tmp=0;
364 Evas_Coord box_inner_item_width_padding = 0;
366 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
367 // unpack all items and entry
368 elm_box_unpack_all(wd->box);
369 EINA_LIST_FOREACH(wd->items, l, item)
373 evas_object_hide(item->button);
374 item->visible = EINA_FALSE;
377 // pack buttons only 1line
382 elm_box_pack_end(wd->box, wd->label);
383 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
385 w -= box_inner_item_width_padding;
389 int count = eina_list_count(wd->items);
390 Evas_Coord button_min_width = 0;
391 /* Evas_Coord button_min_height = 0; */
392 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
394 const char *size_str;
395 size_str = edje_object_data_get(wd->end, "closed_button_width");
396 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
398 size_str = edje_object_data_get(wd->end, "closed_button_height");
399 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
403 EINA_LIST_FOREACH(wd->items, l, item)
407 int w_label_count = 0;
410 elm_box_pack_end(wd->box, item->button);
411 evas_object_show(item->button);
412 item->visible = EINA_TRUE;
415 w -= box_inner_item_width_padding;
418 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
422 snprintf(buf, sizeof(buf), "... + %d", count);
423 elm_object_text_set(wd->end, buf);
424 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
427 if (w < 0 || w < w_label_count)
429 elm_box_unpack(wd->box, item->button);
430 evas_object_hide(item->button);
431 item->visible = EINA_FALSE;
434 snprintf(buf, sizeof(buf), "... + %d", count);
435 elm_object_text_set(wd->end, buf);
436 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
438 elm_box_pack_end(wd->box, wd->end);
439 evas_object_show(wd->end);
441 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
442 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
446 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
448 if (w < button_min_width)
451 Evas_Coord closed_height = 0;
452 const char *height_str = edje_object_data_get(wd->base, "closed_height");
454 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
455 elm_box_unpack(wd->box, item->button);
456 evas_object_hide(item->button);
457 item->visible = EINA_FALSE;
460 rectSize = w - button_min_width;
461 if (!wd->rect_for_end)
463 Evas *e = evas_object_evas_get(obj);
464 wd->rect_for_end = evas_object_rectangle_add(e);
465 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
467 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get());
468 elm_box_pack_end(wd->box, wd->rect_for_end);
469 evas_object_show(wd->rect_for_end);
471 elm_box_pack_end(wd->box, wd->end);
472 evas_object_show(wd->end);
474 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
475 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
484 // unpack all items and entry
485 elm_box_unpack_all(wd->box);
486 EINA_LIST_FOREACH(wd->items, l, item)
490 evas_object_hide(item->button);
491 item->visible = EINA_FALSE;
494 evas_object_hide(wd->end);
496 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
498 // pack buttons only 1line
500 if (wd->label) elm_box_pack_end(wd->box, wd->label);
504 EINA_LIST_FOREACH(wd->items, l, item)
508 elm_box_pack_end(wd->box, item->button);
509 evas_object_show(item->button);
510 item->visible = EINA_TRUE;
514 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
515 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)wd->shrink);
517 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
519 _set_vis_guidetext(obj);
524 _view_update(Evas_Object *obj)
526 Evas_Coord width = 1, height = 1;
527 Widget_Data *wd = elm_widget_data_get(obj);
529 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
534 elm_box_unpack(wd->box, wd->label);
535 elm_box_pack_start(wd->box, wd->label);
536 evas_object_size_hint_min_get(wd->label, &width, &height);
541 Evas_Coord guide_text_width = wd->w_box - width;
542 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
545 // update buttons in shrink mode
546 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
547 _shrink_mode_set(obj, 1);
550 _set_vis_guidetext(obj);
554 _set_label(Evas_Object *obj, const char* str)
556 Widget_Data *wd = elm_widget_data_get(obj);
558 if (!wd || !str) return;
561 Evas_Coord width, height, sum_width = 0;
562 evas_object_size_hint_min_set(wd->label, 0, 0);
563 evas_object_resize(wd->label, 0, 0);
564 edje_object_part_text_set(wd->label, "mbe.label", str);
566 if (!strcmp(str, ""))
568 /* FIXME: not work yet */
569 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
570 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
575 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
576 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
580 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
583 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
586 evas_object_size_hint_min_set(wd->label, sum_width, height);
588 evas_object_show(wd->label);
593 _set_guidetext(Evas_Object *obj, const char* str)
595 Widget_Data *wd = elm_widget_data_get(obj);
597 if (!wd || !str) return;
600 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
601 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
602 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
603 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
606 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
611 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
613 Widget_Data *wd = elm_widget_data_get(obj);
614 Elm_Multibuttonentry_Item *item = NULL;
618 item = eina_list_data_get(wd->current);
620 if (item && item->button)
624 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
625 edje_object_signal_emit(item->button, "default", "");
628 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
629 edje_object_signal_emit(item->button, "focused", "");
630 evas_object_smart_callback_call(obj, "item,selected", item);
633 edje_object_signal_emit(item->button, "default", "");
641 _change_current_button(Evas_Object *obj, Evas_Object *btn)
643 Widget_Data *wd = elm_widget_data_get(obj);
645 Elm_Multibuttonentry_Item *item;
649 // change the state of previous button to "default"
650 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
652 // change the current
653 EINA_LIST_FOREACH(wd->items, l, item)
655 if (item->button == btn)
661 // change the state of current button to "focused"
662 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
666 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
668 Widget_Data *wd = elm_widget_data_get(data);
670 Elm_Multibuttonentry_Item *item = NULL;
671 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
673 _select_button(data, obj);
675 if ((wd->current) && ((item = eina_list_data_get(wd->current)) != NULL))
676 evas_object_smart_callback_call(data, "item,clicked", item);
680 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
682 Widget_Data *wd = elm_widget_data_get(obj);
684 if (!wd || !btn) return;
686 evas_object_del(btn);
690 _del_button_item(Elm_Multibuttonentry_Item *item)
693 Elm_Multibuttonentry_Item *_item;
697 Evas_Object *obj = WIDGET(item);
698 wd = elm_widget_data_get(obj);
700 EINA_LIST_FOREACH(wd->items, l, _item)
704 wd->items = eina_list_remove(wd->items, _item);
705 elm_box_unpack(wd->box, _item->button);
707 evas_object_smart_callback_call(obj, "item,deleted", _item);
709 _del_button_obj(obj, _item->button);
711 if (wd->current == l)
716 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
717 _shrink_mode_set(obj, 1);
719 if (!eina_list_count(wd->items))
720 _set_vis_guidetext(obj);
724 _select_button(Evas_Object *obj, Evas_Object *btn)
726 Widget_Data *wd = elm_widget_data_get(obj);
731 _change_current_button(obj, btn);
732 if (elm_widget_focus_get(obj))
734 elm_object_focus_set(wd->entry, EINA_FALSE);
735 evas_object_focus_set(btn, EINA_TRUE);
740 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
741 if (elm_widget_focus_get(obj))
742 elm_object_focus_set(wd->entry, EINA_TRUE);
747 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
750 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
751 Evas_Coord w_btn = 0, button_max_width = 0;
752 const char *size_str;
753 const char *ellipsis = "<ellipsis=1.0>";
755 size_str = edje_object_data_get(btn, "button_max_size");
756 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
757 const char *button_text = edje_object_part_text_get(btn, "elm.btn.text");
759 // decide the size of button
760 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
761 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
762 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
763 w_btn = w_text + 2*padding_outer + 2*padding_inner;
767 if (button_max_width < w_btn)
769 vw = button_max_width;
770 edje_object_part_text_set(btn, "elm.btn.text", ellipsis);
771 edje_object_part_text_append(btn, "elm.btn.text", button_text);
777 evas_object_resize(btn, vw, h_btn);
778 evas_object_size_hint_min_set(btn, vw, h_btn);
780 if (realw) *realw = rw;
781 if (vieww) *vieww = vw;
785 _item_del_pre_hook(Elm_Object_Item *it)
787 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
788 _del_button_item((Elm_Multibuttonentry_Item *) it);
792 static Elm_Multibuttonentry_Item*
793 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
795 Elm_Multibuttonentry_Item *item;
796 Elm_Multibuttonentry_Item_Filter *item_filter;
799 Evas_Coord width = -1, height = -1;
800 char *str_utf8 = NULL;
802 Widget_Data *wd = elm_widget_data_get(obj);
804 if (!wd || !wd->box || !wd->entry) return NULL;
806 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
808 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
812 btn = edje_object_add(evas_object_evas_get(obj));
813 str_utf8 = elm_entry_markup_to_utf8(str);
815 //entry is cleared when text is made to button
816 elm_object_text_set(wd->entry, "");
818 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
819 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
820 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
822 evas_object_size_hint_min_set(btn, width, height);
824 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
825 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
826 evas_object_show(btn);
829 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
832 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
833 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
834 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
835 elm_widget_item_data_set(item, data);
837 _resize_button(btn, &rw, &vw);
841 item->visible = EINA_TRUE;
845 case MULTIBUTTONENTRY_POS_START:
846 wd->items = eina_list_prepend(wd->items, item);
847 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
849 elm_widget_sub_object_add(obj, btn);
850 _shrink_mode_set(obj, 1);
855 elm_box_pack_after(wd->box, btn, wd->label);
857 elm_box_pack_start(wd->box, btn);
858 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
859 _set_vis_guidetext(obj);
862 case MULTIBUTTONENTRY_POS_END:
863 wd->items = eina_list_append(wd->items, item);
864 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
866 elm_widget_sub_object_add(obj, btn);
867 evas_object_hide(btn);
871 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
872 _set_vis_guidetext(obj);
876 elm_box_pack_before(wd->box, btn, wd->entry);
878 elm_box_pack_end(wd->box, btn);
881 elm_box_pack_end(wd->box, btn);
884 case MULTIBUTTONENTRY_POS_BEFORE:
886 wd->items = eina_list_prepend_relative(wd->items, item, reference);
888 wd->items = eina_list_append(wd->items, item);
889 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
891 elm_widget_sub_object_add(obj, btn);
892 evas_object_hide(btn);
893 _shrink_mode_set(obj, 1);
898 elm_box_pack_before(wd->box, btn, reference->button);
901 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
902 _set_vis_guidetext(obj);
906 elm_box_pack_before(wd->box, btn, wd->entry);
908 elm_box_pack_end(wd->box, btn);
911 elm_box_pack_end(wd->box, btn);
915 case MULTIBUTTONENTRY_POS_AFTER:
917 wd->items = eina_list_append_relative(wd->items, item, reference);
919 wd->items = eina_list_append(wd->items, item);
920 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
922 elm_widget_sub_object_add(obj, btn);
923 _shrink_mode_set(obj, 1);
928 elm_box_pack_after(wd->box, btn, reference->button);
931 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
932 _set_vis_guidetext(obj);
936 elm_box_pack_before(wd->box, btn, wd->entry);
938 elm_box_pack_end(wd->box, btn);
941 elm_box_pack_end(wd->box, btn);
949 evas_object_smart_callback_call(obj, "item,added", item);
957 _add_button(Evas_Object *obj, const char *str)
959 Widget_Data *wd = elm_widget_data_get(obj);
962 _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
965 static Elm_Multibuttonentry_Item_Filter*
966 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
968 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
969 if (!item_filter) return NULL;
971 item_filter->callback_func= func;
972 item_filter->data = data;
978 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
984 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
986 Widget_Data *wd = elm_widget_data_get(data);
987 Elm_Multibuttonentry_Item *item = NULL;
989 if (!wd || !wd->base || !wd->box) return;
991 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
993 if (wd->last_btn_select)
996 ((strcmp(ev->keyname, "BackSpace") == 0) ||
997 (strcmp(ev->keyname, "BackSpace (") == 0)))
999 item = eina_list_data_get(wd->current);
1002 _del_button_item(item);
1003 elm_widget_item_free(item);
1004 elm_object_focus_set(wd->entry, EINA_TRUE);
1007 else if (((!wd->current && (wd->n_str == 0) &&
1008 (strcmp(ev->keyname, "BackSpace") == 0)) ||
1009 (strcmp(ev->keyname, "BackSpace (") == 0)))
1011 item = eina_list_data_get(eina_list_last(wd->items));
1013 _select_button(data, item->button);
1017 wd->last_btn_select = EINA_TRUE;
1021 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1023 Widget_Data *wd = elm_widget_data_get(data);
1024 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1028 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
1029 wd->last_btn_select = EINA_FALSE;
1033 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1035 Widget_Data *wd = elm_widget_data_get(data);
1036 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1039 if (!wd || !wd->base || !wd->box) return;
1041 str = elm_object_text_get(wd->entry);
1043 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1045 _add_button(data, str);
1051 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1053 Widget_Data *wd = elm_widget_data_get(data);
1056 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1057 elm_object_focus_set(wd->entry, EINA_TRUE);
1061 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1063 Widget_Data *wd = elm_widget_data_get(data);
1064 Elm_Multibuttonentry_Item *item = NULL;
1070 item = eina_list_data_get(wd->current);
1071 elm_object_focus_set(wd->entry, EINA_FALSE);
1072 evas_object_focus_set(item->button, EINA_TRUE);
1077 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1079 Widget_Data *wd = elm_widget_data_get(data);
1084 str = elm_object_text_get(wd->entry);
1086 _add_button(data, str);
1090 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1092 Widget_Data *wd = elm_widget_data_get(data);
1097 str = elm_object_text_get(wd->entry);
1098 wd->n_str = strlen(str);
1102 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1104 Evas_Coord en_x, en_y, en_w, en_h;
1106 Widget_Data *wd = elm_widget_data_get(data);
1109 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1112 elm_widget_show_region_set(wd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
1116 _view_init(Evas_Object *obj)
1118 Widget_Data *wd = elm_widget_data_get(obj);
1124 wd->box = elm_box_add (obj);
1125 if (!wd->box) return;
1126 elm_widget_sub_object_add(obj, wd->box);
1127 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1128 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1129 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1133 wd->label = edje_object_add(evas_object_evas_get(obj));
1134 if (!wd->label) return;
1135 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1136 _set_label(obj, "");
1137 elm_widget_sub_object_add(obj, wd->label);
1142 wd->entry = elm_entry_add (obj);
1143 if (!wd->entry) return;
1144 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1145 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1146 elm_object_text_set(wd->entry, "");
1147 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1148 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1149 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1150 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1151 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1152 evas_object_show(wd->entry);
1153 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1158 const char *end_type;
1160 end_type = edje_object_data_get(wd->base, "closed_button_type");
1161 if (!end_type || !strcmp(end_type, "label"))
1163 wd->end = elm_label_add (obj);
1164 if (!wd->end) return;
1165 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1166 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1170 const char *size_str;
1171 wd->end = edje_object_add(evas_object_evas_get(obj));
1172 if (!wd->end) return;
1173 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1174 Evas_Coord button_min_width = 0;
1175 Evas_Coord button_min_height = 0;
1177 size_str = edje_object_data_get(wd->end, "closed_button_width");
1178 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1179 size_str = edje_object_data_get(wd->end, "closed_button_height");
1180 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1182 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1183 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1184 elm_widget_sub_object_add(obj, wd->end);
1190 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1192 Evas_Coord minw, minh, mnw, mnh, ww;
1193 Evas_Coord w, cw = 0, cmaxh = 0;
1195 Evas_Object_Box_Option *opt;
1198 /* FIXME: need to calc max */
1202 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1203 evas_object_size_hint_min_get(box, &minw, NULL);
1205 EINA_LIST_FOREACH(priv->children, l, opt)
1207 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1208 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1212 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1215 if (mnw != -1 && (w - cw) >= mnw)
1230 if (cmaxh < mnh) cmaxh = mnh;
1235 evas_object_size_hint_min_set(box, minw, minh);
1239 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1241 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1243 Evas_Object_Box_Option *opt;
1247 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1249 EINA_LIST_FOREACH(priv->children, l, opt)
1251 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1252 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1256 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1259 if (mnw != -1 && (w - cw) >= mnw)
1269 if (index > obj_index) return cmaxh;
1275 if (cmaxh < mnh) cmaxh = mnh;
1284 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1286 Evas_Coord x, y, w, h, xx, yy;
1289 Evas_Coord minw, minh;
1291 Evas_Object_Box_Option *opt;
1293 _calculate_box_min_size(o, priv);
1295 evas_object_geometry_get(o, &x, &y, &w, &h);
1297 evas_object_size_hint_min_get(o, &minw, &minh);
1298 evas_object_size_hint_align_get(o, &ax, &ay);
1301 x = x + ((w - minw) * (1.0 - ax));
1306 y = y + ((h - minh) * (1.0 - ay));
1313 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1315 EINA_LIST_FOREACH(priv->children, l, opt)
1317 Evas_Coord mnw, mnh, mxw, mxh;
1322 evas_object_size_hint_align_get(obj, &ax, &ay);
1323 evas_object_size_hint_weight_get(obj, &wx, &wy);
1324 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1325 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1327 if (ax == -1.0) {fw = 1; ax = 0.5;}
1328 if (ay == -1.0) {fh = 1; ay = 0.5;}
1329 Evas_Coord ww, hh, ow, oh;
1333 if ((elm_widget_is(obj)) && (!(strcmp(elm_widget_type_get(obj), "entry"))) && (mnw == -1))
1336 if (mnw != -1 && (w - cw) >= mnw)
1343 hh = _calculate_item_max_height(o, priv, obj_index);
1347 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1350 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1359 evas_object_move(obj,
1360 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1361 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1362 evas_object_resize(obj, ow, oh);
1365 if (cmaxh < hh) cmaxh = hh;
1372 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1374 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1376 Elm_Multibuttonentry_Item *item;
1377 if (part && strcmp(part, "default")) return;
1379 item = (Elm_Multibuttonentry_Item *) it;
1380 edje_object_part_text_set(item->button, "elm.btn.text", label);
1381 _resize_button(item->button, &item->rw, &item->vw);
1385 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1387 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1388 Elm_Multibuttonentry_Item *item;
1389 if (part && strcmp(part, "default")) return NULL;
1390 item = (Elm_Multibuttonentry_Item *) it;
1391 return edje_object_part_text_get(item->button, "elm.btn.text");
1395 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1397 ELM_CHECK_WIDTYPE(obj, widtype);
1398 if (part && strcmp(part, "default")) return;
1399 if (label) _set_label(obj, label);
1400 else _set_label(obj, "");
1404 _text_get_hook(const Evas_Object *obj, const char *part)
1406 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1408 if (part && strcmp(part, "default")) return NULL;
1409 wd = elm_widget_data_get(obj);
1410 if (!wd) return NULL;
1411 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1416 elm_multibuttonentry_add(Evas_Object *parent)
1422 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1424 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1425 elm_widget_type_set(obj, "multibuttonentry");
1426 elm_widget_sub_object_add(parent, obj);
1427 elm_widget_data_set(obj, wd);
1429 elm_widget_del_hook_set(obj, _del_hook);
1430 elm_widget_theme_hook_set(obj, _theme_hook);
1431 elm_widget_event_hook_set(obj, _event_hook);
1432 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1433 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1434 elm_widget_text_set_hook_set(obj, _text_set_hook);
1435 elm_widget_text_get_hook_set(obj, _text_get_hook);
1437 wd->base = edje_object_add(e);
1438 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1439 elm_widget_resize_object_set(obj, wd->base);
1440 elm_widget_can_focus_set(obj, EINA_TRUE);
1442 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1443 wd->focused = EINA_FALSE;
1444 wd->last_btn_select = EINA_TRUE;
1446 wd->rect_for_end= NULL;
1447 wd->add_callback = NULL;
1448 wd->add_callback_data = NULL;
1457 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1459 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1460 Widget_Data *wd = elm_widget_data_get(obj);
1462 if (!wd) return NULL;
1468 elm_multibuttonentry_label_get(const Evas_Object *obj)
1470 return _text_get_hook(obj, NULL);
1474 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1476 _text_set_hook(obj, NULL, label);
1480 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1482 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1483 Widget_Data *wd = elm_widget_data_get(obj);
1485 if (!wd) return NULL;
1486 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1491 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1493 ELM_CHECK_WIDTYPE(obj, widtype);
1494 Widget_Data *wd = elm_widget_data_get(obj);
1498 _set_guidetext(obj, guidetext);
1500 _set_guidetext(obj, "");
1504 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1506 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1507 Widget_Data *wd = elm_widget_data_get(obj);
1510 return wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? 1 : 0;
1514 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1516 ELM_CHECK_WIDTYPE(obj, widtype);
1517 Widget_Data *wd = elm_widget_data_get(obj);
1519 if (!wd || !wd->box ||
1520 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? 1 : 0) == shrink) return;
1521 _shrink_mode_set(obj, shrink);
1524 EAPI Elm_Object_Item *
1525 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1527 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1528 Elm_Multibuttonentry_Item *item;
1529 if (!label) return NULL;
1530 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1531 return (Elm_Object_Item *) item;
1534 EAPI Elm_Object_Item *
1535 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1537 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1538 Elm_Multibuttonentry_Item *item;
1539 if (!label) return NULL;
1540 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1541 return (Elm_Object_Item *) item;
1544 EAPI Elm_Object_Item *
1545 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1547 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1548 Elm_Multibuttonentry_Item *item;
1549 if (!label) return NULL;
1550 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE,
1551 (Elm_Multibuttonentry_Item *) before, data);
1552 return (Elm_Object_Item *) item;
1555 EAPI Elm_Object_Item *
1556 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
1558 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1559 Elm_Multibuttonentry_Item *item;
1560 if (!label) return NULL;
1561 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER,
1562 (Elm_Multibuttonentry_Item *) after, data);
1563 return (Elm_Object_Item *) item;
1566 EAPI const Eina_List *
1567 elm_multibuttonentry_items_get(const Evas_Object *obj)
1569 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1570 Widget_Data *wd = elm_widget_data_get(obj);
1571 if (!wd) return NULL;
1575 EAPI Elm_Object_Item *
1576 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1578 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1579 Widget_Data *wd = elm_widget_data_get(obj);
1580 if (!wd) return NULL;
1581 return eina_list_data_get(wd->items);
1584 EAPI Elm_Object_Item *
1585 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1587 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1588 Widget_Data *wd = elm_widget_data_get(obj);
1589 if (!wd) return NULL;
1590 return eina_list_data_get(eina_list_last(wd->items));
1593 EAPI Elm_Object_Item *
1594 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1596 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1597 Widget_Data *wd = elm_widget_data_get(obj);
1598 if (!wd) return NULL;
1599 return eina_list_data_get(wd->current);
1603 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
1605 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1606 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1607 if (selected) _select_button(WIDGET(item), item->button);
1608 else _select_button(WIDGET(item), NULL);
1612 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1614 ELM_CHECK_WIDTYPE(obj, widtype);
1615 Widget_Data *wd = elm_widget_data_get(obj);
1617 _select_button(obj, NULL);
1621 elm_multibuttonentry_clear(Evas_Object *obj)
1623 ELM_CHECK_WIDTYPE(obj, widtype);
1624 Elm_Multibuttonentry_Item *item;
1625 Widget_Data *wd = elm_widget_data_get(obj);
1630 EINA_LIST_FREE(wd->items, item)
1632 elm_box_unpack(wd->box, item->button);
1633 _del_button_obj(obj, item->button);
1643 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1645 elm_object_item_del(it);
1649 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1651 return _item_text_get_hook(it, NULL);
1655 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1657 _item_text_set_hook(it, NULL, str);
1660 EAPI Elm_Object_Item *
1661 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1663 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1666 Elm_Multibuttonentry_Item *_item;
1668 wd = elm_widget_data_get(WIDGET(it));
1669 if (!wd) return NULL;
1671 EINA_LIST_FOREACH(wd->items, l, _item)
1673 if (_item == (Elm_Multibuttonentry_Item *) it)
1675 l = eina_list_prev(l);
1676 if (!l) return NULL;
1677 return eina_list_data_get(l);
1683 EAPI Elm_Object_Item *
1684 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1686 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1689 Elm_Multibuttonentry_Item *_item;
1690 wd = elm_widget_data_get(WIDGET(it));
1691 if (!wd) return NULL;
1693 EINA_LIST_FOREACH(wd->items, l, _item)
1695 if (_item == (Elm_Multibuttonentry_Item *) it)
1697 l = eina_list_next(l);
1698 if (!l) return NULL;
1699 return eina_list_data_get(l);
1706 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1708 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1709 return elm_widget_item_data_get(it);
1713 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1715 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1716 return elm_widget_item_data_set(it, data);
1720 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1722 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1723 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1726 Widget_Data *wd = elm_widget_data_get(obj);
1729 ELM_CHECK_WIDTYPE(obj, widtype);
1730 EINA_SAFETY_ON_NULL_RETURN(func);
1732 new_item_filter= _filter_new(func, data);
1733 if (!new_item_filter) return;
1735 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1737 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1739 printf("Already Registered this item filter!!!!\n");
1743 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1747 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1749 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1750 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1752 Widget_Data *wd = elm_widget_data_get(obj);
1755 ELM_CHECK_WIDTYPE(obj, widtype);
1756 EINA_SAFETY_ON_NULL_RETURN(func);
1758 new_item_filter = _filter_new(func, data);
1759 if (!new_item_filter) return;
1761 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1763 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1765 printf("Already Registered this item filter!!!!\n");
1769 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1773 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1777 Elm_Multibuttonentry_Item_Filter *item_filter;
1779 wd = elm_widget_data_get(obj);
1781 EINA_SAFETY_ON_NULL_RETURN(func);
1783 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1785 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1787 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1788 _filter_free(item_filter);
1795 elm_multibuttonentry_view_mode(Evas_Object *obj, Eina_Bool view_mode)
1797 ELM_CHECK_WIDTYPE(obj, widtype);
1798 Widget_Data *wd = elm_widget_data_get(obj);
1799 wd->view_mode = view_mode;
1803 elm_box_unpack(wd->box, wd->entry);
1804 evas_object_hide(wd->entry);