1 #include <Elementary.h>
5 * @defgroup Frame Frame
7 * This holds some content and has a title. Looks like a frame, but
8 * supports styles so multple frames are avaible
11 typedef struct _Widget_Data Widget_Data;
19 static const char *widtype = NULL;
20 static void _del_hook(Evas_Object *obj);
21 static void _theme_hook(Evas_Object *obj);
22 static void _sizing_eval(Evas_Object *obj);
23 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
24 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
27 _del_hook(Evas_Object *obj)
29 Widget_Data *wd = elm_widget_data_get(obj);
35 _theme_hook(Evas_Object *obj)
37 Widget_Data *wd = elm_widget_data_get(obj);
39 _elm_theme_object_set(obj, wd->frm, "frame", "base", elm_widget_style_get(obj));
41 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
42 edje_object_scale_set(wd->frm, elm_widget_scale_get(obj) * _elm_config->scale);
47 _sizing_eval(Evas_Object *obj)
49 Widget_Data *wd = elm_widget_data_get(obj);
50 Evas_Coord minw = -1, minh = -1;
52 edje_object_size_min_calc(wd->frm, &minw, &minh);
53 evas_object_size_hint_min_set(obj, minw, minh);
54 evas_object_size_hint_max_set(obj, -1, -1);
58 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
60 Widget_Data *wd = elm_widget_data_get(data);
61 // FIXME: why is this needed? how does edje get this unswallowed or
62 // lose its callbacks to edje
64 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
69 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
71 Widget_Data *wd = elm_widget_data_get(obj);
72 Evas_Object *sub = event_info;
74 if (sub == wd->content)
76 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
77 _changed_size_hints, obj);
84 * Add a new frame to the parent
86 * @param parent The parent object
87 * @return The new object or NULL if it cannot be created
92 elm_frame_add(Evas_Object *parent)
98 wd = ELM_NEW(Widget_Data);
99 e = evas_object_evas_get(parent);
100 obj = elm_widget_add(e);
101 ELM_SET_WIDTYPE(widtype, "frame");
102 elm_widget_type_set(obj, "frame");
103 elm_widget_sub_object_add(parent, obj);
104 elm_widget_data_set(obj, wd);
105 elm_widget_del_hook_set(obj, _del_hook);
106 elm_widget_theme_hook_set(obj, _theme_hook);
108 wd->frm = edje_object_add(e);
109 _elm_theme_object_set(obj, wd->frm, "frame", "base", "default");
110 elm_widget_resize_object_set(obj, wd->frm);
112 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
119 * Set the frame label
121 * @param obj The frame object
122 * @param label The label of this frame object
127 elm_frame_label_set(Evas_Object *obj, const char *label)
129 ELM_CHECK_WIDTYPE(obj, widtype);
130 Widget_Data *wd = elm_widget_data_get(obj);
132 edje_object_part_text_set(wd->frm, "elm.text", label);
137 * Get the frame label
139 * @param obj The frame object
141 * @return The label of this frame objet or NULL if unable to get frame
146 elm_frame_label_get(const Evas_Object *obj)
148 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
149 Widget_Data *wd = elm_widget_data_get(obj);
150 if ((!wd) || (!wd->frm)) return NULL;
151 return edje_object_part_text_get(wd->frm, "elm.text");
155 * Set the frame content
157 * @param obj The frame object
158 * @param content The content will be filled in this frame object
163 elm_frame_content_set(Evas_Object *obj, Evas_Object *content)
165 ELM_CHECK_WIDTYPE(obj, widtype);
166 Widget_Data *wd = elm_widget_data_get(obj);
168 if ((wd->content != content) && (wd->content))
169 elm_widget_sub_object_del(obj, wd->content);
170 wd->content = content;
173 elm_widget_sub_object_add(obj, content);
174 evas_object_event_callback_add(content,
175 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
176 _changed_size_hints, obj);
177 edje_object_part_swallow(wd->frm, "elm.swallow.content", content);