1 #include <Elementary.h>
5 * @defgroup Panes panes
9 typedef struct _Widget_Data Widget_Data;
28 Eina_Bool clicked_double;
32 static const char *widtype = NULL;
33 static void _del_hook(Evas_Object *obj);
34 static void _theme_hook(Evas_Object *obj);
35 static void _sizing_eval(Evas_Object *obj);
36 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
39 _del_hook(Evas_Object *obj)
41 Widget_Data *wd = elm_widget_data_get(obj);
47 _theme_hook(Evas_Object *obj)
49 Widget_Data *wd = elm_widget_data_get(obj);
50 const char *style = elm_widget_style_get(obj);
54 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
56 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
58 if (wd->contents.left)
59 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.right);
60 if (wd->contents.right)
61 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
63 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
69 _sizing_eval(Evas_Object *obj)
71 Widget_Data *wd = elm_widget_data_get(obj);
76 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
82 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
84 Widget_Data *wd = elm_widget_data_get(obj);
85 Evas_Object *sub = event_info;
88 if (sub == wd->contents.left)
90 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
91 _changed_size_hints, obj);
92 wd->contents.left = NULL;
95 else if (sub == wd->contents.right)
97 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
98 _changed_size_hints, obj);
99 wd->contents.right= NULL;
105 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
107 evas_object_smart_callback_call(data, "clicked", NULL);
111 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
113 Widget_Data *wd = elm_widget_data_get(data);
115 wd->clicked_double = EINA_TRUE;
119 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
121 evas_object_smart_callback_call(data, "press", NULL);
125 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
127 Widget_Data *wd = elm_widget_data_get(data);
128 evas_object_smart_callback_call(data, "unpress", NULL);
130 if (wd->clicked_double)
132 evas_object_smart_callback_call(data, "clicked,double", NULL);
133 wd->clicked_double = EINA_FALSE;
138 * Add a new panes to the parent
140 * @param parent The parent object
141 * @return The new object or NULL if it cannot be created
146 elm_panes_add(Evas_Object *parent)
152 wd = ELM_NEW(Widget_Data);
153 e = evas_object_evas_get(parent);
154 obj = elm_widget_add(e);
155 ELM_SET_WIDTYPE(widtype, "panes");
156 elm_widget_type_set(obj, "panes");
157 elm_widget_sub_object_add(parent, obj);
158 elm_widget_data_set(obj, wd);
159 elm_widget_del_hook_set(obj, _del_hook);
160 elm_widget_theme_hook_set(obj, _theme_hook);
162 wd->panes = edje_object_add(e);
163 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
164 elm_widget_resize_object_set(obj, wd->panes);
165 evas_object_show(wd->panes);
167 elm_panes_content_left_size_set(obj, 0.5);
169 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
171 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
172 _clicked_double, obj);
173 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
175 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
178 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
179 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
180 _changed_size_hints, obj);
186 EAPI void elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
188 Widget_Data *wd = elm_widget_data_get(obj);
190 if (wd->contents.left)
192 evas_object_del(wd->contents.left);
193 wd->contents.left = NULL;
198 wd->contents.left = content;
199 elm_widget_sub_object_add(obj, content);
200 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
205 EAPI void elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
207 Widget_Data *wd = elm_widget_data_get(obj);
209 if (wd->contents.right)
211 evas_object_del(wd->contents.right);
212 wd->contents.right = NULL;
217 wd->contents.right = content;
218 elm_widget_sub_object_add(obj, content);
219 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
225 *elm_panes_content_left_get(const Evas_Object *obj)
227 Widget_Data *wd = elm_widget_data_get(obj);
228 return wd->contents.left;
232 *elm_panes_content_right_get(const Evas_Object *obj)
234 Widget_Data *wd = elm_widget_data_get(obj);
235 return wd->contents.right;
239 elm_panes_content_left_size_get(const Evas_Object *obj)
241 Widget_Data *wd = elm_widget_data_get(obj);
244 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
253 elm_panes_content_left_size_set(Evas_Object *obj, double size)
255 Widget_Data *wd = elm_widget_data_get(obj);
258 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
260 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
264 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
266 Widget_Data *wd = elm_widget_data_get(obj);
268 wd->horizontal = horizontal;
270 elm_panes_content_left_size_set(obj, 0.5);
274 elm_panes_horizontal_is(const Evas_Object *obj)
276 Widget_Data *wd = elm_widget_data_get(obj);
278 return wd->horizontal;