Fix elm_multibuttonentry API to have callbacks. For now we only have the API format fixed. This code needs lot more refactoring after discussing with the widget author. So, we will address the implementation later.

Signed-off-by: Sanjeev BA <eflelev8@gmail.com>

SVN revision: 68866
This commit is contained in:
Sanjeev BA 2012-03-07 02:57:36 +00:00 committed by Sanjeev BA
parent fbcd46acea
commit 9832fdca93
2 changed files with 26 additions and 24 deletions

View File

@ -10,16 +10,15 @@ typedef enum _Multibuttonentry_Pos
MULTIBUTTONENTRY_POS_END,
MULTIBUTTONENTRY_POS_BEFORE,
MULTIBUTTONENTRY_POS_AFTER,
MULTIBUTTONENTRY_POS_NUM
} Multibuttonentry_Pos;
typedef enum _Multibuttonentry_Button_State
{
MULTIBUTTONENTRY_BUTTON_STATE_DEFAULT,
MULTIBUTTONENTRY_BUTTON_STATE_SELECTED,
MULTIBUTTONENTRY_BUTTON_STATE_NUM
} Multibuttonentry_Button_State;
typedef enum _MultiButtonEntry_Closed_Button_Type
{
MULTIBUTTONENTRY_CLOSED_IMAGE,
@ -43,6 +42,7 @@ struct _Multibuttonentry_Item
Evas_Object *button;
Evas_Coord vw, rw; // vw: visual width, real width
Eina_Bool visible: 1;
Evas_Smart_Cb func;
};
typedef struct _Elm_Multibuttonentry_Item_Filter
@ -98,7 +98,7 @@ static void _button_clicked(void *data, Evas_Object *obj, const char *emission,
static void _del_button_obj(Evas_Object *obj, Evas_Object *btn);
static void _del_button_item(Elm_Multibuttonentry_Item *item);
static void _select_button(Evas_Object *obj, Evas_Object *btn);
static Elm_Object_Item *_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, void *data);
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);
static void _evas_mbe_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info);
static void _entry_key_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
@ -791,7 +791,7 @@ _item_del_pre_hook(Elm_Object_Item *it)
}
static Elm_Object_Item*
_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, void *data)
_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const void *ref, Evas_Smart_Cb func, void *data)
{
Elm_Multibuttonentry_Item *item;
Elm_Multibuttonentry_Item_Filter *item_filter;
@ -843,6 +843,11 @@ _add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, co
item->vw = vw;
item->visible = EINA_TRUE;
if (func)
{
item->func = func;
}
switch (pos)
{
case MULTIBUTTONENTRY_POS_START:
@ -1021,7 +1026,7 @@ _entry_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, vo
if ((strcmp(str, "") != 0) && (strcmp(ev->keyname, "KP_Enter") == 0 || strcmp(ev->keyname, "Return") == 0 ))
{
_add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
_add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
wd->n_str = 0;
}
}
@ -1062,7 +1067,7 @@ _entry_focus_out_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __
str = elm_object_text_get(wd->entry);
if (strlen(str))
_add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL);
_add_button_item(data, str, MULTIBUTTONENTRY_POS_END, NULL, NULL, NULL);
}
static void
@ -1221,7 +1226,7 @@ _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj
Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
const Eina_List *l;
Evas_Object_Box_Option *opt;
int index = 0;
int local_index = 0;
double wx;
evas_object_geometry_get(box, NULL, NULL, &w, NULL);
@ -1243,7 +1248,7 @@ _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj
if ((cw + ww) > w)
{
if (index > obj_index) return cmaxh;
if (local_index > obj_index) return cmaxh;
cw = 0;
cmaxh = 0;
}
@ -1251,7 +1256,7 @@ _calculate_item_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj
cw += ww;
if (cmaxh < mnh) cmaxh = mnh;
index++;
local_index++;
}
return cmaxh;
@ -1529,27 +1534,27 @@ elm_multibuttonentry_expanded_set(Evas_Object *obj, Eina_Bool expanded)
}
EAPI Elm_Object_Item *
elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data)
elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
{
return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, data);
return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_START, NULL, func, data);
}
EAPI Elm_Object_Item *
elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data)
elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data)
{
return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, data);
return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_END, NULL, func, data);
}
EAPI Elm_Object_Item *
elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data)
elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data)
{
return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, data);
return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_BEFORE, before, func, data);
}
EAPI Elm_Object_Item *
elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data)
elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data)
{
return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, data);
return _add_button_item(obj, label, MULTIBUTTONENTRY_POS_AFTER, after, func, data);
}
EAPI const Eina_List *

View File

@ -13,18 +13,15 @@
* of addresses, each of which is an item that can be clicked for further actions.
*
* Smart callbacks one can register:
* XXX: remove "item,selected". use callback from item_append/prepend instead. (discussed with MBE contributor)
* - @c "item,selected" - when item is selected. May be called on backspace key.
* - @c "item,added" - when a new multibuttonentry item is added.
* - @c "item,deleted" - when a multibuttonentry item is deleted.
* XXX: remove "item,clicked". use callback from item_append/prepend instead. (discussed with MBE contributor)
* - @c "item,clicked" - selected item of multibuttonentry is clicked.
* - @c "clicked" - when multibuttonentry is clicked.
* - @c "focused" - when multibuttonentry is focused.
* - @c "unfocused" - when multibuttonentry is unfocused.
* - @c "expanded" - when multibuttonentry is expanded.
* - @c "contracted" - when multibuttonentry is contracted.
* XXX: change "shrink,state,changed" to "expand,state,changed"
* - @c "shrink,state,changed" - when shrink mode state of multibuttonentry is
* changed.
*
@ -124,7 +121,7 @@ EAPI void elm_multibuttonentry_expanded_set(Evas_Object *o
*
* @ingroup Multibuttonentry
*/
EAPI Elm_Object_Item *elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, void *data);
EAPI Elm_Object_Item *elm_multibuttonentry_item_prepend(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data);
/**
* Append a new item to the multibuttonentry
@ -137,7 +134,7 @@ EAPI Elm_Object_Item *elm_multibuttonentry_item_prepend(Evas_Object *obj, const
*
* @ingroup Multibuttonentry
*/
EAPI Elm_Object_Item *elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, void *data);
EAPI Elm_Object_Item *elm_multibuttonentry_item_append(Evas_Object *obj, const char *label, Evas_Smart_Cb func, void *data);
/**
* Add a new item to the multibuttonentry before the indicated object
@ -152,7 +149,7 @@ EAPI Elm_Object_Item *elm_multibuttonentry_item_append(Evas_Object *obj, const c
*
* @ingroup Multibuttonentry
*/
EAPI Elm_Object_Item *elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, void *data);
EAPI Elm_Object_Item *elm_multibuttonentry_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *label, Evas_Smart_Cb func, void *data);
/**
* Add a new item to the multibuttonentry after the indicated object
@ -166,7 +163,7 @@ EAPI Elm_Object_Item *elm_multibuttonentry_item_insert_before(Evas_Object *obj,
*
* @ingroup Multibuttonentry
*/
EAPI Elm_Object_Item *elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, void *data);
EAPI Elm_Object_Item *elm_multibuttonentry_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *label, Evas_Smart_Cb func, void *data);
/**
* Get a list of items in the multibuttonentry