1 #include <Elementary.h>
5 * @defgroup Frame Frame
8 * This holds some content and has a title. Looks like a frame, but
9 * supports styles so multple frames are avaible
12 typedef struct _Widget_Data Widget_Data;
20 static const char *widtype = NULL;
21 static void _del_hook(Evas_Object *obj);
22 static void _theme_hook(Evas_Object *obj);
23 static void _sizing_eval(Evas_Object *obj);
24 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
25 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
28 _del_hook(Evas_Object *obj)
30 Widget_Data *wd = elm_widget_data_get(obj);
36 _theme_hook(Evas_Object *obj)
38 Widget_Data *wd = elm_widget_data_get(obj);
40 _elm_theme_object_set(obj, wd->frm, "frame", "base", elm_widget_style_get(obj));
42 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
43 edje_object_scale_set(wd->frm, elm_widget_scale_get(obj) * _elm_config->scale);
48 _sizing_eval(Evas_Object *obj)
50 Widget_Data *wd = elm_widget_data_get(obj);
51 Evas_Coord minw = -1, minh = -1;
53 edje_object_size_min_calc(wd->frm, &minw, &minh);
54 evas_object_size_hint_min_set(obj, minw, minh);
55 evas_object_size_hint_max_set(obj, -1, -1);
59 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
61 Widget_Data *wd = elm_widget_data_get(data);
62 // FIXME: why is this needed? how does edje get this unswallowed or
63 // lose its callbacks to edje
65 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
70 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
72 Widget_Data *wd = elm_widget_data_get(obj);
73 Evas_Object *sub = event_info;
75 if (sub == wd->content)
77 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
78 _changed_size_hints, obj);
85 * Add a new frame to the parent
87 * @param parent The parent object
88 * @return The new object or NULL if it cannot be created
93 elm_frame_add(Evas_Object *parent)
99 wd = ELM_NEW(Widget_Data);
100 e = evas_object_evas_get(parent);
101 obj = elm_widget_add(e);
102 ELM_SET_WIDTYPE(widtype, "frame");
103 elm_widget_type_set(obj, "frame");
104 elm_widget_sub_object_add(parent, obj);
105 elm_widget_data_set(obj, wd);
106 elm_widget_del_hook_set(obj, _del_hook);
107 elm_widget_theme_hook_set(obj, _theme_hook);
109 wd->frm = edje_object_add(e);
110 _elm_theme_object_set(obj, wd->frm, "frame", "base", "default");
111 elm_widget_resize_object_set(obj, wd->frm);
113 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
120 * Set the frame label
122 * @param obj The frame object
123 * @param label The label of this frame object
128 elm_frame_label_set(Evas_Object *obj, const char *label)
130 ELM_CHECK_WIDTYPE(obj, widtype);
131 Widget_Data *wd = elm_widget_data_get(obj);
133 edje_object_part_text_set(wd->frm, "elm.text", label);
138 * Get the frame label
140 * @param obj The frame object
142 * @return The label of this frame objet or NULL if unable to get frame
147 elm_frame_label_get(const Evas_Object *obj)
149 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
150 Widget_Data *wd = elm_widget_data_get(obj);
151 if ((!wd) || (!wd->frm)) return NULL;
152 return edje_object_part_text_get(wd->frm, "elm.text");
156 * Set the frame content
158 * @param obj The frame object
159 * @param content The content will be filled in this frame object
164 elm_frame_content_set(Evas_Object *obj, Evas_Object *content)
166 ELM_CHECK_WIDTYPE(obj, widtype);
167 Widget_Data *wd = elm_widget_data_get(obj);
169 if ((wd->content != content) && (wd->content))
170 elm_widget_sub_object_del(obj, wd->content);
171 wd->content = content;
174 elm_widget_sub_object_add(obj, content);
175 evas_object_event_callback_add(content,
176 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
177 _changed_size_hints, obj);
178 edje_object_part_swallow(wd->frm, "elm.swallow.content", content);