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 _changed_size_hint_cb(void *data, Evas *evas, Evas_Object *obj, void *event)
\r
164 Evas_Object *eo = (Evas_Object *)data;
\r
165 Widget_Data *wd = elm_widget_data_get(data);
\r
171 _resize_cb(void *data, Evas *evas, Evas_Object *obj, void *event)
\r
173 Widget_Data *wd = elm_widget_data_get(data);
\r
177 evas_object_geometry_get(wd->box, NULL, NULL, &w, &h);
\r
179 if (wd->h_box < h) evas_object_smart_callback_call (data, "expanded", NULL);
\r
180 else if (wd->h_box > h) evas_object_smart_callback_call (data, "contracted", NULL);
\r
186 _view_update(data);
\r
190 _event_init(Evas_Object *obj)
\r
192 Widget_Data *wd = elm_widget_data_get(obj);
\r
193 if (!wd || !wd->base) return;
\r
197 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
\r
198 evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hint_cb, obj);
\r
204 evas_object_smart_callback_add(wd->entry, "focused", _entry_focused, obj);
\r
205 evas_object_smart_callback_add(wd->entry, "unfocused", _entry_unfocused, obj);
\r
211 _contracted_state_set(Evas_Object *obj, int contracted)
\r
213 Widget_Data *wd = elm_widget_data_get(obj);
\r
215 Elm_Multibuttonentry_Item *item;
\r
216 if (!wd || !wd->box) return;
\r
218 if (wd->contracted == contracted) return;
\r
220 elm_scrolled_entry_entry_set(wd->entry, "");
\r
222 if (contracted == 1)
\r
224 Evas_Coord w=0, w_tmp=0;
\r
226 // unpack all items and entry
\r
227 EINA_LIST_FOREACH(wd->items, l, item)
\r
231 elm_box_unpack(wd->box, item->button);
\r
232 evas_object_hide(item->button);
\r
233 item->visible = EINA_FALSE;
\r
236 elm_box_unpack(wd->box, wd->entry);
\r
237 evas_object_hide(wd->entry);
\r
240 // pack buttons only 1line
\r
244 if (wd->rect) evas_object_geometry_get (wd->rect, NULL, NULL, &w_tmp, NULL);
\r
248 if (wd->label) evas_object_geometry_get (wd->label, NULL, NULL, &w_tmp, NULL);
\r
253 int count = eina_list_count(wd->items);
\r
254 EINA_LIST_FOREACH(wd->items, l, item)
\r
258 int w_label_count = 0;
\r
259 char buf[MAX_STR] = {0,};
\r
261 elm_box_pack_end(wd->box, item->button);
\r
262 evas_object_show(item->button);
\r
263 item->visible = EINA_TRUE;
\r
270 snprintf(buf, sizeof(buf), "... + %d", count);
\r
271 elm_label_label_set(wd->end, buf);
\r
272 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
\r
275 if (w < 0 || w < w_label_count)
\r
277 elm_box_unpack(wd->box, item->button);
\r
278 evas_object_hide(item->button);
\r
279 item->visible = EINA_FALSE;
\r
282 snprintf(buf, sizeof(buf), "... + %d", count);
\r
283 elm_label_label_set(wd->end, buf);
\r
284 evas_object_size_hint_min_get(wd->end, &w_label_count, NULL);
\r
286 elm_box_pack_end(wd->box, wd->end);
\r
287 evas_object_show(wd->end);
\r
297 // unpack last label
\r
298 elm_box_unpack(wd->box, wd->end);
\r
299 evas_object_hide(wd->end);
\r
301 // pack remain btns
\r
303 EINA_LIST_FOREACH(wd->items, l, item)
\r
305 if (item && !item->visible)
\r
307 elm_box_pack_end(wd->box, item->button);
\r
308 evas_object_show(item->button);
\r
313 elm_box_pack_end(wd->box, wd->entry);
\r
314 evas_object_show(wd->entry);
\r
317 wd->contracted = contracted;
\r
318 evas_object_smart_callback_call(obj, "contracted,state,changed", wd->contracted);
\r
322 _view_update(Evas_Object *obj)
\r
324 Widget_Data *wd = elm_widget_data_get(obj);
\r
325 if (!wd || !wd->box || !wd->entry) return;
\r
327 if (wd->contracted == 1)
\r
329 _contracted_state_set(obj, 0);
\r
330 _contracted_state_set(obj, 1);
\r
333 if (wd->guidetext && (wd->contracted != 1))
\r
335 if (!eina_list_count (wd->items))
\r
337 if (elm_widget_focus_get (obj))
\r
339 elm_box_unpack(wd->box, wd->entry);
\r
340 elm_box_unpack(wd->box, wd->guidetext);
\r
341 evas_object_hide(wd->guidetext);
\r
343 elm_box_pack_end(wd->box, wd->entry);
\r
344 evas_object_show(wd->entry);
\r
346 //elm_widget_focus_set(wd->entry, EINA_TRUE); //FIXME
\r
350 elm_box_unpack(wd->box, wd->guidetext);
\r
351 elm_box_unpack(wd->box, wd->entry);
\r
352 evas_object_hide(wd->entry);
\r
354 elm_box_pack_end(wd->box, wd->guidetext);
\r
355 evas_object_show(wd->guidetext);
\r
360 elm_box_unpack(wd->box, wd->entry);
\r
361 elm_box_unpack(wd->box, wd->guidetext);
\r
362 evas_object_hide(wd->guidetext);
\r
364 elm_box_pack_end(wd->box, wd->entry);
\r
365 evas_object_show(wd->entry);
\r
372 _entry_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
\r
374 printf("\n>>>>>>[%s][%d]\n", __FUNCTION__, __LINE__);
\r
375 //if (data) _view_update (data);
\r
379 _entry_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
\r
381 printf("\n>>>>>>[%s][%d]\n", __FUNCTION__, __LINE__);
\r
382 //if (data) _view_update (data);
\r
387 _set_label(Evas_Object *obj, const char* str)
\r
389 Widget_Data *wd = elm_widget_data_get(obj);
\r
390 if (!wd || !str) return;
\r
394 if (! (wd->label = elm_label_add (obj))) return;
\r
395 elm_object_style_set(wd->label, "extended/multibuttonentry_default");
\r
396 elm_label_ellipsis_set(wd->label, EINA_TRUE);
\r
397 elm_label_wrap_width_set(wd->label, 180);
\r
398 elm_label_text_align_set(wd->label, "left");
\r
399 evas_object_size_hint_weight_set(wd->label, 0.0, EVAS_HINT_EXPAND);
\r
400 evas_object_size_hint_align_set(wd->label, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
403 if (wd->rect) elm_box_pack_after (wd->box, wd->label, wd->rect);
\r
404 else elm_box_pack_start(wd->box, wd->label);
\r
406 evas_object_show(wd->label);
\r
409 elm_label_label_set(wd->label, str);
\r
414 _set_guidetext(Evas_Object *obj, const char* str)
\r
416 Widget_Data *wd = elm_widget_data_get(obj);
\r
417 if (!wd || !str) return;
\r
419 if (!wd->guidetext)
\r
421 if (! (wd->guidetext = edje_object_add (evas_object_evas_get (obj)))) return;
\r
422 _elm_theme_object_set(obj, wd->guidetext, "multibuttonentry", "guidetext", elm_widget_style_get(obj));
\r
423 evas_object_size_hint_min_set(wd->guidetext, 280, 0);
\r
424 evas_object_size_hint_weight_set(wd->guidetext, 0.0, EVAS_HINT_EXPAND);
\r
425 evas_object_size_hint_align_set(wd->guidetext, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
428 if (wd->guidetext) edje_object_part_text_set (wd->guidetext, "elm.text", str);
\r
433 _change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state)
\r
435 Widget_Data *wd = elm_widget_data_get(obj);
\r
436 Elm_Multibuttonentry_Item *item = NULL;
\r
440 item = eina_list_data_get(wd->current);
\r
442 if (item && item->button)
\r
446 case MULTIBUTONENTRY_BUTTON_STATE_DEFAULT:
\r
447 edje_object_signal_emit(item->button, "default", "");
\r
448 wd->current = NULL;
\r
450 case MULTIBUTONENTRY_BUTTON_STATE_SELECTED:
\r
451 edje_object_signal_emit(item->button, "focused", "");
\r
452 evas_object_smart_callback_call(obj, "selected", item);
\r
455 edje_object_signal_emit(item->button, "default", "");
\r
456 wd->current = NULL;
\r
463 _change_current_button(Evas_Object *obj, Evas_Object *btn)
\r
465 Widget_Data *wd = elm_widget_data_get(obj);
\r
467 Elm_Multibuttonentry_Item *item;
\r
470 // change the state of previous button to "default"
\r
471 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
\r
473 // change the current
\r
474 EINA_LIST_FOREACH(wd->items, l, item)
\r
476 if (item->button == btn)
\r
483 // chagne the state of current button to "focused"
\r
484 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_SELECTED);
\r
489 _button_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
\r
491 Widget_Data *wd = elm_widget_data_get(data);
\r
492 static char str[MAX_STR];
\r
495 strncpy(str, elm_scrolled_entry_entry_get(wd->entry), MAX_STR);
\r
496 str[MAX_STR - 1]= 0;
\r
499 _add_button(data, str);
\r
501 _change_current_button(data, obj);
\r
505 _del_button_obj(Evas_Object *obj, Evas_Object *btn)
\r
507 Widget_Data *wd = elm_widget_data_get(obj);
\r
508 Evas_Object *label;
\r
509 if (!wd || !btn) return;
\r
514 label = edje_object_part_swallow_get(btn, "elm.label");
\r
515 edje_object_part_unswallow(btn, label);
\r
516 evas_object_del(label);
\r
519 evas_object_del(btn);
\r
524 _del_button_item(Elm_Multibuttonentry_Item *item)
\r
527 Elm_Multibuttonentry_Item *_item;
\r
531 Evas_Object *obj = item->multibuttonentry;
\r
532 wd = elm_widget_data_get(obj);
\r
535 EINA_LIST_FOREACH(wd->items, l, _item)
\r
537 if (_item == item)
\r
539 wd->items = eina_list_remove(wd->items, _item);
\r
540 elm_box_unpack(wd->box, _item->button);
\r
541 evas_object_smart_callback_call(obj, "deleted", _item);
\r
542 _del_button_obj(obj, _item->button);
\r
544 if (wd->current == l)
\r
545 wd->current = NULL;
\r
552 _del_button(Evas_Object *obj)
\r
554 Widget_Data *wd = elm_widget_data_get(obj);
\r
555 Elm_Multibuttonentry_Item *item;
\r
556 if (!wd || !wd->items) return;
\r
560 // let the last button focus
\r
561 item = eina_list_data_get(eina_list_last(wd->items));
\r
562 if (item->button) _change_current_button (obj, item->button);
\r
566 item = eina_list_data_get(wd->current);
\r
569 _del_button_item(item);
\r
574 static Elm_Multibuttonentry_Item*
\r
575 _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
\r
577 Elm_Multibuttonentry_Item *item;
\r
579 Evas_Object *label;
\r
580 Evas_Coord w_label, h_label, w_btn, h_btn, padding_outer, padding_inner;
\r
581 Widget_Data *wd = elm_widget_data_get(obj);
\r
582 if (!wd || !wd->box || !wd->entry) return NULL;
\r
584 if (wd->contracted == 1) return NULL;
\r
587 btn = edje_object_add(evas_object_evas_get(obj));
\r
588 _elm_theme_object_set(obj, btn, "multibuttonentry", "btn", elm_widget_style_get(obj));
\r
589 edje_object_signal_callback_add(btn, "clicked", "elm", _button_clicked, obj);
\r
590 evas_object_size_hint_weight_set(btn, 0.0, 0.0);
\r
591 evas_object_show(btn);
\r
594 label = elm_label_add(obj);
\r
595 elm_object_style_set(label, "extended/multibuttonentry_button");
\r
596 elm_label_label_set(label, str);
\r
597 elm_label_ellipsis_set(label, EINA_TRUE);
\r
598 edje_object_part_swallow(btn, "elm.label", label);
\r
600 // decide the size of button
\r
601 evas_object_size_hint_min_get(label, &w_label, &h_label);
\r
602 edje_object_part_geometry_get(btn, "elm.base", NULL, NULL, NULL, &h_btn);
\r
603 edje_object_part_geometry_get(btn, "left.padding", NULL, NULL, &padding_outer, NULL);
\r
604 edje_object_part_geometry_get(btn, "left.inner.padding", NULL, NULL, &padding_inner, NULL);
\r
605 w_btn = w_label + 2*padding_outer + 2*padding_inner;
\r
607 // append item list
\r
608 item = ELM_NEW(Elm_Multibuttonentry_Item);
\r
611 item->multibuttonentry = obj;
\r
612 item->button = btn;
\r
613 item->label = label;
\r
616 item->vw =(MAX_W_BTN < w_btn) ? MAX_W_BTN : w_btn;
\r
617 item->visible = EINA_TRUE;
\r
621 case MULTIBUTONENTRY_POS_START:
\r
622 wd->items = eina_list_prepend(wd->items, item);
\r
624 elm_box_pack_after(wd->box, btn, wd->label);
\r
626 case MULTIBUTONENTRY_POS_END:
\r
627 wd->items = eina_list_append(wd->items, item);
\r
629 elm_box_pack_before(wd->box, btn, wd->entry);
\r
631 case MULTIBUTONENTRY_POS_BEFORE:
\r
634 wd->items = eina_list_prepend_relative(wd->items, item, reference);
\r
636 elm_box_pack_before(wd->box, btn, reference->button);
\r
640 wd->items = eina_list_append(wd->items, item);
\r
642 elm_box_pack_before(wd->box, btn, wd->entry);
\r
645 case MULTIBUTONENTRY_POS_AFTER:
\r
648 wd->items = eina_list_append_relative(wd->items, item, reference);
\r
650 elm_box_pack_after(wd->box, btn, reference->button);
\r
654 wd->items = eina_list_append(wd->items, item);
\r
656 elm_box_pack_before(wd->box, btn, wd->entry);
\r
664 //resize btn and label
\r
665 evas_object_resize(btn, item->vw, h_btn);
\r
666 evas_object_size_hint_min_set(btn, item->vw, h_btn);
\r
667 if ( (item->rw != item->vw) && (item->vw - 2*padding_outer - 2*padding_inner >=0))
\r
669 evas_object_resize(label, item->vw - 2*padding_outer - 2*padding_inner, h_label);
\r
670 elm_label_wrap_width_set(label, item->vw - 2*padding_outer - 2*padding_inner );
\r
673 evas_object_smart_callback_call(obj, "added", item);
\r
679 _add_button(Evas_Object *obj, char *str)
\r
681 Widget_Data *wd = elm_widget_data_get(obj);
\r
684 //remove entry text
\r
685 elm_scrolled_entry_entry_set(wd->entry, "");
\r
688 _add_button_item(obj, str, MULTIBUTONENTRY_POS_END, NULL, NULL);
\r
692 _evas_key_up_cb(void *data, Evas *e , Evas_Object *obj , void *event_info )
\r
694 Widget_Data *wd = elm_widget_data_get(data);
\r
695 Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event_info;
\r
696 static char str[MAX_STR];
\r
697 if (!wd || !wd->base || !wd->box) return;
\r
699 strncpy(str, elm_scrolled_entry_entry_get(wd->entry), MAX_STR);
\r
700 str[MAX_STR - 1]= 0;
\r
702 if ( (wd->n_str == 0) && (strcmp (str, "") == 0) && ( (strcmp (ev->keyname, "BackSpace") == 0)|| (strcmp (ev->keyname, "BackSpace (") == 0)))
\r
704 _del_button(data);
\r
706 else if ( (strcmp (str, "") != 0) && (strcmp (ev->keyname, "KP_Enter") == 0 ||strcmp (ev->keyname, "Return") == 0 ))
\r
708 _add_button(data, str);
\r
717 wd->n_str = strlen(str);
\r
721 _view_init(Evas_Object *obj)
\r
723 Widget_Data *wd = elm_widget_data_get(obj);
\r
728 if (! (wd->box = elm_box_add (obj))) return;
\r
729 elm_widget_sub_object_add(obj, wd->box);
\r
730 elm_box_extended_mode_set(wd->box, EINA_TRUE);
\r
731 elm_box_homogenous_set(wd->box, EINA_FALSE);
\r
732 edje_object_part_swallow(wd->base, "box.swallow", wd->box);
\r
738 if (! (wd->rect = edje_object_add (evas_object_evas_get (obj)))) return;
\r
739 _elm_theme_object_set(obj, wd->rect, "multibuttonentry", "rect", elm_widget_style_get(obj));
\r
740 elm_widget_sub_object_add(obj, wd->rect);
\r
741 edje_object_part_geometry_get(wd->rect, "elm.base", NULL, NULL, &w, &h);
\r
742 evas_object_size_hint_min_set(wd->rect, w, h);
\r
743 evas_object_size_hint_weight_set(wd->rect, 0.0, EVAS_HINT_EXPAND);
\r
744 evas_object_size_hint_align_set(wd->rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
745 if (wd->box) elm_box_pack_start (wd->box, wd->rect);
\r
746 evas_object_show(wd->rect);
\r
751 if (! (wd->entry = elm_scrolled_entry_add (obj))) return;
\r
752 elm_scrolled_entry_single_line_set(wd->entry, EINA_TRUE);
\r
753 elm_scrolled_entry_entry_set(wd->entry, "");
\r
754 elm_scrolled_entry_cursor_end_set(wd->entry);
\r
755 evas_object_size_hint_min_set(wd->entry, MIN_W_ENTRY, 0);
\r
756 evas_object_event_callback_add(wd->entry, EVAS_CALLBACK_KEY_UP, _evas_key_up_cb, obj);
\r
757 evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
\r
758 evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
\r
759 if (wd->box) elm_box_pack_end (wd->box, wd->entry);
\r
760 evas_object_show(wd->entry);
\r
765 if (! (wd->end = elm_label_add (obj))) return;
\r
766 elm_object_style_set(wd->end, "extended/multibuttonentry_default");
\r
771 * Add a new multibuttonentry to the parent
\r
773 * @param parent The parent object
\r
774 * @return The new object or NULL if it cannot be created
\r
776 * @ingroup Multibuttonentry
\r
779 elm_multibuttonentry_add(Evas_Object *parent)
\r
784 if (!parent) return NULL;
\r
786 wd = ELM_NEW(Widget_Data);
\r
787 e = evas_object_evas_get(parent);
\r
788 if (!e) return NULL;
\r
789 obj = elm_widget_add(e);
\r
790 ELM_SET_WIDTYPE(widtype, "multibuttonentry");
\r
791 elm_widget_type_set(obj, "multibuttonentry");
\r
792 elm_widget_sub_object_add(parent, obj);
\r
793 elm_widget_data_set(obj, wd);
\r
795 elm_widget_del_hook_set(obj, _del_hook);
\r
796 elm_widget_theme_hook_set(obj, _theme_hook);
\r
797 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
\r
799 wd->base = edje_object_add(e);
\r
800 _elm_theme_object_set(obj, wd->base, "multibuttonentry", "base", "default");
\r
801 elm_widget_resize_object_set(obj, wd->base);
\r
803 wd->contracted = 0;
\r
813 * Get the entry of the multibuttonentry object
\r
815 * @param obj The multibuttonentry object
\r
816 * @return The entry object, or NULL if none
\r
818 * @ingroup Multibuttonentry
\r
821 elm_multibuttonentry_entry_get(Evas_Object *obj)
\r
823 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
824 Widget_Data *wd = elm_widget_data_get(obj);
\r
825 if (!wd) return NULL;
\r
833 * @param obj The multibuttonentry object
\r
834 * @return The label, or NULL if none
\r
836 * @ingroup Multibuttonentry
\r
839 elm_multibuttonentry_label_get(Evas_Object *obj)
\r
841 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
842 Widget_Data *wd = elm_widget_data_get(obj);
\r
843 if (!wd) return NULL;
\r
844 if (wd->label) return elm_label_label_get(wd->label);
\r
851 * @param obj The multibuttonentry object
\r
852 * @param label The text label string
\r
854 * @ingroup Multibuttonentry
\r
857 elm_multibuttonentry_label_set(Evas_Object *obj, const char *label)
\r
859 ELM_CHECK_WIDTYPE(obj, widtype);
\r
860 Widget_Data *wd = elm_widget_data_get(obj);
\r
861 if (!wd || !label) return;
\r
862 _set_label(obj, label);
\r
866 * Get the guide text
\r
868 * @param obj The multibuttonentry object
\r
869 * @return The guide text, or NULL if none
\r
871 * @ingroup Multibuttonentry
\r
874 elm_multibuttonentry_guide_text_get(Evas_Object *obj)
\r
876 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
877 Widget_Data *wd = elm_widget_data_get(obj);
\r
878 if (!wd) return NULL;
\r
879 if (wd->guidetext) return elm_label_label_get(wd->guidetext);
\r
884 * Set the guide text
\r
886 * @param obj The multibuttonentry object
\r
887 * @param label The guide text string
\r
889 * @ingroup Multibuttonentry
\r
892 elm_multibuttonentry_guide_text_set(Evas_Object *obj, const char *guidetext)
\r
894 ELM_CHECK_WIDTYPE(obj, widtype);
\r
895 Widget_Data *wd = elm_widget_data_get(obj);
\r
896 if (!wd || !guidetext) return;
\r
897 _set_guidetext(obj, guidetext);
\r
901 * Get the value of contracted state.
\r
903 * @param obj The multibuttonentry object
\r
904 * @param the value of contracted state.
\r
906 * @ingroup Multibuttonentry
\r
909 elm_multibuttonentry_contracted_state_get(Evas_Object *obj)
\r
911 ELM_CHECK_WIDTYPE(obj, widtype) -1;
\r
912 Widget_Data *wd = elm_widget_data_get(obj);
\r
913 if (!wd) return -1;
\r
914 return wd->contracted;
\r
918 * Set/Unset the multibuttonentry to contracted state of single line
\r
920 * @param obj The multibuttonentry object
\r
921 * @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
923 * @ingroup Multibuttonentry
\r
926 elm_multibuttonentry_contracted_state_set(Evas_Object *obj, int contracted)
\r
928 ELM_CHECK_WIDTYPE(obj, widtype);
\r
929 Widget_Data *wd = elm_widget_data_get(obj);
\r
930 if (!wd || !wd->box || (wd->contracted == contracted)) return;
\r
931 _contracted_state_set(obj, contracted);
\r
935 * Prepend a new item to the multibuttonentry
\r
937 * @param obj The multibuttonentry object
\r
938 * @param label The label of new item
\r
939 * @param data The ponter to the data to be attached
\r
940 * @return A handle to the item added or NULL if not possible
\r
942 * @ingroup Multibuttonentry
\r
944 EAPI Elm_Multibuttonentry_Item *
\r
945 elm_multibuttonentry_item_add_start(Evas_Object *obj, const char *label, void *data)
\r
947 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
948 Widget_Data *wd = elm_widget_data_get(obj);
\r
949 Elm_Multibuttonentry_Item *item;
\r
950 if (!wd || !label) return NULL;
\r
951 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_START, NULL, data);
\r
956 * Append a new item to the multibuttonentry
\r
958 * @param obj The multibuttonentry object
\r
959 * @param label The label of new item
\r
960 * @param data The ponter to the data to be attached
\r
961 * @return A handle to the item added or NULL if not possible
\r
963 * @ingroup Multibuttonentry
\r
965 EAPI Elm_Multibuttonentry_Item *
\r
966 elm_multibuttonentry_item_add_end(Evas_Object *obj, const char *label, void *data)
\r
968 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
969 Widget_Data *wd = elm_widget_data_get(obj);
\r
970 Elm_Multibuttonentry_Item *item;
\r
971 if (!wd || !label) return NULL;
\r
972 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_END, NULL, data);
\r
977 * Add a new item to the multibuttonentry before the indicated object
\r
980 * @param obj The multibuttonentry object
\r
981 * @param label The label of new item
\r
982 * @param before The item before which to add it
\r
983 * @param data The ponter to the data to be attached
\r
984 * @return A handle to the item added or NULL if not possible
\r
986 * @ingroup Multibuttonentry
\r
988 EAPI Elm_Multibuttonentry_Item *
\r
989 elm_multibuttonentry_item_add_before(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *before, void *data)
\r
991 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
992 Widget_Data *wd = elm_widget_data_get(obj);
\r
993 Elm_Multibuttonentry_Item *item;
\r
994 if (!wd || !label) return NULL;
\r
995 item = _add_button_item(obj, label, MULTIBUTONENTRY_POS_BEFORE, before, data);
\r
1000 * Add a new item to the multibuttonentry after the indicated object
\r
1002 * @param obj The multibuttonentry object
\r
1003 * @param label The label of new item
\r
1004 * @param after The item after 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_after(Evas_Object *obj, const char *label, Elm_Multibuttonentry_Item *after, 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_AFTER, after, data);
\r
1022 * Get a list of items in the multibuttonentry
\r
1024 * @param obj The multibuttonentry object
\r
1025 * @return The list of items, or NULL if none
\r
1027 * @ingroup Multibuttonentry
\r
1029 EAPI const Eina_List *
\r
1030 elm_multibuttonentry_items_get(Evas_Object *obj)
\r
1032 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1033 Widget_Data *wd = elm_widget_data_get(obj);
\r
1034 if (!wd) return NULL;
\r
1039 * Get the first item in the multibuttonentry
\r
1041 * @param obj The multibuttonentry object
\r
1042 * @return The first item, or NULL if none
\r
1044 * @ingroup Multibuttonentry
\r
1046 EAPI Elm_Multibuttonentry_Item *
\r
1047 elm_multibuttonentry_item_first_get(Evas_Object *obj)
\r
1049 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1050 Widget_Data *wd = elm_widget_data_get(obj);
\r
1051 if (!wd || !wd->items) return NULL;
\r
1052 return eina_list_data_get(wd->items);
\r
1056 * Get the last item in the multibuttonentry
\r
1058 * @param obj The multibuttonentry object
\r
1059 * @return The last item, or NULL if none
\r
1061 * @ingroup Multibuttonentry
\r
1063 EAPI Elm_Multibuttonentry_Item *
\r
1064 elm_multibuttonentry_item_last_get(Evas_Object *obj)
\r
1066 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1067 Widget_Data *wd = elm_widget_data_get(obj);
\r
1068 if (!wd || !wd->items) return NULL;
\r
1069 return eina_list_data_get(eina_list_last(wd->items));
\r
1073 * Get the selected item in the multibuttonentry
\r
1075 * @param obj The multibuttonentry object
\r
1076 * @return The selected item, or NULL if none
\r
1078 * @ingroup Multibuttonentry
\r
1080 EAPI Elm_Multibuttonentry_Item *
\r
1081 elm_multibuttonentry_item_selected_get(Evas_Object *obj)
\r
1083 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
\r
1084 Widget_Data *wd = elm_widget_data_get(obj);
\r
1085 if (!wd || !wd->current) return NULL;
\r
1086 return eina_list_data_get(wd->current);
\r
1090 * Set the selected state of an item
\r
1092 * @param item The item
\r
1094 * @ingroup Multibuttonentry
\r
1097 elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item)
\r
1101 Elm_Multibuttonentry_Item *_item;
\r
1102 if (!item) return;
\r
1103 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
\r
1104 wd = elm_widget_data_get(item->multibuttonentry);
\r
1107 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1109 if (_item == item)
\r
1111 _change_current_button(item->multibuttonentry, item->button);
\r
1117 * unselect all of items.
\r
1119 * @param obj The multibuttonentry object
\r
1121 * @ingroup Multibuttonentry
\r
1124 elm_multibuttonentry_item_unselect_all(Evas_Object *obj)
\r
1126 ELM_CHECK_WIDTYPE(obj, widtype);
\r
1127 Widget_Data *wd = elm_widget_data_get(obj);
\r
1129 _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT);
\r
1133 * Remove all items in the multibuttonentry.
\r
1135 * @param obj The multibuttonentry object
\r
1137 * @ingroup Multibuttonentry
\r
1140 elm_multibuttonentry_items_del(Evas_Object *obj)
\r
1142 ELM_CHECK_WIDTYPE(obj, widtype);
\r
1143 Widget_Data *wd = elm_widget_data_get(obj);
\r
1148 Elm_Multibuttonentry_Item *item;
\r
1149 EINA_LIST_FREE(wd->items, item)
\r
1151 elm_box_unpack(wd->box, item->button);
\r
1152 _del_button_obj(obj, item->button);
\r
1157 wd->current = NULL;
\r
1161 * Delete a given item
\r
1163 * @param item The item
\r
1165 * @ingroup Multibuttonentry
\r
1168 elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item)
\r
1170 if (!item) return;
\r
1171 _del_button_item(item);
\r
1175 * Get the label of a given item
\r
1177 * @param item The item
\r
1178 * @return The label of a given item, or NULL if none
\r
1180 * @ingroup Multibuttonentry
\r
1183 elm_multibuttonentry_item_label_get(Elm_Multibuttonentry_Item *item)
\r
1187 Elm_Multibuttonentry_Item *_item;
\r
1188 if (!item) return NULL;
\r
1189 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
\r
1190 wd = elm_widget_data_get(item->multibuttonentry);
\r
1191 if (!wd || !wd->items) return NULL;
\r
1193 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1194 if (_item == item)
\r
1196 Evas_Object *label = edje_object_part_swallow_get(_item->button, "elm.label");
\r
1197 if (label) return elm_label_label_get (label);
\r
1204 * Set the label of a given item
\r
1206 * @param item The item
\r
1207 * @param label The text label string
\r
1209 * @ingroup Multibuttonentry
\r
1212 elm_multibuttonentry_item_label_set(Elm_Multibuttonentry_Item *item, const char *str)
\r
1216 Elm_Multibuttonentry_Item *_item;
\r
1217 if (!item || !str) return;
\r
1218 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype);
\r
1219 wd = elm_widget_data_get(item->multibuttonentry);
\r
1220 if (!wd || !wd->items) return;
\r
1222 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1223 if (_item == item)
\r
1225 Evas_Object *label = edje_object_part_swallow_get(_item->button, "elm.label");
\r
1226 if (label) elm_label_label_set (label, str);
\r
1232 * Get the previous item in the multibuttonentry
\r
1234 * @param item The item
\r
1235 * @return The item before the item @p item
\r
1237 * @ingroup Multibuttonentry
\r
1239 EAPI Elm_Multibuttonentry_Item *
\r
1240 elm_multibuttonentry_item_prev(Elm_Multibuttonentry_Item *item)
\r
1244 Elm_Multibuttonentry_Item *_item;
\r
1245 if (!item) return NULL;
\r
1246 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
\r
1247 wd = elm_widget_data_get(item->multibuttonentry);
\r
1248 if (!wd || !wd->items) return NULL;
\r
1250 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1251 if (_item == item)
\r
1253 l = eina_list_prev(l);
\r
1254 if (!l) return NULL;
\r
1255 return eina_list_data_get(l);
\r
1261 * Get the next item in the multibuttonentry
\r
1263 * @param item The item
\r
1264 * @return The item after the item @p item
\r
1266 * @ingroup Multibuttonentry
\r
1268 EAPI Elm_Multibuttonentry_Item *
\r
1269 elm_multibuttonentry_item_next(Elm_Multibuttonentry_Item *item)
\r
1273 Elm_Multibuttonentry_Item *_item;
\r
1274 if (!item) return NULL;
\r
1275 ELM_CHECK_WIDTYPE(item->multibuttonentry, widtype) NULL;
\r
1276 wd = elm_widget_data_get(item->multibuttonentry);
\r
1277 if (!wd || !wd->items) return NULL;
\r
1279 EINA_LIST_FOREACH(wd->items, l, _item)
\r
1280 if (_item == item)
\r
1282 l = eina_list_next(l);
\r
1283 if (!l) return NULL;
\r
1284 return eina_list_data_get(l);
\r
1290 * Get private data of item
\r
1292 * @param item The item
\r
1293 * @return The data pointer stored, or NULL if none was stored
\r
1295 * @ingroup Multibuttonentry
\r
1298 elm_multibuttonentry_item_data_get(Elm_Multibuttonentry_Item *item)
\r
1300 if (!item) return NULL;
\r
1301 return item->data;
\r
1305 * Set private data of item
\r
1307 * @param item The item
\r
1308 * @param data The ponter to the data to be attached
\r
1310 * @ingroup Multibuttonentry
\r
1313 elm_multibuttonentry_item_data_set(Elm_Multibuttonentry_Item *item, void *data)
\r
1315 if (!item) return;
\r
1316 item->data = data;
\r