*/
typedef struct _Widget_Data Widget_Data;
+
struct _Widget_Data
{
- Evas_Object *tbl, *scr;
- Evas_Coord itemsize_h, itemsize_v;
- Evas_Coord minw, minh;
- Evas_Coord horizontal, vertical;
- int x, y;
- Eina_Bool homogeneous :1;
+ Evas_Object *tbl, *scr;
+ Evas_Coord itemsize_h, itemsize_v;
+ Evas_Coord minw, minh;
+ Evas_Coord horizontal, vertical;
+ int x, y;
+ Eina_Bool homogeneous:1;
};
-static void _del_hook(Evas_Object *obj);
-static void _sizing_eval(Evas_Object *obj, int mode);
-static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _changed_size_min(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _sub_del(void *data, Evas_Object *obj, void *event_info);
-static void _show_event(void *data, Evas_Object *obj, void *event_info);
+static void _del_hook(Evas_Object * obj);
-static void _del_pre_hook(Evas_Object *obj)
-{
- Widget_Data *wd = elm_widget_data_get(obj);
+static void _sizing_eval(Evas_Object * obj, int mode);
+
+static void _changed_size_hints(void *data, Evas * e, Evas_Object * obj,
+ void *event_info);
+static void _changed_size_min(void *data, Evas * e, Evas_Object * obj,
+ void *event_info);
+static void _sub_del(void *data, Evas_Object * obj, void *event_info);
- evas_object_event_callback_del_full(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
- evas_object_event_callback_del_full(wd->tbl, EVAS_CALLBACK_RESIZE, _changed_size_min, obj);
- evas_object_del(wd->tbl);
- evas_object_del(wd->scr);
+static void _show_event(void *data, Evas_Object * obj, void *event_info);
+
+static void
+_del_pre_hook(Evas_Object * obj)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ evas_object_event_callback_del_full(wd->tbl,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ evas_object_event_callback_del_full(wd->tbl, EVAS_CALLBACK_RESIZE,
+ _changed_size_min, obj);
+ evas_object_del(wd->tbl);
+ wd->tbl = NULL;
+ evas_object_del(wd->scr);
+ wd->scr = NULL;
}
-static void _del_hook(Evas_Object *obj)
+static void
+_del_hook(Evas_Object * obj)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- free(wd);
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ free(wd);
}
-static Eina_Bool _arrange_table(Evas_Object *obj)
+static Eina_Bool
+_arrange_table(Evas_Object * obj)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Eina_List* l, *l_temp = NULL;
- Evas_Object* item;
- int i = 0;
-
- if (wd) {
- if (wd->tbl) {
- int index = eina_list_count(evas_object_table_children_get(wd->tbl));
- if (!index)
- return EINA_FALSE;
-
- elm_gridbox_item_size_set(obj, wd->itemsize_h, wd->itemsize_v);
- l = evas_object_table_children_get(wd->tbl);
-
- EINA_LIST_FOREACH (l, l_temp, item) {
- evas_object_table_unpack(wd->tbl, item);
- elm_widget_sub_object_del(wd->tbl, item);
- evas_object_table_pack(wd->tbl, item, i % wd->x, i / wd->x, 1, 1);
- i++;
- }
- }
- }
-
- return EINA_TRUE;
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ Eina_List *l, *l_temp = NULL;
+
+ Evas_Object *item;
+
+ int i = 0;
+
+ if (wd)
+ {
+ if (wd->tbl)
+ {
+ int index =
+ eina_list_count(evas_object_table_children_get(wd->tbl));
+ if (!index)
+ return EINA_FALSE;
+
+ elm_gridbox_item_size_set(obj, wd->itemsize_h, wd->itemsize_v);
+ l = evas_object_table_children_get(wd->tbl);
+
+ EINA_LIST_FOREACH(l, l_temp, item)
+ {
+ evas_object_table_unpack(wd->tbl, item);
+ elm_widget_sub_object_del(wd->tbl, item);
+ evas_object_table_pack(wd->tbl, item, i % wd->x, i / wd->x, 1,
+ 1);
+ i++;
+ }
+ }
+ }
+
+ return EINA_TRUE;
}
-static void _sizing_eval(Evas_Object *obj, int mode)
+static void
+_sizing_eval(Evas_Object * obj, int mode)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
- Evas_Coord w, h;
-
- evas_object_size_hint_min_get(wd->scr, &minw, &minh);
- evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
- evas_object_size_hint_min_set(obj, minw, minh);
- evas_object_size_hint_max_set(obj, maxw, maxh);
- evas_object_geometry_get(wd->scr, NULL, NULL, &w, &h);
-
- if (w < minw)
- w = minw;
- if (h < minh)
- h = minh;
- if ((maxw >= 0) && (w > maxw))
- w = maxw;
- if ((maxh >= 0) && (h > maxh))
- h = maxh;
- evas_object_resize(obj, w, h);
-
- wd->minw = w;
- wd->minh = h;
-
- if (wd->homogeneous) {
- wd->x = w / wd->itemsize_h;
- wd->y = h / wd->itemsize_v;
- wd->horizontal = (wd->minw - wd->x * wd->itemsize_h) / wd->x;
- wd->vertical = (wd->minh - wd->y * wd->itemsize_v) / wd->y;
- elm_gridbox_padding_set(obj, wd->horizontal, wd->vertical);
- }
-
- if (!mode)
- _arrange_table(obj);
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
+
+ Evas_Coord w, h;
+
+ evas_object_size_hint_min_get(wd->scr, &minw, &minh);
+ evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
+ evas_object_size_hint_min_set(obj, minw, minh);
+ evas_object_size_hint_max_set(obj, maxw, maxh);
+ evas_object_geometry_get(wd->scr, NULL, NULL, &w, &h);
+
+ if (w < minw)
+ w = minw;
+ if (h < minh)
+ h = minh;
+ if ((maxw >= 0) && (w > maxw))
+ w = maxw;
+ if ((maxh >= 0) && (h > maxh))
+ h = maxh;
+ evas_object_resize(obj, w, h);
+
+ wd->minw = w;
+ wd->minh = h;
+ if (w < wd->itemsize_h || h < wd->itemsize_v)
+ return;
+ if (wd->homogeneous)
+ {
+ wd->x = w / wd->itemsize_h;
+ wd->y = h / wd->itemsize_v;
+ wd->horizontal = (wd->minw - wd->x * wd->itemsize_h) / wd->x;
+ wd->vertical = (wd->minh - wd->y * wd->itemsize_v) / wd->y;
+ elm_gridbox_padding_set(obj, wd->horizontal, wd->vertical);
+ }
+
+ if (!mode)
+ _arrange_table(obj);
}
-static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
+static void
+_changed_size_hints(void *data, Evas * e, Evas_Object * obj, void *event_info)
{
- _sizing_eval(data, 0);
+ _sizing_eval(data, 0);
}
-static void _changed_size_min(void *data, Evas *e, Evas_Object *obj, void *event_info)
+static void
+_changed_size_min(void *data, Evas * e, Evas_Object * obj, void *event_info)
{
- _sizing_eval(data, 0);
+ _sizing_eval(data, 0);
}
-static void _sub_del(void *data, Evas_Object *obj, void *event_info)
+static void
+_sub_del(void *data, Evas_Object * obj, void *event_info)
{
- _sizing_eval(obj, 1);
+ _sizing_eval(obj, 1);
}
-static void _show_event(void *data, Evas_Object *obj, void *event_info)
+static void
+_show_event(void *data, Evas_Object * obj, void *event_info)
{
- _sizing_eval(data, 0);
+ _sizing_eval(data, 0);
}
-static void _freeze_on(void *data, Evas_Object *obj, void *event_info)
+static void
+_freeze_on(void *data, Evas_Object * obj, void *event_info)
{
- Widget_Data *wd = elm_widget_data_get(obj);
+ Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd)
- return;
- evas_object_smart_callback_call(wd->scr, "scroll-freeze-on", NULL);
+ if (!wd)
+ return;
+ evas_object_smart_callback_call(wd->scr, "scroll-freeze-on", NULL);
}
-static void _freeze_off(void *data, Evas_Object *obj, void *event_info)
+static void
+_freeze_off(void *data, Evas_Object * obj, void *event_info)
{
- Widget_Data *wd = elm_widget_data_get(obj);
+ Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd)
- return;
- evas_object_smart_callback_call(wd->scr, "scroll-freeze-off", NULL);
+ if (!wd)
+ return;
+ evas_object_smart_callback_call(wd->scr, "scroll-freeze-off", NULL);
}
/**
* @ingroup Gridbox
*/
EAPI Evas_Object *
-elm_gridbox_add(Evas_Object *parent)
+elm_gridbox_add(Evas_Object * parent)
{
- Evas_Object *obj;
- Evas *e;
- Widget_Data *wd;
-
- wd = ELM_NEW(Widget_Data);
- e = evas_object_evas_get(parent);
- obj = elm_widget_add(e);
- elm_widget_type_set(obj, "gridbox");
- elm_widget_sub_object_add(parent, obj);
- elm_widget_data_set(obj, wd);
- elm_widget_del_hook_set(obj, _del_hook);
- elm_widget_del_pre_hook_set(obj, _del_pre_hook);
-
- wd->scr = elm_scroller_add(parent);
- elm_widget_resize_object_set(obj, wd->scr);
- elm_scroller_bounce_set(wd->scr, 0, 1);
-
- wd->tbl = evas_object_table_add(e);
- evas_object_size_hint_weight_set(wd->tbl, 0.0, 0.0);
- elm_scroller_content_set(wd->scr, wd->tbl);
- evas_object_show(wd->tbl);
-
- evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
- evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _changed_size_min, obj);
- evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_SHOW, _show_event, obj);
-
- evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
- evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
- evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
-
- _sizing_eval(obj, 0);
-
- return obj;
+ Evas_Object *obj;
+
+ Evas *e;
+
+ Widget_Data *wd;
+
+ wd = ELM_NEW(Widget_Data);
+ e = evas_object_evas_get(parent);
+ obj = elm_widget_add(e);
+ elm_widget_type_set(obj, "gridbox");
+ elm_widget_sub_object_add(parent, obj);
+ elm_widget_data_set(obj, wd);
+ elm_widget_del_hook_set(obj, _del_hook);
+ elm_widget_del_pre_hook_set(obj, _del_pre_hook);
+
+ wd->scr = elm_scroller_add(parent);
+ elm_widget_resize_object_set(obj, wd->scr);
+ elm_scroller_bounce_set(wd->scr, 0, 1);
+
+ wd->tbl = evas_object_table_add(e);
+ evas_object_size_hint_weight_set(wd->tbl, 0.0, 0.0);
+ elm_scroller_content_set(wd->scr, wd->tbl);
+ evas_object_show(wd->tbl);
+
+ evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE,
+ _changed_size_min, obj);
+ evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_SHOW, _show_event,
+ obj);
+
+ evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
+ evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
+ evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
+
+ _sizing_eval(obj, 0);
+
+ return obj;
}
/**
*
* @ingroup Gridbox
*/
-EAPI void elm_gridbox_padding_set(Evas_Object *obj, Evas_Coord horizontal, Evas_Coord vertical)
+EAPI void
+elm_gridbox_padding_set(Evas_Object * obj, Evas_Coord horizontal,
+ Evas_Coord vertical)
{
- Widget_Data *wd = elm_widget_data_get(obj);
+ Widget_Data *wd = elm_widget_data_get(obj);
- wd->horizontal = horizontal;
- wd->vertical = vertical;
+ if (!wd)
+ return;
- if (wd)
- evas_object_table_padding_set(wd->tbl, horizontal, vertical);
+ wd->horizontal = horizontal;
+ wd->vertical = vertical;
+ if (wd->tbl)
+ evas_object_table_padding_set(wd->tbl, horizontal, vertical);
}
/**
*
* @ingroup Gridbox
*/
-EAPI void elm_gridbox_item_size_set(Evas_Object *obj, Evas_Coord h_itemsize, Evas_Coord v_itemsize)
+EAPI void
+elm_gridbox_item_size_set(Evas_Object * obj, Evas_Coord h_itemsize,
+ Evas_Coord v_itemsize)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord minw = -1, minh = -1;
- Evas_Coord w, h;
-
- if (!wd)
- return;
-
- wd->itemsize_h = h_itemsize;
- wd->itemsize_v = v_itemsize;
- evas_object_size_hint_min_get(wd->scr, &minw, &minh);
- evas_object_geometry_get(obj, NULL, NULL, &w, &h);
- if (w < minw)
- w = minw;
- if (h < minh)
- h = minh;
- wd->x = w / h_itemsize;
- wd->y = h / v_itemsize;
-
- if (!wd->x)
- wd->x = 1;
- if (!wd->y)
- wd->y = 1;
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ Evas_Coord minw = -1, minh = -1;
+
+ Evas_Coord w, h;
+
+ if (!wd)
+ return;
+
+ wd->itemsize_h = h_itemsize;
+ wd->itemsize_v = v_itemsize;
+ evas_object_size_hint_min_get(wd->scr, &minw, &minh);
+ evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+ if (w < minw)
+ w = minw;
+ if (h < minh)
+ h = minh;
+ wd->x = w / h_itemsize;
+ wd->y = h / v_itemsize;
+
+ if (!wd->x)
+ wd->x = 1;
+ if (!wd->y)
+ wd->y = 1;
+ _sizing_eval(obj, 1);
}
/**
*
* @ingroup Gridbox
*/
-EAPI void elm_gridbox_pack(Evas_Object *obj, Evas_Object *subobj)
+EAPI void
+elm_gridbox_pack(Evas_Object * obj, Evas_Object * subobj)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- int index = eina_list_count(evas_object_table_children_get(wd->tbl));
- evas_object_size_hint_min_set(subobj, wd->itemsize_h, wd->itemsize_v);
- evas_object_size_hint_max_set(subobj, wd->itemsize_h, wd->itemsize_v);
- elm_widget_sub_object_add(obj, subobj);
- evas_object_table_pack(wd->tbl, subobj, index % wd->x, index / wd->x, 1, 1);
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ int index = eina_list_count(evas_object_table_children_get(wd->tbl));
+
+ evas_object_size_hint_min_set(subobj, wd->itemsize_h, wd->itemsize_v);
+ evas_object_size_hint_max_set(subobj, wd->itemsize_h, wd->itemsize_v);
+ elm_widget_sub_object_add(obj, subobj);
+ evas_object_table_pack(wd->tbl, subobj, index % wd->x, index / wd->x, 1, 1);
}
/**
*
* @ingroup Gridbox
*/
-EAPI Eina_Bool elm_gridbox_unpack(Evas_Object *obj, Evas_Object *subobj)
+EAPI Eina_Bool
+elm_gridbox_unpack(Evas_Object * obj, Evas_Object * subobj)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Eina_Bool ret = 0;
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ Eina_Bool ret = 0;
- elm_widget_sub_object_del(wd->tbl, subobj);
- ret = evas_object_table_unpack(wd->tbl, subobj);
+ elm_widget_sub_object_del(wd->tbl, subobj);
+ ret = evas_object_table_unpack(wd->tbl, subobj);
- _arrange_table(obj);
+ _arrange_table(obj);
- return ret;
+ return ret;
}
/**
* @ingroup Gridbox
*/
EAPI Eina_List *
-elm_gridbox_children_get(Evas_Object *obj)
+elm_gridbox_children_get(Evas_Object * obj)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Eina_List *new_list = NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ Eina_List *new_list = NULL;
- new_list = evas_object_table_children_get(wd->tbl);
+ new_list = evas_object_table_children_get(wd->tbl);
- return new_list;
+ return new_list;
}
/**
*
* @ingroup Gridbox
*/
-EAPI void elm_gridbox_homogenous_padding_set(Evas_Object *obj, Eina_Bool homogenous)
+EAPI void
+elm_gridbox_homogenous_padding_set(Evas_Object * obj, Eina_Bool homogenous)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- wd->homogeneous = homogenous;
-}
+ Widget_Data *wd = elm_widget_data_get(obj);
+ wd->homogeneous = homogenous;
+}
if (wd->panel_btn_idx > 0) {
//show more button
edje_object_signal_emit(wd->lay, "more_btn_show", "");
-EINA_LIST_FOREACH (wd->items, l, it)
- {
- _elm_theme_object_set(obj, it->base, "softkey", "panel_button", elm_widget_style_get(obj));
- if(it->label) {
- edje_object_part_text_set(it->base, "elm.text", it->label); // set text
+ EINA_LIST_FOREACH (wd->items, l, it) {
+ _elm_theme_object_set(obj, it->base, "softkey", "panel_button", elm_widget_style_get(obj));
+ if (it->label) {
+ edje_object_part_text_set(it->base, "elm.text", it->label); // set text
+ }
}
}
}
-}
-_sizing_eval( obj );
+ _sizing_eval(obj);
}
static void _sub_del(void *data, Evas_Object *obj, void *event_info)
if (!wd)
return;
-EINA_LIST_FOREACH(wd->items, l, it)
-{
- if(sub == it->icon) {
- it->icon = NULL;
+ EINA_LIST_FOREACH(wd->items, l, it) {
+ if (sub == it->icon) {
+ it->icon = NULL;
+ }
+ break;
}
- break;
-}
}
static void _sizing_eval(Evas_Object *obj)
switch (type)
{
- case ELM_SK_LEFT_BTN:
- evas_object_move(btn, wd->x, wd->y);
- break;
- case ELM_SK_RIGHT_BTN:
- edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w, NULL);
- evas_object_move(btn, wd->x + wd->w - btn_w, wd->y);
- break;
- default:
- break;
+ case ELM_SK_LEFT_BTN:
+ evas_object_move(btn, wd->x, wd->y);
+ break;
+ case ELM_SK_RIGHT_BTN:
+ edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w, NULL);
+ evas_object_move(btn, wd->x + wd->w - btn_w, wd->y);
+ break;
+ default:
+ break;
}
return 0;
return;
wd->is_horizontal = horizontal_mode;
if (wd->panel) {
- if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
- || (edje_object_data_get(wd->panel, "panel_height") == NULL)
- || (edje_object_data_get(wd->panel, "panel_height_horizontal") == NULL)) {
+ if ((edje_object_data_get(wd->panel, "max_item_count") == NULL) || (edje_object_data_get(wd->panel, "panel_height") == NULL) || (edje_object_data_get(wd->panel, "panel_height_horizontal") == NULL)) {
wd->panel_suppported = EINA_FALSE;
}
else
sprintf(buff, "button_%d", (wd->panel_btn_idx + wd->max_button));
edje_object_signal_emit(wd->panel, buff, "panel_rect");
wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
- evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height_horizontal"))
- * wd->scale_factor)));
+ evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height_horizontal")) * wd->scale_factor)));
}
else {
sprintf(buff, "button_%d", (wd->panel_btn_idx));
edje_object_signal_emit(wd->panel, buff, "panel_rect");
wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
- evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height"))
- * wd->scale_factor)));
+ evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height")) * wd->scale_factor)));
}
}
_calc_win_height(wd);
return NULL;
}
- /* set item data */
- it = ELM_NEW(Elm_Softkey_Item);
- it->obj = obj;
- it->func = func;
- it->data = data;
-
/* get evas */
evas = evas_object_evas_get(obj);
if (!evas)
return NULL;
+ /* set item data */
+ it = ELM_NEW(Elm_Softkey_Item);
+ it->obj = obj;
+ it->func = func;
+ it->data = data;
+ it->label = NULL;
/* load button edj */
if (wd->button[type] == NULL) {
if (type == ELM_SK_LEFT_BTN) {
}
it->base = wd->button[type] = edje_object_add(evas);
- if (!wd->button[type])
+ if (!wd->button[type]) {
+ free(it);
return NULL;
+ }
_elm_theme_object_set(obj, wd->button[type], "softkey", button_type, elm_widget_style_get(obj));
wd->button_show[type] = EINA_TRUE;
elm_softkey_item_label_set(it, label);
elm_softkey_item_icon_set(it, icon);
-
- evas_object_data_set(wd->button[type], "item_data", it);
+ if (wd->button[type])
+ evas_object_data_set(wd->button[type], "item_data", it);
+ else {
+ if (it->label)
+ eina_stringshare_del(it->label);
+ it->label = NULL;
+ free(it);
+ return NULL;
+ }
return it;
}
return NULL;
}
- /* set item data */
- it = ELM_NEW(Elm_Softkey_Item);
- wd->items = eina_list_append(wd->items, it);
- it->obj = obj;
- it->label = eina_stringshare_add(label);
- it->icon = icon;
- it->func = func;
- it->data = data;
-
/* get evas */
evas = evas_object_evas_get(obj);
if (!evas)
evas_object_show(wd->panel);
}
wd->panel_height = 0;
- if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
- || (edje_object_data_get(wd->panel, "panel_height") == NULL)
- || (edje_object_data_get(wd->panel, "panel_height_horizontal") == NULL)) {
+ if ((edje_object_data_get(wd->panel, "max_item_count") == NULL) || (edje_object_data_get(wd->panel, "panel_height") == NULL) || (edje_object_data_get(wd->panel, "panel_height_horizontal") == NULL)) {
//If this key is not found in data section, then it means the panel won't come.
wd->max_button = 0;
// delete panel
else {
wd->max_button = (int) (atoi(edje_object_data_get(wd->panel, "max_item_count")));
if (wd->is_horizontal) {
- evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height_horizontal"))
- * wd->scale_factor)));
+ evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height_horizontal")) * wd->scale_factor)));
}
else {
- evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height"))
- * wd->scale_factor)));
+ evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height")) * wd->scale_factor)));
}
}
evas_object_clip_set(wd->panel, evas_object_clip_get(obj));
}
+ wd->panel_btn_idx++;
if (wd->panel_btn_idx >= wd->max_button)
return NULL;
- wd->panel_btn_idx++;
-
- if (evas_object_visible_get(obj)) {
- /* show more button */
- edje_object_signal_emit(wd->lay, "more_btn_show", "");
- }
-
+ /* set item data */
+ it = ELM_NEW(Elm_Softkey_Item);
+ wd->items = eina_list_append(wd->items, it);
+ it->obj = obj;
+ if (label)
+ it->label = eina_stringshare_add(label);
+ it->icon = icon;
+ it->func = func;
+ it->data = data;
/* load panel button */
it->base = btn = edje_object_add(evas);
- if (!btn)
+ if (!btn) {
+ if (it->label)
+ eina_stringshare_del(it->label);
+ free(it);
+ wd->panel_btn_idx--;
return NULL;
+ }
_elm_theme_object_set(obj, btn, "softkey", "panel_button", elm_widget_style_get(obj));
edje_object_part_text_set(btn, "elm.text", label); /* set text */
evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN, _panel_down_cb, it);
evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _panel_up_cb, it);
- /* swallow button */
- sprintf(button_name, "panel_button_area_%d", wd->panel_btn_idx);
- edje_object_part_swallow(wd->panel, button_name, btn);
- if (wd->is_horizontal) {
- sprintf(buff, "button_%d", wd->max_button + wd->panel_btn_idx);
- edje_object_signal_emit(wd->panel, buff, "panel_rect");
- wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
+ if (wd->panel) {
+ /* swallow button */
+ sprintf(button_name, "panel_button_area_%d", wd->panel_btn_idx);
+ edje_object_part_swallow(wd->panel, button_name, btn);
+
+ if (wd->is_horizontal) {
+ sprintf(buff, "button_%d", wd->max_button + wd->panel_btn_idx);
+ edje_object_signal_emit(wd->panel, buff, "panel_rect");
+ const char* val = edje_object_data_get(wd->panel, buff);
+ if (val)
+ wd->panel_height = (int) (atoi(val) * wd->scale_factor);
+ else {
+ if (it->label)
+ eina_stringshare_del(it->label);
+ evas_object_del(it->base);
+ free(it);
+ wd->panel_btn_idx--;
+ return NULL;
+ }
+ }
+ else {
+ sprintf(buff, "button_%d", wd->panel_btn_idx);
+ edje_object_signal_emit(wd->panel, buff, "panel_rect");
+ const char* val = edje_object_data_get(wd->panel, buff);
+ if (val)
+ wd->panel_height = (int) (atoi(val) * wd->scale_factor);
+ else {
+ if (it->label)
+ eina_stringshare_del(it->label);
+ evas_object_del(it->base);
+ free(it);
+ wd->panel_btn_idx--;
+ return NULL;
+ }
+ }
}
else {
- sprintf(buff, "button_%d", wd->panel_btn_idx);
- edje_object_signal_emit(wd->panel, buff, "panel_rect");
- wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
+ wd->panel_btn_idx--;
+ return NULL;
}
+ if (evas_object_visible_get(obj)) {
+ /* show more button */
+ edje_object_signal_emit(wd->lay, "more_btn_show", "");
+ }
return it;
}
_delete_button(btn);
}
- EINA_LIST_FREE(wd->items, it)
- {
+ EINA_LIST_FREE(wd->items, it) {
eina_stringshare_del(it->label);
free(it);
}