2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
typedef struct _Widget_Data Widget_Data;
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
struct _Widget_Data
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
Evas_Object *tbl;
|
2008-09-29 23:58:56 -07:00
|
|
|
};
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2008-10-06 18:23:49 -07:00
|
|
|
static void _del_hook(Evas_Object *obj);
|
|
|
|
static void _sizing_eval(Evas_Object *obj);
|
2008-10-06 23:55:11 -07:00
|
|
|
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
2011-02-08 04:08:28 -08:00
|
|
|
static void _theme_hook(Evas_Object *obj);
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2009-10-26 03:11:14 -07:00
|
|
|
static void
|
|
|
|
_del_pre_hook(Evas_Object *obj)
|
|
|
|
{
|
2010-03-09 16:31:54 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
|
2009-11-13 14:22:05 -08:00
|
|
|
evas_object_del(wd->tbl);
|
2009-10-26 03:11:14 -07:00
|
|
|
}
|
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
static void
|
2008-10-06 18:23:49 -07:00
|
|
|
_del_hook(Evas_Object *obj)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 18:23:49 -07:00
|
|
|
free(wd);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2010-09-27 14:13:36 -07:00
|
|
|
static Eina_Bool
|
2010-10-06 13:24:19 -07:00
|
|
|
_elm_table_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
|
2010-09-27 14:13:36 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-10-06 13:24:19 -07:00
|
|
|
const Eina_List *items;
|
2010-09-27 14:13:36 -07:00
|
|
|
void *(*list_data_get) (const Eina_List *list);
|
|
|
|
Eina_List *(*list_free) (Eina_List *list);
|
|
|
|
|
|
|
|
if ((!wd) || (!wd->tbl))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
/* Focus chain */
|
|
|
|
/* TODO: Change this to use other chain */
|
2010-10-06 13:24:22 -07:00
|
|
|
if ((items = elm_widget_focus_custom_chain_get(obj)))
|
2010-09-27 14:13:36 -07:00
|
|
|
{
|
|
|
|
list_data_get = eina_list_data_get;
|
2010-10-06 13:24:22 -07:00
|
|
|
list_free = NULL;
|
2010-09-27 14:13:36 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-06 13:24:22 -07:00
|
|
|
items = evas_object_table_children_get(wd->tbl);
|
2010-09-27 14:13:36 -07:00
|
|
|
list_data_get = eina_list_data_get;
|
2010-10-06 13:24:22 -07:00
|
|
|
list_free = eina_list_free;
|
2010-09-27 14:13:36 -07:00
|
|
|
|
|
|
|
if (!items) return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2010-10-06 13:24:13 -07:00
|
|
|
Eina_Bool ret = elm_widget_focus_list_next_get(obj, items, list_data_get,
|
2010-10-06 13:24:09 -07:00
|
|
|
dir, next);
|
2010-09-27 14:13:36 -07:00
|
|
|
|
|
|
|
if (list_free)
|
2010-10-14 07:10:33 -07:00
|
|
|
list_free((Eina_List *)items);
|
2010-09-27 14:13:36 -07:00
|
|
|
|
2010-10-06 13:24:09 -07:00
|
|
|
return ret;
|
2010-09-27 14:13:36 -07:00
|
|
|
}
|
|
|
|
|
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) || (!wd->tbl))
|
|
|
|
return;
|
|
|
|
|
|
|
|
evas_object_table_mirrored_set(wd->tbl, rtl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
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));
|
|
|
|
}
|
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
static void
|
2008-10-06 18:23:49 -07:00
|
|
|
_sizing_eval(Evas_Object *obj)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
|
|
|
Evas_Coord w, h;
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 18:23:49 -07:00
|
|
|
evas_object_size_hint_min_get(wd->tbl, &minw, &minh);
|
|
|
|
evas_object_size_hint_max_get(wd->tbl, &maxw, &maxh);
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
|
|
|
if (w < minw) w = minw;
|
|
|
|
if (h < minh) h = minh;
|
|
|
|
if ((maxw >= 0) && (w > maxw)) w = maxw;
|
|
|
|
if ((maxh >= 0) && (h > maxh)) h = maxh;
|
|
|
|
evas_object_resize(obj, w, h);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
2008-10-06 18:23:49 -07:00
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
_sizing_eval(data);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2008-10-06 23:55:11 -07:00
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2008-10-06 23:55:11 -07:00
|
|
|
{
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_table_add(Evas_Object *parent)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2008-10-06 18:23:49 -07:00
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2011-03-31 23:08:02 -07:00
|
|
|
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "table");
|
2009-05-13 05:21:52 -07:00
|
|
|
elm_widget_type_set(obj, "table");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
2009-10-26 03:11:14 -07:00
|
|
|
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
|
2010-10-06 13:24:13 -07:00
|
|
|
elm_widget_focus_next_hook_set(obj, _elm_table_focus_next_hook);
|
2010-09-27 14:13:36 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
|
|
|
elm_widget_highlight_ignore_set(obj, EINA_FALSE);
|
2011-02-08 04:08:28 -08:00
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2009-09-28 12:43:56 -07:00
|
|
|
wd->tbl = evas_object_table_add(e);
|
2008-10-06 18:23:49 -07:00
|
|
|
evas_object_event_callback_add(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
2011-04-01 04:20:18 -07:00
|
|
|
_changed_size_hints, obj);
|
2008-10-06 18:23:49 -07:00
|
|
|
elm_widget_resize_object_set(obj, wd->tbl);
|
2008-10-06 23:55:11 -07:00
|
|
|
|
|
|
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2011-02-08 04:08:28 -08:00
|
|
|
_mirrored_set(obj, elm_widget_mirrored_get(obj));
|
2008-10-06 18:23:49 -07:00
|
|
|
return obj;
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
2011-05-03 21:53:39 -07:00
|
|
|
elm_table_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2011-05-03 21:53:39 -07:00
|
|
|
evas_object_table_homogeneous_set(wd->tbl, homogeneous);
|
|
|
|
}
|
|
|
|
|
2010-11-10 03:36:58 -08:00
|
|
|
EAPI Eina_Bool
|
2011-05-03 21:53:39 -07:00
|
|
|
elm_table_homogeneous_get(const Evas_Object *obj)
|
2010-11-10 03:36:58 -08:00
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return EINA_FALSE;
|
|
|
|
return evas_object_table_homogeneous_get(wd->tbl);
|
|
|
|
}
|
|
|
|
|
2009-10-22 15:07:02 -07:00
|
|
|
EAPI void
|
|
|
|
elm_table_padding_set(Evas_Object *obj, Evas_Coord horizontal, Evas_Coord vertical)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-10-22 15:07:02 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2009-10-22 15:07:02 -07:00
|
|
|
evas_object_table_padding_set(wd->tbl, horizontal, vertical);
|
|
|
|
}
|
|
|
|
|
2010-11-10 03:36:58 -08:00
|
|
|
EAPI void
|
|
|
|
elm_table_padding_get(const Evas_Object *obj, Evas_Coord *horizontal, Evas_Coord *vertical)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
evas_object_table_padding_get(wd->tbl, horizontal, vertical);
|
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI void
|
|
|
|
elm_table_pack(Evas_Object *obj, Evas_Object *subobj, int x, int y, int w, int h)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2008-10-06 18:23:49 -07:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2008-10-06 18:23:49 -07:00
|
|
|
elm_widget_sub_object_add(obj, subobj);
|
2009-09-28 12:43:56 -07:00
|
|
|
evas_object_table_pack(wd->tbl, subobj, x, y, w, h);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
2010-02-11 19:50:19 -08:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_table_unpack(Evas_Object *obj, Evas_Object *subobj)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2010-02-11 19:50:19 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2010-02-11 19:50:19 -08:00
|
|
|
elm_widget_sub_object_del(obj, subobj);
|
|
|
|
evas_object_table_unpack(wd->tbl, subobj);
|
|
|
|
}
|
|
|
|
|
2011-06-17 04:36:08 -07:00
|
|
|
EAPI void
|
|
|
|
elm_table_pack_set(Evas_Object *subobj, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = elm_widget_parent_widget_get(subobj);
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
evas_object_table_pack(wd->tbl, subobj, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_table_pack_get(Evas_Object *subobj, int *x, int *y, int *w, int *h)
|
|
|
|
{
|
|
|
|
Evas_Object *obj = elm_widget_parent_widget_get(subobj);
|
|
|
|
unsigned short ix, iy, iw, ih;
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return;
|
|
|
|
evas_object_table_pack_get(wd->tbl, subobj, &ix, &iy, &iw, &ih);
|
|
|
|
if (x) *x = ix;
|
|
|
|
if (y) *y = iy;
|
|
|
|
if (w) *w = iw;
|
|
|
|
if (h) *h = ih;
|
|
|
|
}
|
|
|
|
|
2010-02-11 19:50:19 -08:00
|
|
|
EAPI void
|
|
|
|
elm_table_clear(Evas_Object *obj, Eina_Bool clear)
|
|
|
|
{
|
2011-05-18 00:04:51 -07:00
|
|
|
Eina_List *chld;
|
|
|
|
Evas_Object *o;
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2010-02-11 19:50:19 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 16:31:54 -08:00
|
|
|
if (!wd) return;
|
2011-05-18 00:04:51 -07:00
|
|
|
chld = evas_object_table_children_get(wd->tbl);
|
|
|
|
EINA_LIST_FREE(chld, o) elm_widget_sub_object_del(obj, o);
|
2010-02-11 19:50:19 -08:00
|
|
|
evas_object_table_clear(wd->tbl, clear);
|
|
|
|
}
|