2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2009-09-17 15:39:18 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Frame Frame
|
|
|
|
*
|
|
|
|
* This holds some content and has a title. Looks like a frame, but
|
|
|
|
* supports styles so multple frames are avaible
|
|
|
|
*/
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
|
|
|
Evas_Object *frm;
|
2008-10-06 23:55:11 -07:00
|
|
|
Evas_Object *content;
|
2008-10-06 18:23:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void _del_hook(Evas_Object *obj);
|
2008-11-15 05:58:50 -08:00
|
|
|
static void _theme_hook(Evas_Object *obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
|
|
|
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
2008-10-06 23:55:11 -07:00
|
|
|
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
2008-10-06 18:23:49 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:04:05 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
2008-11-15 05:58:50 -08:00
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
2008-12-08 01:24:46 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:04:05 -07:00
|
|
|
|
2009-04-22 21:03:27 -07:00
|
|
|
_elm_theme_set(wd->frm, "frame", "base", elm_widget_style_get(obj));
|
2008-12-08 01:24:46 -08:00
|
|
|
if (wd->content)
|
|
|
|
edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
|
2009-02-02 21:09:03 -08:00
|
|
|
edje_object_scale_set(wd->frm, elm_widget_scale_get(obj) * _elm_config->scale);
|
2008-11-15 05:58:50 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
edje_object_size_min_calc(wd->frm, &minw, &minh);
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
|
|
|
_sizing_eval(data);
|
|
|
|
}
|
|
|
|
|
2008-10-06 23:55:11 -07:00
|
|
|
static void
|
|
|
|
_sub_del(void *data, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Object *sub = event_info;
|
2009-09-26 11:04:05 -07:00
|
|
|
|
2008-10-06 23:55:11 -07:00
|
|
|
if (sub == wd->content)
|
|
|
|
{
|
2009-10-22 14:46:54 -07:00
|
|
|
evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
2009-10-25 22:54:22 -07:00
|
|
|
_changed_size_hints, obj);
|
2008-10-06 23:55:11 -07:00
|
|
|
wd->content = NULL;
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:39:18 -07:00
|
|
|
/**
|
|
|
|
* Add a new frame to the parent
|
|
|
|
*
|
|
|
|
* @param parent The parent object
|
|
|
|
* @return The new object or NULL if it cannot be created
|
|
|
|
*
|
|
|
|
* @ingroup Frame
|
|
|
|
*/
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_frame_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
wd = ELM_NEW(Widget_Data);
|
|
|
|
e = evas_object_evas_get(parent);
|
|
|
|
obj = elm_widget_add(e);
|
2009-05-13 05:21:52 -07:00
|
|
|
elm_widget_type_set(obj, "frame");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
2008-11-15 05:58:50 -08:00
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
wd->frm = edje_object_add(e);
|
2008-10-08 02:33:05 -07:00
|
|
|
_elm_theme_set(wd->frm, "frame", "base", "default");
|
2008-10-06 18:23:49 -07:00
|
|
|
elm_widget_resize_object_set(obj, wd->frm);
|
2008-10-06 23:55:11 -07:00
|
|
|
|
|
|
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:39:18 -07:00
|
|
|
/**
|
|
|
|
* Set the frame label
|
|
|
|
*
|
|
|
|
* @param obj The frame object
|
|
|
|
* @param label The label of this frame object
|
|
|
|
*
|
|
|
|
* @ingroup Frame
|
|
|
|
*/
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
|
|
|
elm_frame_label_set(Evas_Object *obj, const char *label)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:04:05 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
edje_object_part_text_set(wd->frm, "elm.text", label);
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:39:18 -07:00
|
|
|
/**
|
|
|
|
* Get the frame label
|
|
|
|
*
|
|
|
|
* @param obj The frame object
|
|
|
|
*
|
|
|
|
* @return The label of this frame objet or NULL if unable to get frame
|
|
|
|
*
|
|
|
|
* @ingroup Frame
|
|
|
|
*/
|
2009-08-11 03:44:49 -07:00
|
|
|
EAPI const char*
|
|
|
|
elm_frame_label_get(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:04:05 -07:00
|
|
|
|
|
|
|
if ((!wd) || (!wd->frm)) return NULL;
|
2009-08-11 03:44:49 -07:00
|
|
|
return edje_object_part_text_get(wd->frm, "elm.text");
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:39:18 -07:00
|
|
|
/**
|
|
|
|
* Set the frame content
|
|
|
|
*
|
|
|
|
* @param obj The frame object
|
|
|
|
* @param content The content will be filled in this frame object
|
|
|
|
*
|
|
|
|
* @ingroup Frame
|
|
|
|
*/
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
|
|
|
elm_frame_content_set(Evas_Object *obj, Evas_Object *content)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-09-26 11:04:05 -07:00
|
|
|
|
2008-10-06 23:55:11 -07:00
|
|
|
if ((wd->content != content) && (wd->content))
|
|
|
|
elm_widget_sub_object_del(obj, wd->content);
|
|
|
|
wd->content = content;
|
|
|
|
if (content)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 23:55:11 -07:00
|
|
|
elm_widget_sub_object_add(obj, content);
|
2008-10-08 01:14:25 -07:00
|
|
|
edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
|
2009-10-15 06:18:11 -07:00
|
|
|
evas_object_event_callback_add(content,
|
2009-09-26 11:04:05 -07:00
|
|
|
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
2008-10-06 23:55:11 -07:00
|
|
|
_changed_size_hints, obj);
|
|
|
|
_sizing_eval(obj);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
}
|
2008-12-08 01:24:46 -08:00
|
|
|
|
2009-09-17 15:39:18 -07:00
|
|
|
/**
|
|
|
|
* Set the frame style
|
|
|
|
*
|
|
|
|
* @param obj The frame object
|
|
|
|
* @param style The style will be applied in this frame
|
|
|
|
*
|
2009-10-15 06:18:11 -07:00
|
|
|
* DEPRECATED. use elm_object_style_set() instead
|
|
|
|
*
|
2009-09-17 15:39:18 -07:00
|
|
|
* @ingroup Frame
|
|
|
|
*/
|
2008-12-08 01:24:46 -08:00
|
|
|
EAPI void
|
|
|
|
elm_frame_style_set(Evas_Object *obj, const char *style)
|
|
|
|
{
|
2009-04-22 21:03:27 -07:00
|
|
|
elm_widget_style_set(obj, style);
|
2008-12-08 01:24:46 -08:00
|
|
|
}
|