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;
77 Elm_Multibuttonentry_Item_Filter_callback add_callback;
78 void *add_callback_data;
81 static const char *widtype = NULL;
82 static void _del_hook(Evas_Object *obj);
83 static void _theme_hook(Evas_Object *obj);
84 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
85 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
86 static void _sizing_eval(Evas_Object *obj);
87 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
88 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
89 static void _event_init(Evas_Object *obj);
90 static void _shrink_mode_set(Evas_Object *obj, int shrink);
91 static void _view_update(Evas_Object *obj);
92 static void _set_label(Evas_Object *obj, const char *str);
93 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
94 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
95 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
96 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
97 static void _del_button_item(Elm_Multibuttonentry_Item *item);
98 static void _select_button(Evas_Object *obj, Evas_Object *btn);
99 static Elm_Multibuttonentry_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos,
100 const Elm_Multibuttonentry_Item *reference, void *data);
101 static void _add_button(Evas_Object *obj, const char *str);
102 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
103 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
104 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
107 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
108 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
109 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
110 static void _view_init(Evas_Object *obj);
111 static void _set_vis_guidetext(Evas_Object *obj);
112 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
113 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
114 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
115 static void _item_text_set_hook(Elm_Object_Item *it,
118 static const char *_item_text_get_hook(const Elm_Object_Item *it,
121 // XXX: use evas_object_smart_callback_descriptions_set for smart callbacks.
124 _del_hook(Evas_Object *obj)
126 Widget_Data *wd = elm_widget_data_get(obj);
131 Elm_Multibuttonentry_Item *item;
132 EINA_LIST_FREE(wd->items, item)
134 _del_button_obj(obj, item->button);
141 if (wd->entry) evas_object_del (wd->entry);
142 if (wd->label) evas_object_del (wd->label);
143 if (wd->guidetext) evas_object_del (wd->guidetext);
144 if (wd->end) evas_object_del (wd->end);
145 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
149 _theme_hook(Evas_Object *obj)
151 Widget_Data *wd = elm_widget_data_get(obj);
153 Elm_Multibuttonentry_Item *item;
157 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
158 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
159 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
161 EINA_LIST_FOREACH(wd->items, l, item)
164 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
165 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
172 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
174 Widget_Data *wd = elm_widget_data_get(obj);
178 if (elm_widget_focus_get(obj))
182 elm_entry_input_panel_show(wd->entry);
184 else if (((!wd->current) || (!eina_list_count(wd->items))))
186 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
188 elm_entry_input_panel_show(wd->entry);
190 wd->focused = EINA_TRUE;
191 evas_object_smart_callback_call(obj, "focused", NULL);
195 wd->focused = EINA_FALSE;
198 elm_entry_input_panel_hide(wd->entry);
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 elm_entry_input_panel_show(wd->entry);
247 evas_object_smart_callback_call(data, "clicked", NULL);
251 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
253 Evas_Object *eo = (Evas_Object *)data;
254 Widget_Data *wd = elm_widget_data_get(data);
261 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
263 Widget_Data *wd = elm_widget_data_get(data);
267 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
269 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
270 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
279 _event_init(Evas_Object *obj)
281 Widget_Data *wd = elm_widget_data_get(obj);
283 if (!wd || !wd->base) return;
286 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
287 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
292 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
293 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
298 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
299 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
300 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
301 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
302 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
303 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
304 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
309 _set_vis_guidetext(Evas_Object *obj)
311 Widget_Data *wd = elm_widget_data_get(obj);
314 elm_box_unpack(wd->box, wd->guidetext);
315 elm_box_unpack(wd->box, wd->entry);
316 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
318 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
319 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
321 evas_object_hide(wd->entry);
322 elm_box_pack_end(wd->box, wd->guidetext);
323 evas_object_show(wd->guidetext);
324 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
328 evas_object_hide(wd->guidetext);
329 elm_box_pack_end(wd->box, wd->entry);
330 evas_object_show(wd->entry);
331 if (elm_widget_focus_get(obj) || wd->focused)
333 elm_object_focus_set(wd->entry, EINA_TRUE);
334 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
339 _shrink_mode_set(Evas_Object *obj, int shrink)
341 Widget_Data *wd = elm_widget_data_get(obj);
343 Elm_Multibuttonentry_Item *item;
345 if (!wd || !wd->box) return;
346 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
347 evas_object_hide(wd->entry);
348 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
349 evas_object_hide(wd->guidetext);
350 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
352 evas_object_hide(wd->rect_for_end);
353 evas_object_hide(wd->end);
354 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
359 Evas_Coord w=0, w_tmp=0;
360 Evas_Coord box_inner_item_width_padding = 0;
362 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
363 // unpack all items and entry
364 elm_box_unpack_all(wd->box);
365 EINA_LIST_FOREACH(wd->items, l, item)
369 evas_object_hide(item->button);
370 item->visible = EINA_FALSE;
373 // pack buttons only 1line
378 elm_box_pack_end(wd->box, wd->label);
379 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
381 w -= box_inner_item_width_padding;
385 int count = eina_list_count(wd->items);
386 Evas_Coord button_min_width = 0;
387 /* Evas_Coord button_min_height = 0; */
388 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
390 const char *size_str;
391 size_str = edje_object_data_get(wd->end, "closed_button_width");
392 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
394 size_str = edje_object_data_get(wd->end, "closed_button_height");
395 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
399 EINA_LIST_FOREACH(wd->items, l, item)
403 int w_label_count = 0;
406 elm_box_pack_end(wd->box, item->button);
407 evas_object_show(item->button);
408 item->visible = EINA_TRUE;
411 w -= box_inner_item_width_padding;
414 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
418 snprintf(buf, sizeof(buf), "... + %d", count);
419 elm_object_text_set(wd->end, buf);
420 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
423 if (w < 0 || w < w_label_count)
425 elm_box_unpack(wd->box, item->button);
426 evas_object_hide(item->button);
427 item->visible = EINA_FALSE;
430 snprintf(buf, sizeof(buf), "... + %d", count);
431 elm_object_text_set(wd->end, buf);
432 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
434 elm_box_pack_end(wd->box, wd->end);
435 evas_object_show(wd->end);
437 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
438 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
442 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
444 if (w < button_min_width)
447 Evas_Coord closed_height = 0;
448 const char *height_str = edje_object_data_get(wd->base, "closed_height");
450 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
451 elm_box_unpack(wd->box, item->button);
452 evas_object_hide(item->button);
453 item->visible = EINA_FALSE;
456 rectSize = w - button_min_width;
457 if (!wd->rect_for_end)
459 Evas *e = evas_object_evas_get(obj);
460 wd->rect_for_end= evas_object_rectangle_add(e);
461 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
463 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get() );
464 elm_box_pack_end(wd->box, wd->rect_for_end);
465 evas_object_show(wd->rect_for_end);
467 elm_box_pack_end(wd->box, wd->end);
468 evas_object_show(wd->end);
470 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
471 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
480 // unpack all items and entry
481 elm_box_unpack_all(wd->box);
482 EINA_LIST_FOREACH(wd->items, l, item)
486 evas_object_hide(item->button);
487 item->visible = EINA_FALSE;
490 evas_object_hide(wd->end);
492 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
494 // pack buttons only 1line
496 if (wd->label) elm_box_pack_end(wd->box, wd->label);
500 EINA_LIST_FOREACH(wd->items, l, item)
504 elm_box_pack_end(wd->box, item->button);
505 evas_object_show(item->button);
506 item->visible = EINA_TRUE;
510 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
511 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)(long)wd->shrink);
513 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
515 _set_vis_guidetext(obj);
520 _view_update(Evas_Object *obj)
522 Evas_Coord width = 1, height = 1;
523 Widget_Data *wd = elm_widget_data_get(obj);
525 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
530 elm_box_unpack(wd->box, wd->label);
531 elm_box_pack_start(wd->box, wd->label);
532 evas_object_size_hint_min_get(wd->label, &width, &height);
537 Evas_Coord guide_text_width = wd->w_box - width;
538 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
541 // update buttons in shrink mode
542 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
543 _shrink_mode_set(obj, 1);
546 _set_vis_guidetext(obj);
550 _set_label(Evas_Object *obj, const char *str)
552 Widget_Data *wd = elm_widget_data_get(obj);
554 if (!wd || !str) return;
557 Evas_Coord width, height, sum_width = 0;
558 evas_object_size_hint_min_set(wd->label, 0, 0);
559 evas_object_resize(wd->label, 0, 0);
560 edje_object_part_text_set(wd->label, "mbe.label", str);
562 if (!strcmp(str, ""))
564 /* FIXME: not work yet */
565 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
566 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
571 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
572 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
576 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
579 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
582 evas_object_size_hint_min_set(wd->label, sum_width, height);
584 evas_object_show(wd->label);
589 _set_guidetext(Evas_Object *obj, const char *str)
591 Widget_Data *wd = elm_widget_data_get(obj);
593 if (!wd || !str) return;
596 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
597 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
598 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
599 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
602 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
607 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
609 Widget_Data *wd = elm_widget_data_get(obj);
610 Elm_Multibuttonentry_Item *item = NULL;
614 item = eina_list_data_get(wd->current);
616 if (item && item->button)
620 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
621 edje_object_signal_emit(item->button, "default", "");
624 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
625 edje_object_signal_emit(item->button, "focused", "");
626 evas_object_smart_callback_call(obj, "item,selected", item);
629 edje_object_signal_emit(item->button, "default", "");
637 _change_current_button(Evas_Object *obj, Evas_Object *btn)
639 Widget_Data *wd = elm_widget_data_get(obj);
641 Elm_Multibuttonentry_Item *item;
645 // change the state of previous button to "default"
646 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
648 // change the current
649 EINA_LIST_FOREACH(wd->items, l, item)
651 if (item->button == btn)
657 // change the state of current button to "focused"
658 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
662 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
664 Widget_Data *wd = elm_widget_data_get(data);
666 Elm_Multibuttonentry_Item *item = NULL;
667 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
669 _change_current_button(data, obj);
672 if ((item = eina_list_data_get(wd->current)) != NULL)
674 evas_object_smart_callback_call(data, "item,clicked", item);
675 _select_button(data, item->button);
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;
754 size_str = edje_object_data_get(btn, "button_max_size");
755 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
757 // decide the size of button
758 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
759 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
760 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
761 w_btn = w_text + 2*padding_outer + 2*padding_inner;
765 if (button_max_width < w_btn)
766 vw = button_max_width;
771 evas_object_resize(btn, vw, h_btn);
772 evas_object_size_hint_min_set(btn, vw, h_btn);
774 if (realw) *realw = rw;
775 if (vieww) *vieww = vw;
779 _item_del_pre_hook(Elm_Object_Item *it)
781 _del_button_item((Elm_Multibuttonentry_Item *) it);
785 static Elm_Multibuttonentry_Item*
786 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
788 Elm_Multibuttonentry_Item *item;
789 Elm_Multibuttonentry_Item_Filter *item_filter;
792 Evas_Coord width = -1, height = -1;
793 char *str_utf8 = NULL;
794 Widget_Data *wd = elm_widget_data_get(obj);
796 if (!wd || !wd->box || !wd->entry) return NULL;
798 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
800 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
804 btn = edje_object_add(evas_object_evas_get(obj));
805 str_utf8 = elm_entry_markup_to_utf8(str);
807 //entry is cleared when text is made to button
808 elm_object_text_set(wd->entry, "");
810 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
811 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
812 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
814 evas_object_size_hint_min_set(btn, width, height);
816 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
817 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
818 evas_object_show(btn);
821 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
824 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
825 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
826 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
827 elm_widget_item_data_set(item, data);
829 _resize_button(btn, &rw, &vw);
833 item->visible = EINA_TRUE;
837 case MULTIBUTTONENTRY_POS_START:
838 wd->items = eina_list_prepend(wd->items, item);
839 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
841 elm_widget_sub_object_add(obj, btn);
842 _shrink_mode_set(obj, 1);
847 elm_box_pack_after(wd->box, btn, wd->label);
849 elm_box_pack_start(wd->box, btn);
850 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
851 _set_vis_guidetext(obj);
854 case MULTIBUTTONENTRY_POS_END:
855 wd->items = eina_list_append(wd->items, item);
856 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
858 elm_widget_sub_object_add(obj, btn);
859 evas_object_hide(btn);
863 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
864 _set_vis_guidetext(obj);
866 elm_box_pack_before(wd->box, btn, wd->entry);
868 elm_box_pack_end(wd->box, btn);
871 case MULTIBUTTONENTRY_POS_BEFORE:
873 wd->items = eina_list_prepend_relative(wd->items, item, reference);
875 wd->items = eina_list_append(wd->items, item);
876 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
878 elm_widget_sub_object_add(obj, btn);
879 evas_object_hide(btn);
880 _shrink_mode_set(obj, 1);
885 elm_box_pack_before(wd->box, btn, reference->button);
888 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
889 _set_vis_guidetext(obj);
891 elm_box_pack_before(wd->box, btn, wd->entry);
893 elm_box_pack_end(wd->box, btn);
897 case MULTIBUTTONENTRY_POS_AFTER:
899 wd->items = eina_list_append_relative(wd->items, item, reference);
901 wd->items = eina_list_append(wd->items, item);
902 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
904 elm_widget_sub_object_add(obj, btn);
905 _shrink_mode_set(obj, 1);
910 elm_box_pack_after(wd->box, btn, reference->button);
913 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
914 _set_vis_guidetext(obj);
916 elm_box_pack_before(wd->box, btn, wd->entry);
918 elm_box_pack_end(wd->box, btn);
926 evas_object_smart_callback_call(obj, "item,added", item);
934 _add_button(Evas_Object *obj, const char *str)
936 Widget_Data *wd = elm_widget_data_get(obj);
939 _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
942 static Elm_Multibuttonentry_Item_Filter*
943 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
945 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
946 if (!item_filter) return NULL;
948 item_filter->callback_func= func;
949 item_filter->data = data;
955 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
961 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
963 Widget_Data *wd = elm_widget_data_get(data);
964 Elm_Multibuttonentry_Item *item = NULL;
966 if (!wd || !wd->base || !wd->box) return;
968 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
970 if (wd->last_btn_select)
973 ((strcmp(ev->keyname, "BackSpace") == 0) ||
974 (strcmp(ev->keyname, "BackSpace (") == 0)))
976 item = eina_list_data_get(wd->current);
979 _del_button_item(item);
980 elm_widget_item_free(item);
981 elm_object_focus_set(wd->entry, EINA_TRUE);
984 else if (((!wd->current && (wd->n_str == 0) &&
985 (strcmp(ev->keyname, "BackSpace") == 0)) ||
986 (strcmp(ev->keyname, "BackSpace (") == 0)))
988 item = eina_list_data_get(eina_list_last(wd->items));
990 _select_button(data, item->button);
994 wd->last_btn_select = EINA_TRUE;
998 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1000 Widget_Data *wd = elm_widget_data_get(data);
1001 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1005 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
1006 wd->last_btn_select = EINA_FALSE;
1010 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1012 Widget_Data *wd = elm_widget_data_get(data);
1013 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1016 if (!wd || !wd->base || !wd->box) return;
1018 str = elm_object_text_get(wd->entry);
1020 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1022 _add_button(data, str);
1028 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1030 Widget_Data *wd = elm_widget_data_get(data);
1033 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1034 elm_object_focus_set(wd->entry, EINA_TRUE);
1038 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1040 Widget_Data *wd = elm_widget_data_get(data);
1041 Elm_Multibuttonentry_Item *item = NULL;
1047 item = eina_list_data_get(wd->current);
1048 elm_object_focus_set(wd->entry, EINA_FALSE);
1049 evas_object_focus_set(item->button, EINA_TRUE);
1054 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1056 Widget_Data *wd = elm_widget_data_get(data);
1061 str = elm_object_text_get(wd->entry);
1063 _add_button(data, str);
1067 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1069 Widget_Data *wd = elm_widget_data_get(data);
1074 str = elm_object_text_get(wd->entry);
1075 wd->n_str = strlen(str);
1079 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1081 Evas_Coord en_x, en_y, en_w, en_h;
1082 Evas_Coord bx_x, bx_y;
1084 Widget_Data *wd = elm_widget_data_get(data);
1087 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1088 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1091 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
1096 _view_init(Evas_Object *obj)
1098 Widget_Data *wd = elm_widget_data_get(obj);
1104 wd->box = elm_box_add (obj);
1105 if (!wd->box) return;
1106 elm_widget_sub_object_add(obj, wd->box);
1107 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1108 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1109 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1113 wd->label = edje_object_add(evas_object_evas_get(obj));
1114 if (!wd->label) return;
1115 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1116 _set_label(obj, "");
1117 elm_widget_sub_object_add(obj, wd->label);
1122 wd->entry = elm_entry_add (obj);
1123 if (!wd->entry) return;
1124 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1125 elm_object_text_set(wd->entry, "");
1126 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1127 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1128 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1129 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1130 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1131 evas_object_show(wd->entry);
1132 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1137 const char *end_type;
1139 end_type = edje_object_data_get(wd->base, "closed_button_type");
1140 if (!end_type || !strcmp(end_type, "label"))
1142 wd->end = elm_label_add (obj);
1143 if (!wd->end) return;
1144 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1145 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1149 const char *size_str;
1150 wd->end = edje_object_add(evas_object_evas_get(obj));
1151 if (!wd->end) return;
1152 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1153 Evas_Coord button_min_width = 0;
1154 Evas_Coord button_min_height = 0;
1156 size_str = edje_object_data_get(wd->end, "closed_button_width");
1157 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1158 size_str = edje_object_data_get(wd->end, "closed_button_height");
1159 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1161 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1162 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1163 elm_widget_sub_object_add(obj, wd->end);
1169 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1171 Evas_Coord minw, minh, mnw, mnh, ww;
1172 Evas_Coord w, cw = 0, cmaxh = 0;
1174 Evas_Object_Box_Option *opt;
1177 /* FIXME: need to calc max */
1181 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1182 evas_object_size_hint_min_get(box, &minw, NULL);
1184 EINA_LIST_FOREACH(priv->children, l, opt)
1186 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1187 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1191 if (mnw != -1 && (w - cw) >= mnw)
1206 if (cmaxh < mnh) cmaxh = mnh;
1211 evas_object_size_hint_min_set(box, minw, minh);
1215 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1217 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1219 Evas_Object_Box_Option *opt;
1223 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1225 EINA_LIST_FOREACH(priv->children, l, opt)
1227 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1228 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1232 if (mnw != -1 && (w - cw) >= mnw)
1242 if (index > obj_index) return cmaxh;
1248 if (cmaxh < mnh) cmaxh = mnh;
1257 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1259 Evas_Coord x, y, w, h, xx, yy;
1262 Evas_Coord minw, minh;
1264 Evas_Object_Box_Option *opt;
1266 _calculate_box_min_size(o, priv);
1268 evas_object_geometry_get(o, &x, &y, &w, &h);
1270 evas_object_size_hint_min_get(o, &minw, &minh);
1271 evas_object_size_hint_align_get(o, &ax, &ay);
1274 x = x + ((w - minw) * (1.0 - ax));
1279 y = y + ((h - minh) * (1.0 - ay));
1286 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1288 EINA_LIST_FOREACH(priv->children, l, opt)
1290 Evas_Coord mnw, mnh, mxw, mxh;
1295 evas_object_size_hint_align_get(obj, &ax, &ay);
1296 evas_object_size_hint_weight_get(obj, &wx, &wy);
1297 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1298 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1300 if (ax == -1.0) {fw = 1; ax = 0.5;}
1301 if (ay == -1.0) {fh = 1; ay = 0.5;}
1302 Evas_Coord ww, hh, ow, oh;
1306 if (mnw != -1 && (w - cw) >= mnw)
1313 hh = _calculate_item_max_height(o, priv, obj_index);
1317 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1320 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1329 evas_object_move(obj,
1330 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1331 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1332 evas_object_resize(obj, ow, oh);
1335 if (cmaxh < hh) cmaxh = hh;
1342 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1344 Elm_Multibuttonentry_Item *item;
1345 if (part && strcmp(part, "default")) return;
1347 item = (Elm_Multibuttonentry_Item *) it;
1348 edje_object_part_text_set(item->button, "elm.btn.text", label);
1349 _resize_button(item->button, &item->rw, &item->vw);
1353 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1355 Elm_Multibuttonentry_Item *item;
1356 if (part && strcmp(part, "default")) return NULL;
1357 item = (Elm_Multibuttonentry_Item *) it;
1358 return edje_object_part_text_get(item->button, "elm.btn.text");
1362 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1364 ELM_CHECK_WIDTYPE(obj, widtype);
1365 if (part && strcmp(part, "default")) return;
1366 if (label) _set_label(obj, label);
1367 else _set_label(obj, "");
1371 _text_get_hook(const Evas_Object *obj, const char *part)
1373 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1375 if (part && strcmp(part, "default")) return NULL;
1376 wd = elm_widget_data_get(obj);
1377 if (!wd) return NULL;
1378 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1383 elm_multibuttonentry_add(Evas_Object *parent)
1389 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1391 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1392 elm_widget_type_set(obj, "multibuttonentry");
1393 elm_widget_sub_object_add(parent, obj);
1394 elm_widget_data_set(obj, wd);
1396 elm_widget_del_hook_set(obj, _del_hook);
1397 elm_widget_theme_hook_set(obj, _theme_hook);
1398 elm_widget_event_hook_set(obj, _event_hook);
1399 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1400 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1401 elm_widget_text_set_hook_set(obj, _text_set_hook);
1402 elm_widget_text_get_hook_set(obj, _text_get_hook);
1404 wd->base = edje_object_add(e);
1405 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1406 elm_widget_resize_object_set(obj, wd->base);
1407 elm_widget_can_focus_set(obj, EINA_TRUE);
1409 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1410 wd->focused = EINA_FALSE;
1411 wd->last_btn_select = EINA_TRUE;
1413 wd->rect_for_end= NULL;
1414 wd->add_callback = NULL;
1415 wd->add_callback_data = NULL;
1424 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1426 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1427 Widget_Data *wd = elm_widget_data_get(obj);
1429 if (!wd) return NULL;
1435 elm_multibuttonentry_label_get(const Evas_Object *obj)
1437 return _text_get_hook(obj, NULL);
1441 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1443 _text_set_hook(obj, NULL, label);
1447 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1449 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1450 Widget_Data *wd = elm_widget_data_get(obj);
1452 if (!wd) return NULL;
1453 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1458 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1460 ELM_CHECK_WIDTYPE(obj, widtype);
1461 Widget_Data *wd = elm_widget_data_get(obj);
1465 _set_guidetext(obj, guidetext);
1467 _set_guidetext(obj, "");
1470 EINA_DEPRECATED EAPI int
1471 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1473 if (elm_multibuttonentry_expanded_get(obj))
1480 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1482 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1483 Widget_Data *wd = elm_widget_data_get(obj);
1486 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1490 EINA_DEPRECATED EAPI void
1491 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1494 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
1497 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
1501 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1503 ELM_CHECK_WIDTYPE(obj, widtype);
1504 Widget_Data *wd = elm_widget_data_get(obj);
1506 if (!wd || !wd->box ||
1507 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1510 _shrink_mode_set(obj, 0);
1512 _shrink_mode_set(obj, 1);
1516 EAPI Elm_Object_Item *
1517 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1519 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1520 Elm_Multibuttonentry_Item *item;
1521 if (!label) return NULL;
1522 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1523 return (Elm_Object_Item *) item;
1526 EAPI Elm_Object_Item *
1527 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1529 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1530 Elm_Multibuttonentry_Item *item;
1531 if (!label) return NULL;
1532 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1533 return (Elm_Object_Item *) item;
1536 EAPI Elm_Object_Item *
1537 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1539 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1540 Elm_Multibuttonentry_Item *item;
1541 if (!label) return NULL;
1542 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE,
1543 (Elm_Multibuttonentry_Item *) before, data);
1544 return (Elm_Object_Item *) item;
1547 EAPI Elm_Object_Item *
1548 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
1550 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1551 Elm_Multibuttonentry_Item *item;
1552 if (!label) return NULL;
1553 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER,
1554 (Elm_Multibuttonentry_Item *) after, data);
1555 return (Elm_Object_Item *) item;
1558 EAPI const Eina_List *
1559 elm_multibuttonentry_items_get(const Evas_Object *obj)
1561 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1562 Widget_Data *wd = elm_widget_data_get(obj);
1563 if (!wd) return NULL;
1567 EAPI Elm_Object_Item *
1568 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1570 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1571 Widget_Data *wd = elm_widget_data_get(obj);
1572 if (!wd) return NULL;
1573 return eina_list_data_get(wd->items);
1576 EAPI Elm_Object_Item *
1577 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1579 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1580 Widget_Data *wd = elm_widget_data_get(obj);
1581 if (!wd) return NULL;
1582 return eina_list_data_get(eina_list_last(wd->items));
1585 EAPI Elm_Object_Item *
1586 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1588 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1589 Widget_Data *wd = elm_widget_data_get(obj);
1590 if (!wd) return NULL;
1591 return eina_list_data_get(wd->current);
1595 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
1597 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1598 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1599 if (selected) _select_button(WIDGET(item), item->button);
1600 else _select_button(WIDGET(item), NULL);
1604 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1606 ELM_CHECK_WIDTYPE(obj, widtype);
1607 Widget_Data *wd = elm_widget_data_get(obj);
1609 _select_button(obj, NULL);
1613 elm_multibuttonentry_clear(Evas_Object *obj)
1615 ELM_CHECK_WIDTYPE(obj, widtype);
1616 Elm_Multibuttonentry_Item *item;
1617 Widget_Data *wd = elm_widget_data_get(obj);
1622 EINA_LIST_FREE(wd->items, item)
1624 elm_box_unpack(wd->box, item->button);
1625 _del_button_obj(obj, item->button);
1635 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1637 elm_object_item_del(it);
1641 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1643 return _item_text_get_hook(it, NULL);
1647 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1649 _item_text_set_hook(it, NULL, str);
1652 EAPI Elm_Object_Item *
1653 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1655 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1658 Elm_Multibuttonentry_Item *_item;
1660 wd = elm_widget_data_get(WIDGET(it));
1661 if (!wd) return NULL;
1663 EINA_LIST_FOREACH(wd->items, l, _item)
1665 if (_item == (Elm_Multibuttonentry_Item *) it)
1667 l = eina_list_prev(l);
1668 if (!l) return NULL;
1669 return eina_list_data_get(l);
1675 EAPI Elm_Object_Item *
1676 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1678 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1681 Elm_Multibuttonentry_Item *_item;
1682 wd = elm_widget_data_get(WIDGET(it));
1683 if (!wd) return NULL;
1685 EINA_LIST_FOREACH(wd->items, l, _item)
1687 if (_item == (Elm_Multibuttonentry_Item *) it)
1689 l = eina_list_next(l);
1690 if (!l) return NULL;
1691 return eina_list_data_get(l);
1698 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1700 return elm_widget_item_data_get(it);
1704 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1706 return elm_widget_item_data_set(it, data);
1710 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1712 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1713 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1716 Widget_Data *wd = elm_widget_data_get(obj);
1719 ELM_CHECK_WIDTYPE(obj, widtype);
1720 EINA_SAFETY_ON_NULL_RETURN(func);
1722 new_item_filter= _filter_new(func, data);
1723 if (!new_item_filter) return;
1725 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1727 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1729 printf("Already Registered this item filter!!!!\n");
1733 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1737 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1739 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1740 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1742 Widget_Data *wd = elm_widget_data_get(obj);
1745 ELM_CHECK_WIDTYPE(obj, widtype);
1746 EINA_SAFETY_ON_NULL_RETURN(func);
1748 new_item_filter = _filter_new(func, data);
1749 if (!new_item_filter) return;
1751 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1753 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1755 printf("Already Registered this item filter!!!!\n");
1759 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1763 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1767 Elm_Multibuttonentry_Item_Filter *item_filter;
1769 wd = elm_widget_data_get(obj);
1771 EINA_SAFETY_ON_NULL_RETURN(func);
1773 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1775 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1777 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1778 _filter_free(item_filter);