1 #include <Elementary.h>
9 >>>>>>> remotes/origin/upstream
11 typedef enum _Multibuttonentry_Pos
13 MULTIBUTTONENTRY_POS_START,
14 MULTIBUTTONENTRY_POS_END,
15 MULTIBUTTONENTRY_POS_BEFORE,
16 MULTIBUTTONENTRY_POS_AFTER,
18 MULTIBUTTONENTRY_POS_NUM
20 >>>>>>> remotes/origin/upstream
21 } Multibuttonentry_Pos;
23 typedef enum _Multibuttonentry_Button_State
25 MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
26 MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
28 MULTIBUTTONENTRY_BUTTON_STATE_NUM
29 } Multibuttonentry_Button_State;
32 } Multibuttonentry_Button_State;
35 >>>>>>> remotes/origin/upstream
36 typedef enum _MultiButtonEntry_Closed_Button_Type
38 MULTIBUTTONENTRY_CLOSED_IMAGE,
39 MULTIBUTTONENTRY_CLOSED_LABEL
40 } MultiButtonEntry_Closed_Button_Type;
42 typedef enum _Multibuttonentry_View_State
44 MULTIBUTTONENTRY_VIEW_NONE,
45 MULTIBUTTONENTRY_VIEW_GUIDETEXT,
46 MULTIBUTTONENTRY_VIEW_ENTRY,
47 MULTIBUTTONENTRY_VIEW_SHRINK
48 } Multibuttonentry_View_State;
50 typedef struct _Widget_Data Widget_Data;
51 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
53 struct _Multibuttonentry_Item
57 Evas_Coord vw, rw; // vw: visual width, real width
62 >>>>>>> remotes/origin/upstream
65 typedef struct _Elm_Multibuttonentry_Item_Filter
68 Elm_Multibuttonentry_Item_Filter_callback callback_func;
70 Elm_Multibuttonentry_Item_Filter_Cb callback_func;
71 >>>>>>> remotes/origin/upstream
73 } Elm_Multibuttonentry_Item_Filter;
81 Evas_Object *guidetext;
82 Evas_Object *end; // used to represent the total number of invisible buttons
84 Evas_Object *rect_for_end;
85 MultiButtonEntry_Closed_Button_Type end_type;
89 Eina_List *filter_list;
93 const char *labeltxt, *guidetexttxt;
95 >>>>>>> remotes/origin/upstream
97 Multibuttonentry_View_State view_state;
99 Evas_Coord w_box, h_box;
101 Eina_Bool focused: 1;
102 Eina_Bool last_btn_select: 1;
105 Elm_Multibuttonentry_Item_Filter_callback add_callback;
107 Elm_Multibuttonentry_Item_Filter_Cb add_callback;
108 >>>>>>> remotes/origin/upstream
109 void *add_callback_data;
112 static const char *widtype = NULL;
113 static void _del_hook(Evas_Object *obj);
114 static void _theme_hook(Evas_Object *obj);
115 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
116 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info);
117 static void _sizing_eval(Evas_Object *obj);
118 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
119 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
120 static void _event_init(Evas_Object *obj);
122 static void _shrink_mode_set(Evas_Object *obj, int shrink);
124 static void _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink);
125 >>>>>>> remotes/origin/upstream
126 static void _view_update(Evas_Object *obj);
127 static void _set_label(Evas_Object *obj, const char *str);
128 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
129 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
130 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
131 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
132 static void _del_button_item(Elm_Multibuttonentry_Item *item);
133 static void _select_button(Evas_Object *obj, Evas_Object *btn);
135 static Elm_Multibuttonentry_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos,
136 const Elm_Multibuttonentry_Item *reference, void *data);
137 static void _add_button(Evas_Object *obj, const char *str);
139 static Elm_Object_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data);
140 >>>>>>> remotes/origin/upstream
141 static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
142 static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
143 static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
144 static void _entry_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
145 static void _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
146 static void _entry_focus_in_cb(void *data, Evas_Object *obj, void *event_info);
147 static void _entry_focus_out_cb(void *data, Evas_Object *obj, void *event_info);
148 static void _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
149 static void _view_init(Evas_Object *obj);
150 static void _set_vis_guidetext(Evas_Object *obj);
151 static void _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv);
152 static Evas_Coord _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index);
153 static void _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
154 static void _item_text_set_hook(Elm_Object_Item *it,
158 static const char * _item_text_get_hook(const Elm_Object_Item *it,
163 static const char *_item_text_get_hook(const Elm_Object_Item *it,
168 * use evas_object_smart_callback_descriptions_set for smart callbacks.
170 >>>>>>> remotes/origin/upstream
173 _del_hook(Evas_Object *obj)
175 Widget_Data *wd = elm_widget_data_get(obj);
180 Elm_Multibuttonentry_Item *item;
181 EINA_LIST_FREE(wd->items, item)
183 _del_button_obj(obj, item->button);
191 if (wd->entry) evas_object_del (wd->entry);
192 if (wd->label) evas_object_del (wd->label);
193 if (wd->guidetext) evas_object_del (wd->guidetext);
194 if (wd->end) evas_object_del (wd->end);
196 if (wd->labeltxt) eina_stringshare_del(wd->labeltxt);
197 if (wd->guidetexttxt) eina_stringshare_del(wd->guidetexttxt);
198 if (wd->entry) evas_object_del(wd->entry);
199 if (wd->label) evas_object_del(wd->label);
200 if (wd->guidetext) evas_object_del(wd->guidetext);
201 if (wd->end) evas_object_del(wd->end);
202 >>>>>>> remotes/origin/upstream
203 if (wd->rect_for_end) evas_object_del(wd->rect_for_end);
207 _theme_hook(Evas_Object *obj)
209 Widget_Data *wd = elm_widget_data_get(obj);
211 Elm_Multibuttonentry_Item *item;
215 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
217 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
219 if (wd->box) edje_object_part_swallow(wd->base, "box.swallow", wd->box);
220 >>>>>>> remotes/origin/upstream
221 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
223 EINA_LIST_FOREACH(wd->items, l, item)
227 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
229 _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get(obj));
230 >>>>>>> remotes/origin/upstream
231 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
238 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
240 Widget_Data *wd = elm_widget_data_get(obj);
244 if (elm_widget_focus_get(obj))
248 elm_entry_input_panel_show(wd->entry);
250 else if (((!wd->current) || (!eina_list_count(wd->items))))
252 if (wd->entry) elm_entry_cursor_end_set(wd->entry);
254 elm_entry_input_panel_show(wd->entry);
256 wd->focused = EINA_TRUE;
257 evas_object_smart_callback_call(obj, "focused", NULL);
261 wd->focused = EINA_FALSE;
264 elm_entry_input_panel_hide(wd->entry);
265 evas_object_smart_callback_call(obj, "unfocused", NULL);
270 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
276 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
278 Widget_Data *wd = elm_widget_data_get(obj);
281 edje_object_signal_emit(wd->base, emission, source);
285 _sizing_eval(Evas_Object *obj)
287 Widget_Data *wd = elm_widget_data_get(obj);
288 Evas_Coord minw = -1, minh = -1;
289 Evas_Coord left, right, top, bottom;
292 evas_object_size_hint_min_get(wd->box, &minw, &minh);
293 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
294 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
296 minw += (left + right);
297 minh += (top + bottom);
299 evas_object_size_hint_min_set(obj, minw, minh);
303 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
305 Widget_Data *wd = elm_widget_data_get(data);
307 if (!wd || !wd->base) return;
308 wd->focused = EINA_TRUE;
311 elm_entry_input_panel_show(wd->entry);
313 evas_object_smart_callback_call(data, "clicked", NULL);
317 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
319 Evas_Object *eo = (Evas_Object *)data;
320 Widget_Data *wd = elm_widget_data_get(data);
327 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
329 Widget_Data *wd = elm_widget_data_get(data);
333 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
336 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
337 else if (wd->h_box > h) evas_object_smart_callback_call (data, "shrank", NULL);
339 if (wd->h_box < h) evas_object_smart_callback_call(data, "expanded", NULL);
340 else if (wd->h_box > h) evas_object_smart_callback_call(data, "contracted", NULL);
341 >>>>>>> remotes/origin/upstream
350 _event_init(Evas_Object *obj)
352 Widget_Data *wd = elm_widget_data_get(obj);
354 if (!wd || !wd->base) return;
357 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
358 evas_object_event_callback_add(wd->base, EVAS_CALLBACK_KEY_UP, _evas_mbe_key_up_cb, obj);
363 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
364 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
369 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _entry_key_up_cb, obj);
370 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_down_cb, obj);
371 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_RESIZE, _entry_resized_cb, obj);
372 evas_object_smart_callback_add(wd->entry, "changed", _entry_changed_cb, obj);
373 evas_object_smart_callback_add(wd->entry, "focused", _entry_focus_in_cb, obj);
374 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_focus_out_cb, obj);
375 evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked_cb, obj);
380 _set_vis_guidetext(Evas_Object *obj)
382 Widget_Data *wd = elm_widget_data_get(obj);
385 elm_box_unpack(wd->box, wd->guidetext);
386 elm_box_unpack(wd->box, wd->entry);
387 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
389 if (wd && (!eina_list_count(wd->items)) && wd->guidetext
390 && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
392 evas_object_hide(wd->entry);
393 elm_box_pack_end(wd->box, wd->guidetext);
394 evas_object_show(wd->guidetext);
395 wd->view_state = MULTIBUTTONENTRY_VIEW_GUIDETEXT;
399 evas_object_hide(wd->guidetext);
403 elm_box_pack_end(wd->box, wd->entry);
404 evas_object_show(wd->entry);
407 elm_box_pack_end(wd->box, wd->entry);
408 evas_object_show(wd->entry);
409 >>>>>>> remotes/origin/upstream
410 if (elm_widget_focus_get(obj) || wd->focused)
412 elm_object_focus_set(wd->entry, EINA_TRUE);
413 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
419 _shrink_mode_set(Evas_Object *obj, int shrink)
421 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
422 >>>>>>> remotes/origin/upstream
424 Widget_Data *wd = elm_widget_data_get(obj);
426 Elm_Multibuttonentry_Item *item;
428 if (!wd || !wd->box) return;
429 if (wd->view_state == MULTIBUTTONENTRY_VIEW_ENTRY)
430 evas_object_hide(wd->entry);
431 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
432 evas_object_hide(wd->guidetext);
433 else if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
435 evas_object_hide(wd->rect_for_end);
436 evas_object_hide(wd->end);
437 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
443 Evas_Coord w=0, w_tmp=0;
445 if (shrink == EINA_TRUE)
447 Evas_Coord w = 0, w_tmp = 0;
448 >>>>>>> remotes/origin/upstream
449 Evas_Coord box_inner_item_width_padding = 0;
451 elm_box_padding_get(wd->box, &box_inner_item_width_padding, NULL);
452 // unpack all items and entry
453 elm_box_unpack_all(wd->box);
454 EINA_LIST_FOREACH(wd->items, l, item)
458 evas_object_hide(item->button);
459 item->visible = EINA_FALSE;
462 // pack buttons only 1line
467 elm_box_pack_end(wd->box, wd->label);
468 evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
470 w -= box_inner_item_width_padding;
474 int count = eina_list_count(wd->items);
475 Evas_Coord button_min_width = 0;
476 /* Evas_Coord button_min_height = 0; */
477 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
479 const char *size_str;
480 size_str = edje_object_data_get(wd->end, "closed_button_width");
481 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
483 size_str = edje_object_data_get(wd->end, "closed_button_height");
484 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
488 EINA_LIST_FOREACH(wd->items, l, item)
492 int w_label_count = 0;
495 elm_box_pack_end(wd->box, item->button);
496 evas_object_show(item->button);
497 item->visible = EINA_TRUE;
500 w -= box_inner_item_width_padding;
503 if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
507 snprintf(buf, sizeof(buf), "... + %d", count);
508 elm_object_text_set(wd->end, buf);
509 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
512 if (w < 0 || w < w_label_count)
514 elm_box_unpack(wd->box, item->button);
515 evas_object_hide(item->button);
516 item->visible = EINA_FALSE;
519 snprintf(buf, sizeof(buf), "... + %d", count);
520 elm_object_text_set(wd->end, buf);
521 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
523 elm_box_pack_end(wd->box, wd->end);
524 evas_object_show(wd->end);
526 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
528 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
530 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)1);
531 >>>>>>> remotes/origin/upstream
535 else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
537 if (w < button_min_width)
540 Evas_Coord closed_height = 0;
541 const char *height_str = edje_object_data_get(wd->base, "closed_height");
543 if (height_str) closed_height = (Evas_Coord)atoi(height_str);
544 elm_box_unpack(wd->box, item->button);
545 evas_object_hide(item->button);
546 item->visible = EINA_FALSE;
549 rectSize = w - button_min_width;
550 if (!wd->rect_for_end)
552 Evas *e = evas_object_evas_get(obj);
553 wd->rect_for_end = evas_object_rectangle_add(e);
554 evas_object_color_set(wd->rect_for_end, 0, 0, 0, 0);
557 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get());
559 evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * _elm_config->scale);
560 >>>>>>> remotes/origin/upstream
561 elm_box_pack_end(wd->box, wd->rect_for_end);
562 evas_object_show(wd->rect_for_end);
564 elm_box_pack_end(wd->box, wd->end);
565 evas_object_show(wd->end);
567 wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
569 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
571 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)0);
572 >>>>>>> remotes/origin/upstream
581 // unpack all items and entry
582 elm_box_unpack_all(wd->box);
583 EINA_LIST_FOREACH(wd->items, l, item)
587 evas_object_hide(item->button);
588 item->visible = EINA_FALSE;
591 evas_object_hide(wd->end);
593 if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
595 // pack buttons only 1line
597 if (wd->label) elm_box_pack_end(wd->box, wd->label);
601 EINA_LIST_FOREACH(wd->items, l, item)
605 elm_box_pack_end(wd->box, item->button);
606 evas_object_show(item->button);
607 item->visible = EINA_TRUE;
611 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
613 evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)wd->shrink);
615 evas_object_smart_callback_call(obj, "expand,state,changed", (void *)(long)wd->shrink);
616 >>>>>>> remotes/origin/upstream
618 if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
620 _set_vis_guidetext(obj);
625 _view_update(Evas_Object *obj)
627 Evas_Coord width = 1, height = 1;
628 Widget_Data *wd = elm_widget_data_get(obj);
630 if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
635 elm_box_unpack(wd->box, wd->label);
636 elm_box_pack_start(wd->box, wd->label);
637 evas_object_size_hint_min_get(wd->label, &width, &height);
642 Evas_Coord guide_text_width = wd->w_box - width;
643 evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
646 // update buttons in shrink mode
647 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
649 _shrink_mode_set(obj, 1);
651 _shrink_mode_set(obj, EINA_TRUE);
652 >>>>>>> remotes/origin/upstream
655 _set_vis_guidetext(obj);
660 _set_label(Evas_Object *obj, const char* str)
662 _set_label(Evas_Object *obj, const char *str)
663 >>>>>>> remotes/origin/upstream
665 Widget_Data *wd = elm_widget_data_get(obj);
667 if (!wd || !str) return;
670 eina_stringshare_replace(&wd->labeltxt, str);
671 >>>>>>> remotes/origin/upstream
674 Evas_Coord width, height, sum_width = 0;
675 evas_object_size_hint_min_set(wd->label, 0, 0);
676 evas_object_resize(wd->label, 0, 0);
677 edje_object_part_text_set(wd->label, "mbe.label", str);
679 if (!strcmp(str, ""))
681 /* FIXME: not work yet */
682 edje_object_signal_emit(wd->label, "elm,mbe,clear_text", "");
683 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
688 edje_object_signal_emit(wd->label, "elm,mbe,set_text", "");
689 edje_object_part_geometry_get(wd->label, "mbe.label", NULL, NULL, &width, &height);
693 edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
696 edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
699 evas_object_size_hint_min_set(wd->label, sum_width, height);
701 evas_object_show(wd->label);
707 _set_guidetext(Evas_Object *obj, const char* str)
709 _set_guidetext(Evas_Object *obj, const char *str)
710 >>>>>>> remotes/origin/upstream
712 Widget_Data *wd = elm_widget_data_get(obj);
714 if (!wd || !str) return;
718 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
719 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
720 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
721 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
724 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
728 eina_stringshare_replace(&wd->guidetexttxt, str);
729 if (wd->guidetext == NULL)
730 wd->guidetext = edje_object_add(evas_object_evas_get(obj));
734 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry",
735 "guidetext", elm_widget_style_get(obj));
736 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
737 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL,
739 edje_object_part_text_set(wd->guidetext, "elm.text", str);
742 >>>>>>> remotes/origin/upstream
746 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
748 Widget_Data *wd = elm_widget_data_get(obj);
749 Elm_Multibuttonentry_Item *item = NULL;
753 item = eina_list_data_get(wd->current);
755 if (item && item->button)
759 case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
760 edje_object_signal_emit(item->button, "default", "");
763 case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
764 edje_object_signal_emit(item->button, "focused", "");
765 evas_object_smart_callback_call(obj, "item,selected", item);
768 edje_object_signal_emit(item->button, "default", "");
776 _change_current_button(Evas_Object *obj, Evas_Object *btn)
778 Widget_Data *wd = elm_widget_data_get(obj);
780 Elm_Multibuttonentry_Item *item;
784 // change the state of previous button to "default"
785 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
787 // change the current
788 EINA_LIST_FOREACH(wd->items, l, item)
790 if (item->button == btn)
796 // change the state of current button to "focused"
797 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
801 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
803 Widget_Data *wd = elm_widget_data_get(data);
805 Elm_Multibuttonentry_Item *item = NULL;
806 if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
809 _select_button(data, obj);
811 if ((wd->current) && ((item = eina_list_data_get(wd->current)) != NULL))
812 evas_object_smart_callback_call(data, "item,clicked", item);
814 _change_current_button(data, obj);
817 if ((item = eina_list_data_get(wd->current)) != NULL)
819 evas_object_smart_callback_call(data, "item,clicked", item);
820 _select_button(data, item->button);
822 >>>>>>> remotes/origin/upstream
826 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
828 Widget_Data *wd = elm_widget_data_get(obj);
830 if (!wd || !btn) return;
832 evas_object_del(btn);
836 _del_button_item(Elm_Multibuttonentry_Item *item)
839 Elm_Multibuttonentry_Item *_item;
843 Evas_Object *obj = WIDGET(item);
844 wd = elm_widget_data_get(obj);
846 EINA_LIST_FOREACH(wd->items, l, _item)
850 wd->items = eina_list_remove(wd->items, _item);
851 elm_box_unpack(wd->box, _item->button);
853 evas_object_smart_callback_call(obj, "item,deleted", _item);
855 _del_button_obj(obj, _item->button);
857 if (wd->current == l)
862 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
864 _shrink_mode_set(obj, 1);
866 _shrink_mode_set(obj, EINA_TRUE);
867 >>>>>>> remotes/origin/upstream
869 if (!eina_list_count(wd->items))
870 _set_vis_guidetext(obj);
874 _select_button(Evas_Object *obj, Evas_Object *btn)
876 Widget_Data *wd = elm_widget_data_get(obj);
881 _change_current_button(obj, btn);
882 if (elm_widget_focus_get(obj))
884 elm_object_focus_set(wd->entry, EINA_FALSE);
885 evas_object_focus_set(btn, EINA_TRUE);
890 _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
891 if (elm_widget_focus_get(obj))
892 elm_object_focus_set(wd->entry, EINA_TRUE);
897 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
901 Evas_Coord w_text, h_btn, padding_outer = 0;
903 Evas_Coord w_text, h_btn, padding_outer, padding_inner = 0;
904 >>>>>>> remotes/origin/upstream
905 Evas_Coord w_btn = 0, button_max_width = 0;
906 const char *size_str;
908 size_str = edje_object_data_get(btn, "button_max_size");
909 if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
911 // decide the size of button
912 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
913 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &w_text, NULL);
914 edje_object_part_geometry_get(btn, "right.padding", NULL, NULL, &padding_outer, NULL);
916 w_btn = w_text + 2*padding_outer;
918 w_btn = w_text + 2*padding_outer + 2*padding_inner;
919 >>>>>>> remotes/origin/upstream
923 if (button_max_width < w_btn)
924 vw = button_max_width;
929 evas_object_resize(btn, vw, h_btn);
930 evas_object_size_hint_min_set(btn, vw, h_btn);
932 if (realw) *realw = rw;
933 if (vieww) *vieww = vw;
937 _item_del_pre_hook(Elm_Object_Item *it)
940 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
941 _del_button_item((Elm_Multibuttonentry_Item *) it);
945 static Elm_Multibuttonentry_Item*
946 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
948 Elm_Multibuttonentry_Item *item;
949 Elm_Multibuttonentry_Item_Filter *item_filter;
951 _del_button_item((Elm_Multibuttonentry_Item *)it);
955 static Elm_Object_Item*
956 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
958 Elm_Multibuttonentry_Item *item;
959 Elm_Multibuttonentry_Item_Filter *item_filter;
960 Elm_Multibuttonentry_Item *reference = (Elm_Multibuttonentry_Item *)ref;
961 >>>>>>> remotes/origin/upstream
964 Evas_Coord width = -1, height = -1;
965 char *str_utf8 = NULL;
968 Widget_Data *wd = elm_widget_data_get(obj);
970 if (!wd || !wd->box || !wd->entry) return NULL;
972 Widget_Data *wd = elm_widget_data_get(obj);
974 if (!wd || !wd->box || !wd->entry) return NULL;
975 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
976 if (!str) return NULL;
977 >>>>>>> remotes/origin/upstream
979 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
981 if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
985 btn = edje_object_add(evas_object_evas_get(obj));
986 str_utf8 = elm_entry_markup_to_utf8(str);
988 //entry is cleared when text is made to button
989 elm_object_text_set(wd->entry, "");
991 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
992 edje_object_part_text_set(btn, "elm.btn.text", str_utf8);
993 edje_object_part_geometry_get(btn, "elm.btn.text", NULL, NULL, &width, &height);
995 evas_object_size_hint_min_set(btn, width, height);
997 edje_object_signal_callback_add(btn, "mouse,clicked,1", "*", _button_clicked, obj);
998 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
999 evas_object_show(btn);
1002 item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
1005 elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
1006 elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
1007 elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
1008 elm_widget_item_data_set(item, data);
1010 _resize_button(btn, &rw, &vw);
1014 item->visible = EINA_TRUE;
1023 >>>>>>> remotes/origin/upstream
1026 case MULTIBUTTONENTRY_POS_START:
1027 wd->items = eina_list_prepend(wd->items, item);
1028 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
1030 elm_widget_sub_object_add(obj, btn);
1032 _shrink_mode_set(obj, 1);
1034 _shrink_mode_set(obj, EINA_TRUE);
1035 >>>>>>> remotes/origin/upstream
1040 elm_box_pack_after(wd->box, btn, wd->label);
1042 elm_box_pack_start(wd->box, btn);
1043 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
1044 _set_vis_guidetext(obj);
1047 case MULTIBUTTONENTRY_POS_END:
1048 wd->items = eina_list_append(wd->items, item);
1049 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
1051 elm_widget_sub_object_add(obj, btn);
1052 evas_object_hide(btn);
1056 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
1057 _set_vis_guidetext(obj);
1062 elm_box_pack_before(wd->box, btn, wd->entry);
1064 elm_box_pack_end(wd->box, btn);
1067 elm_box_pack_before(wd->box, btn, wd->entry);
1068 >>>>>>> remotes/origin/upstream
1070 elm_box_pack_end(wd->box, btn);
1073 case MULTIBUTTONENTRY_POS_BEFORE:
1075 wd->items = eina_list_prepend_relative(wd->items, item, reference);
1077 wd->items = eina_list_append(wd->items, item);
1078 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
1080 elm_widget_sub_object_add(obj, btn);
1081 evas_object_hide(btn);
1083 _shrink_mode_set(obj, 1);
1085 _shrink_mode_set(obj, EINA_TRUE);
1086 >>>>>>> remotes/origin/upstream
1091 elm_box_pack_before(wd->box, btn, reference->button);
1094 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
1095 _set_vis_guidetext(obj);
1100 elm_box_pack_before(wd->box, btn, wd->entry);
1102 elm_box_pack_end(wd->box, btn);
1105 elm_box_pack_before(wd->box, btn, wd->entry);
1106 >>>>>>> remotes/origin/upstream
1108 elm_box_pack_end(wd->box, btn);
1112 case MULTIBUTTONENTRY_POS_AFTER:
1114 wd->items = eina_list_append_relative(wd->items, item, reference);
1116 wd->items = eina_list_append(wd->items, item);
1117 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
1119 elm_widget_sub_object_add(obj, btn);
1121 _shrink_mode_set(obj, 1);
1123 _shrink_mode_set(obj, EINA_TRUE);
1124 >>>>>>> remotes/origin/upstream
1129 elm_box_pack_after(wd->box, btn, reference->button);
1132 if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
1133 _set_vis_guidetext(obj);
1138 elm_box_pack_before(wd->box, btn, wd->entry);
1140 elm_box_pack_end(wd->box, btn);
1143 elm_box_pack_before(wd->box, btn, wd->entry);
1144 >>>>>>> remotes/origin/upstream
1146 elm_box_pack_end(wd->box, btn);
1154 evas_object_smart_callback_call(obj, "item,added", item);
1163 _add_button(Evas_Object *obj, const char *str)
1165 Widget_Data *wd = elm_widget_data_get(obj);
1168 _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
1171 static Elm_Multibuttonentry_Item_Filter*
1172 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1174 return (Elm_Object_Item *)item;
1177 static Elm_Multibuttonentry_Item_Filter*
1178 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1179 >>>>>>> remotes/origin/upstream
1181 Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
1182 if (!item_filter) return NULL;
1184 item_filter->callback_func= func;
1185 item_filter->data = data;
1191 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
1197 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1199 Widget_Data *wd = elm_widget_data_get(data);
1200 Elm_Multibuttonentry_Item *item = NULL;
1202 if (!wd || !wd->base || !wd->box) return;
1204 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
1206 if (wd->last_btn_select)
1209 ((strcmp(ev->keyname, "BackSpace") == 0) ||
1211 (strcmp(ev->keyname, "BackSpace (") == 0)))
1213 (strcmp(ev->keyname, "Delete") == 0)))
1214 >>>>>>> remotes/origin/upstream
1216 item = eina_list_data_get(wd->current);
1219 _del_button_item(item);
1220 elm_widget_item_free(item);
1221 elm_object_focus_set(wd->entry, EINA_TRUE);
1224 else if (((!wd->current && (wd->n_str == 0) &&
1225 (strcmp(ev->keyname, "BackSpace") == 0)) ||
1227 (strcmp(ev->keyname, "BackSpace (") == 0)))
1229 (strcmp(ev->keyname, "Delete") == 0)))
1230 >>>>>>> remotes/origin/upstream
1232 item = eina_list_data_get(eina_list_last(wd->items));
1234 _select_button(data, item->button);
1238 wd->last_btn_select = EINA_TRUE;
1242 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1244 Widget_Data *wd = elm_widget_data_get(data);
1245 Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1250 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
1252 if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "Delete") == 0 )))
1253 >>>>>>> remotes/origin/upstream
1254 wd->last_btn_select = EINA_FALSE;
1258 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1260 Widget_Data *wd = elm_widget_data_get(data);
1261 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1264 if (!wd || !wd->base || !wd->box) return;
1266 str = elm_object_text_get(wd->entry);
1268 if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1271 _add_button(data, str);
1273 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1274 >>>>>>> remotes/origin/upstream
1280 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1282 Widget_Data *wd = elm_widget_data_get(data);
1285 _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1286 elm_object_focus_set(wd->entry, EINA_TRUE);
1290 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1292 Widget_Data *wd = elm_widget_data_get(data);
1293 Elm_Multibuttonentry_Item *item = NULL;
1299 item = eina_list_data_get(wd->current);
1300 elm_object_focus_set(wd->entry, EINA_FALSE);
1301 evas_object_focus_set(item->button, EINA_TRUE);
1306 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1308 Widget_Data *wd = elm_widget_data_get(data);
1313 str = elm_object_text_get(wd->entry);
1316 _add_button(data, str);
1318 _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1319 >>>>>>> remotes/origin/upstream
1323 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1325 Widget_Data *wd = elm_widget_data_get(data);
1330 str = elm_object_text_get(wd->entry);
1331 wd->n_str = strlen(str);
1335 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1337 Evas_Coord en_x, en_y, en_w, en_h;
1340 Evas_Coord bx_x, bx_y;
1341 >>>>>>> remotes/origin/upstream
1343 Widget_Data *wd = elm_widget_data_get(data);
1346 evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1350 elm_widget_show_region_set(wd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
1352 evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1355 elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
1357 >>>>>>> remotes/origin/upstream
1361 _view_init(Evas_Object *obj)
1363 Widget_Data *wd = elm_widget_data_get(obj);
1370 wd->box = elm_box_add (obj);
1372 wd->box = elm_box_add(obj);
1373 >>>>>>> remotes/origin/upstream
1374 if (!wd->box) return;
1375 elm_widget_sub_object_add(obj, wd->box);
1376 elm_box_layout_set(wd->box, _box_layout_cb, NULL, NULL);
1377 elm_box_homogeneous_set(wd->box, EINA_FALSE);
1378 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
1382 wd->label = edje_object_add(evas_object_evas_get(obj));
1383 if (!wd->label) return;
1384 _elm_theme_object_set(obj, wd->label, "multibuttonentry", "label", elm_widget_style_get(obj));
1385 _set_label(obj, "");
1386 elm_widget_sub_object_add(obj, wd->label);
1392 wd->entry = elm_entry_add (obj);
1393 if (!wd->entry) return;
1394 elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1396 wd->entry = elm_entry_add(obj);
1397 if (!wd->entry) return;
1398 >>>>>>> remotes/origin/upstream
1399 elm_entry_single_line_set(wd->entry, EINA_TRUE);
1400 elm_object_text_set(wd->entry, "");
1401 elm_entry_input_panel_enabled_set(wd->entry, EINA_FALSE);
1402 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
1403 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1404 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
1406 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1408 if (wd->box) elm_box_pack_end(wd->box, wd->entry);
1409 >>>>>>> remotes/origin/upstream
1410 evas_object_show(wd->entry);
1411 wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
1416 const char *end_type;
1418 end_type = edje_object_data_get(wd->base, "closed_button_type");
1419 if (!end_type || !strcmp(end_type, "label"))
1422 wd->end = elm_label_add (obj);
1424 wd->end = elm_label_add(obj);
1425 >>>>>>> remotes/origin/upstream
1426 if (!wd->end) return;
1427 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
1428 wd->end_type = MULTIBUTTONENTRY_CLOSED_LABEL;
1432 const char *size_str;
1433 wd->end = edje_object_add(evas_object_evas_get(obj));
1434 if (!wd->end) return;
1435 _elm_theme_object_set(obj, wd->end, "multibuttonentry", "closedbutton", elm_widget_style_get(obj));
1436 Evas_Coord button_min_width = 0;
1437 Evas_Coord button_min_height = 0;
1439 size_str = edje_object_data_get(wd->end, "closed_button_width");
1440 if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
1441 size_str = edje_object_data_get(wd->end, "closed_button_height");
1442 if (size_str) button_min_height = (Evas_Coord)atoi(size_str);
1444 wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1446 evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1448 evas_object_size_hint_min_set(wd->end,
1449 button_min_width * _elm_config->scale,
1450 button_min_height * _elm_config->scale);
1451 >>>>>>> remotes/origin/upstream
1452 elm_widget_sub_object_add(obj, wd->end);
1458 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1460 Evas_Coord minw, minh, mnw, mnh, ww;
1461 Evas_Coord w, cw = 0, cmaxh = 0;
1463 Evas_Object_Box_Option *opt;
1466 /* FIXME: need to calc max */
1470 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1471 evas_object_size_hint_min_get(box, &minw, NULL);
1473 EINA_LIST_FOREACH(priv->children, l, opt)
1475 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1476 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1481 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1485 >>>>>>> remotes/origin/upstream
1486 if (mnw != -1 && (w - cw) >= mnw)
1496 >>>>>>> remotes/origin/upstream
1505 if (cmaxh < mnh) cmaxh = mnh;
1510 evas_object_size_hint_min_set(box, minw, minh);
1514 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1516 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1518 Evas_Object_Box_Option *opt;
1522 int local_index = 0;
1523 >>>>>>> remotes/origin/upstream
1526 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1528 EINA_LIST_FOREACH(priv->children, l, opt)
1530 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1531 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1536 if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1539 if (mnw != -1 && (w - cw) >= mnw)
1549 if (index > obj_index) return cmaxh;
1551 if (mnw != -1 && (w - cw) >= mnw)
1561 if (local_index > obj_index) return cmaxh;
1562 >>>>>>> remotes/origin/upstream
1568 if (cmaxh < mnh) cmaxh = mnh;
1574 >>>>>>> remotes/origin/upstream
1581 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1583 Evas_Coord x, y, w, h, xx, yy;
1586 Evas_Coord minw, minh;
1588 Evas_Object_Box_Option *opt;
1590 _calculate_box_min_size(o, priv);
1592 evas_object_geometry_get(o, &x, &y, &w, &h);
1594 evas_object_size_hint_min_get(o, &minw, &minh);
1595 evas_object_size_hint_align_get(o, &ax, &ay);
1598 x = x + ((w - minw) * (1.0 - ax));
1603 y = y + ((h - minh) * (1.0 - ay));
1610 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1612 EINA_LIST_FOREACH(priv->children, l, opt)
1614 Evas_Coord mnw, mnh, mxw, mxh;
1619 evas_object_size_hint_align_get(obj, &ax, &ay);
1620 evas_object_size_hint_weight_get(obj, &wx, &wy);
1621 evas_object_size_hint_min_get(obj, &mnw, &mnh);
1622 evas_object_size_hint_max_get(obj, &mxw, &mxh);
1624 if (ax == -1.0) {fw = 1; ax = 0.5;}
1625 if (ay == -1.0) {fh = 1; ay = 0.5;}
1626 Evas_Coord ww, hh, ow, oh;
1631 if ((elm_widget_is(obj)) && (!(strcmp(elm_widget_type_get(obj), "entry"))) && (mnw == -1))
1634 if (mnw != -1 && (w - cw) >= mnw)
1642 if (mnw != -1 && (w - cw) >= mnw)
1649 >>>>>>> remotes/origin/upstream
1650 hh = _calculate_item_max_height(o, priv, obj_index);
1654 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1657 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1666 evas_object_move(obj,
1667 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
1668 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
1669 evas_object_resize(obj, ow, oh);
1672 if (cmaxh < hh) cmaxh = hh;
1679 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1682 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1684 Elm_Multibuttonentry_Item *item;
1685 if (part && strcmp(part, "default")) return;
1687 item = (Elm_Multibuttonentry_Item *) it;
1689 Elm_Multibuttonentry_Item *item;
1690 if (part && strcmp(part, "default")) return;
1692 item = (Elm_Multibuttonentry_Item *)it;
1693 >>>>>>> remotes/origin/upstream
1694 edje_object_part_text_set(item->button, "elm.btn.text", label);
1695 _resize_button(item->button, &item->rw, &item->vw);
1699 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1702 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1703 Elm_Multibuttonentry_Item *item;
1704 if (part && strcmp(part, "default")) return NULL;
1705 item = (Elm_Multibuttonentry_Item *) it;
1707 Elm_Multibuttonentry_Item *item;
1708 if (part && strcmp(part, "default")) return NULL;
1709 item = (Elm_Multibuttonentry_Item *)it;
1710 >>>>>>> remotes/origin/upstream
1711 return edje_object_part_text_get(item->button, "elm.btn.text");
1715 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1717 ELM_CHECK_WIDTYPE(obj, widtype);
1719 if (part && strcmp(part, "default")) return;
1720 if (label) _set_label(obj, label);
1721 else _set_label(obj, "");
1723 if (!part || !strcmp(part, "default"))
1725 if (label) _set_label(obj, label);
1726 else _set_label(obj, "");
1728 else if (!strcmp(part, "guide"))
1730 if (label) _set_guidetext(obj, label);
1731 else _set_guidetext(obj, "");
1733 >>>>>>> remotes/origin/upstream
1737 _text_get_hook(const Evas_Object *obj, const char *part)
1739 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1742 if (part && strcmp(part, "default")) return NULL;
1743 wd = elm_widget_data_get(obj);
1744 if (!wd) return NULL;
1745 if (wd->label) return edje_object_part_text_get(wd->label, "mbe.label");
1747 Widget_Data *wd = elm_widget_data_get(obj);
1748 if (!wd) return NULL;
1750 if (!part || !strcmp(part, "default"))
1752 return wd->labeltxt;
1754 else if (!strcmp(part, "guide"))
1756 return wd->guidetexttxt;
1758 >>>>>>> remotes/origin/upstream
1763 elm_multibuttonentry_add(Evas_Object *parent)
1769 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1771 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
1772 elm_widget_type_set(obj, "multibuttonentry");
1773 elm_widget_sub_object_add(parent, obj);
1774 elm_widget_data_set(obj, wd);
1776 elm_widget_del_hook_set(obj, _del_hook);
1777 elm_widget_theme_hook_set(obj, _theme_hook);
1778 elm_widget_event_hook_set(obj, _event_hook);
1779 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1780 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
1781 elm_widget_text_set_hook_set(obj, _text_set_hook);
1782 elm_widget_text_get_hook_set(obj, _text_get_hook);
1784 wd->base = edje_object_add(e);
1785 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
1786 elm_widget_resize_object_set(obj, wd->base);
1787 elm_widget_can_focus_set(obj, EINA_TRUE);
1789 wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1790 wd->focused = EINA_FALSE;
1791 wd->last_btn_select = EINA_TRUE;
1794 wd->rect_for_end= NULL;
1796 wd->rect_for_end = NULL;
1797 >>>>>>> remotes/origin/upstream
1798 wd->add_callback = NULL;
1799 wd->add_callback_data = NULL;
1808 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1810 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1811 Widget_Data *wd = elm_widget_data_get(obj);
1813 if (!wd) return NULL;
1821 EINA_DEPRECATED EAPI const char *
1822 >>>>>>> remotes/origin/upstream
1823 elm_multibuttonentry_label_get(const Evas_Object *obj)
1825 return _text_get_hook(obj, NULL);
1831 EINA_DEPRECATED EAPI void
1832 >>>>>>> remotes/origin/upstream
1833 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1835 _text_set_hook(obj, NULL, label);
1841 EINA_DEPRECATED EAPI const char *
1842 >>>>>>> remotes/origin/upstream
1843 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1845 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1846 Widget_Data *wd = elm_widget_data_get(obj);
1848 if (!wd) return NULL;
1849 if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1856 EINA_DEPRECATED EAPI void
1857 >>>>>>> remotes/origin/upstream
1858 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1860 ELM_CHECK_WIDTYPE(obj, widtype);
1861 Widget_Data *wd = elm_widget_data_get(obj);
1866 _set_guidetext(obj, guidetext);
1868 _set_guidetext(obj, "");
1872 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1876 _set_guidetext(obj, guidetext);
1879 EINA_DEPRECATED EAPI int
1880 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1882 if (elm_multibuttonentry_expanded_get(obj))
1889 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1891 >>>>>>> remotes/origin/upstream
1892 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1893 Widget_Data *wd = elm_widget_data_get(obj);
1897 return wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? 1 : 0;
1901 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1904 return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1908 EINA_DEPRECATED EAPI void
1909 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1912 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
1915 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
1919 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1921 >>>>>>> remotes/origin/upstream
1922 ELM_CHECK_WIDTYPE(obj, widtype);
1923 Widget_Data *wd = elm_widget_data_get(obj);
1925 if (!wd || !wd->box ||
1927 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? 1 : 0) == shrink) return;
1928 _shrink_mode_set(obj, shrink);
1931 EAPI Elm_Object_Item *
1932 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1934 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1935 Elm_Multibuttonentry_Item *item;
1936 if (!label) return NULL;
1937 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
1938 return (Elm_Object_Item *) item;
1941 EAPI Elm_Object_Item *
1942 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1944 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1945 Elm_Multibuttonentry_Item *item;
1946 if (!label) return NULL;
1947 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
1948 return (Elm_Object_Item *) item;
1951 EAPI Elm_Object_Item *
1952 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1954 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1955 Elm_Multibuttonentry_Item *item;
1956 if (!label) return NULL;
1957 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE,
1958 (Elm_Multibuttonentry_Item *) before, data);
1959 return (Elm_Object_Item *) item;
1962 EAPI Elm_Object_Item *
1963 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
1965 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1966 Elm_Multibuttonentry_Item *item;
1967 if (!label) return NULL;
1968 item = _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER,
1969 (Elm_Multibuttonentry_Item *) after, data);
1970 return (Elm_Object_Item *) item;
1972 ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1975 _shrink_mode_set(obj, EINA_FALSE);
1977 _shrink_mode_set(obj, EINA_TRUE);
1981 EAPI Elm_Object_Item *
1982 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1984 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
1987 EAPI Elm_Object_Item *
1988 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1990 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
1993 EAPI Elm_Object_Item *
1994 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
1996 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
1999 EAPI Elm_Object_Item *
2000 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
2002 return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
2003 >>>>>>> remotes/origin/upstream
2006 EAPI const Eina_List *
2007 elm_multibuttonentry_items_get(const Evas_Object *obj)
2009 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2010 Widget_Data *wd = elm_widget_data_get(obj);
2011 if (!wd) return NULL;
2015 EAPI Elm_Object_Item *
2016 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
2018 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2019 Widget_Data *wd = elm_widget_data_get(obj);
2020 if (!wd) return NULL;
2021 return eina_list_data_get(wd->items);
2024 EAPI Elm_Object_Item *
2025 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
2027 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2028 Widget_Data *wd = elm_widget_data_get(obj);
2029 if (!wd) return NULL;
2030 return eina_list_data_get(eina_list_last(wd->items));
2033 EAPI Elm_Object_Item *
2034 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
2036 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2037 Widget_Data *wd = elm_widget_data_get(obj);
2038 if (!wd) return NULL;
2039 return eina_list_data_get(wd->current);
2044 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
2046 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2047 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
2049 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
2051 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2052 Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *)it;
2053 >>>>>>> remotes/origin/upstream
2054 if (selected) _select_button(WIDGET(item), item->button);
2055 else _select_button(WIDGET(item), NULL);
2060 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
2062 ELM_CHECK_WIDTYPE(obj, widtype);
2063 Widget_Data *wd = elm_widget_data_get(obj);
2065 _select_button(obj, NULL);
2068 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
2070 //TODO : To be implemented.
2071 if (!it) return EINA_FALSE;
2073 >>>>>>> remotes/origin/upstream
2077 elm_multibuttonentry_clear(Evas_Object *obj)
2079 ELM_CHECK_WIDTYPE(obj, widtype);
2080 Elm_Multibuttonentry_Item *item;
2081 Widget_Data *wd = elm_widget_data_get(obj);
2086 EINA_LIST_FREE(wd->items, item)
2088 elm_box_unpack(wd->box, item->button);
2089 _del_button_obj(obj, item->button);
2099 elm_multibuttonentry_item_del(Elm_Object_Item *it)
2101 elm_object_item_del(it);
2105 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
2107 return _item_text_get_hook(it, NULL);
2111 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
2113 _item_text_set_hook(it, NULL, str);
2116 EAPI Elm_Object_Item *
2117 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
2119 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2122 Elm_Multibuttonentry_Item *_item;
2124 wd = elm_widget_data_get(WIDGET(it));
2125 if (!wd) return NULL;
2127 EINA_LIST_FOREACH(wd->items, l, _item)
2130 if (_item == (Elm_Multibuttonentry_Item *) it)
2132 if (_item == (Elm_Multibuttonentry_Item *)it)
2133 >>>>>>> remotes/origin/upstream
2135 l = eina_list_prev(l);
2136 if (!l) return NULL;
2137 return eina_list_data_get(l);
2143 EAPI Elm_Object_Item *
2144 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
2146 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2149 Elm_Multibuttonentry_Item *_item;
2150 wd = elm_widget_data_get(WIDGET(it));
2151 if (!wd) return NULL;
2153 EINA_LIST_FOREACH(wd->items, l, _item)
2156 if (_item == (Elm_Multibuttonentry_Item *) it)
2158 if (_item == (Elm_Multibuttonentry_Item *)it)
2159 >>>>>>> remotes/origin/upstream
2161 l = eina_list_next(l);
2162 if (!l) return NULL;
2163 return eina_list_data_get(l);
2170 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
2173 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2175 >>>>>>> remotes/origin/upstream
2176 return elm_widget_item_data_get(it);
2180 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
2183 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2185 >>>>>>> remotes/origin/upstream
2186 return elm_widget_item_data_set(it, data);
2191 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
2193 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
2194 >>>>>>> remotes/origin/upstream
2196 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
2197 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
2200 Widget_Data *wd = elm_widget_data_get(obj);
2203 ELM_CHECK_WIDTYPE(obj, widtype);
2204 EINA_SAFETY_ON_NULL_RETURN(func);
2206 new_item_filter= _filter_new(func, data);
2207 if (!new_item_filter) return;
2209 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
2212 if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
2214 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
2215 >>>>>>> remotes/origin/upstream
2217 printf("Already Registered this item filter!!!!\n");
2221 wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
2226 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
2228 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
2229 >>>>>>> remotes/origin/upstream
2231 Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
2232 Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
2234 Widget_Data *wd = elm_widget_data_get(obj);
2237 ELM_CHECK_WIDTYPE(obj, widtype);
2238 EINA_SAFETY_ON_NULL_RETURN(func);
2240 new_item_filter = _filter_new(func, data);
2241 if (!new_item_filter) return;
2243 EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
2245 if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
2247 printf("Already Registered this item filter!!!!\n");
2251 wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
2256 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
2258 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
2259 >>>>>>> remotes/origin/upstream
2263 Elm_Multibuttonentry_Item_Filter *item_filter;
2265 wd = elm_widget_data_get(obj);
2267 EINA_SAFETY_ON_NULL_RETURN(func);
2269 EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
2271 if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
2273 wd->filter_list = eina_list_remove_list(wd->filter_list, l);
2274 _filter_free(item_filter);
2282 elm_multibuttonentry_view_mode(Evas_Object *obj, Eina_Bool view_mode)
2284 ELM_CHECK_WIDTYPE(obj, widtype);
2285 Widget_Data *wd = elm_widget_data_get(obj);
2286 wd->view_mode = view_mode;
2290 elm_box_unpack(wd->box, wd->entry);
2291 evas_object_hide(wd->entry);
2297 >>>>>>> remotes/origin/upstream