From dc415939ad122d8ad37415bbd60c0f429c1e0ca7 Mon Sep 17 00:00:00 2001 From: Hyunsil Date: Fri, 24 Sep 2010 21:48:02 +0900 Subject: [PATCH] [multibuttonentry] add an API elm_multibuttonentry_unselect_all() --- src/lib/Elementary.h.in | 1 + src/lib/elm_multibuttonentry.c | 65 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/lib/Elementary.h.in diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in old mode 100644 new mode 100755 index 2aac952..d089dc1 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -2644,6 +2644,7 @@ extern "C" { EAPI Elm_Multibuttonentry_Item *elm_multibuttonentry_item_last_get(Evas_Object *obj); EAPI Elm_Multibuttonentry_Item *elm_multibuttonentry_item_selected_get(Evas_Object *obj); EAPI void elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item); + EAPI void elm_multibuttonentry_item_unselect_all(Evas_Object *obj); EAPI void elm_multibuttonentry_item_del(Elm_Multibuttonentry_Item *item); EAPI void elm_multibuttonentry_items_del(Evas_Object *obj); EAPI const char *elm_multibuttonentry_item_label_get(Elm_Multibuttonentry_Item *item); diff --git a/src/lib/elm_multibuttonentry.c b/src/lib/elm_multibuttonentry.c index 107fba0..2ef20ed 100755 --- a/src/lib/elm_multibuttonentry.c +++ b/src/lib/elm_multibuttonentry.c @@ -22,6 +22,14 @@ typedef enum _Multibuttonentry_Pos MULTIBUTONENTRY_POS_NUM }Multibuttonentry_Pos; +typedef enum _Multibuttonentry_Button_State +{ + MULTIBUTONENTRY_BUTTON_STATE_DEFAULT, + MULTIBUTONENTRY_BUTTON_STATE_SELECTED, + MULTIBUTONENTRY_BUTTON_STATE_NUM +}Multibuttonentry_Button_State; + + struct _Multibuttonentry_Item { Evas_Object *multibuttonentry; Evas_Object *button; @@ -181,6 +189,34 @@ _set_label(Evas_Object *obj, const char* str) } static void +_change_current_button_state(Evas_Object *obj, Multibuttonentry_Button_State state) +{ + Widget_Data *wd = elm_widget_data_get(obj); + Elm_Multibuttonentry_Item *item = NULL; + if (!wd) return; + + if(wd->current) + item = eina_list_data_get(wd->current); + + if(item && item->button){ + switch(state){ + case MULTIBUTONENTRY_BUTTON_STATE_DEFAULT: + edje_object_signal_emit(item->button, "default", ""); + wd->current = NULL; + break; + case MULTIBUTONENTRY_BUTTON_STATE_SELECTED: + edje_object_signal_emit(item->button, "focused", ""); + evas_object_smart_callback_call(obj, "selected", item); + break; + default: + edje_object_signal_emit(item->button, "default", ""); + wd->current = NULL; + break; + } + } +} + +static void _change_current_button(Evas_Object *obj, Evas_Object *btn) { Widget_Data *wd = elm_widget_data_get(obj); @@ -189,10 +225,7 @@ _change_current_button(Evas_Object *obj, Evas_Object *btn) if (!wd) return; // change the state of previous button to "default" - if(wd->current){ - item = eina_list_data_get(wd->current); - edje_object_signal_emit(item->button,"default", ""); - } + _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT); // change the current EINA_LIST_FOREACH(wd->items, l, item) { @@ -203,11 +236,8 @@ _change_current_button(Evas_Object *obj, Evas_Object *btn) } // chagne the state of current button to "focused" - if(wd->current){ - item = eina_list_data_get(wd->current); - edje_object_signal_emit(item->button,"focused", ""); - evas_object_smart_callback_call(obj, "selected", item); - } + _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_SELECTED); + } static void @@ -707,6 +737,23 @@ elm_multibuttonentry_item_selected_set(Elm_Multibuttonentry_Item *item) } /** + * unselect all of items. + * + * @param obj The multibuttonentry object + * + * @ingroup Multibuttonentry + */ +EAPI void +elm_multibuttonentry_item_unselect_all(Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + _change_current_button_state(obj, MULTIBUTONENTRY_BUTTON_STATE_DEFAULT); +} + +/** * Remove all items in the multibuttonentry. * * @param obj The multibuttonentry object -- 2.7.4