2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
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;
|
2010-09-23 22:11:33 -07:00
|
|
|
const char *label;
|
2008-10-06 18:23:49 -07:00
|
|
|
};
|
|
|
|
|
2012-01-03 16:41:37 -08:00
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
|
|
|
|
|
|
|
static const Evas_Smart_Cb_Description _signals[] = {
|
|
|
|
{SIG_CLICKED, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2008-10-06 18:23:49 -07:00
|
|
|
static void _del_hook(Evas_Object *obj);
|
2011-02-08 04:08:28 -08:00
|
|
|
static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
|
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);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2010-09-23 22:11:33 -07:00
|
|
|
if (wd->label) eina_stringshare_del(wd->label);
|
2008-10-06 18:23:49 -07:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
2011-02-08 04:08:28 -08:00
|
|
|
static void
|
|
|
|
_mirrored_set(Evas_Object *obj, Eina_Bool rtl)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
edje_object_mirrored_set(wd->frm, rtl);
|
|
|
|
}
|
|
|
|
|
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);
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2011-02-09 08:14:02 -08:00
|
|
|
_elm_widget_mirrored_reload(obj);
|
2011-02-08 04:08:28 -08:00
|
|
|
_mirrored_set(obj, elm_widget_mirrored_get(obj));
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->frm, "frame", "base", elm_widget_style_get(obj));
|
2010-09-23 22:11:33 -07:00
|
|
|
edje_object_part_text_set(wd->frm, "elm.text", wd->label);
|
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);
|
|
|
|
}
|
|
|
|
|
2010-10-01 12:02:58 -07:00
|
|
|
static Eina_Bool
|
2010-10-06 13:24:19 -07:00
|
|
|
_elm_frame_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
|
2010-10-01 12:02:58 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Object *cur;
|
|
|
|
|
|
|
|
if ((!wd) || (!wd->content))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
cur = wd->content;
|
|
|
|
|
|
|
|
/* Try Focus cycle in subitem */
|
2010-10-06 13:24:13 -07:00
|
|
|
return elm_widget_focus_next_get(cur, dir, next);
|
2010-10-01 12:02:58 -07:00
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-11-09 04:32:10 -08:00
|
|
|
Evas_Coord minw = -1, minh = -1;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
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);
|
2009-11-09 04:32:10 -08:00
|
|
|
evas_object_size_hint_max_set(obj, -1, -1);
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-10-06 18:23:49 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2009-10-26 01:27:08 -07:00
|
|
|
// FIXME: why is this needed? how does edje get this unswallowed or
|
|
|
|
// lose its callbacks to edje
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2009-10-26 01:27:08 -07:00
|
|
|
edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
|
2008-10-06 18:23:49 -07:00
|
|
|
_sizing_eval(data);
|
|
|
|
}
|
|
|
|
|
2008-10-06 23:55:11 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
|
2008-10-06 23:55:11 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Object *sub = event_info;
|
2010-03-09 03:42:53 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 23:55:11 -07:00
|
|
|
if (sub == wd->content)
|
|
|
|
{
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -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);
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
wd->content = NULL;
|
|
|
|
_sizing_eval(obj);
|
2008-10-06 23:55:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-29 02:11:45 -07:00
|
|
|
static void
|
|
|
|
_elm_frame_label_set(Evas_Object *obj, const char *item, const char *label)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2011-07-04 03:52:23 -07:00
|
|
|
if (item && strcmp(item, "default")) return;
|
2011-06-29 02:11:45 -07:00
|
|
|
if (!wd) return;
|
|
|
|
eina_stringshare_replace(&(wd->label), label);
|
|
|
|
edje_object_part_text_set(wd->frm, "elm.text", wd->label);
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
_elm_frame_label_get(const Evas_Object *obj, const char *item)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2011-07-04 03:52:23 -07:00
|
|
|
if (item && strcmp(item, "default")) return NULL;
|
2011-06-29 02:11:45 -07:00
|
|
|
if (!wd) return NULL;
|
|
|
|
return wd->label;
|
|
|
|
}
|
|
|
|
|
2011-10-28 21:32:24 -07:00
|
|
|
static void
|
2011-11-16 04:51:53 -08:00
|
|
|
_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
|
2011-10-28 21:32:24 -07:00
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2011-11-16 04:51:53 -08:00
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
if (part && strcmp(part, "default")) return;
|
|
|
|
wd = elm_widget_data_get(obj);
|
2011-10-28 21:32:24 -07:00
|
|
|
if (!wd) return;
|
|
|
|
if (wd->content == content) return;
|
|
|
|
if (wd->content) evas_object_del(wd->content);
|
|
|
|
wd->content = content;
|
|
|
|
if (content)
|
|
|
|
{
|
|
|
|
elm_widget_sub_object_add(obj, content);
|
|
|
|
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
|
|
|
|
}
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2011-11-16 04:51:53 -08:00
|
|
|
_content_get_hook(const Evas_Object *obj, const char *part)
|
2011-10-28 21:32:24 -07:00
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2011-11-16 04:51:53 -08:00
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
if (part && strcmp(part, "default")) return NULL;
|
|
|
|
wd = elm_widget_data_get(obj);
|
2011-10-28 21:32:24 -07:00
|
|
|
if (!wd) return NULL;
|
|
|
|
return wd->content;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2011-11-16 04:51:53 -08:00
|
|
|
_content_unset_hook(Evas_Object *obj, const char *part)
|
2011-10-28 21:32:24 -07:00
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
2011-11-16 04:51:53 -08:00
|
|
|
Widget_Data *wd;
|
2011-10-28 21:32:24 -07:00
|
|
|
Evas_Object *content;
|
2011-11-16 04:51:53 -08:00
|
|
|
if (part && strcmp(part, "default")) return NULL;
|
|
|
|
wd = elm_widget_data_get(obj);
|
2011-10-28 21:32:24 -07:00
|
|
|
if (!wd) return NULL;
|
|
|
|
if (!wd->content) return NULL;
|
|
|
|
content = wd->content;
|
|
|
|
elm_widget_sub_object_del(obj, wd->content);
|
2011-10-30 17:13:32 -07:00
|
|
|
evas_object_event_callback_del_full(wd->content,
|
|
|
|
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
2011-10-28 21:32:24 -07:00
|
|
|
edje_object_part_unswallow(wd->frm, wd->content);
|
|
|
|
wd->content = NULL;
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
2012-01-03 16:41:37 -08:00
|
|
|
static void
|
2012-01-03 17:04:00 -08:00
|
|
|
_signal_click(Evas_Object *fr, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
2012-01-03 16:41:37 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd;
|
2012-01-03 17:04:00 -08:00
|
|
|
wd = elm_widget_data_get(fr);
|
2012-01-03 16:41:37 -08:00
|
|
|
if (!wd) return;
|
2012-01-03 17:04:00 -08:00
|
|
|
evas_object_smart_callback_call(fr, SIG_CLICKED, NULL);
|
2012-01-03 16:41:37 -08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2011-03-31 23:08:02 -07:00
|
|
|
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
|
elementary - entry, genlist, gengrid, image, icon, hover, frame, diskselector, index, layout, label, conform, flip, flipselector - removed white spaces
SVN revision: 58252
2011-04-01 04:32:33 -07:00
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "frame");
|
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);
|
2010-10-06 13:24:13 -07:00
|
|
|
elm_widget_focus_next_hook_set(obj, _elm_frame_focus_next_hook);
|
2010-09-29 05:22:30 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
2011-07-04 02:18:16 -07:00
|
|
|
elm_widget_text_set_hook_set(obj, _elm_frame_label_set);
|
|
|
|
elm_widget_text_get_hook_set(obj, _elm_frame_label_get);
|
2011-10-28 21:32:24 -07:00
|
|
|
elm_widget_content_set_hook_set(obj, _content_set_hook);
|
|
|
|
elm_widget_content_get_hook_set(obj, _content_get_hook);
|
|
|
|
elm_widget_content_unset_hook_set(obj, _content_unset_hook);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
wd->frm = edje_object_add(e);
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, 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);
|
2012-01-03 17:04:00 -08:00
|
|
|
edje_object_signal_callback_add(wd->frm, "elm,action,click", "elm",
|
|
|
|
(Edje_Signal_Cb)_signal_click, obj);
|
2012-01-03 16:41:37 -08:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _signals);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2011-02-08 04:08:28 -08:00
|
|
|
_mirrored_set(obj, elm_widget_mirrored_get(obj));
|
2008-10-06 18:23:49 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_frame_label_set(Evas_Object *obj, const char *label)
|
|
|
|
{
|
2011-06-29 02:11:45 -07:00
|
|
|
_elm_frame_label_set(obj, NULL, label);
|
2008-10-06 18:23:49 -07:00
|
|
|
}
|
|
|
|
|
2010-03-09 03:42:53 -08:00
|
|
|
EAPI const char *
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_frame_label_get(const Evas_Object *obj)
|
2009-08-11 03:44:49 -07:00
|
|
|
{
|
2011-06-29 02:11:45 -07:00
|
|
|
return _elm_frame_label_get(obj, NULL);
|
2009-08-11 03:44:49 -07:00
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
|
|
|
elm_frame_content_set(Evas_Object *obj, Evas_Object *content)
|
|
|
|
{
|
2011-10-28 21:32:24 -07:00
|
|
|
_content_set_hook(obj, NULL, content);
|
2010-06-16 13:58:09 -07:00
|
|
|
}
|
|
|
|
|
2010-10-14 11:54:42 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_frame_content_get(const Evas_Object *obj)
|
|
|
|
{
|
2011-10-28 21:32:24 -07:00
|
|
|
return _content_get_hook(obj, NULL);
|
2010-10-14 11:54:42 -07:00
|
|
|
}
|
|
|
|
|
2010-06-16 13:58:09 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_frame_content_unset(Evas_Object *obj)
|
|
|
|
{
|
2011-10-28 21:32:24 -07:00
|
|
|
return _content_unset_hook(obj, NULL);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|