Merge remote-tracking branch 'remotes/origin/upstream'
[framework/uifw/elementary.git] / src / lib / elc_multibuttonentry.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 #define MAX_STR 256
5 <<<<<<< HEAD
6 #define MIN_W_ENTRY 20
7 =======
8 #define MIN_W_ENTRY 10
9 >>>>>>> remotes/origin/upstream
10
11 typedef enum _Multibuttonentry_Pos
12   {
13      MULTIBUTTONENTRY_POS_START,
14      MULTIBUTTONENTRY_POS_END,
15      MULTIBUTTONENTRY_POS_BEFORE,
16      MULTIBUTTONENTRY_POS_AFTER,
17 <<<<<<< HEAD
18      MULTIBUTTONENTRY_POS_NUM
19 =======
20 >>>>>>> remotes/origin/upstream
21   } Multibuttonentry_Pos;
22
23 typedef enum _Multibuttonentry_Button_State
24   {
25      MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
26      MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
27 <<<<<<< HEAD
28      MULTIBUTTONENTRY_BUTTON_STATE_NUM
29   } Multibuttonentry_Button_State;
30
31 =======
32   } Multibuttonentry_Button_State;
33
34
35 >>>>>>> remotes/origin/upstream
36 typedef enum _MultiButtonEntry_Closed_Button_Type
37   {
38      MULTIBUTTONENTRY_CLOSED_IMAGE,
39      MULTIBUTTONENTRY_CLOSED_LABEL
40   } MultiButtonEntry_Closed_Button_Type;
41
42 typedef enum _Multibuttonentry_View_State
43   {
44      MULTIBUTTONENTRY_VIEW_NONE,
45      MULTIBUTTONENTRY_VIEW_GUIDETEXT,
46      MULTIBUTTONENTRY_VIEW_ENTRY,
47      MULTIBUTTONENTRY_VIEW_SHRINK
48   } Multibuttonentry_View_State;
49
50 typedef struct _Widget_Data Widget_Data;
51 typedef struct _Multibuttonentry_Item Elm_Multibuttonentry_Item;
52
53 struct _Multibuttonentry_Item
54   {
55      ELM_WIDGET_ITEM;
56      Evas_Object *button;
57      Evas_Coord vw, rw; // vw: visual width, real width
58      Eina_Bool  visible: 1;
59 <<<<<<< HEAD
60 =======
61      Evas_Smart_Cb func;
62 >>>>>>> remotes/origin/upstream
63   };
64
65 typedef struct _Elm_Multibuttonentry_Item_Filter
66   {
67 <<<<<<< HEAD
68      Elm_Multibuttonentry_Item_Filter_callback callback_func;
69 =======
70      Elm_Multibuttonentry_Item_Filter_Cb callback_func;
71 >>>>>>> remotes/origin/upstream
72      void *data;
73   } Elm_Multibuttonentry_Item_Filter;
74
75 struct _Widget_Data
76   {
77      Evas_Object *base;
78      Evas_Object *box;
79      Evas_Object *entry;
80      Evas_Object *label;
81      Evas_Object *guidetext;
82      Evas_Object *end;   // used to represent the total number of invisible buttons
83
84      Evas_Object *rect_for_end;
85      MultiButtonEntry_Closed_Button_Type end_type;
86
87      Eina_List *items;
88      Eina_List *current;
89      Eina_List *filter_list;
90
91 <<<<<<< HEAD
92 =======
93      const char *labeltxt, *guidetexttxt;
94
95 >>>>>>> remotes/origin/upstream
96      int n_str;
97      Multibuttonentry_View_State view_state;
98
99      Evas_Coord w_box, h_box;
100      int  shrink;
101      Eina_Bool focused: 1;
102      Eina_Bool last_btn_select: 1;
103 <<<<<<< HEAD
104      Eina_Bool view_mode;
105      Elm_Multibuttonentry_Item_Filter_callback add_callback;
106 =======
107      Elm_Multibuttonentry_Item_Filter_Cb add_callback;
108 >>>>>>> remotes/origin/upstream
109      void *add_callback_data;
110   };
111
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);
121 <<<<<<< HEAD
122 static void _shrink_mode_set(Evas_Object *obj, int shrink);
123 =======
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);
134 <<<<<<< HEAD
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);
138 =======
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,
155 <<<<<<< HEAD
156                                const char *part,
157                                const char *label);
158 static const char * _item_text_get_hook(const Elm_Object_Item *it,
159                                         const char *part);
160 =======
161                                 const char *part,
162                                 const char *label);
163 static const char *_item_text_get_hook(const Elm_Object_Item *it,
164                                        const char *part);
165
166  /*  TODO
167   *  Code refactoring
168   *  use evas_object_smart_callback_descriptions_set for smart callbacks.
169   */
170 >>>>>>> remotes/origin/upstream
171
172 static void
173 _del_hook(Evas_Object *obj)
174 {
175    Widget_Data *wd = elm_widget_data_get(obj);
176
177    if (!wd) return;
178    if (wd->items)
179      {
180         Elm_Multibuttonentry_Item *item;
181         EINA_LIST_FREE(wd->items, item)
182           {
183              _del_button_obj(obj, item->button);
184              free(item);
185           }
186         wd->items = NULL;
187      }
188    wd->current = NULL;
189
190 <<<<<<< HEAD
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);
195 =======
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);
204 }
205
206 static void
207 _theme_hook(Evas_Object *obj)
208 {
209    Widget_Data *wd = elm_widget_data_get(obj);
210    Eina_List *l;
211    Elm_Multibuttonentry_Item *item;
212
213    if (!wd) return;
214
215    _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
216 <<<<<<< HEAD
217    if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
218 =======
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);
222
223    EINA_LIST_FOREACH(wd->items, l, item)
224      {
225         if (item->button)
226 <<<<<<< HEAD
227           _elm_theme_object_set(obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
228 =======
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);
232      }
233
234    _sizing_eval(obj);
235 }
236
237 static void
238 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
239 {
240    Widget_Data *wd = elm_widget_data_get(obj);
241
242    if (!wd) return;
243
244    if (elm_widget_focus_get(obj))
245      {
246         if ((wd->current))
247           {
248              elm_entry_input_panel_show(wd->entry);
249           }
250         else if (((!wd->current) || (!eina_list_count(wd->items))))
251           {
252              if (wd->entry) elm_entry_cursor_end_set(wd->entry);
253              _view_update(obj);
254              elm_entry_input_panel_show(wd->entry);
255           }
256         wd->focused = EINA_TRUE;
257         evas_object_smart_callback_call(obj, "focused", NULL);
258      }
259    else
260      {
261         wd->focused = EINA_FALSE;
262         _view_update(obj);
263
264         elm_entry_input_panel_hide(wd->entry);
265         evas_object_smart_callback_call(obj, "unfocused", NULL);
266      }
267 }
268
269 static Eina_Bool
270 _event_hook(Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type __UNUSED__, void *event_info __UNUSED__)
271 {
272    return EINA_TRUE;
273 }
274
275 static void
276 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
277 {
278    Widget_Data *wd = elm_widget_data_get(obj);
279
280    if (!wd) return;
281    edje_object_signal_emit(wd->base, emission, source);
282 }
283
284 static void
285 _sizing_eval(Evas_Object *obj)
286 {
287    Widget_Data *wd = elm_widget_data_get(obj);
288    Evas_Coord minw = -1, minh = -1;
289    Evas_Coord left, right, top, bottom;
290
291    if (!wd) return;
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);
295
296    minw += (left + right);
297    minh += (top + bottom);
298
299    evas_object_size_hint_min_set(obj, minw, minh);
300 }
301
302 static void
303 _signal_mouse_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
304 {
305    Widget_Data *wd = elm_widget_data_get(data);
306
307    if (!wd || !wd->base) return;
308    wd->focused = EINA_TRUE;
309    _view_update(data);
310
311    elm_entry_input_panel_show(wd->entry);
312
313    evas_object_smart_callback_call(data, "clicked", NULL);
314 }
315
316 static void
317 _changed_size_hint_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
318 {
319    Evas_Object *eo = (Evas_Object *)data;
320    Widget_Data *wd = elm_widget_data_get(data);
321
322    if (!wd) return;
323    _sizing_eval(eo);
324 }
325
326 static void
327 _resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
328 {
329    Widget_Data *wd = elm_widget_data_get(data);
330    Evas_Coord w, h;
331
332    if (!wd) return;
333    evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
334
335 <<<<<<< HEAD
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);
338 =======
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
342
343    wd->w_box = w;
344    wd->h_box = h;
345
346    _view_update(data);
347 }
348
349 static void
350 _event_init(Evas_Object *obj)
351 {
352    Widget_Data *wd = elm_widget_data_get(obj);
353
354    if (!wd || !wd->base) return;
355    if (wd->base)
356      {
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);
359      }
360
361    if (wd->box)
362      {
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);
365      }
366
367    if (wd->entry)
368      {
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);
376      }
377 }
378
379 static void
380 _set_vis_guidetext(Evas_Object *obj)
381 {
382    Widget_Data *wd = elm_widget_data_get(obj);
383
384    if (!wd) return;
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;
388
389    if (wd && (!eina_list_count(wd->items)) && wd->guidetext
390        && (!elm_widget_focus_get(obj)) && (!wd->focused) && (!wd->n_str))
391      {
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;
396      }
397    else
398      {
399         evas_object_hide(wd->guidetext);
400 <<<<<<< HEAD
401         if (!wd->view_mode)
402           {
403              elm_box_pack_end(wd->box, wd->entry);
404              evas_object_show(wd->entry);
405           }
406 =======
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)
411           if (!wd->current)
412             elm_object_focus_set(wd->entry, EINA_TRUE);
413         wd->view_state = MULTIBUTTONENTRY_VIEW_ENTRY;
414      }
415 }
416
417 static void
418 <<<<<<< HEAD
419 _shrink_mode_set(Evas_Object *obj, int shrink)
420 =======
421 _shrink_mode_set(Evas_Object *obj, Eina_Bool shrink)
422 >>>>>>> remotes/origin/upstream
423 {
424    Widget_Data *wd = elm_widget_data_get(obj);
425    Eina_List *l;
426    Elm_Multibuttonentry_Item *item;
427
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)
434      {
435         evas_object_hide(wd->rect_for_end);
436         evas_object_hide(wd->end);
437         wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
438      }
439
440 <<<<<<< HEAD
441    if (shrink == 1)
442      {
443         Evas_Coord w=0, w_tmp=0;
444 =======
445    if (shrink == EINA_TRUE)
446      {
447         Evas_Coord w = 0, w_tmp = 0;
448 >>>>>>> remotes/origin/upstream
449         Evas_Coord box_inner_item_width_padding = 0;
450
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)
455           {
456              if (item)
457                {
458                   evas_object_hide(item->button);
459                   item->visible = EINA_FALSE;
460                }
461           }
462         // pack buttons only 1line
463         w = wd->w_box;
464
465         if (wd->label)
466           {
467              elm_box_pack_end(wd->box, wd->label);
468              evas_object_size_hint_min_get(wd->label, &w_tmp, NULL);
469              w -= w_tmp;
470              w -= box_inner_item_width_padding;
471           }
472
473         item = NULL;
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)
478           {
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);
482              /* it use for later
483              size_str = edje_object_data_get(wd->end, "closed_button_height");
484              if (size_str) button_min_width = (Evas_Coord)atoi(size_str);
485               */
486           }
487
488         EINA_LIST_FOREACH(wd->items, l, item)
489           {
490              if (item)
491                {
492                   int w_label_count = 0;
493                   char buf[MAX_STR];
494
495                   elm_box_pack_end(wd->box, item->button);
496                   evas_object_show(item->button);
497                   item->visible = EINA_TRUE;
498
499                   w -= item->vw;
500                   w -= box_inner_item_width_padding;
501                   count--;
502
503                   if (wd->end_type == MULTIBUTTONENTRY_CLOSED_LABEL)
504                     {
505                        if (count > 0)
506                          {
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);
510                          }
511
512                        if (w < 0 || w < w_label_count)
513                          {
514                             elm_box_unpack(wd->box, item->button);
515                             evas_object_hide(item->button);
516                             item->visible = EINA_FALSE;
517
518                             count++;
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);
522
523                             elm_box_pack_end(wd->box, wd->end);
524                             evas_object_show(wd->end);
525
526                             wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
527 <<<<<<< HEAD
528                             evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)1);
529 =======
530                             evas_object_smart_callback_call(obj, "expand,state,changed", (void *)1);
531 >>>>>>> remotes/origin/upstream
532                             break;
533                          }
534                     }
535                   else if (wd->end_type == MULTIBUTTONENTRY_CLOSED_IMAGE)
536                     {
537                        if (w < button_min_width)
538                          {
539                             Evas_Coord rectSize;
540                             Evas_Coord closed_height = 0;
541                             const char *height_str = edje_object_data_get(wd->base, "closed_height");
542
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;
547
548                             w += item->vw;
549                             rectSize = w - button_min_width;
550                             if (!wd->rect_for_end)
551                               {
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);
555                               }
556 <<<<<<< HEAD
557                             evas_object_size_hint_min_set(wd->rect_for_end, rectSize, closed_height * elm_scale_get());
558 =======
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);
563
564                             elm_box_pack_end(wd->box, wd->end);
565                             evas_object_show(wd->end);
566
567                             wd->view_state = MULTIBUTTONENTRY_VIEW_SHRINK;
568 <<<<<<< HEAD
569                             evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)0);
570 =======
571                             evas_object_smart_callback_call(obj, "expand,state,changed", (void *)0);
572 >>>>>>> remotes/origin/upstream
573                             break;
574                          }
575                     }
576                }
577           }
578      }
579    else
580      {
581         // unpack all items and entry
582         elm_box_unpack_all(wd->box);
583         EINA_LIST_FOREACH(wd->items, l, item)
584           {
585              if (item)
586                {
587                   evas_object_hide(item->button);
588                   item->visible = EINA_FALSE;
589                }
590           }
591         evas_object_hide(wd->end);
592
593         if (wd->rect_for_end) evas_object_hide(wd->rect_for_end);
594
595         // pack buttons only 1line
596
597         if (wd->label) elm_box_pack_end(wd->box, wd->label);
598
599         // pack remain btns
600         item = NULL;
601         EINA_LIST_FOREACH(wd->items, l, item)
602           {
603              if (item)
604                {
605                   elm_box_pack_end(wd->box, item->button);
606                   evas_object_show(item->button);
607                   item->visible = EINA_TRUE;
608                }
609           }
610
611         wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
612 <<<<<<< HEAD
613         evas_object_smart_callback_call(obj, "shrink,state,changed", (void *)wd->shrink);
614 =======
615         evas_object_smart_callback_call(obj, "expand,state,changed", (void *)(long)wd->shrink);
616 >>>>>>> remotes/origin/upstream
617      }
618    if (wd->view_state != MULTIBUTTONENTRY_VIEW_SHRINK)
619      {
620         _set_vis_guidetext(obj);
621      }
622 }
623
624 static void
625 _view_update(Evas_Object *obj)
626 {
627    Evas_Coord width = 1, height = 1;
628    Widget_Data *wd = elm_widget_data_get(obj);
629
630    if (!wd || !wd->box || !wd->entry || !(wd->w_box > 0)) return;
631
632    // update label
633    if (wd->label)
634      {
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);
638      }
639
640    if (wd->guidetext)
641      {
642         Evas_Coord guide_text_width = wd->w_box - width;
643         evas_object_size_hint_min_set(wd->guidetext, guide_text_width, height);
644      }
645
646    // update buttons in shrink mode
647    if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
648 <<<<<<< HEAD
649      _shrink_mode_set(obj, 1);
650 =======
651      _shrink_mode_set(obj, EINA_TRUE);
652 >>>>>>> remotes/origin/upstream
653
654    // update guidetext
655    _set_vis_guidetext(obj);
656 }
657
658 static void
659 <<<<<<< HEAD
660 _set_label(Evas_Object *obj, const char* str)
661 =======
662 _set_label(Evas_Object *obj, const char *str)
663 >>>>>>> remotes/origin/upstream
664 {
665    Widget_Data *wd = elm_widget_data_get(obj);
666
667    if (!wd || !str) return;
668 <<<<<<< HEAD
669 =======
670    eina_stringshare_replace(&wd->labeltxt, str);
671 >>>>>>> remotes/origin/upstream
672    if (wd->label)
673    {
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);
678
679       if (!strcmp(str, ""))
680         {
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);
684            sum_width += width;
685         }
686       else
687         {
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);
690
691            sum_width += width;
692
693            edje_object_part_geometry_get(wd->label, "mbe.label.left.padding", NULL, NULL, &width, NULL);
694            sum_width += width;
695
696            edje_object_part_geometry_get(wd->label, "mbe.label.right.padding", NULL, NULL, &width, NULL);
697            sum_width += width;
698         }
699       evas_object_size_hint_min_set(wd->label, sum_width, height);
700    }
701    evas_object_show(wd->label);
702    _view_update(obj);
703 }
704
705 static void
706 <<<<<<< HEAD
707 _set_guidetext(Evas_Object *obj, const char* str)
708 =======
709 _set_guidetext(Evas_Object *obj, const char *str)
710 >>>>>>> remotes/origin/upstream
711 {
712    Widget_Data *wd = elm_widget_data_get(obj);
713
714    if (!wd || !str) return;
715 <<<<<<< HEAD
716    if (!wd->guidetext)
717      {
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);
722      }
723
724    if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
725    _view_update(obj);
726 =======
727
728    eina_stringshare_replace(&wd->guidetexttxt, str);
729    if (wd->guidetext == NULL)
730      wd->guidetext = edje_object_add(evas_object_evas_get(obj));
731
732    if (wd->guidetext)
733      {
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,
738                                                            EVAS_HINT_FILL);
739         edje_object_part_text_set(wd->guidetext, "elm.text", str);
740         _view_update(obj);
741      }
742 >>>>>>> remotes/origin/upstream
743 }
744
745 static void
746 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
747 {
748    Widget_Data *wd = elm_widget_data_get(obj);
749    Elm_Multibuttonentry_Item *item = NULL;
750
751    if (!wd) return;
752    if (wd->current)
753      item = eina_list_data_get(wd->current);
754
755    if (item && item->button)
756      {
757         switch (state)
758           {
759              case MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT:
760                 edje_object_signal_emit(item->button, "default", "");
761                 wd->current = NULL;
762                 break;
763              case MULTIBUTTONENTRY_BUTTON_STATE_SELECTED:
764                 edje_object_signal_emit(item->button, "focused", "");
765                 evas_object_smart_callback_call(obj, "item,selected", item);
766                 break;
767              default:
768                 edje_object_signal_emit(item->button, "default", "");
769                 wd->current = NULL;
770                 break;
771           }
772      }
773 }
774
775 static void
776 _change_current_button(Evas_Object *obj, Evas_Object *btn)
777 {
778    Widget_Data *wd = elm_widget_data_get(obj);
779    Eina_List *l;
780    Elm_Multibuttonentry_Item *item;
781
782    if (!wd) return;
783
784    // change the state of previous button to "default"
785    _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
786
787    // change the current
788    EINA_LIST_FOREACH(wd->items, l, item)
789      {
790         if (item->button == btn)
791           {
792              wd->current = l;
793              break;
794           }
795      }
796    // change the state of current button to "focused"
797    _change_current_button_state(obj, MULTIBUTTONENTRY_BUTTON_STATE_SELECTED);
798 }
799
800 static void
801 _button_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
802 {
803    Widget_Data *wd = elm_widget_data_get(data);
804
805    Elm_Multibuttonentry_Item *item = NULL;
806    if (!wd || wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) return;
807
808 <<<<<<< HEAD
809    _select_button(data, obj);
810
811    if ((wd->current) && ((item = eina_list_data_get(wd->current)) != NULL))
812      evas_object_smart_callback_call(data, "item,clicked", item);
813 =======
814    _change_current_button(data, obj);
815
816    if (wd->current)
817      if ((item = eina_list_data_get(wd->current)) != NULL)
818        {
819           evas_object_smart_callback_call(data, "item,clicked", item);
820           _select_button(data, item->button);
821        }
822 >>>>>>> remotes/origin/upstream
823 }
824
825 static void
826 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
827 {
828    Widget_Data *wd = elm_widget_data_get(obj);
829
830    if (!wd || !btn) return;
831    if (btn)
832      evas_object_del(btn);
833 }
834
835 static void
836 _del_button_item(Elm_Multibuttonentry_Item *item)
837 {
838    Eina_List *l;
839    Elm_Multibuttonentry_Item *_item;
840    if (!item) return;
841    Widget_Data *wd;
842
843    Evas_Object *obj = WIDGET(item);
844    wd = elm_widget_data_get(obj);
845    if (!wd) return;
846    EINA_LIST_FOREACH(wd->items, l, _item)
847      {
848         if (_item == item)
849           {
850              wd->items = eina_list_remove(wd->items, _item);
851              elm_box_unpack(wd->box, _item->button);
852
853              evas_object_smart_callback_call(obj, "item,deleted", _item);
854
855              _del_button_obj(obj, _item->button);
856
857              if (wd->current == l)
858                wd->current = NULL;
859              break;
860           }
861      }
862    if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
863 <<<<<<< HEAD
864      _shrink_mode_set(obj, 1);
865 =======
866      _shrink_mode_set(obj, EINA_TRUE);
867 >>>>>>> remotes/origin/upstream
868
869    if (!eina_list_count(wd->items))
870      _set_vis_guidetext(obj);
871 }
872
873 static void
874 _select_button(Evas_Object *obj, Evas_Object *btn)
875 {
876    Widget_Data *wd = elm_widget_data_get(obj);
877
878    if (!wd) return;
879    if (btn)
880      {
881         _change_current_button(obj, btn);
882         if (elm_widget_focus_get(obj))
883           {
884              elm_object_focus_set(wd->entry, EINA_FALSE);
885              evas_object_focus_set(btn, EINA_TRUE);
886           }
887      }
888    else
889      {
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);
893      }
894 }
895
896 static void
897 _resize_button(Evas_Object *btn, Evas_Coord *realw, Evas_Coord *vieww)
898 {
899    Evas_Coord rw, vw;
900 <<<<<<< HEAD
901    Evas_Coord w_text, h_btn, padding_outer = 0;
902 =======
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;
907
908    size_str = edje_object_data_get(btn, "button_max_size");
909    if (size_str) button_max_width = (Evas_Coord)atoi(size_str);
910
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);
915 <<<<<<< HEAD
916    w_btn = w_text + 2*padding_outer;
917 =======
918    w_btn = w_text + 2*padding_outer + 2*padding_inner;
919 >>>>>>> remotes/origin/upstream
920
921    rw = w_btn;
922
923    if (button_max_width < w_btn)
924      vw = button_max_width;
925    else
926      vw = w_btn;
927
928    //resize btn
929    evas_object_resize(btn, vw, h_btn);
930    evas_object_size_hint_min_set(btn, vw, h_btn);
931
932    if (realw) *realw = rw;
933    if (vieww) *vieww = vw;
934 }
935
936 static Eina_Bool
937 _item_del_pre_hook(Elm_Object_Item *it)
938 {
939 <<<<<<< HEAD
940    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
941    _del_button_item((Elm_Multibuttonentry_Item *) it);
942    return EINA_TRUE;
943 }
944
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)
947 {
948    Elm_Multibuttonentry_Item *item;
949    Elm_Multibuttonentry_Item_Filter *item_filter;
950 =======
951    _del_button_item((Elm_Multibuttonentry_Item *)it);
952    return EINA_TRUE;
953 }
954
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)
957 {
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
962    Eina_List *l;
963    Evas_Object *btn;
964    Evas_Coord width = -1, height = -1;
965    char *str_utf8 = NULL;
966 <<<<<<< HEAD
967
968    Widget_Data *wd = elm_widget_data_get(obj);
969
970    if (!wd || !wd->box || !wd->entry) return NULL;
971 =======
972    Widget_Data *wd = elm_widget_data_get(obj);
973
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
978
979    EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
980      {
981         if (!(item_filter->callback_func(obj, str, data, item_filter->data)))
982           return NULL;
983      }
984    // add button
985    btn = edje_object_add(evas_object_evas_get(obj));
986    str_utf8 = elm_entry_markup_to_utf8(str);
987
988    //entry is cleared when text is made to button
989    elm_object_text_set(wd->entry, "");
990
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);
994
995    evas_object_size_hint_min_set(btn, width, height);
996
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);
1000
1001    // append item list
1002    item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
1003    if (item)
1004      {
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);
1009         Evas_Coord rw, vw;
1010         _resize_button(btn, &rw, &vw);
1011         item->button = btn;
1012         item->rw = rw;
1013         item->vw = vw;
1014         item->visible = EINA_TRUE;
1015
1016 <<<<<<< HEAD
1017 =======
1018         if (func)
1019           {
1020               item->func = func;
1021           }
1022
1023 >>>>>>> remotes/origin/upstream
1024         switch (pos)
1025           {
1026              case MULTIBUTTONENTRY_POS_START:
1027                 wd->items = eina_list_prepend(wd->items, item);
1028                 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
1029                   {
1030                      elm_widget_sub_object_add(obj, btn);
1031 <<<<<<< HEAD
1032                      _shrink_mode_set(obj, 1);
1033 =======
1034                      _shrink_mode_set(obj, EINA_TRUE);
1035 >>>>>>> remotes/origin/upstream
1036                   }
1037                 else
1038                   {
1039                      if (wd->label)
1040                        elm_box_pack_after(wd->box, btn, wd->label);
1041                      else
1042                        elm_box_pack_start(wd->box, btn);
1043                      if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
1044                        _set_vis_guidetext(obj);
1045                   }
1046                 break;
1047              case MULTIBUTTONENTRY_POS_END:
1048                 wd->items = eina_list_append(wd->items, item);
1049                 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
1050                   {
1051                      elm_widget_sub_object_add(obj, btn);
1052                      evas_object_hide(btn);
1053                   }
1054                 else
1055                   {
1056                      if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
1057                        _set_vis_guidetext(obj);
1058                      if (wd->entry)
1059 <<<<<<< HEAD
1060                        {
1061                           if (!wd->view_mode)
1062                             elm_box_pack_before(wd->box, btn, wd->entry);
1063                           else
1064                             elm_box_pack_end(wd->box, btn);
1065                        }
1066 =======
1067                        elm_box_pack_before(wd->box, btn, wd->entry);
1068 >>>>>>> remotes/origin/upstream
1069                      else
1070                        elm_box_pack_end(wd->box, btn);
1071                   }
1072                 break;
1073              case MULTIBUTTONENTRY_POS_BEFORE:
1074                 if (reference)
1075                      wd->items = eina_list_prepend_relative(wd->items, item, reference);
1076                 else
1077                      wd->items = eina_list_append(wd->items, item);
1078                 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
1079                   {
1080                      elm_widget_sub_object_add(obj, btn);
1081                      evas_object_hide(btn);
1082 <<<<<<< HEAD
1083                      _shrink_mode_set(obj, 1);
1084 =======
1085                      _shrink_mode_set(obj, EINA_TRUE);
1086 >>>>>>> remotes/origin/upstream
1087                   }
1088                 else
1089                   {
1090                      if (reference)
1091                        elm_box_pack_before(wd->box, btn, reference->button);
1092                      else
1093                        {
1094                           if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
1095                             _set_vis_guidetext(obj);
1096                           if (wd->entry)
1097 <<<<<<< HEAD
1098                             {
1099                                if (!wd->view_mode)
1100                                  elm_box_pack_before(wd->box, btn, wd->entry);
1101                                else
1102                                  elm_box_pack_end(wd->box, btn);
1103                             }
1104 =======
1105                             elm_box_pack_before(wd->box, btn, wd->entry);
1106 >>>>>>> remotes/origin/upstream
1107                           else
1108                             elm_box_pack_end(wd->box, btn);
1109                        }
1110                   }
1111                 break;
1112              case MULTIBUTTONENTRY_POS_AFTER:
1113                 if (reference)
1114                      wd->items = eina_list_append_relative(wd->items, item, reference);
1115                 else
1116                      wd->items = eina_list_append(wd->items, item);
1117                 if (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK)
1118                   {
1119                      elm_widget_sub_object_add(obj, btn);
1120 <<<<<<< HEAD
1121                      _shrink_mode_set(obj, 1);
1122 =======
1123                      _shrink_mode_set(obj, EINA_TRUE);
1124 >>>>>>> remotes/origin/upstream
1125                   }
1126                 else
1127                   {
1128                      if (reference)
1129                        elm_box_pack_after(wd->box, btn, reference->button);
1130                      else
1131                        {
1132                           if (wd->view_state == MULTIBUTTONENTRY_VIEW_GUIDETEXT)
1133                             _set_vis_guidetext(obj);
1134                           if (wd->entry)
1135 <<<<<<< HEAD
1136                             {
1137                                if (!wd->view_mode)
1138                                  elm_box_pack_before(wd->box, btn, wd->entry);
1139                                else
1140                                  elm_box_pack_end(wd->box, btn);
1141                             }
1142 =======
1143                             elm_box_pack_before(wd->box, btn, wd->entry);
1144 >>>>>>> remotes/origin/upstream
1145                           else
1146                             elm_box_pack_end(wd->box, btn);
1147                        }
1148                   }
1149                 break;
1150              default:
1151                 break;
1152           }
1153      }
1154    evas_object_smart_callback_call(obj, "item,added", item);
1155
1156    free(str_utf8);
1157
1158 <<<<<<< HEAD
1159    return item;
1160 }
1161
1162 static void
1163 _add_button(Evas_Object *obj, const char *str)
1164 {
1165    Widget_Data *wd = elm_widget_data_get(obj);
1166    if (!wd) return;
1167
1168    _add_button_item(obj, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
1169 }
1170
1171 static Elm_Multibuttonentry_Item_Filter*
1172 _filter_new(Elm_Multibuttonentry_Item_Filter_callback func, void *data)
1173 =======
1174    return (Elm_Object_Item *)item;
1175 }
1176
1177 static Elm_Multibuttonentry_Item_Filter*
1178 _filter_new(Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
1179 >>>>>>> remotes/origin/upstream
1180 {
1181    Elm_Multibuttonentry_Item_Filter *item_filter = ELM_NEW(Elm_Multibuttonentry_Item_Filter);
1182    if (!item_filter) return NULL;
1183
1184    item_filter->callback_func= func;
1185    item_filter->data = data;
1186
1187    return item_filter;
1188 }
1189
1190 static void
1191 _filter_free(Elm_Multibuttonentry_Item_Filter *item_filter)
1192 {
1193    free(item_filter);
1194 }
1195
1196 static void
1197 _evas_mbe_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1198 {
1199    Widget_Data *wd = elm_widget_data_get(data);
1200    Elm_Multibuttonentry_Item *item = NULL;
1201
1202    if (!wd || !wd->base || !wd->box) return;
1203
1204    Evas_Event_Key_Up *ev = (Evas_Event_Key_Up*)event_info;
1205
1206    if (wd->last_btn_select)
1207      {
1208         if (wd->current &&
1209             ((strcmp(ev->keyname, "BackSpace") == 0) ||
1210 <<<<<<< HEAD
1211              (strcmp(ev->keyname, "BackSpace (") == 0)))
1212 =======
1213              (strcmp(ev->keyname, "Delete") == 0)))
1214 >>>>>>> remotes/origin/upstream
1215           {
1216              item = eina_list_data_get(wd->current);
1217              if (item)
1218                {
1219                   _del_button_item(item);
1220                   elm_widget_item_free(item);
1221                   elm_object_focus_set(wd->entry, EINA_TRUE);
1222                }
1223           }
1224         else if (((!wd->current && (wd->n_str == 0) &&
1225                    (strcmp(ev->keyname, "BackSpace") == 0)) ||
1226 <<<<<<< HEAD
1227                   (strcmp(ev->keyname, "BackSpace (") == 0)))
1228 =======
1229                    (strcmp(ev->keyname, "Delete") == 0)))
1230 >>>>>>> remotes/origin/upstream
1231           {
1232              item = eina_list_data_get(eina_list_last(wd->items));
1233              if (item)
1234                _select_button(data, item->button);
1235           }
1236      }
1237    else
1238      wd->last_btn_select = EINA_TRUE;
1239 }
1240
1241 static void
1242 _entry_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1243 {
1244    Widget_Data *wd = elm_widget_data_get(data);
1245    Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
1246
1247    if (!wd) return;
1248
1249 <<<<<<< HEAD
1250    if ((wd->n_str == 1) && (strcmp(ev->keyname, "BackSpace") == 0 || (strcmp(ev->keyname, "BackSpace (") == 0 )))
1251 =======
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;
1255 }
1256
1257 static void
1258 _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1259 {
1260    Widget_Data *wd = elm_widget_data_get(data);
1261    Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
1262    const char *str;
1263
1264    if (!wd || !wd->base || !wd->box) return;
1265
1266    str = elm_object_text_get(wd->entry);
1267
1268    if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
1269      {
1270 <<<<<<< HEAD
1271         _add_button(data, str);
1272 =======
1273         _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1274 >>>>>>> remotes/origin/upstream
1275         wd->n_str = 0;
1276      }
1277 }
1278
1279 static void
1280 _entry_clicked_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1281 {
1282    Widget_Data *wd = elm_widget_data_get(data);
1283    if (!wd) return;
1284
1285    _change_current_button_state(data, MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT);
1286    elm_object_focus_set(wd->entry, EINA_TRUE);
1287 }
1288
1289 static void
1290 _entry_focus_in_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1291 {
1292    Widget_Data *wd = elm_widget_data_get(data);
1293    Elm_Multibuttonentry_Item *item = NULL;
1294
1295    if (!wd) return;
1296
1297    if (wd->current)
1298      {
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);
1302      }
1303 }
1304
1305 static void
1306 _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1307 {
1308    Widget_Data *wd = elm_widget_data_get(data);
1309    const char *str;
1310
1311    if (!wd) return;
1312
1313    str = elm_object_text_get(wd->entry);
1314    if (strlen(str))
1315 <<<<<<< HEAD
1316      _add_button(data, str);
1317 =======
1318      _add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
1319 >>>>>>> remotes/origin/upstream
1320 }
1321
1322 static void
1323 _entry_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1324 {
1325    Widget_Data *wd = elm_widget_data_get(data);
1326    const char *str;
1327
1328    if (!wd) return;
1329
1330    str = elm_object_text_get(wd->entry);
1331    wd->n_str = strlen(str);
1332 }
1333
1334 static void
1335 _entry_resized_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1336 {
1337    Evas_Coord en_x, en_y, en_w, en_h;
1338 <<<<<<< HEAD
1339 =======
1340    Evas_Coord bx_x, bx_y;
1341 >>>>>>> remotes/origin/upstream
1342
1343    Widget_Data *wd = elm_widget_data_get(data);
1344    if (!wd) return;
1345
1346    evas_object_geometry_get(wd->entry, &en_x, &en_y, &en_w, &en_h);
1347 <<<<<<< HEAD
1348
1349    if (wd->focused)
1350      elm_widget_show_region_set(wd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
1351 =======
1352    evas_object_geometry_get(wd->box, &bx_x, &bx_y, NULL, NULL);
1353
1354    if (wd->focused)
1355      elm_widget_show_region_set(wd->box, en_x - bx_x, en_y - bx_y, en_w,
1356                                 en_h, EINA_TRUE);
1357 >>>>>>> remotes/origin/upstream
1358 }
1359
1360 static void
1361 _view_init(Evas_Object *obj)
1362 {
1363    Widget_Data *wd = elm_widget_data_get(obj);
1364
1365    if (!wd) return;
1366
1367    if (!wd->box)
1368      {
1369 <<<<<<< HEAD
1370         wd->box = elm_box_add (obj);
1371 =======
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);
1379      }
1380    if (!wd->label)
1381      {
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);
1387      }
1388
1389    if (!wd->entry)
1390      {
1391 <<<<<<< HEAD
1392         wd->entry = elm_entry_add (obj);
1393         if (!wd->entry) return;
1394         elm_entry_scrollable_set(wd->entry, EINA_TRUE);
1395 =======
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);
1405 <<<<<<< HEAD
1406         if (wd->box) elm_box_pack_end (wd->box, wd->entry);
1407 =======
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;
1412      }
1413
1414    if (!wd->end)
1415      {
1416         const char *end_type;
1417
1418         end_type = edje_object_data_get(wd->base, "closed_button_type");
1419         if (!end_type || !strcmp(end_type, "label"))
1420           {
1421 <<<<<<< HEAD
1422              wd->end = elm_label_add (obj);
1423 =======
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;
1429           }
1430         else
1431           {
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;
1438
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);
1443
1444              wd->end_type = MULTIBUTTONENTRY_CLOSED_IMAGE;
1445 <<<<<<< HEAD
1446              evas_object_size_hint_min_set(wd->end, button_min_width * elm_scale_get(), button_min_height * elm_scale_get());
1447 =======
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);
1453           }
1454      }
1455 }
1456
1457 static void
1458 _calculate_box_min_size(Evas_Object *box, Evas_Object_Box_Data *priv)
1459 {
1460    Evas_Coord minw, minh, mnw, mnh, ww;
1461    Evas_Coord w, cw = 0, cmaxh = 0;
1462    const Eina_List *l;
1463    Evas_Object_Box_Option *opt;
1464    double wx;
1465
1466    /* FIXME: need to calc max */
1467    minw = 0;
1468    minh = 0;
1469
1470    evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1471    evas_object_size_hint_min_get(box, &minw, NULL);
1472
1473    EINA_LIST_FOREACH(priv->children, l, opt)
1474      {
1475         evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1476         evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1477
1478         if (wx)
1479           {
1480 <<<<<<< HEAD
1481              if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1482                mnw = MIN_W_ENTRY;
1483
1484 =======
1485 >>>>>>> remotes/origin/upstream
1486              if (mnw != -1 && (w - cw) >= mnw)
1487                ww = w - cw;
1488              else
1489                ww = w;
1490           }
1491         else
1492 <<<<<<< HEAD
1493           ww = mnw;
1494 =======
1495            ww = mnw;
1496 >>>>>>> remotes/origin/upstream
1497
1498         if ((cw + mnw) > w)
1499           {
1500              minh += cmaxh;
1501              cw = 0;
1502              cmaxh = 0;
1503           }
1504         cw += ww;
1505         if (cmaxh < mnh) cmaxh = mnh;
1506      }
1507
1508    minh += cmaxh;
1509
1510    evas_object_size_hint_min_set(box, minw, minh);
1511 }
1512
1513 static Evas_Coord
1514 _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
1515 {
1516    Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
1517    const Eina_List *l;
1518    Evas_Object_Box_Option *opt;
1519 <<<<<<< HEAD
1520    int index = 0;
1521 =======
1522    int local_index = 0;
1523 >>>>>>> remotes/origin/upstream
1524    double wx;
1525
1526    evas_object_geometry_get(box, NULL, NULL, &w, NULL);
1527
1528    EINA_LIST_FOREACH(priv->children, l, opt)
1529      {
1530         evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
1531         evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
1532
1533         if (wx)
1534           {
1535 <<<<<<< HEAD
1536              if ((elm_widget_is(opt->obj)) && (!(strcmp(elm_widget_type_get(opt->obj), "entry"))) && (mnw == -1))
1537                mnw = MIN_W_ENTRY;
1538
1539              if (mnw != -1 && (w - cw) >= mnw)
1540                ww = w - cw;
1541              else
1542                ww = w;
1543           }
1544         else
1545           ww = mnw;
1546
1547         if ((cw + ww) > w)
1548           {
1549              if (index > obj_index) return cmaxh;
1550 =======
1551              if (mnw != -1 && (w - cw) >= mnw)
1552                 ww = w - cw;
1553              else
1554                 ww = w;
1555           }
1556         else
1557            ww = mnw;
1558
1559         if ((cw + ww) > w)
1560           {
1561              if (local_index > obj_index) return cmaxh;
1562 >>>>>>> remotes/origin/upstream
1563              cw = 0;
1564              cmaxh = 0;
1565           }
1566
1567         cw += ww;
1568         if (cmaxh < mnh) cmaxh = mnh;
1569
1570 <<<<<<< HEAD
1571         index++;
1572 =======
1573         local_index++;
1574 >>>>>>> remotes/origin/upstream
1575      }
1576
1577    return cmaxh;
1578 }
1579
1580 static void
1581 _box_layout_cb(Evas_Object *o, Evas_Object_Box_Data *priv, void *data __UNUSED__)
1582 {
1583    Evas_Coord x, y, w, h, xx, yy;
1584    const Eina_List *l;
1585    Evas_Object *obj;
1586    Evas_Coord minw, minh;
1587    double ax, ay;
1588    Evas_Object_Box_Option *opt;
1589
1590    _calculate_box_min_size(o, priv);
1591
1592    evas_object_geometry_get(o, &x, &y, &w, &h);
1593
1594    evas_object_size_hint_min_get(o, &minw, &minh);
1595    evas_object_size_hint_align_get(o, &ax, &ay);
1596    if (w < minw)
1597      {
1598         x = x + ((w - minw) * (1.0 - ax));
1599         w = minw;
1600      }
1601    if (h < minh)
1602      {
1603         y = y + ((h - minh) * (1.0 - ay));
1604         h = minh;
1605      }
1606
1607    xx = x;
1608    yy = y;
1609
1610    Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
1611
1612    EINA_LIST_FOREACH(priv->children, l, opt)
1613      {
1614         Evas_Coord mnw, mnh, mxw, mxh;
1615         double wx, wy;
1616         int fw, fh;
1617
1618         obj = opt->obj;
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);
1623         fw = fh = 0;
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;
1627
1628         if (wx)
1629           {
1630 <<<<<<< HEAD
1631              if ((elm_widget_is(obj)) && (!(strcmp(elm_widget_type_get(obj), "entry"))) && (mnw == -1))
1632                mnw = MIN_W_ENTRY;
1633
1634              if (mnw != -1 && (w - cw) >= mnw)
1635                ww = w - cw;
1636              else
1637                ww = w;
1638           }
1639         else
1640           ww = mnw;
1641 =======
1642              if (mnw != -1 && (w - cw) >= mnw)
1643                 ww = w - cw;
1644              else
1645                 ww = w;
1646           }
1647         else
1648            ww = mnw;
1649 >>>>>>> remotes/origin/upstream
1650         hh = _calculate_item_max_height(o, priv, obj_index);
1651
1652         ow = mnw;
1653         if (fw) ow = ww;
1654         if ((mxw >= 0) && (mxw < ow)) ow = mxw;
1655         oh = mnh;
1656         if (fh) oh = hh;
1657         if ((mxh >= 0) && (mxh < oh)) oh = mxh;
1658
1659         if ((cw + ww) > w)
1660           {
1661              ch += cmaxh;
1662              cw = 0;
1663              cmaxh = 0;
1664           }
1665
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);
1670
1671         cw += ww;
1672         if (cmaxh < hh) cmaxh = hh;
1673
1674         obj_index++;
1675      }
1676 }
1677
1678 static void
1679 _item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
1680 {
1681 <<<<<<< HEAD
1682    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1683
1684    Elm_Multibuttonentry_Item *item;
1685    if (part && strcmp(part, "default")) return;
1686    if (!label) return;
1687    item = (Elm_Multibuttonentry_Item *) it;
1688 =======
1689    Elm_Multibuttonentry_Item *item;
1690    if (part && strcmp(part, "default")) return;
1691    if (!label) 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);
1696 }
1697
1698 static const char *
1699 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
1700 {
1701 <<<<<<< HEAD
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;
1706 =======
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");
1712 }
1713
1714 static void
1715 _text_set_hook(Evas_Object *obj, const char *part, const char *label)
1716 {
1717    ELM_CHECK_WIDTYPE(obj, widtype);
1718 <<<<<<< HEAD
1719    if (part && strcmp(part, "default")) return;
1720    if (label) _set_label(obj, label);
1721    else  _set_label(obj, "");
1722 =======
1723    if (!part || !strcmp(part, "default"))
1724      {
1725         if (label) _set_label(obj, label);
1726         else _set_label(obj, "");
1727      }
1728    else if (!strcmp(part, "guide"))
1729      {
1730         if (label) _set_guidetext(obj, label);
1731         else _set_guidetext(obj, "");
1732      }
1733 >>>>>>> remotes/origin/upstream
1734 }
1735
1736 static const char *
1737 _text_get_hook(const Evas_Object *obj, const char *part)
1738 {
1739    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1740 <<<<<<< HEAD
1741    Widget_Data *wd;
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");
1746 =======
1747    Widget_Data *wd = elm_widget_data_get(obj);
1748    if (!wd) return NULL;
1749
1750    if (!part || !strcmp(part, "default"))
1751      {
1752         return wd->labeltxt;
1753      }
1754    else if (!strcmp(part, "guide"))
1755      {
1756         return wd->guidetexttxt;
1757      }
1758 >>>>>>> remotes/origin/upstream
1759    return NULL;
1760 }
1761
1762 EAPI Evas_Object *
1763 elm_multibuttonentry_add(Evas_Object *parent)
1764 {
1765    Evas_Object *obj;
1766    Evas *e;
1767    Widget_Data *wd;
1768
1769    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1770
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);
1775
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);
1783
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);
1788
1789    wd->view_state = MULTIBUTTONENTRY_VIEW_NONE;
1790    wd->focused = EINA_FALSE;
1791    wd->last_btn_select = EINA_TRUE;
1792    wd->n_str = 0;
1793 <<<<<<< HEAD
1794    wd->rect_for_end= NULL;
1795 =======
1796    wd->rect_for_end = NULL;
1797 >>>>>>> remotes/origin/upstream
1798    wd->add_callback = NULL;
1799    wd->add_callback_data = NULL;
1800
1801    _view_init(obj);
1802    _event_init(obj);
1803
1804    return obj;
1805 }
1806
1807 EAPI Evas_Object *
1808 elm_multibuttonentry_entry_get(const Evas_Object *obj)
1809 {
1810    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1811    Widget_Data *wd = elm_widget_data_get(obj);
1812
1813    if (!wd) return NULL;
1814
1815    return wd->entry;
1816 }
1817
1818 <<<<<<< HEAD
1819 EAPI const char *
1820 =======
1821 EINA_DEPRECATED EAPI const char *
1822 >>>>>>> remotes/origin/upstream
1823 elm_multibuttonentry_label_get(const Evas_Object *obj)
1824 {
1825    return _text_get_hook(obj, NULL);
1826 }
1827
1828 <<<<<<< HEAD
1829 EAPI void
1830 =======
1831 EINA_DEPRECATED EAPI void
1832 >>>>>>> remotes/origin/upstream
1833 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
1834 {
1835    _text_set_hook(obj, NULL, label);
1836 }
1837
1838 <<<<<<< HEAD
1839 EAPI const char *
1840 =======
1841 EINA_DEPRECATED EAPI const char *
1842 >>>>>>> remotes/origin/upstream
1843 elm_multibuttonentry_guide_text_get(const Evas_Object *obj)
1844 {
1845    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1846    Widget_Data *wd = elm_widget_data_get(obj);
1847
1848    if (!wd) return NULL;
1849    if (wd->guidetext) return edje_object_part_text_get(wd->guidetext, "elm.text");
1850    return NULL;
1851 }
1852
1853 <<<<<<< HEAD
1854 EAPI void
1855 =======
1856 EINA_DEPRECATED EAPI void
1857 >>>>>>> remotes/origin/upstream
1858 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
1859 {
1860    ELM_CHECK_WIDTYPE(obj, widtype);
1861    Widget_Data *wd = elm_widget_data_get(obj);
1862
1863    if (!wd) return;
1864 <<<<<<< HEAD
1865    if (guidetext)
1866      _set_guidetext(obj, guidetext);
1867    else
1868      _set_guidetext(obj, "");
1869 }
1870
1871 EAPI int
1872 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1873 {
1874 =======
1875
1876    _set_guidetext(obj, guidetext);
1877 }
1878
1879 EINA_DEPRECATED EAPI int
1880 elm_multibuttonentry_shrink_mode_get(const Evas_Object *obj)
1881 {
1882    if (elm_multibuttonentry_expanded_get(obj))
1883      return 0;
1884    else
1885      return 1;
1886 }
1887
1888 EAPI Eina_Bool
1889 elm_multibuttonentry_expanded_get(const Evas_Object *obj)
1890 {
1891 >>>>>>> remotes/origin/upstream
1892    ELM_CHECK_WIDTYPE(obj, widtype) -1;
1893    Widget_Data *wd = elm_widget_data_get(obj);
1894
1895    if (!wd) return -1;
1896 <<<<<<< HEAD
1897    return wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? 1 : 0;
1898 }
1899
1900 EAPI void
1901 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1902 {
1903 =======
1904      return (wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK ? EINA_FALSE : EINA_TRUE);
1905
1906 }
1907
1908 EINA_DEPRECATED EAPI void
1909 elm_multibuttonentry_shrink_mode_set(Evas_Object *obj, int shrink)
1910 {
1911    if (shrink == 0)
1912      elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
1913
1914    if (shrink == 1)
1915      elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
1916 }
1917
1918 EAPI void
1919 elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
1920 {
1921 >>>>>>> remotes/origin/upstream
1922    ELM_CHECK_WIDTYPE(obj, widtype);
1923    Widget_Data *wd = elm_widget_data_get(obj);
1924
1925    if (!wd || !wd->box ||
1926 <<<<<<< HEAD
1927        ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? 1 : 0) == shrink) return;
1928    _shrink_mode_set(obj, shrink);
1929 }
1930
1931 EAPI Elm_Object_Item *
1932 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
1933 {
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;
1939 }
1940
1941 EAPI Elm_Object_Item *
1942 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
1943 {
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;
1949 }
1950
1951 EAPI Elm_Object_Item *
1952 elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
1953 {
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;
1960 }
1961
1962 EAPI Elm_Object_Item *
1963 elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
1964 {
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;
1971 =======
1972        ((wd->view_state == MULTIBUTTONENTRY_VIEW_SHRINK) ? EINA_FALSE : EINA_TRUE) == expanded) return;
1973
1974    if (expanded)
1975      _shrink_mode_set(obj, EINA_FALSE);
1976    else
1977      _shrink_mode_set(obj, EINA_TRUE);
1978
1979 }
1980
1981 EAPI Elm_Object_Item *
1982 elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1983 {
1984    return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
1985 }
1986
1987 EAPI Elm_Object_Item *
1988 elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
1989 {
1990    return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
1991 }
1992
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)
1995 {
1996    return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
1997 }
1998
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)
2001 {
2002    return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
2003 >>>>>>> remotes/origin/upstream
2004 }
2005
2006 EAPI const Eina_List *
2007 elm_multibuttonentry_items_get(const Evas_Object *obj)
2008 {
2009    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2010    Widget_Data *wd = elm_widget_data_get(obj);
2011    if (!wd) return NULL;
2012    return wd->items;
2013 }
2014
2015 EAPI Elm_Object_Item *
2016 elm_multibuttonentry_first_item_get(const Evas_Object *obj)
2017 {
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);
2022 }
2023
2024 EAPI Elm_Object_Item *
2025 elm_multibuttonentry_last_item_get(const Evas_Object *obj)
2026 {
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));
2031 }
2032
2033 EAPI Elm_Object_Item *
2034 elm_multibuttonentry_selected_item_get(const Evas_Object *obj)
2035 {
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);
2040 }
2041
2042 EAPI void
2043 <<<<<<< HEAD
2044 elm_multibuttonentry_item_select(Elm_Object_Item *it, Eina_Bool selected)
2045 {
2046    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2047    Elm_Multibuttonentry_Item *item = (Elm_Multibuttonentry_Item *) it;
2048 =======
2049 elm_multibuttonentry_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
2050 {
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);
2056 }
2057
2058 <<<<<<< HEAD
2059 EAPI void
2060 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
2061 {
2062    ELM_CHECK_WIDTYPE(obj, widtype);
2063    Widget_Data *wd = elm_widget_data_get(obj);
2064    if (!wd) return;
2065    _select_button(obj, NULL);
2066 =======
2067 EAPI Eina_Bool
2068 elm_multibuttonentry_item_selected_get(const Elm_Object_Item *it)
2069 {
2070    //TODO : To be implemented.
2071    if (!it) return EINA_FALSE;
2072    return EINA_TRUE;
2073 >>>>>>> remotes/origin/upstream
2074 }
2075
2076 EAPI void
2077 elm_multibuttonentry_clear(Evas_Object *obj)
2078 {
2079    ELM_CHECK_WIDTYPE(obj, widtype);
2080    Elm_Multibuttonentry_Item *item;
2081    Widget_Data *wd = elm_widget_data_get(obj);
2082    if (!wd) return;
2083
2084    if (wd->items)
2085      {
2086         EINA_LIST_FREE(wd->items, item)
2087           {
2088              elm_box_unpack(wd->box, item->button);
2089              _del_button_obj(obj, item->button);
2090              free(item);
2091           }
2092         wd->items = NULL;
2093      }
2094    wd->current = NULL;
2095    _view_update(obj);
2096 }
2097
2098 EAPI void
2099 elm_multibuttonentry_item_del(Elm_Object_Item *it)
2100 {
2101    elm_object_item_del(it);
2102 }
2103
2104 EAPI const char *
2105 elm_multibuttonentry_item_label_get(const Elm_Object_Item *it)
2106 {
2107    return _item_text_get_hook(it, NULL);
2108 }
2109
2110 EAPI void
2111 elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str)
2112 {
2113    _item_text_set_hook(it, NULL, str);
2114 }
2115
2116 EAPI Elm_Object_Item *
2117 elm_multibuttonentry_item_prev_get(const Elm_Object_Item *it)
2118 {
2119    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2120    Widget_Data *wd;
2121    Eina_List *l;
2122    Elm_Multibuttonentry_Item *_item;
2123
2124    wd = elm_widget_data_get(WIDGET(it));
2125    if (!wd) return NULL;
2126
2127    EINA_LIST_FOREACH(wd->items, l, _item)
2128      {
2129 <<<<<<< HEAD
2130         if (_item == (Elm_Multibuttonentry_Item *) it)
2131 =======
2132         if (_item == (Elm_Multibuttonentry_Item *)it)
2133 >>>>>>> remotes/origin/upstream
2134           {
2135              l = eina_list_prev(l);
2136              if (!l) return NULL;
2137              return eina_list_data_get(l);
2138           }
2139      }
2140    return NULL;
2141 }
2142
2143 EAPI Elm_Object_Item *
2144 elm_multibuttonentry_item_next_get(const Elm_Object_Item *it)
2145 {
2146    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2147    Widget_Data *wd;
2148    Eina_List *l;
2149    Elm_Multibuttonentry_Item *_item;
2150    wd = elm_widget_data_get(WIDGET(it));
2151    if (!wd) return NULL;
2152
2153    EINA_LIST_FOREACH(wd->items, l, _item)
2154      {
2155 <<<<<<< HEAD
2156         if (_item == (Elm_Multibuttonentry_Item *) it)
2157 =======
2158         if (_item == (Elm_Multibuttonentry_Item *)it)
2159 >>>>>>> remotes/origin/upstream
2160           {
2161              l = eina_list_next(l);
2162              if (!l) return NULL;
2163              return eina_list_data_get(l);
2164           }
2165      }
2166    return NULL;
2167 }
2168
2169 EAPI void *
2170 elm_multibuttonentry_item_data_get(const Elm_Object_Item *it)
2171 {
2172 <<<<<<< HEAD
2173    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2174 =======
2175 >>>>>>> remotes/origin/upstream
2176    return elm_widget_item_data_get(it);
2177 }
2178
2179 EAPI void
2180 elm_multibuttonentry_item_data_set(Elm_Object_Item *it, void *data)
2181 {
2182 <<<<<<< HEAD
2183    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
2184 =======
2185 >>>>>>> remotes/origin/upstream
2186    return elm_widget_item_data_set(it, data);
2187 }
2188
2189 EAPI void
2190 <<<<<<< HEAD
2191 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
2192 =======
2193 elm_multibuttonentry_item_filter_append(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
2194 >>>>>>> remotes/origin/upstream
2195 {
2196    Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
2197    Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
2198    Eina_List *l;
2199
2200    Widget_Data *wd = elm_widget_data_get(obj);
2201    if (!wd) return;
2202
2203    ELM_CHECK_WIDTYPE(obj, widtype);
2204    EINA_SAFETY_ON_NULL_RETURN(func);
2205
2206    new_item_filter= _filter_new(func, data);
2207    if (!new_item_filter) return;
2208
2209    EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
2210      {
2211 <<<<<<< HEAD
2212         if ( _item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
2213 =======
2214         if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
2215 >>>>>>> remotes/origin/upstream
2216           {
2217              printf("Already Registered this item filter!!!!\n");
2218              return;
2219           }
2220      }
2221    wd->filter_list = eina_list_append(wd->filter_list, new_item_filter);
2222 }
2223
2224 EAPI void
2225 <<<<<<< HEAD
2226 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
2227 =======
2228 elm_multibuttonentry_item_filter_prepend(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
2229 >>>>>>> remotes/origin/upstream
2230 {
2231    Elm_Multibuttonentry_Item_Filter *new_item_filter = NULL;
2232    Elm_Multibuttonentry_Item_Filter *_item_filter = NULL;
2233    Eina_List *l;
2234    Widget_Data *wd = elm_widget_data_get(obj);
2235    if (!wd) return;
2236
2237    ELM_CHECK_WIDTYPE(obj, widtype);
2238    EINA_SAFETY_ON_NULL_RETURN(func);
2239
2240    new_item_filter = _filter_new(func, data);
2241    if (!new_item_filter) return;
2242
2243    EINA_LIST_FOREACH(wd->filter_list, l, _item_filter)
2244      {
2245         if (_item_filter && ((_item_filter->callback_func == func) && (_item_filter->data == data)))
2246           {
2247              printf("Already Registered this item filter!!!!\n");
2248              return;
2249           }
2250      }
2251    wd->filter_list = eina_list_prepend(wd->filter_list, new_item_filter);
2252 }
2253
2254 EAPI void
2255 <<<<<<< HEAD
2256 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_callback func, void *data)
2257 =======
2258 elm_multibuttonentry_item_filter_remove(Evas_Object *obj, Elm_Multibuttonentry_Item_Filter_Cb func, void *data)
2259 >>>>>>> remotes/origin/upstream
2260 {
2261    Widget_Data *wd;
2262    Eina_List *l;
2263    Elm_Multibuttonentry_Item_Filter *item_filter;
2264
2265    wd = elm_widget_data_get(obj);
2266
2267    EINA_SAFETY_ON_NULL_RETURN(func);
2268
2269    EINA_LIST_FOREACH(wd->filter_list, l, item_filter)
2270      {
2271         if ((item_filter->callback_func == func) && ((!data) || (item_filter->data == data)))
2272           {
2273              wd->filter_list = eina_list_remove_list(wd->filter_list, l);
2274              _filter_free(item_filter);
2275              return;
2276           }
2277      }
2278 }
2279 <<<<<<< HEAD
2280
2281 EAPI void
2282 elm_multibuttonentry_view_mode(Evas_Object *obj, Eina_Bool view_mode)
2283 {
2284    ELM_CHECK_WIDTYPE(obj, widtype);
2285    Widget_Data *wd = elm_widget_data_get(obj);
2286    wd->view_mode = view_mode;
2287
2288    if (view_mode)
2289      {
2290         elm_box_unpack(wd->box, wd->entry);
2291         evas_object_hide(wd->entry);
2292      }
2293    else
2294      _view_update(obj);
2295 }
2296 =======
2297 >>>>>>> remotes/origin/upstream