2009-08-21 05:25:50 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
|
|
|
Evas_Object *sep;
|
2009-08-24 00:03:11 -07:00
|
|
|
Eina_Bool horizontal;
|
2009-08-21 05:25:50 -07:00
|
|
|
};
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2009-08-21 05:25:50 -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);
|
2009-08-21 05:25:50 -07:00
|
|
|
static void _theme_hook(Evas_Object *obj);
|
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
|
|
|
|
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-08-21 05:25:50 -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->sep, rtl);
|
|
|
|
}
|
|
|
|
|
2009-08-21 05:25:50 -07:00
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -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));
|
2009-08-21 05:25:50 -07:00
|
|
|
if (wd->horizontal)
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->sep, "separator", "horizontal", elm_widget_style_get(obj));
|
2009-08-21 05:25:50 -07:00
|
|
|
else
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->sep, "separator", "vertical", elm_widget_style_get(obj));
|
2009-08-21 05:25:50 -07:00
|
|
|
edje_object_scale_set(wd->sep, elm_widget_scale_get(obj) * _elm_config->scale);
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-08-21 05:25:50 -07:00
|
|
|
edje_object_size_min_calc(wd->sep, &minw, &minh);
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
evas_object_size_hint_align_set(obj, maxw, maxh);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_separator_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
2011-03-31 23:08:02 -07:00
|
|
|
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
|
2011-04-01 04:24:15 -07:00
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "separator");
|
2009-08-26 00:46:11 -07:00
|
|
|
wd->horizontal = EINA_FALSE;
|
2009-08-21 05:25:50 -07:00
|
|
|
elm_widget_type_set(obj, "separator");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
2010-09-27 21:28:14 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
2009-08-21 05:25:50 -07:00
|
|
|
|
|
|
|
wd->sep = edje_object_add(e);
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_object_set(obj, wd->sep, "separator", "vertical", "default");
|
2009-08-21 05:25:50 -07:00
|
|
|
elm_widget_resize_object_set(obj, wd->sep);
|
2011-02-08 04:08:28 -08:00
|
|
|
_mirrored_set(obj, elm_widget_mirrored_get(obj));
|
2009-08-21 05:25:50 -07:00
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_separator_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-08-21 05:25:50 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2009-08-26 00:46:11 -07:00
|
|
|
if (!wd) return;
|
2009-08-21 05:25:50 -07:00
|
|
|
horizontal = !!horizontal;
|
|
|
|
if (wd->horizontal == horizontal) return;
|
|
|
|
wd->horizontal = horizontal;
|
|
|
|
_theme_hook(obj);
|
|
|
|
}
|
2009-08-21 06:07:15 -07:00
|
|
|
|
|
|
|
EAPI Eina_Bool
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_separator_horizontal_get(const Evas_Object *obj)
|
2009-08-21 06:07:15 -07:00
|
|
|
{
|
2010-03-09 08:46:13 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-08-21 06:07:15 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-02-11 08:13:41 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
2009-08-21 06:07:15 -07:00
|
|
|
return wd->horizontal;
|
|
|
|
}
|