1 #include <Elementary.h>
\r
2 #include "elm_priv.h"
\r
5 * @defgroup Multibuttonentry Multibuttonentry
\r
6 * @ingroup Elementary
\r
8 * This is a Multibuttonentry.
\r
11 #define MAX_STR 256
\r
12 #define MAX_W_BTN 200
\r
13 #define MIN_W_ENTRY 20
\r
15 typedef enum _Multibuttonentry_Pos
\r
17 MULTIBUTONENTRY_POS_START,
\r
18 MULTIBUTONENTRY_POS_END,
\r
19 MULTIBUTONENTRY_POS_BEFORE,
\r
20 MULTIBUTONENTRY_POS_AFTER,
\r
21 MULTIBUTONENTRY_POS_NUM
\r
22 } Multibuttonentry_Pos;
\r
24 typedef enum _Multibuttonentry_Button_State
\r
26 MULTIBUTONENTRY_BUTTON_STATE_DEFAULT,
\r
27 MULTIBUTONENTRY_BUTTON_STATE_SELECTED,
\r
28 MULTIBUTONENTRY_BUTTON_STATE_NUM
\r
29 } Multibuttonentry_Button_State;
\r
31 struct _Multibuttonentry_Item
\r
33 Evas_Object *multibuttonentry;
\r
34 Evas_Object *button;
\r
37 Evas_Coord vw, rw; // vw: visual width, real width
\r
38 Eina_Bool visible: 1;
\r
41 typedef struct _Widget_Data Widget_Data;
\r
42 struct _Widget_Data
\r
49 Evas_Object *guidetext;
\r
50 Evas_Object *end; // used to represent the total number of invisible buttons
\r
57 Evas_Coord w_box, h_box;
\r
59 Eina_Bool focused: 1;
\r
62 static const char *widtype = NULL;
\r
63 static void _del_hook(Evas_Object *obj);
\r
64 static void _theme_hook(Evas_Object *obj);
\r
65 static void _on_focus_hook(void *data __UNUSED__, Evas_Object *obj);
\r
66 static void _sizing_eval(Evas_Object *obj);
\r
67 static void _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
\r
68 static void _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event);
\r
69 static void _event_init(Evas_Object *obj);
\r
70 static void _contracted_state_set(Evas_Object *obj, int contracted);
\r
71 static void _view_update(Evas_Object *obj);
\r
72 static void _set_label(Evas_Object *obj, const char* str);
\r
73 static void _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state);
\r
74 static void _change_current_button(Evas_Object *obj, Evas_Object *btn);
\r
75 static void _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
\r
76 static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
\r
77 static void _del_button_item(Elm_Multibuttonentry_Item *item);
\r
78 static void _del_button(Evas_Object *obj);
\r
79 static Elm_Multibuttonentry_Item* _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data);
\r
80 static void _add_button(Evas_Object *obj, char *str);
\r
81 static void _evas_key_up_cb(void *data, Evas *e , Evas_Object *obj , void *event_info );
\r
82 static void _view_init(Evas_Object *obj);
\r
83 //static void _entry_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
\r
84 //static void _entry_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__);
\r
87 _del_hook(Evas_Object *obj)
\r
89 Widget_Data *wd = elm_widget_data_get(obj);
\r
94 Elm_Multibuttonentry_Item *item;
\r
95 EINA_LIST_FREE(wd->items, item)
\r
97 _del_button_obj(obj, item->button);
\r
102 wd->current = NULL;
\r
104 if (wd->rect) evas_object_del (wd->rect);
\r
105 if (wd->entry) evas_object_del (wd->entry);
\r
106 if (wd->label) evas_object_del (wd->label);
\r
107 if (wd->guidetext) evas_object_del (wd->guidetext);
\r
108 if (wd->end) evas_object_del (wd->end);
\r
112 _theme_hook(Evas_Object *obj)
\r
114 Widget_Data *wd = elm_widget_data_get(obj);
\r
116 Elm_Multibuttonentry_Item *item;
\r
119 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", elm_widget_style_get(obj));
\r
120 if (wd->box) edje_object_part_swallow (wd->base, "box.swallow", wd->box);
\r
121 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
\r
123 EINA_LIST_FOREACH(wd->items, l, item)
\r
126 _elm_theme_object_set (obj, item->button, "multibuttonentry", "btn", elm_widget_style_get (obj));
\r
128 edje_object_part_swallow (item->button, "elm.label", item->label);
\r
129 edje_object_scale_set(item->button, elm_widget_scale_get(obj) * _elm_config->scale);
\r
136 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
\r
138 Widget_Data *wd = elm_widget_data_get(obj);
\r
144 _sizing_eval(Evas_Object *obj)
\r
146 Widget_Data *wd = elm_widget_data_get(obj);
\r
147 Evas_Coord minw = -1, minh = -1;
\r
148 Evas_Coord left, right, top, bottom;
\r
151 evas_object_size_hint_min_get(wd->box, &minw, &minh);
\r
152 edje_object_part_geometry_get(wd->base, "top.left.pad", NULL, NULL, &left, &top);
\r
153 edje_object_part_geometry_get(wd->base, "bottom.right.pad", NULL, NULL, &right, &bottom);
\r
155 minw += (left + right);
\r
156 minh += (top + bottom);
\r
158 evas_object_size_hint_min_set(obj, minw, minh);
\r
162 _signal_mouse_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
\r
164 Widget_Data *wd = elm_widget_data_get(data);
\r
165 if(!wd || !wd->base) return;
\r
167 evas_object_smart_callback_call(data, "clicked", NULL);
\r
171 _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event)
\r
173 Evas_Object *eo = (Evas_Object *)data;
\r
174 Widget_Data *wd = elm_widget_data_get(data);
\r
180 _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event)
\r
182 Widget_Data *wd = elm_widget_data_get(data);
\r
186 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
\r
188 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
\r
189 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
\r
195 _view_update(data);
\r
199 _event_init(Evas_Object *obj)
\r
201 Widget_Data *wd = elm_widget_data_get(obj);
\r
202 if (!wd || !wd->base) return;
\r
206 edje_object_signal_callback_add(wd->base, "mouse,clicked,1", "*", _signal_mouse_clicked, obj);
\r
211 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
\r
212 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
\r
218 evas_object_smart_callback_add(wd->entry, "focused", _entry_focused, obj);
\r
219 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_unfocused, obj);
\r
225 _contracted_state_set(Evas_Object *obj, int contracted)
\r
227 Widget_Data *wd = elm_widget_data_get(obj);
\r
229 Elm_Multibuttonentry_Item *item;
\r
230 if (!wd || !wd->box) return;
\r
232 if (wd->contracted == contracted) return;
\r
234 elm_scrolled_entry_entry_set(wd->entry, "");
\r
236 if (contracted == 1)
\r
238 Evas_Coord w=0, w_tmp=0;
\r
240 // unpack all items and entry
\r
241 EINA_LIST_FOREACH(wd->items, l, item)
\r
245 elm_box_unpack(wd->box, item->button);
\r
246 evas_object_hide(item->button);
\r
247 item->visible = EINA_FALSE;
\r
250 elm_box_unpack(wd->box, wd->entry);
\r
251 evas_object_hide(wd->entry);
\r
254 // pack buttons only 1line
\r
258 if (wd->rect) evas_object_geometry_get (wd->rect, NULL, NULL, &w_tmp, NULL);
\r
262 if (wd->label) evas_object_geometry_get (wd->label, NULL, NULL, &w_tmp, NULL);
\r
267 int count = eina_list_count(wd->items);
\r
268 EINA_LIST_FOREACH(wd->items, l, item)
\r
272 int w_label_count = 0;
\r
273 char buf[MAX_STR] = {0,};
\r
275 elm_box_pack_end(wd->box, item->button);
\r
276 evas_object_show(item->button);
\r
277 item->visible = EINA_TRUE;
\r
284 snprintf(buf, sizeof(buf), "... + %d", count);
\r
285 elm_label_label_set(wd->end, buf);
\r
286 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
\r
289 if (w < 0 || w < w_label_count)
\r
291 elm_box_unpack(wd->box, item->button);
\r
292 evas_object_hide(item->button);
\r
293 item->visible = EINA_FALSE;
\r
296 snprintf(buf, sizeof(buf), "... + %d", count);
\r
297 elm_label_label_set(wd->end, buf);
\r
298 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
\r
300 elm_box_pack_end(wd->box, wd->end);
\r
301 evas_object_show(wd->end);
\r
311 // unpack last label
\r
312 elm_box_unpack(wd->box, wd->end);
\r
313 evas_object_hide(wd->end);
\r
315 // pack remain btns
\r
317 EINA_LIST_FOREACH(wd->items, l, item)
\r
319 if (item && !item->visible)
\r
321 elm_box_pack_end(wd->box, item->button);
\r
322 evas_object_show(item->button);
\r
327 elm_box_pack_end(wd->box, wd->entry);
\r
328 evas_object_show(wd->entry);
\r
331 wd->contracted = contracted;
\r
332 evas_object_smart_callback_call(obj, "contracted,state,changed", wd->contracted);
\r
336 _view_update(Evas_Object *obj)
\r
338 Widget_Data *wd = elm_widget_data_get(obj);
\r
339 if (!wd || !wd->box || !wd->entry) return;
\r
341 if (wd->contracted == 1)
\r
343 _contracted_state_set(obj, 0);
\r
344 _contracted_state_set(obj, 1);
\r
347 if (wd->guidetext && (wd->contracted != 1))
\r
349 if (!eina_list_count (wd->items))
\r
351 if (elm_widget_focus_get (obj))
\r
353 elm_box_unpack(wd->box, wd->entry);
\r
354 elm_box_unpack(wd->box, wd->guidetext);
\r
355 evas_object_hide(wd->guidetext);
\r
357 elm_box_pack_end(wd->box, wd->entry);
\r
358 evas_object_show(wd->entry);
\r
360 //elm_widget_focus_set(wd->entry, EINA_TRUE); //FIXME
\r
364 elm_box_unpack(wd->box, wd->guidetext);
\r
365 elm_box_unpack(wd->box, wd->entry);
\r
366 evas_object_hide(wd->entry);
\r
368 elm_box_pack_end(wd->box, wd->guidetext);
\r
369 evas_object_show(wd->guidetext);
\r
374 elm_box_unpack(wd->box, wd->entry);
\r
375 elm_box_unpack(wd->box, wd->guidetext);
\r
376 evas_object_hide(wd->guidetext);
\r
378 elm_box_pack_end(wd->box, wd->entry);
\r
379 evas_object_show(wd->entry);
\r
386 _entry_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
\r
388 printf("\n>>>>>>[%s][%d]\n", __FUNCTION__, __LINE__);
\r
389 //if (data) _view_update (data);
\r
393 _entry_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
\r
395 printf("\n>>>>>>[%s][%d]\n", __FUNCTION__, __LINE__);
\r
396 //if (data) _view_update (data);
\r
401 _set_label(Evas_Object *obj, const char* str)
\r
403 Widget_Data *wd = elm_widget_data_get(obj);
\r
404 if (!wd || !str) return;
\r
408 if (! (wd->label = elm_label_add (obj))) return;
\r
409 elm_object_style_set(wd->label, "extended/multibuttonentry_default");
\r
410 elm_label_ellipsis_set(wd->label, EINA_TRUE);
\r
411 elm_label_wrap_width_set(wd->label, 180);
\r
412 elm_label_text_align_set(wd->label, "left");
\r
413 evas_object_size_hint_weight_set(wd->label, 0.0, EVAS_HINT_EXPAND);
\r
414 evas_object_size_hint_align_set(wd->label, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
417 if (wd->rect) elm_box_pack_after (wd->box, wd->label, wd->rect);
\r
418 else elm_box_pack_start(wd->box, wd->label);
\r
420 evas_object_show(wd->label);
\r
423 elm_label_label_set(wd->label, str);
\r
428 _set_guidetext(Evas_Object *obj, const char* str)
\r
430 Widget_Data *wd = elm_widget_data_get(obj);
\r
431 if (!wd || !str) return;
\r
433 if (!wd->guidetext)
\r
435 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
\r
436 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
\r
437 evas_object_size_hint_min_set(wd->guidetext, 280, 0);
\r
438 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
\r
439 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
442 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
\r
447 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
\r
449 Widget_Data *wd = elm_widget_data_get(obj);
\r
450 Elm_Multibuttonentry_Item *item = NULL;
\r
454 item = eina_list_data_get(wd->current);
\r
456 if (item && item->button)
\r
460 case MULTIBUTONENTRY_BUTTON_STATE_DEFAULT:
\r
461 edje_object_signal_emit(item->button, "default", "");
\r
462 wd->current = NULL;
\r
464 case MULTIBUTONENTRY_BUTTON_STATE_SELECTED:
\r
465 edje_object_signal_emit(item->button, "focused", "");
\r
466 evas_object_smart_callback_call(obj, "selected", item); // will be removed!
\r
467 evas_object_smart_callback_call(obj, "item,selected", item);
\r
470 edje_object_signal_emit(item->button, "default", "");
\r
471 wd->current = NULL;
\r
478 _change_current_button(Evas_Object *obj, Evas_Object *btn)
\r
480 Widget_Data *wd = elm_widget_data_get(obj);
\r
482 Elm_Multibuttonentry_Item *item;
\r
485 // change the state of previous button to "default"
\r
486 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
\r
488 // change the current
\r
489 EINA_LIST_FOREACH(wd->items, l, item)
\r
491 if (item->button == btn)
\r
498 // chagne the state of current button to "focused"
\r
499 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_SELECTED);
\r
504 _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
\r
506 Widget_Data *wd = elm_widget_data_get(data);
\r
507 static char str[MAX_STR];
\r
508 Elm_Multibuttonentry_Item *item = NULL;
\r
511 strncpy(str, elm_scrolled_entry_entry_get(wd->entry), MAX_STR);
\r
512 str[MAX_STR - 1]= 0;
\r
515 _add_button(data, str);
\r
517 _change_current_button(data, obj);
\r
520 if(item = eina_list_data_get(wd->current))
\r
521 evas_object_smart_callback_call(data, "item,clicked", item);
\r
525 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
\r
527 Widget_Data *wd = elm_widget_data_get(obj);
\r
528 Evas_Object *label;
\r
529 if (!wd || !btn) return;
\r
534 label = edje_object_part_swallow_get(btn, "elm.label");
\r
535 edje_object_part_unswallow(btn, label);
\r
536 evas_object_del(label);
\r
539 evas_object_del(btn);
\r
544 _del_button_item(Elm_Multibuttonentry_Item *item)
\r
547 Elm_Multibuttonentry_Item *_item;
\r
551 Evas_Object *obj = item->multibuttonentry;
\r
552 wd = elm_widget_data_get(obj);
\r
555 EINA_LIST_FOREACH(wd->items, l, _item)
\r
557 if (_item == item)
\r
559 wd->items = eina_list_remove(wd->items, _item);
\r
560 elm_box_unpack(wd->box, _item->button);
\r
561 evas_object_smart_callback_call(obj, "deleted", _item); // will be removed!
\r
562 evas_object_smart_callback_call(obj, "item,deleted", _item);
\r
563 _del_button_obj(obj, _item->button);
\r
565 if (wd->current == l)
\r
566 wd->current = NULL;
\r
573 _del_button(Evas_Object *obj)
\r
575 Widget_Data *wd = elm_widget_data_get(obj);
\r
576 Elm_Multibuttonentry_Item *item;
\r
577 if (!wd || !wd->items) return;
\r
581 // let the last button focus
\r
582 item = eina_list_data_get(eina_list_last(wd->items));
\r
583 if (item->button) _change_current_button (obj, item->button);
\r
587 item = eina_list_data_get(wd->current);
\r
590 _del_button_item(item);
\r
595 static Elm_Multibuttonentry_Item*
\r
596 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
\r
598 Elm_Multibuttonentry_Item *item;
\r
600 Evas_Object *label;
\r
601 Evas_Coord w_label, h_label, w_btn, h_btn, padding_outer, padding_inner;
\r
602 Widget_Data *wd = elm_widget_data_get(obj);
\r
603 if (!wd || !wd->box || !wd->entry) return NULL;
\r
605 if (wd->contracted == 1) return NULL;
\r
608 btn = edje_object_add(evas_object_evas_get(obj));
\r
609 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
\r
610 edje_object_signal_callback_add(btn, "clicked", "elm", _button_clicked, obj);
\r
611 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
\r
612 evas_object_show(btn);
\r
615 label = elm_label_add(obj);
\r
616 elm_object_style_set(label, "extended/multibuttonentry_button");
\r
617 elm_label_label_set(label, str);
\r
618 elm_label_ellipsis_set(label, EINA_TRUE);
\r
619 edje_object_part_swallow(btn, "elm.label", label);
\r
621 // decide the size of button
\r
622 evas_object_size_hint_min_get(label, &w_label, &h_label);
\r
623 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
\r
624 edje_object_part_geometry_get(btn, "left.padding", NULL, NULL, &padding_outer, NULL);
\r
625 edje_object_part_geometry_get(btn, "left.inner.padding", NULL, NULL, &padding_inner, NULL);
\r
626 w_btn = w_label + 2*padding_outer + 2*padding_inner;
\r
628 // append item list
\r
629 item = ELM_NEW(Elm_Multibuttonentry_Item);
\r
632 item->multibuttonentry = obj;
\r
633 item->button = btn;
\r
634 item->label = label;
\r
637 item->vw =(MAX_W_BTN < w_btn) ? MAX_W_BTN : w_btn;
\r
638 item->visible = EINA_TRUE;
\r
642 case MULTIBUTONENTRY_POS_START:
\r
643 wd->items = eina_list_prepend(wd->items, item);
\r
645 elm_box_pack_after(wd->box, btn, wd->label);
\r
647 case MULTIBUTONENTRY_POS_END:
\r
648 wd->items = eina_list_append(wd->items, item);
\r
650 elm_box_pack_before(wd->box, btn, wd->entry);
\r
652 case MULTIBUTONENTRY_POS_BEFORE:
\r
655 wd->items = eina_list_prepend_relative(wd->items, item, reference);
\r
657 elm_box_pack_before(wd->box, btn, reference->button);
\r
661 wd->items = eina_list_append(wd->items, item);
\r
663 elm_box_pack_before(wd->box, btn, wd->entry);
\r
666 case MULTIBUTONENTRY_POS_AFTER:
\r
669 wd->items = eina_list_append_relative(wd->items, item, reference);
\r
671 elm_box_pack_after(wd->box, btn, reference->button);
\r
675 wd->items = eina_list_append(wd->items, item);
\r
677 elm_box_pack_before(wd->box, btn, wd->entry);
\r
685 //resize btn and label
\r
686 evas_object_resize(btn, item->vw, h_btn);
\r
687 evas_object_size_hint_min_set(btn, item->vw, h_btn);
\r
688 if ( (item->rw != item->vw) && (item->vw - 2*padding_outer - 2*padding_inner >=0))
\r
690 evas_object_resize(label, item->vw - 2*padding_outer - 2*padding_inner, h_label);
\r
691 elm_label_wrap_width_set(label, item->vw - 2*padding_outer - 2*padding_inner );
\r
694 evas_object_smart_callback_call(obj, "added", item); // will be removed!
\r
695 evas_object_smart_callback_call(obj, "item,added", item);
\r
701 _add_button(Evas_Object *obj, char *str)
\r
703 Widget_Data *wd = elm_widget_data_get(obj);
\r
706 //remove entry text
\r
707 elm_scrolled_entry_entry_set(wd->entry, "");
\r
710 _add_button_item(obj, str, MULTIBUTONENTRY_POS_END, NULL, NULL);
\r
714 _evas_key_up_cb(void *data, Evas *e , Evas_Object *obj , void *event_info )
\r
716 Widget_Data *wd = elm_widget_data_get(data);
\r
717 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
\r
718 static char str[MAX_STR];
\r
719 if (!wd || !wd->base || !wd->box) return;
\r
721 strncpy(str, elm_scrolled_entry_entry_get(wd->entry), MAX_STR);
\r
722 str[MAX_STR - 1]= 0;
\r
724 if ( (wd->n_str == 0) && (strcmp (str, "") == 0) && ( (strcmp (ev->keyname, "BackSpace") == 0)|| (strcmp (ev->keyname, "BackSpace (") == 0)))
\r
726 _del_button(data);
\r
728 else if ( (strcmp (str, "") != 0) && (strcmp (ev->keyname, "KP_Enter") == 0 ||strcmp (ev->keyname, "Return") == 0 ))
\r
730 _add_button(data, str);
\r
739 wd->n_str = strlen(str);
\r
743 _view_init(Evas_Object *obj)
\r
745 Widget_Data *wd = elm_widget_data_get(obj);
\r
750 if (! (wd->box = elm_box_add (obj))) return;
\r
751 elm_widget_sub_object_add(obj, wd->box);
\r
752 elm_box_extended_set(wd->box, EINA_TRUE);
\r
753 elm_box_homogenous_set(wd->box, EINA_FALSE);
\r
754 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
\r
760 if (! (wd->rect = edje_object_add (evas_object_evas_get (obj)))) return;
\r
761 _elm_theme_object_set(obj, wd->rect, "multibuttonentry", "rect", elm_widget_style_get(obj));
\r
762 elm_widget_sub_object_add(obj, wd->rect);
\r
763 edje_object_part_geometry_get(wd->rect, "elm.base", NULL, NULL, &w, &h);
\r
764 evas_object_size_hint_min_set(wd->rect, w, h);
\r
765 evas_object_size_hint_weight_set(wd->rect, 0.0, EVAS_HINT_EXPAND);
\r
766 evas_object_size_hint_align_set(wd->rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
767 if (wd->box) elm_box_pack_start (wd->box, wd->rect);
\r
768 evas_object_show(wd->rect);
\r
773 if (! (wd->entry = elm_scrolled_entry_add (obj))) return;
\r
774 elm_scrolled_entry_single_line_set(wd->entry, EINA_TRUE);
\r
775 elm_scrolled_entry_entry_set(wd->entry, "");
\r
776 elm_scrolled_entry_cursor_end_set(wd->entry);
\r
777 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
\r
778 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _evas_key_up_cb, obj);
\r
779 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
780 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
781 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
\r
782 evas_object_show(wd->entry);
\r
787 if (! (wd->end = elm_label_add (obj))) return;
\r
788 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
\r
793 * Add a new multibuttonentry to the parent
\r
795 * @param parent The parent object
\r
796 * @return The new object or NULL if it cannot be created
\r
798 * @ingroup Multibuttonentry
\r
801 elm_multibuttonentry_add(Evas_Object *parent)
\r
806 if (!parent) return NULL;
\r
808 wd = ELM_NEW(Widget_Data);
\r
809 e = evas_object_evas_get(parent);
\r
810 if (!e) return NULL;
\r
811 obj = elm_widget_add(e);
\r
812 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
\r
813 elm_widget_type_set(obj, "multibuttonentry");
\r
814 elm_widget_sub_object_add(parent, obj);
\r
815 elm_widget_data_set(obj, wd);
\r
817 elm_widget_del_hook_set(obj, _del_hook);
\r
818 elm_widget_theme_hook_set(obj, _theme_hook);
\r
819 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
\r
821 wd->base = edje_object_add(e);
\r
822 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
\r
823 elm_widget_resize_object_set(obj, wd->base);
\r
825 wd->contracted = 0;
\r
835 * Get the entry of the multibuttonentry object
\r
837 * @param obj The multibuttonentry object
\r
838 * @return The entry object, or NULL if none
\r
840 * @ingroup Multibuttonentry
\r
843 elm_multibuttonentry_entry_get(Evas_Object *obj)
\r
845 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
846 Widget_Data *wd = elm_widget_data_get(obj);
\r
847 if (!wd) return NULL;
\r
855 * @param obj The multibuttonentry object
\r
856 * @return The label, or NULL if none
\r
858 * @ingroup Multibuttonentry
\r
861 elm_multibuttonentry_label_get(Evas_Object *obj)
\r
863 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
864 Widget_Data *wd = elm_widget_data_get(obj);
\r
865 if (!wd) return NULL;
\r
866 if (wd->label) return elm_label_label_get(wd->label);
\r
873 * @param obj The multibuttonentry object
\r
874 * @param label The text label string
\r
876 * @ingroup Multibuttonentry
\r
879 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
\r
881 ELM_CHECK_WIDTYPE(obj, widtype);
\r
882 Widget_Data *wd = elm_widget_data_get(obj);
\r
883 if (!wd || !label) return;
\r
884 _set_label(obj, label);
\r
888 * Get the guide text
\r
890 * @param obj The multibuttonentry object
\r
891 * @return The guide text, or NULL if none
\r
893 * @ingroup Multibuttonentry
\r
896 elm_multibuttonentry_guide_text_get(Evas_Object *obj)
\r
898 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
899 Widget_Data *wd = elm_widget_data_get(obj);
\r
900 if (!wd) return NULL;
\r
901 if (wd->guidetext) return elm_label_label_get(wd->guidetext);
\r
906 * Set the guide text
\r
908 * @param obj The multibuttonentry object
\r
909 * @param label The guide text string
\r
911 * @ingroup Multibuttonentry
\r
914 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
\r
916 ELM_CHECK_WIDTYPE(obj, widtype);
\r
917 Widget_Data *wd = elm_widget_data_get(obj);
\r
918 if (!wd || !guidetext) return;
\r
919 _set_guidetext(obj, guidetext);
\r
923 * Get the value of contracted state.
\r
925 * @param obj The multibuttonentry object
\r
926 * @param the value of contracted state.
\r
928 * @ingroup Multibuttonentry
\r
931 elm_multibuttonentry_contracted_state_get(Evas_Object *obj)
\r
933 ELM_CHECK_WIDTYPE(obj, widtype) -1;
\r
934 Widget_Data *wd = elm_widget_data_get(obj);
\r
935 if (!wd) return -1;
\r
936 return wd->contracted;
\r
940 * Set/Unset the multibuttonentry to contracted state of single line
\r
942 * @param obj The multibuttonentry object
\r
943 * @param the value of contracted state. set this to 1 to set the multibuttonentry to contracted state of single line. set this to 0 to unset the contracted state.
\r
945 * @ingroup Multibuttonentry
\r
948 elm_multibuttonentry_contracted_state_set(Evas_Object *obj, int contracted)
\r
950 ELM_CHECK_WIDTYPE(obj, widtype);
\r
951 Widget_Data *wd = elm_widget_data_get(obj);
\r
952 if (!wd || !wd->box || (wd->contracted == contracted)) return;
\r
953 _contracted_state_set(obj, contracted);
\r
957 * Prepend a new item to the multibuttonentry
\r
959 * @param obj The multibuttonentry object
\r
960 * @param label The label of new item
\r
961 * @param data The ponter to the data to be attached
\r
962 * @return A handle to the item added or NULL if not possible
\r
964 * @ingroup Multibuttonentry
\r
966 EAPI Elm_Multibuttonentry_Item *
\r
967 elm_multibuttonentry_item_add_start(Evas_Object *obj, const char *label, void *data)
\r
969 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
970 Widget_Data *wd = elm_widget_data_get(obj);
\r
971 Elm_Multibuttonentry_Item *item;
\r
972 if (!wd || !label) return NULL;
\r
973 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_START, NULL, data);
\r
978 * Append a new item to the multibuttonentry
\r
980 * @param obj The multibuttonentry object
\r
981 * @param label The label of new item
\r
982 * @param data The ponter to the data to be attached
\r
983 * @return A handle to the item added or NULL if not possible
\r
985 * @ingroup Multibuttonentry
\r
987 EAPI Elm_Multibuttonentry_Item *
\r
988 elm_multibuttonentry_item_add_end(Evas_Object *obj, const char *label, void *data)
\r
990 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
991 Widget_Data *wd = elm_widget_data_get(obj);
\r
992 Elm_Multibuttonentry_Item *item;
\r
993 if (!wd || !label) return NULL;
\r
994 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_END, NULL, data);
\r
999 * Add a new item to the multibuttonentry before the indicated object
\r
1002 * @param obj The multibuttonentry object
\r
1003 * @param label The label of new item
\r
1004 * @param before The item before which to add it
\r
1005 * @param data The ponter to the data to be attached
\r
1006 * @return A handle to the item added or NULL if not possible
\r
1008 * @ingroup Multibuttonentry
\r
1010 EAPI Elm_Multibuttonentry_Item *
\r
1011 elm_multibuttonentry_item_add_before(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *before, void *data)
\r
1013 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1014 Widget_Data *wd = elm_widget_data_get(obj);
\r
1015 Elm_Multibuttonentry_Item *item;
\r
1016 if (!wd || !label) return NULL;
\r
1017 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_BEFORE, before, data);
\r
1022 * Add a new item to the multibuttonentry after the indicated object
\r
1024 * @param obj The multibuttonentry object
\r
1025 * @param label The label of new item
\r
1026 * @param after The item after which to add it
\r
1027 * @param data The ponter to the data to be attached
\r
1028 * @return A handle to the item added or NULL if not possible
\r
1030 * @ingroup Multibuttonentry
\r
1032 EAPI Elm_Multibuttonentry_Item *
\r
1033 elm_multibuttonentry_item_add_after(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *after, void *data)
\r
1035 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1036 Widget_Data *wd = elm_widget_data_get(obj);
\r
1037 Elm_Multibuttonentry_Item *item;
\r
1038 if (!wd || !label) return NULL;
\r
1039 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_AFTER, after, data);
\r
1044 * Get a list of items in the multibuttonentry
\r
1046 * @param obj The multibuttonentry object
\r
1047 * @return The list of items, or NULL if none
\r
1049 * @ingroup Multibuttonentry
\r
1051 EAPI const Eina_List *
\r
1052 elm_multibuttonentry_items_get(Evas_Object *obj)
\r
1054 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1055 Widget_Data *wd = elm_widget_data_get(obj);
\r
1056 if (!wd) return NULL;
\r
1061 * Get the first item in the multibuttonentry
\r
1063 * @param obj The multibuttonentry object
\r
1064 * @return The first item, or NULL if none
\r
1066 * @ingroup Multibuttonentry
\r
1068 EAPI Elm_Multibuttonentry_Item *
\r
1069 elm_multibuttonentry_item_first_get(Evas_Object *obj)
\r
1071 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1072 Widget_Data *wd = elm_widget_data_get(obj);
\r
1073 if (!wd || !wd->items) return NULL;
\r
1074 return eina_list_data_get(wd->items);
\r
1078 * Get the last item in the multibuttonentry
\r
1080 * @param obj The multibuttonentry object
\r
1081 * @return The last item, or NULL if none
\r
1083 * @ingroup Multibuttonentry
\r
1085 EAPI Elm_Multibuttonentry_Item *
\r
1086 elm_multibuttonentry_item_last_get(Evas_Object *obj)
\r
1088 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1089 Widget_Data *wd = elm_widget_data_get(obj);
\r
1090 if (!wd || !wd->items) return NULL;
\r
1091 return eina_list_data_get(eina_list_last(wd->items));
\r
1095 * Get the selected item in the multibuttonentry
\r
1097 * @param obj The multibuttonentry object
\r
1098 * @return The selected item, or NULL if none
\r
1100 * @ingroup Multibuttonentry
\r
1102 EAPI Elm_Multibuttonentry_Item *
\r
1103 elm_multibuttonentry_item_selected_get(Evas_Object *obj)
\r
1105 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1106 Widget_Data *wd = elm_widget_data_get(obj);
\r
1107 if (!wd || !wd->current) return NULL;
\r
1108 return eina_list_data_get(wd->current);
\r
1112 * Set the selected state of an item
\r
1114 * @param item The item
\r
1116 * @ingroup Multibuttonentry
\r
1119 elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item)
\r
1123 Elm_Multibuttonentry_Item *_item;
\r
1124 if (!item) return;
\r
1125 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
\r
1126 wd = elm_widget_data_get(item->multibuttonentry);
\r
1129 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1131 if (_item == item)
\r
1133 _change_current_button(item->multibuttonentry, item->button);
\r
1139 * unselect all of items.
\r
1141 * @param obj The multibuttonentry object
\r
1143 * @ingroup Multibuttonentry
\r
1146 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
\r
1148 ELM_CHECK_WIDTYPE(obj, widtype);
\r
1149 Widget_Data *wd = elm_widget_data_get(obj);
\r
1151 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
\r
1155 * Remove all items in the multibuttonentry.
\r
1157 * @param obj The multibuttonentry object
\r
1159 * @ingroup Multibuttonentry
\r
1162 elm_multibuttonentry_items_del(Evas_Object *obj)
\r
1164 ELM_CHECK_WIDTYPE(obj, widtype);
\r
1165 Widget_Data *wd = elm_widget_data_get(obj);
\r
1170 Elm_Multibuttonentry_Item *item;
\r
1171 EINA_LIST_FREE(wd->items, item)
\r
1173 elm_box_unpack(wd->box, item->button);
\r
1174 _del_button_obj(obj, item->button);
\r
1179 wd->current = NULL;
\r
1183 * Delete a given item
\r
1185 * @param item The item
\r
1187 * @ingroup Multibuttonentry
\r
1190 elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
\r
1192 if (!item) return;
\r
1193 _del_button_item(item);
\r
1197 * Get the label of a given item
\r
1199 * @param item The item
\r
1200 * @return The label of a given item, or NULL if none
\r
1202 * @ingroup Multibuttonentry
\r
1205 elm_multibuttonentry_item_label_get(Elm_Multibuttonentry_Item *item)
\r
1209 Elm_Multibuttonentry_Item *_item;
\r
1210 if (!item) return NULL;
\r
1211 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
\r
1212 wd = elm_widget_data_get(item->multibuttonentry);
\r
1213 if (!wd || !wd->items) return NULL;
\r
1215 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1216 if (_item == item)
\r
1218 Evas_Object *label = edje_object_part_swallow_get(_item->button, "elm.label");
\r
1219 if (label) return elm_label_label_get (label);
\r
1226 * Set the label of a given item
\r
1228 * @param item The item
\r
1229 * @param label The text label string
\r
1231 * @ingroup Multibuttonentry
\r
1234 elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
\r
1238 Elm_Multibuttonentry_Item *_item;
\r
1239 if (!item || !str) return;
\r
1240 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
\r
1241 wd = elm_widget_data_get(item->multibuttonentry);
\r
1242 if (!wd || !wd->items) return;
\r
1244 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1245 if (_item == item)
\r
1247 Evas_Object *label = edje_object_part_swallow_get(_item->button, "elm.label");
\r
1248 if (label) elm_label_label_set (label, str);
\r
1254 * Get the previous item in the multibuttonentry
\r
1256 * @param item The item
\r
1257 * @return The item before the item @p item
\r
1259 * @ingroup Multibuttonentry
\r
1261 EAPI Elm_Multibuttonentry_Item *
\r
1262 elm_multibuttonentry_item_prev(Elm_Multibuttonentry_Item *item)
\r
1266 Elm_Multibuttonentry_Item *_item;
\r
1267 if (!item) return NULL;
\r
1268 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
\r
1269 wd = elm_widget_data_get(item->multibuttonentry);
\r
1270 if (!wd || !wd->items) return NULL;
\r
1272 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1273 if (_item == item)
\r
1275 l = eina_list_prev(l);
\r
1276 if (!l) return NULL;
\r
1277 return eina_list_data_get(l);
\r
1283 * Get the next item in the multibuttonentry
\r
1285 * @param item The item
\r
1286 * @return The item after the item @p item
\r
1288 * @ingroup Multibuttonentry
\r
1290 EAPI Elm_Multibuttonentry_Item *
\r
1291 elm_multibuttonentry_item_next(Elm_Multibuttonentry_Item *item)
\r
1295 Elm_Multibuttonentry_Item *_item;
\r
1296 if (!item) return NULL;
\r
1297 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
\r
1298 wd = elm_widget_data_get(item->multibuttonentry);
\r
1299 if (!wd || !wd->items) return NULL;
\r
1301 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1302 if (_item == item)
\r
1304 l = eina_list_next(l);
\r
1305 if (!l) return NULL;
\r
1306 return eina_list_data_get(l);
\r
1312 * Get private data of item
\r
1314 * @param item The item
\r
1315 * @return The data pointer stored, or NULL if none was stored
\r
1317 * @ingroup Multibuttonentry
\r
1320 elm_multibuttonentry_item_data_get(Elm_Multibuttonentry_Item *item)
\r
1322 if (!item) return NULL;
\r
1323 return item->data;
\r
1327 * Set private data of item
\r
1329 * @param item The item
\r
1330 * @param data The ponter to the data to be attached
\r
1332 * @ingroup Multibuttonentry
\r
1335 elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
\r
1337 if (!item) return;
\r
1338 item->data = data;
\r