1 #include <Elementary.h>
5 * @defgroup Panes panes
9 typedef struct _Widget_Data Widget_Data;
28 Eina_Bool clicked_double;
33 static const char *widtype = NULL;
34 static void _del_hook(Evas_Object *obj);
35 static void _theme_hook(Evas_Object *obj);
36 static void _sizing_eval(Evas_Object *obj);
37 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
40 _del_hook(Evas_Object *obj)
42 Widget_Data *wd = elm_widget_data_get(obj);
48 _theme_hook(Evas_Object *obj)
50 Widget_Data *wd = elm_widget_data_get(obj);
51 const char *style = elm_widget_style_get(obj);
55 _elm_theme_object_set(obj, wd->panes, "panes", "horizontal", style);
57 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", style);
59 if (wd->contents.left)
60 edje_object_part_swallow(wd->panes, "elm.swallow.left", wd->contents.right);
61 if (wd->contents.right)
62 edje_object_part_swallow(wd->panes, "elm.swallow.right", wd->contents.right);
64 edje_object_scale_set(wd->panes, elm_widget_scale_get(obj) *
70 _sizing_eval(Evas_Object *obj)
72 Widget_Data *wd = elm_widget_data_get(obj);
77 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
83 _sub_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
85 Widget_Data *wd = elm_widget_data_get(obj);
86 Evas_Object *sub = event_info;
89 if (sub == wd->contents.left)
91 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
92 _changed_size_hints, obj);
93 wd->contents.left = NULL;
96 else if (sub == wd->contents.right)
98 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
99 _changed_size_hints, obj);
100 wd->contents.right= NULL;
106 _clicked(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
108 evas_object_smart_callback_call(data, "clicked", NULL);
112 _clicked_double(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
114 Widget_Data *wd = elm_widget_data_get(data);
116 wd->clicked_double = EINA_TRUE;
120 _press(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
122 evas_object_smart_callback_call(data, "press", NULL);
126 _unpress(void *data, Evas_Object *obj __UNUSED__ , const char *emission __UNUSED__, const char *source __UNUSED__)
128 Widget_Data *wd = elm_widget_data_get(data);
129 evas_object_smart_callback_call(data, "unpress", NULL);
131 if (wd->clicked_double)
133 evas_object_smart_callback_call(data, "clicked,double", NULL);
134 wd->clicked_double = EINA_FALSE;
139 * Add a new panes to the parent
141 * @param parent The parent object
142 * @return The new object or NULL if it cannot be created
147 elm_panes_add(Evas_Object *parent)
153 wd = ELM_NEW(Widget_Data);
154 e = evas_object_evas_get(parent);
155 obj = elm_widget_add(e);
156 ELM_SET_WIDTYPE(widtype, "panes");
157 elm_widget_type_set(obj, "panes");
158 elm_widget_sub_object_add(parent, obj);
159 elm_widget_data_set(obj, wd);
160 elm_widget_del_hook_set(obj, _del_hook);
161 elm_widget_theme_hook_set(obj, _theme_hook);
163 wd->panes = edje_object_add(e);
164 _elm_theme_object_set(obj, wd->panes, "panes", "vertical", "default");
165 elm_widget_resize_object_set(obj, wd->panes);
166 evas_object_show(wd->panes);
168 elm_panes_content_left_size_set(obj, 0.5);
170 edje_object_signal_callback_add(wd->panes, "elm,action,click", "",
172 edje_object_signal_callback_add(wd->panes, "elm,action,click,double", "",
173 _clicked_double, obj);
174 edje_object_signal_callback_add(wd->panes, "elm,action,press", "",
176 edje_object_signal_callback_add(wd->panes, "elm,action,unpress", "",
179 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
180 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
181 _changed_size_hints, obj);
188 * Set a control as a left/top content of the pane
190 * @param obj The pane object
191 * @param content The object to be set as content
195 EAPI void elm_panes_content_left_set(Evas_Object *obj, Evas_Object *content)
197 Widget_Data *wd = elm_widget_data_get(obj);
199 if (wd->contents.left)
201 evas_object_del(wd->contents.left);
202 wd->contents.left = NULL;
207 wd->contents.left = content;
208 elm_widget_sub_object_add(obj, content);
209 edje_object_part_swallow(wd->panes, "elm.swallow.left", content);
214 * Set a control as a right/bottom content of the pane
216 * @param obj The pane object
217 * @param content The object to be set as content
221 EAPI void elm_panes_content_right_set(Evas_Object *obj, Evas_Object *content)
223 Widget_Data *wd = elm_widget_data_get(obj);
225 if (wd->contents.right)
227 evas_object_del(wd->contents.right);
228 wd->contents.right = NULL;
233 wd->contents.right = content;
234 elm_widget_sub_object_add(obj, content);
235 edje_object_part_swallow(wd->panes, "elm.swallow.right", content);
240 * Get the left/top content of the pane
242 * @param obj The pane object
243 * @return The Evas Object set as a left/top content of the pane
248 *elm_panes_content_left_get(const Evas_Object *obj)
250 Widget_Data *wd = elm_widget_data_get(obj);
251 return wd->contents.left;
255 * Get the right/bottom content of the pane
257 * @param obj The pane object
258 * @return The Evas Object set as a right/bottom content of the pane
263 *elm_panes_content_right_get(const Evas_Object *obj)
265 Widget_Data *wd = elm_widget_data_get(obj);
266 return wd->contents.right;
270 * Get the relative normalized size of left/top content of the pane
272 * @param obj The pane object
273 * @return The value of type double in the range [0.0,1.0]
278 elm_panes_content_left_size_get(const Evas_Object *obj)
280 Widget_Data *wd = elm_widget_data_get(obj);
283 edje_object_part_drag_value_get(wd->panes, "elm.bar", &w, &h);
292 * Set a size of the left content with a relative normalized double value
294 * @param obj The pane object
295 * @param size The value of type double in the range [0.0,1.0]
300 elm_panes_content_left_size_set(Evas_Object *obj, double size)
302 Widget_Data *wd = elm_widget_data_get(obj);
305 edje_object_part_drag_value_set(wd->panes, "elm.bar", 0.0, size);
307 edje_object_part_drag_value_set(wd->panes, "elm.bar", size, 0.0);
311 * Set the type of an existing pane object to horizontal/vertical
313 * @param obj The pane object
314 * @param horizontal Boolean value. If true, then the type is set to horizontal else vertical
319 elm_panes_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
321 Widget_Data *wd = elm_widget_data_get(obj);
323 wd->horizontal = horizontal;
325 elm_panes_content_left_size_set(obj, 0.5);
329 * Indicate if the type of pane object is horizontal or not
331 * @param obj The pane object
332 * @return true if it is of horizontal type else false
337 elm_panes_horizontal_is(const Evas_Object *obj)
339 Widget_Data *wd = elm_widget_data_get(obj);
341 return wd->horizontal;
345 * Set a handler of the pane object non-movable or movable
347 * @param obj The pane object
348 * @param fixed If set to true then the views size can't be changed using handler otherwise using handler they can be resized
353 elm_panes_fixed_set(Evas_Object *obj, Eina_Bool fixed)
355 Widget_Data *wd = elm_widget_data_get(obj);
357 if(wd->fixed == EINA_TRUE)
358 edje_object_signal_emit(wd->panes, "elm.fixed", "movement.decider");
360 edje_object_signal_emit(wd->panes, "elm.unfixed", "movement.decider");
364 * Indicate if the handler of the pane object can be moved with user interaction
366 * @param obj The pane object
367 * @return false if the views can be resized using handler else true
372 elm_panes_fixed_is(const Evas_Object *obj)
374 Widget_Data *wd = elm_widget_data_get(obj);