elementary/segment_control - deprecates 2 APIs and supports elm_object_common APIs.
*deprecated elm_segment_control_item_label_set elm_segment_control_item_icon_set SVN revision: 66731
This commit is contained in:
parent
6b127fc932
commit
176fc43fc4
|
@ -69,7 +69,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
|
|||
elm_segment_control_item_del_at(sc, 2);
|
||||
|
||||
seg_it = elm_segment_control_item_get(sc, 0);
|
||||
elm_segment_control_item_label_set(seg_it, "Only Text");
|
||||
elm_object_item_text_set(seg_it, "Only Text");
|
||||
|
||||
count = elm_segment_control_item_count_get(sc);
|
||||
seg_it = elm_segment_control_item_get(sc, count / 2);
|
||||
|
|
|
@ -2496,3 +2496,51 @@ EINA_DEPRECATED EAPI Eina_Bool elm_toolbar_orientation_get(const Evas_Object
|
|||
* @ingroup Video
|
||||
*/
|
||||
EINA_DEPRECATED EAPI void elm_player_video_set(Evas_Object *player, Evas_Object *video);
|
||||
|
||||
/**
|
||||
* Set the label of item.
|
||||
*
|
||||
* @param it The item of segment control.
|
||||
* @param text The label of item.
|
||||
*
|
||||
* The label to be displayed by the item.
|
||||
* Label will be at right of the icon (if set).
|
||||
*
|
||||
* If a label was passed as argument on item creation, with function
|
||||
* elm_control_segment_item_add(), it will be already
|
||||
* displayed by the item.
|
||||
*
|
||||
* @see elm_segment_control_item_label_get()
|
||||
* @see elm_segment_control_item_add()
|
||||
* @deprecated Use elm_object_item_text_set() instead
|
||||
*
|
||||
* @ingroup SegmentControl
|
||||
*/
|
||||
EINA_DEPRECATED EAPI void elm_segment_control_item_label_set(Elm_Object_Item *it, const char *label);
|
||||
|
||||
|
||||
/**
|
||||
* Set the icon associated to the item.
|
||||
*
|
||||
* @param it The segment control item.
|
||||
* @param icon The icon object to associate with @p it.
|
||||
*
|
||||
* The icon object to use at left side of the item. An
|
||||
* icon can be any Evas object, but usually it is an icon created
|
||||
* with elm_icon_add().
|
||||
*
|
||||
* Once the icon object is set, a previously set one will be deleted.
|
||||
* @warning Setting the same icon for two items will cause the icon to
|
||||
* dissapear from the first item.
|
||||
*
|
||||
* If an icon was passed as argument on item creation, with function
|
||||
* elm_segment_control_item_add(), it will be already
|
||||
* associated to the item.
|
||||
*
|
||||
* @see elm_segment_control_item_add()
|
||||
* @see elm_segment_control_item_icon_get()
|
||||
* @deprecated Use elm_object_item_part_content_set() instead
|
||||
*
|
||||
* @ingroup SegmentControl
|
||||
*/
|
||||
EINA_DEPRECATED EAPI void elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
|
||||
|
|
|
@ -434,6 +434,75 @@ _item_find(const Evas_Object *obj, int idx)
|
|||
return it;
|
||||
}
|
||||
|
||||
static void
|
||||
_item_text_set_hook(Elm_Object_Item *it, const char *part, const char *label)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
||||
Widget_Data *wd;
|
||||
Elm_Segment_Item *item;
|
||||
|
||||
if (part && strcmp(part, "default")) return;
|
||||
|
||||
item = (Elm_Segment_Item *) it;
|
||||
wd = elm_widget_item_data_get(item);
|
||||
if (!wd) return;
|
||||
|
||||
eina_stringshare_replace(&item->label, label);
|
||||
if (item->label)
|
||||
edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
|
||||
else
|
||||
edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
|
||||
edje_object_message_signal_process(VIEW(item));
|
||||
//label can be NULL also.
|
||||
edje_object_part_text_set(VIEW(item), "elm.text", item->label);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_item_text_get_hook(const Elm_Object_Item *it, const char *part)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
if (part && strcmp(part, "default")) return NULL;
|
||||
return ((Elm_Segment_Item *) it)->label;
|
||||
}
|
||||
|
||||
static void
|
||||
_item_content_set_hook(Elm_Object_Item *it,
|
||||
const char *part,
|
||||
Evas_Object *content)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
||||
Elm_Segment_Item *item;
|
||||
|
||||
if (part && strcmp(part, "icon")) return;
|
||||
|
||||
item = (Elm_Segment_Item *) it;
|
||||
|
||||
//Remove the existing icon
|
||||
if (item->icon)
|
||||
{
|
||||
edje_object_part_unswallow(VIEW(item), item->icon);
|
||||
evas_object_del(item->icon);
|
||||
item->icon = NULL;
|
||||
}
|
||||
item->icon = content;
|
||||
if (item->icon)
|
||||
{
|
||||
elm_widget_sub_object_add(VIEW(item), item->icon);
|
||||
edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
|
||||
edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
|
||||
}
|
||||
else
|
||||
edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_item_content_get_hook(const Elm_Object_Item *it, const char *part)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
if (part && strcmp(part, "icon")) return NULL;
|
||||
return ((Elm_Segment_Item *) it)->icon;
|
||||
}
|
||||
|
||||
static Elm_Segment_Item*
|
||||
_item_new(Evas_Object *obj, Evas_Object *icon, const char *label)
|
||||
{
|
||||
|
@ -446,6 +515,10 @@ _item_new(Evas_Object *obj, Evas_Object *icon, const char *label)
|
|||
it = elm_widget_item_new(obj, Elm_Segment_Item);
|
||||
if (!it) return NULL;
|
||||
elm_widget_item_data_set(it, wd);
|
||||
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
|
||||
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
|
||||
elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
|
||||
elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
|
||||
|
||||
VIEW(it) = edje_object_add(evas_object_evas_get(obj));
|
||||
edje_object_scale_set(VIEW(it), elm_widget_scale_get(VIEW(it))
|
||||
|
@ -598,69 +671,30 @@ EAPI const char*
|
|||
elm_segment_control_item_label_get(const Evas_Object *obj, int idx)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Elm_Segment_Item *it;
|
||||
|
||||
it = _item_find(obj, idx);
|
||||
Elm_Segment_Item *it = _item_find(obj, idx);
|
||||
if (it) return it->label;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_segment_control_item_label_set(Elm_Object_Item* it, const char* label)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
||||
Widget_Data *wd;
|
||||
Elm_Segment_Item *item = (Elm_Segment_Item *) it;
|
||||
|
||||
wd = elm_widget_item_data_get(item);
|
||||
if (!wd) return;
|
||||
|
||||
eina_stringshare_replace(&item->label, label);
|
||||
if (item->label)
|
||||
edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
|
||||
else
|
||||
edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
|
||||
edje_object_message_signal_process(VIEW(item));
|
||||
//label can be NULL also.
|
||||
edje_object_part_text_set(VIEW(item), "elm.text", item->label);
|
||||
_item_text_set_hook(it, NULL, label);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_segment_control_item_icon_get(const Evas_Object *obj, int idx)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Elm_Segment_Item *it;
|
||||
|
||||
it = _item_find(obj, idx);
|
||||
Elm_Segment_Item *it = _item_find(obj, idx);
|
||||
if (it) return it->icon;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon)
|
||||
{
|
||||
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
|
||||
Elm_Segment_Item *item = (Elm_Segment_Item *) it;
|
||||
|
||||
//Remove the existing icon
|
||||
if (item->icon)
|
||||
{
|
||||
edje_object_part_unswallow(VIEW(item), item->icon);
|
||||
evas_object_del(item->icon);
|
||||
item->icon = NULL;
|
||||
}
|
||||
|
||||
item->icon = icon;
|
||||
if (item->icon)
|
||||
{
|
||||
elm_widget_sub_object_add(VIEW(item), item->icon);
|
||||
edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
|
||||
edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
|
||||
}
|
||||
else
|
||||
edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
|
||||
_item_content_set_hook(it, NULL, icon);
|
||||
}
|
||||
|
||||
EAPI int
|
||||
|
|
|
@ -197,26 +197,6 @@ EAPI Elm_Object_Item *elm_segment_control_item_get(const Evas_Object *obj, int i
|
|||
*/
|
||||
EAPI const char *elm_segment_control_item_label_get(const Evas_Object *obj, int index);
|
||||
|
||||
/**
|
||||
* Set the label of item.
|
||||
*
|
||||
* @param it The item of segment control.
|
||||
* @param text The label of item.
|
||||
*
|
||||
* The label to be displayed by the item.
|
||||
* Label will be at right of the icon (if set).
|
||||
*
|
||||
* If a label was passed as argument on item creation, with function
|
||||
* elm_control_segment_item_add(), it will be already
|
||||
* displayed by the item.
|
||||
*
|
||||
* @see elm_segment_control_item_label_get()
|
||||
* @see elm_segment_control_item_add()
|
||||
*
|
||||
* @ingroup SegmentControl
|
||||
*/
|
||||
EAPI void elm_segment_control_item_label_set(Elm_Object_Item *it, const char *label);
|
||||
|
||||
/**
|
||||
* Get the icon associated to the item.
|
||||
*
|
||||
|
@ -236,31 +216,6 @@ EAPI void elm_segment_control_item_label_set(Elm_Object_Item *it, c
|
|||
*/
|
||||
EAPI Evas_Object *elm_segment_control_item_icon_get(const Evas_Object *obj, int index);
|
||||
|
||||
/**
|
||||
* Set the icon associated to the item.
|
||||
*
|
||||
* @param it The segment control item.
|
||||
* @param icon The icon object to associate with @p it.
|
||||
*
|
||||
* The icon object to use at left side of the item. An
|
||||
* icon can be any Evas object, but usually it is an icon created
|
||||
* with elm_icon_add().
|
||||
*
|
||||
* Once the icon object is set, a previously set one will be deleted.
|
||||
* @warning Setting the same icon for two items will cause the icon to
|
||||
* dissapear from the first item.
|
||||
*
|
||||
* If an icon was passed as argument on item creation, with function
|
||||
* elm_segment_control_item_add(), it will be already
|
||||
* associated to the item.
|
||||
*
|
||||
* @see elm_segment_control_item_add()
|
||||
* @see elm_segment_control_item_icon_get()
|
||||
*
|
||||
* @ingroup SegmentControl
|
||||
*/
|
||||
EAPI void elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
|
||||
|
||||
/**
|
||||
* Get the index of an item.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue