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, const Elm_Multibuttonentry_Item *reference, void *data);
100 static void _add_button(Evas_Object *obj, const char *str);
101 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
102 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
103 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
104 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
106 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
107 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
108 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
109 static void _view_init(Evas_Object *obj);
110 static void _set_vis_guidetext(Evas_Object *obj);
111 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
112 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
113 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
114 static void _item_text_set_hook(Elm_Object_Item *it,
117 static const char *_item_text_get_hook(const Elm_Object_Item *it,
120 // XXX: use evas_object_smart_callback_descriptions_set for smart callbacks.
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 if (elm_widget_focus_get(obj))
181 elm_entry_input_panel_show(wd->entry);
183 else if (((!wd->current) || (!eina_list_count(wd->items))))
185 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
187 elm_entry_input_panel_show(wd->entry);
189 wd->focused = EINA_TRUE;
190 evas_object_smart_callback_call(obj, "focused", NULL);
194 wd->focused = EINA_FALSE;
197 elm_entry_input_panel_hide(wd->entry);
198 evas_object_smart_callback_call(obj, "unfocused", NULL);
203 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
209 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
211 Widget_Data *wd = elm_widget_data_get(obj);
214 edje_object_signal_emit(wd->base, emission, source);
218 _sizing_eval(Evas_Object *obj)
220 Widget_Data *wd = elm_widget_data_get(obj);
221 Evas_Coord minw = -1, minh = -1;
222 Evas_Coord left, right, top, bottom;
225 evas_object_size_hint_min_get(wd->box, &minw, &minh);
226 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
227 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
229 minw += (left + right);
230 minh += (top + bottom);
232 evas_object_size_hint_min_set(obj, minw, minh);
236 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
238 Widget_Data *wd = elm_widget_data_get(data);
240 if (!wd || !wd->base) return;
241 wd->focused = EINA_TRUE;
244 elm_entry_input_panel_show(wd->entry);
246 evas_object_smart_callback_call(data, "clicked", NULL);
250 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
252 Evas_Object *eo = (Evas_Object *)data;
253 Widget_Data *wd = elm_widget_data_get(data);
260 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
262 Widget_Data *wd = elm_widget_data_get(data);
266 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
268 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
269 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
278 _event_init(Evas_Object *obj)
280 Widget_Data *wd = elm_widget_data_get(obj);
282 if (!wd || !wd->base) return;
285 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
286 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
291 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
292 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
297 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
298 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
299 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
300 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
301 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
302 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
303 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
308 _set_vis_guidetext(Evas_Object *obj)
310 Widget_Data *wd = elm_widget_data_get(obj);
313 elm_box_unpack(wd->box, wd->guidetext);
314 elm_box_unpack(wd->box, wd->entry);
315 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
317 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
318 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
320 evas_object_hide(wd->entry);
321 elm_box_pack_end(wd->box, wd->guidetext);
322 evas_object_show(wd->guidetext);
323 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
327 evas_object_hide(wd->guidetext);
328 elm_box_pack_end(wd->box, wd->entry);
329 evas_object_show(wd->entry);
330 if (elm_widget_focus_get(obj) || wd->focused)
332 elm_object_focus_set(wd->entry, EINA_TRUE);
333 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
338 _shrink_mode_set(Evas_Object *obj, int shrink)
340 Widget_Data *wd = elm_widget_data_get(obj);
342 Elm_Multibuttonentry_Item *item;
344 if (!wd || !wd->box) return;
345 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
346 evas_object_hide(wd->entry);
347 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
348 evas_object_hide(wd->guidetext);
349 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
351 evas_object_hide(wd->rect_for_end);
352 evas_object_hide(wd->end);
353 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
358 Evas_Coord w=0, w_tmp=0;
359 Evas_Coord box_inner_item_width_padding = 0;
361 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
362 // unpack all items and entry
363 elm_box_unpack_all(wd->box);
364 EINA_LIST_FOREACH(wd->items, l, item)
368 evas_object_hide(item->button);
369 item->visible = EINA_FALSE;
372 // pack buttons only 1line
377 elm_box_pack_end(wd->box, wd->label);
378 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
380 w -= box_inner_item_width_padding;
384 int count = eina_list_count(wd->items);
385 Evas_Coord button_min_width = 0;
386 /* Evas_Coord button_min_height = 0; */
387 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
389 const char *size_str;
390 size_str = edje_object_data_get(wd->end, "closed_button_width");
391 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
393 size_str = edje_object_data_get(wd->end, "closed_button_height");
394 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
398 EINA_LIST_FOREACH(wd->items, l, item)
402 int w_label_count = 0;
405 elm_box_pack_end(wd->box, item->button);
406 evas_object_show(item->button);
407 item->visible = EINA_TRUE;
410 w -= box_inner_item_width_padding;
413 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
417 snprintf(buf, sizeof(buf), "... + %d", count);
418 elm_object_text_set(wd->end, buf);
419 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
422 if (w < 0 || w < w_label_count)
424 elm_box_unpack(wd->box, item->button);
425 evas_object_hide(item->button);
426 item->visible = EINA_FALSE;
429 snprintf(buf, sizeof(buf), "... + %d", count);
430 elm_object_text_set(wd->end, buf);
431 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
433 elm_box_pack_end(wd->box, wd->end);
434 evas_object_show(wd->end);
436 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
437 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
441 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
443 if (w < button_min_width)
446 Evas_Coord closed_height = 0;
447 const char *height_str = edje_object_data_get(wd->base, "closed_height");
449 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
450 elm_box_unpack(wd->box, item->button);
451 evas_object_hide(item->button);
452 item->visible = EINA_FALSE;
455 rectSize = w - button_min_width;
456 if (!wd->rect_for_end)
458 Evas *e = evas_object_evas_get(obj);
459 wd->rect_for_end= evas_object_rectangle_add(e);
460 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
462 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get() );
463 elm_box_pack_end(wd->box, wd->rect_for_end);
464 evas_object_show(wd->rect_for_end);
466 elm_box_pack_end(wd->box, wd->end);
467 evas_object_show(wd->end);
469 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
470 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
479 // unpack all items and entry
480 elm_box_unpack_all(wd->box);
481 EINA_LIST_FOREACH(wd->items, l, item)
485 evas_object_hide(item->button);
486 item->visible = EINA_FALSE;
489 evas_object_hide(wd->end);
491 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
493 // pack buttons only 1line
495 if (wd->label) elm_box_pack_end(wd->box, wd->label);
499 EINA_LIST_FOREACH(wd->items, l, item)
503 elm_box_pack_end(wd->box, item->button);
504 evas_object_show(item->button);
505 item->visible = EINA_TRUE;
509 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
510 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)(long)wd->shrink);
512 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
514 _set_vis_guidetext(obj);
519 _view_update(Evas_Object *obj)
521 Evas_Coord width = 1, height = 1;
522 Widget_Data *wd = elm_widget_data_get(obj);
524 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
529 elm_box_unpack(wd->box, wd->label);
530 elm_box_pack_start(wd->box, wd->label);
531 evas_object_size_hint_min_get(wd->label, &width, &height);
536 Evas_Coord guide_text_width = wd->w_box - width;
537 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
540 // update buttons in shrink mode
541 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
542 _shrink_mode_set(obj, 1);
545 _set_vis_guidetext(obj);
549 _set_label(Evas_Object *obj, const char *str)
551 Widget_Data *wd = elm_widget_data_get(obj);
553 if (!wd || !str) return;
556 Evas_Coord width, height, sum_width = 0;
557 evas_object_size_hint_min_set(wd->label, 0, 0);
558 evas_object_resize(wd->label, 0, 0);
559 edje_object_part_text_set(wd->label, "mbe.label", str);
561 if (!strcmp(str, ""))
563 /* FIXME: not work yet */
564 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
565 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
570 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
571 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
575 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
578 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
581 evas_object_size_hint_min_set(wd->label, sum_width, height);
583 evas_object_show(wd->label);
588 _set_guidetext(Evas_Object *obj, const char *str)
590 Widget_Data *wd = elm_widget_data_get(obj);
592 if (!wd || !str) return;
595 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
596 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
597 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
598 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
601 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
606 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
608 Widget_Data *wd = elm_widget_data_get(obj);
609 Elm_Multibuttonentry_Item *item = NULL;
613 item = eina_list_data_get(wd->current);
615 if (item && item->button)
619 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
620 edje_object_signal_emit(item->button, "default", "");
623 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
624 edje_object_signal_emit(item->button, "focused", "");
625 evas_object_smart_callback_call(obj, "item,selected", item);
628 edje_object_signal_emit(item->button, "default", "");
636 _change_current_button(Evas_Object *obj, Evas_Object *btn)
638 Widget_Data *wd = elm_widget_data_get(obj);
640 Elm_Multibuttonentry_Item *item;
644 // change the state of previous button to "default"
645 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
647 // change the current
648 EINA_LIST_FOREACH(wd->items, l, item)
650 if (item->button == btn)
656 // change the state of current button to "focused"
657 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
661 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
663 Widget_Data *wd = elm_widget_data_get(data);
665 Elm_Multibuttonentry_Item *item = NULL;
666 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
668 _change_current_button(data, obj);
671 if ((item = eina_list_data_get(wd->current)) != NULL)
673 evas_object_smart_callback_call(data, "item,clicked", item);
674 _select_button(data, item->button);
679 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
681 Widget_Data *wd = elm_widget_data_get(obj);
683 if (!wd || !btn) return;
685 evas_object_del(btn);
689 _del_button_item(Elm_Multibuttonentry_Item *item)
692 Elm_Multibuttonentry_Item *_item;
696 Evas_Object *obj = WIDGET(item);
697 wd = elm_widget_data_get(obj);
699 EINA_LIST_FOREACH(wd->items, l, _item)
703 wd->items = eina_list_remove(wd->items, _item);
704 elm_box_unpack(wd->box, _item->button);
706 evas_object_smart_callback_call(obj, "item,deleted", _item);
708 _del_button_obj(obj, _item->button);
710 if (wd->current == l)
715 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
716 _shrink_mode_set(obj, 1);
718 if (!eina_list_count(wd->items))
719 _set_vis_guidetext(obj);
723 _select_button(Evas_Object *obj, Evas_Object *btn)
725 Widget_Data *wd = elm_widget_data_get(obj);
730 _change_current_button(obj, btn);
731 if (elm_widget_focus_get(obj))
733 elm_object_focus_set(wd->entry, EINA_FALSE);
734 evas_object_focus_set(btn, EINA_TRUE);
739 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
740 if (elm_widget_focus_get(obj))
741 elm_object_focus_set(wd->entry, EINA_TRUE);
746 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
749 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
750 Evas_Coord w_btn = 0, button_max_width = 0;
751 const char *size_str;
753 size_str = edje_object_data_get(btn, "button_max_size");
754 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
756 // decide the size of button
757 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
758 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
759 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
760 w_btn = w_text + 2*padding_outer + 2*padding_inner;
764 if (button_max_width < w_btn)
765 vw = button_max_width;
770 evas_object_resize(btn, vw, h_btn);
771 evas_object_size_hint_min_set(btn, vw, h_btn);
773 if (realw) *realw = rw;
774 if (vieww) *vieww = vw;
778 _item_del_pre_hook(Elm_Object_Item *it)
780 _del_button_item((Elm_Multibuttonentry_Item *) it);
784 static Elm_Multibuttonentry_Item*
785 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
787 Elm_Multibuttonentry_Item *item;
788 Elm_Multibuttonentry_Item_Filter *item_filter;
791 Evas_Coord width = -1, height = -1;
792 char *str_utf8 = NULL;
793 Widget_Data *wd = elm_widget_data_get(obj);
795 if (!wd || !wd->box || !wd->entry) return NULL;
797 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
799 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
803 btn = edje_object_add(evas_object_evas_get(obj));
804 str_utf8 = elm_entry_markup_to_utf8(str);
806 //entry is cleared when text is made to button
807 elm_object_text_set(wd->entry, "");
809 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
810 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
811 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
813 evas_object_size_hint_min_set(btn, width, height);
815 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
816 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
817 evas_object_show(btn);
820 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
823 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
824 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
825 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
826 elm_widget_item_data_set(item, data);
828 _resize_button(btn, &rw, &vw);
832 item->visible = EINA_TRUE;
836 case MULTIBUTTONENTRY_POS_START:
837 wd->items = eina_list_prepend(wd->items, item);
838 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
840 elm_widget_sub_object_add(obj, btn);
841 _shrink_mode_set(obj, 1);
846 elm_box_pack_after(wd->box, btn, wd->label);
848 elm_box_pack_start(wd->box, btn);
849 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
850 _set_vis_guidetext(obj);
853 case MULTIBUTTONENTRY_POS_END:
854 wd->items = eina_list_append(wd->items, item);
855 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
857 elm_widget_sub_object_add(obj, btn);
858 evas_object_hide(btn);
862 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
863 _set_vis_guidetext(obj);
865 elm_box_pack_before(wd->box, btn, wd->entry);
867 elm_box_pack_end(wd->box, btn);
870 case MULTIBUTTONENTRY_POS_BEFORE:
872 wd->items = eina_list_prepend_relative(wd->items, item, reference);
874 wd->items = eina_list_append(wd->items, item);
875 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
877 elm_widget_sub_object_add(obj, btn);
878 evas_object_hide(btn);
879 _shrink_mode_set(obj, 1);
884 elm_box_pack_before(wd->box, btn, reference->button);
887 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
888 _set_vis_guidetext(obj);
890 elm_box_pack_before(wd->box, btn, wd->entry);
892 elm_box_pack_end(wd->box, btn);
896 case MULTIBUTTONENTRY_POS_AFTER:
898 wd->items = eina_list_append_relative(wd->items, item, reference);
900 wd->items = eina_list_append(wd->items, item);
901 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
903 elm_widget_sub_object_add(obj, btn);
904 _shrink_mode_set(obj, 1);
909 elm_box_pack_after(wd->box, btn, reference->button);
912 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
913 _set_vis_guidetext(obj);
915 elm_box_pack_before(wd->box, btn, wd->entry);
917 elm_box_pack_end(wd->box, btn);
925 evas_object_smart_callback_call(obj, "item,added", item);
933 _add_button(Evas_Object *obj, const char *str)
935 Widget_Data *wd = elm_widget_data_get(obj);
938 _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
941 static Elm_Multibuttonentry_Item_Filter*
942 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
944 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
945 if (!item_filter) return NULL;
947 item_filter->callback_func= func;
948 item_filter->data = data;
954 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
960 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
962 Widget_Data *wd = elm_widget_data_get(data);
963 Elm_Multibuttonentry_Item *item = NULL;
965 if (!wd || !wd->base || !wd->box) return;
967 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
969 if (wd->last_btn_select)
972 ((strcmp(ev->keyname, "BackSpace") == 0) ||
973 (strcmp(ev->keyname, "Delete") == 0)))
975 item = eina_list_data_get(wd->current);
978 _del_button_item(item);
979 elm_widget_item_free(item);
980 elm_object_focus_set(wd->entry, EINA_TRUE);
983 else if (((!wd->current && (wd->n_str == 0) &&
984 (strcmp(ev->keyname, "BackSpace") == 0)) ||
985 (strcmp(ev->keyname, "Delete") == 0)))
987 item = eina_list_data_get(eina_list_last(wd->items));
989 _select_button(data, item->button);
993 wd->last_btn_select = EINA_TRUE;
997 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
999 Widget_Data *wd = elm_widget_data_get(data);
1000 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1004 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1005 wd->last_btn_select = EINA_FALSE;
1009 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1011 Widget_Data *wd = elm_widget_data_get(data);
1012 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1015 if (!wd || !wd->base || !wd->box) return;
1017 str = elm_object_text_get(wd->entry);
1019 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1021 _add_button(data, str);
1027 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1029 Widget_Data *wd = elm_widget_data_get(data);
1032 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1033 elm_object_focus_set(wd->entry, EINA_TRUE);
1037 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1039 Widget_Data *wd = elm_widget_data_get(data);
1040 Elm_Multibuttonentry_Item *item = NULL;
1046 item = eina_list_data_get(wd->current);
1047 elm_object_focus_set(wd->entry, EINA_FALSE);
1048 evas_object_focus_set(item->button, EINA_TRUE);
1053 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1055 Widget_Data *wd = elm_widget_data_get(data);
1060 str = elm_object_text_get(wd->entry);
1062 _add_button(data, str);
1066 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1068 Widget_Data *wd = elm_widget_data_get(data);
1073 str = elm_object_text_get(wd->entry);
1074 wd->n_str = strlen(str);
1078 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1080 Evas_Coord en_x, en_y, en_w, en_h;
1081 Evas_Coord bx_x, bx_y;
1083 Widget_Data *wd = elm_widget_data_get(data);
1086 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1087 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1090 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
1095 _view_init(Evas_Object *obj)
1097 Widget_Data *wd = elm_widget_data_get(obj);
1103 wd->box = elm_box_add (obj);
1104 if (!wd->box) return;
1105 elm_widget_sub_object_add(obj, wd->box);
1106 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1107 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1108 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1112 wd->label = edje_object_add(evas_object_evas_get(obj));
1113 if (!wd->label) return;
1114 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1115 _set_label(obj, "");
1116 elm_widget_sub_object_add(obj, wd->label);
1121 wd->entry = elm_entry_add (obj);
1122 if (!wd->entry) return;
1123 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1124 elm_object_text_set(wd->entry, "");
1125 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1126 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1127 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1128 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1129 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1130 evas_object_show(wd->entry);
1131 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1136 const char *end_type;
1138 end_type = edje_object_data_get(wd->base, "closed_button_type");
1139 if (!end_type || !strcmp(end_type, "label"))
1141 wd->end = elm_label_add (obj);
1142 if (!wd->end) return;
1143 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1144 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1148 const char *size_str;
1149 wd->end = edje_object_add(evas_object_evas_get(obj));
1150 if (!wd->end) return;
1151 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1152 Evas_Coord button_min_width = 0;
1153 Evas_Coord button_min_height = 0;
1155 size_str = edje_object_data_get(wd->end, "closed_button_width");
1156 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1157 size_str = edje_object_data_get(wd->end, "closed_button_height");
1158 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1160 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1161 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1162 elm_widget_sub_object_add(obj, wd->end);
1168 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1170 Evas_Coord minw, minh, mnw, mnh, ww;
1171 Evas_Coord w, cw = 0, cmaxh = 0;
1173 Evas_Object_Box_Option *opt;
1176 /* FIXME: need to calc max */
1180 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1181 evas_object_size_hint_min_get(box, &minw, NULL);
1183 EINA_LIST_FOREACH(priv->children, l, opt)
1185 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1186 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1190 if (mnw != -1 && (w - cw) >= mnw)
1205 if (cmaxh < mnh) cmaxh = mnh;
1210 evas_object_size_hint_min_set(box, minw, minh);
1214 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1216 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1218 Evas_Object_Box_Option *opt;
1222 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1224 EINA_LIST_FOREACH(priv->children, l, opt)
1226 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1227 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1231 if (mnw != -1 && (w - cw) >= mnw)
1241 if (index > obj_index) return cmaxh;
1247 if (cmaxh < mnh) cmaxh = mnh;
1256 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1258 Evas_Coord x, y, w, h, xx, yy;
1261 Evas_Coord minw, minh;
1263 Evas_Object_Box_Option *opt;
1265 _calculate_box_min_size(o, priv);
1267 evas_object_geometry_get(o, &x, &y, &w, &h);
1269 evas_object_size_hint_min_get(o, &minw, &minh);
1270 evas_object_size_hint_align_get(o, &ax, &ay);
1273 x = x + ((w - minw) * (1.0 - ax));
1278 y = y + ((h - minh) * (1.0 - ay));
1285 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1287 EINA_LIST_FOREACH(priv->children, l, opt)
1289 Evas_Coord mnw, mnh, mxw, mxh;
1294 evas_object_size_hint_align_get(obj, &ax, &ay);
1295 evas_object_size_hint_weight_get(obj, &wx, &wy);
1296 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1297 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1299 if (ax == -1.0) {fw = 1; ax = 0.5;}
1300 if (ay == -1.0) {fh = 1; ay = 0.5;}
1301 Evas_Coord ww, hh, ow, oh;
1305 if (mnw != -1 && (w - cw) >= mnw)
1312 hh = _calculate_item_max_height(o, priv, obj_index);
1316 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1319 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1328 evas_object_move(obj,
1329 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1330 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1331 evas_object_resize(obj, ow, oh);
1334 if (cmaxh < hh) cmaxh = hh;
1341 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1343 Elm_Multibuttonentry_Item *item;
1344 if (part && strcmp(part, "default")) return;
1346 item = (Elm_Multibuttonentry_Item *) it;
1347 edje_object_part_text_set(item->button, "elm.btn.text", label);
1348 _resize_button(item->button, &item->rw, &item->vw);
1352 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1354 Elm_Multibuttonentry_Item *item;
1355 if (part && strcmp(part, "default")) return NULL;
1356 item = (Elm_Multibuttonentry_Item *) it;
1357 return edje_object_part_text_get(item->button, "elm.btn.text");
1361 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1363 ELM_CHECK_WIDTYPE(obj, widtype);
1364 if (part && strcmp(part, "default")) return;
1365 if (label) _set_label(obj, label);
1366 else _set_label(obj, "");
1370 _text_get_hook(const Evas_Object *obj, const char *part)
1372 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1374 if (part && strcmp(part, "default")) return NULL;
1375 wd = elm_widget_data_get(obj);
1376 if (!wd) return NULL;
1377 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1382 elm_multibuttonentry_add(Evas_Object *parent)
1388 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1390 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1391 elm_widget_type_set(obj, "multibuttonentry");
1392 elm_widget_sub_object_add(parent, obj);
1393 elm_widget_data_set(obj, wd);
1395 elm_widget_del_hook_set(obj, _del_hook);
1396 elm_widget_theme_hook_set(obj, _theme_hook);
1397 elm_widget_event_hook_set(obj, _event_hook);
1398 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1399 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1400 elm_widget_text_set_hook_set(obj, _text_set_hook);
1401 elm_widget_text_get_hook_set(obj, _text_get_hook);
1403 wd->base = edje_object_add(e);
1404 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1405 elm_widget_resize_object_set(obj, wd->base);
1406 elm_widget_can_focus_set(obj, EINA_TRUE);
1408 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1409 wd->focused = EINA_FALSE;
1410 wd->last_btn_select = EINA_TRUE;
1412 wd->rect_for_end= NULL;
1413 wd->add_callback = NULL;
1414 wd->add_callback_data = NULL;
1423 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1425 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1426 Widget_Data *wd = elm_widget_data_get(obj);
1428 if (!wd) return NULL;
1434 elm_multibuttonentry_label_get(const Evas_Object *obj)
1436 return _text_get_hook(obj, NULL);
1440 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1442 _text_set_hook(obj, NULL, label);
1446 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1448 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1449 Widget_Data *wd = elm_widget_data_get(obj);
1451 if (!wd) return NULL;
1452 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1457 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1459 ELM_CHECK_WIDTYPE(obj, widtype);
1460 Widget_Data *wd = elm_widget_data_get(obj);
1464 _set_guidetext(obj, guidetext);
1467 EINA_DEPRECATED EAPI int
1468 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1470 if (elm_multibuttonentry_expanded_get(obj))
1477 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1479 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1480 Widget_Data *wd = elm_widget_data_get(obj);
1483 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1487 EINA_DEPRECATED EAPI void
1488 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1491 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
1494 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
1498 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1500 ELM_CHECK_WIDTYPE(obj, widtype);
1501 Widget_Data *wd = elm_widget_data_get(obj);
1503 if (!wd || !wd->box ||
1504 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1507 _shrink_mode_set(obj, 0);
1509 _shrink_mode_set(obj, 1);
1513 EAPI Elm_Object_Item *
1514 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1516 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1517 Elm_Multibuttonentry_Item *item;
1518 if (!label) return NULL;
1519 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1520 return (Elm_Object_Item *) item;
1523 EAPI Elm_Object_Item *
1524 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1526 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1527 Elm_Multibuttonentry_Item *item;
1528 if (!label) return NULL;
1529 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1530 return (Elm_Object_Item *) item;
1533 EAPI Elm_Object_Item *
1534 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1536 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1537 Elm_Multibuttonentry_Item *item;
1538 if (!label) return NULL;
1539 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE,
1540 (Elm_Multibuttonentry_Item *) before, data);
1541 return (Elm_Object_Item *) item;
1544 EAPI Elm_Object_Item *
1545 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, 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_AFTER,
1551 (Elm_Multibuttonentry_Item *) after, data);
1552 return (Elm_Object_Item *) item;
1555 EAPI const Eina_List *
1556 elm_multibuttonentry_items_get(const Evas_Object *obj)
1558 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1559 Widget_Data *wd = elm_widget_data_get(obj);
1560 if (!wd) return NULL;
1564 EAPI Elm_Object_Item *
1565 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
1567 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1568 Widget_Data *wd = elm_widget_data_get(obj);
1569 if (!wd) return NULL;
1570 return eina_list_data_get(wd->items);
1573 EAPI Elm_Object_Item *
1574 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
1576 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1577 Widget_Data *wd = elm_widget_data_get(obj);
1578 if (!wd) return NULL;
1579 return eina_list_data_get(eina_list_last(wd->items));
1582 EAPI Elm_Object_Item *
1583 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
1585 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1586 Widget_Data *wd = elm_widget_data_get(obj);
1587 if (!wd) return NULL;
1588 return eina_list_data_get(wd->current);
1592 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
1594 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1595 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
1596 if (selected) _select_button(WIDGET(item), item->button);
1597 else _select_button(WIDGET(item), NULL);
1601 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
1603 ELM_CHECK_WIDTYPE(obj, widtype);
1604 Widget_Data *wd = elm_widget_data_get(obj);
1606 _select_button(obj, NULL);
1610 elm_multibuttonentry_clear(Evas_Object *obj)
1612 ELM_CHECK_WIDTYPE(obj, widtype);
1613 Elm_Multibuttonentry_Item *item;
1614 Widget_Data *wd = elm_widget_data_get(obj);
1619 EINA_LIST_FREE(wd->items, item)
1621 elm_box_unpack(wd->box, item->button);
1622 _del_button_obj(obj, item->button);
1632 elm_multibuttonentry_item_del(Elm_Object_Item *it)
1634 elm_object_item_del(it);
1638 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
1640 return _item_text_get_hook(it, NULL);
1644 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
1646 _item_text_set_hook(it, NULL, str);
1649 EAPI Elm_Object_Item *
1650 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
1652 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1655 Elm_Multibuttonentry_Item *_item;
1657 wd = elm_widget_data_get(WIDGET(it));
1658 if (!wd) return NULL;
1660 EINA_LIST_FOREACH(wd->items, l, _item)
1662 if (_item == (Elm_Multibuttonentry_Item *) it)
1664 l = eina_list_prev(l);
1665 if (!l) return NULL;
1666 return eina_list_data_get(l);
1672 EAPI Elm_Object_Item *
1673 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
1675 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1678 Elm_Multibuttonentry_Item *_item;
1679 wd = elm_widget_data_get(WIDGET(it));
1680 if (!wd) return NULL;
1682 EINA_LIST_FOREACH(wd->items, l, _item)
1684 if (_item == (Elm_Multibuttonentry_Item *) it)
1686 l = eina_list_next(l);
1687 if (!l) return NULL;
1688 return eina_list_data_get(l);
1695 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
1697 return elm_widget_item_data_get(it);
1701 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
1703 return elm_widget_item_data_set(it, data);
1707 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1709 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1710 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1713 Widget_Data *wd = elm_widget_data_get(obj);
1716 ELM_CHECK_WIDTYPE(obj, widtype);
1717 EINA_SAFETY_ON_NULL_RETURN(func);
1719 new_item_filter= _filter_new(func, data);
1720 if (!new_item_filter) return;
1722 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1724 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1726 printf("Already Registered this item filter!!!!\n");
1730 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
1734 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1736 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
1737 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
1739 Widget_Data *wd = elm_widget_data_get(obj);
1742 ELM_CHECK_WIDTYPE(obj, widtype);
1743 EINA_SAFETY_ON_NULL_RETURN(func);
1745 new_item_filter = _filter_new(func, data);
1746 if (!new_item_filter) return;
1748 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
1750 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
1752 printf("Already Registered this item filter!!!!\n");
1756 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
1760 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1764 Elm_Multibuttonentry_Item_Filter *item_filter;
1766 wd = elm_widget_data_get(obj);
1768 EINA_SAFETY_ON_NULL_RETURN(func);
1770 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
1772 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
1774 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
1775 _filter_free(item_filter);