1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
8 Evas_Object *obj, *grd;
11 static const char *widtype = NULL;
12 static void _del_hook(Evas_Object *obj);
13 static void _theme_hook(Evas_Object *obj);
16 _del_hook(Evas_Object *obj)
18 Widget_Data *wd = elm_widget_data_get(obj);
24 _elm_grid_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
26 Widget_Data *wd = elm_widget_data_get(obj);
27 const Eina_List *items;
28 void *(*list_data_get) (const Eina_List *list);
29 Eina_List *(*list_free) (Eina_List *list);
31 if ((!wd) || (!wd->grd))
35 /* TODO: Change this to use other chain */
36 if ((items = elm_widget_focus_custom_chain_get(obj)))
38 list_data_get = eina_list_data_get;
43 items = evas_object_grid_children_get(wd->grd);
44 list_data_get = eina_list_data_get;
45 list_free = eina_list_free;
47 if (!items) return EINA_FALSE;
50 Eina_Bool ret = elm_widget_focus_list_next_get(obj, items, list_data_get,
54 list_free((Eina_List *)items);
60 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
62 Widget_Data *wd = elm_widget_data_get(obj);
63 if ((!wd) || (!wd->grd)) return;
64 evas_object_grid_mirrored_set(wd->grd, rtl);
68 _theme_hook(Evas_Object *obj)
70 _elm_widget_mirrored_reload(obj);
71 _mirrored_set(obj, elm_widget_mirrored_get(obj));
75 elm_grid_add(Evas_Object *parent)
81 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
82 ELM_SET_WIDTYPE(widtype, "grid");
83 elm_widget_type_set(obj, "grid");
84 elm_widget_sub_object_add(parent, obj);
85 elm_widget_data_set(obj, wd);
86 elm_widget_del_hook_set(obj, _del_hook);
87 elm_widget_focus_next_hook_set(obj, _elm_grid_focus_next_hook);
88 elm_widget_can_focus_set(obj, EINA_FALSE);
89 elm_widget_theme_hook_set(obj, _theme_hook);
91 wd->grd = evas_object_grid_add(e);
92 evas_object_grid_size_set(wd->grd, 100, 100);
93 elm_widget_resize_object_set(obj, wd->grd);
95 _mirrored_set(obj, elm_widget_mirrored_get(obj));
100 elm_grid_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
102 ELM_CHECK_WIDTYPE(obj, widtype);
103 Widget_Data *wd = elm_widget_data_get(obj);
105 evas_object_grid_size_set(wd->grd, w, h);
109 elm_grid_size_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
111 ELM_CHECK_WIDTYPE(obj, widtype);
112 Widget_Data *wd = elm_widget_data_get(obj);
114 evas_object_grid_size_get(wd->grd, w, h);
118 elm_grid_pack(Evas_Object *obj, Evas_Object *subobj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
120 ELM_CHECK_WIDTYPE(obj, widtype);
121 Widget_Data *wd = elm_widget_data_get(obj);
123 elm_widget_sub_object_add(obj, subobj);
124 evas_object_grid_pack(wd->grd, subobj, x, y, w, h);
128 elm_grid_unpack(Evas_Object *obj, Evas_Object *subobj)
130 ELM_CHECK_WIDTYPE(obj, widtype);
131 Widget_Data *wd = elm_widget_data_get(obj);
133 elm_widget_sub_object_del(obj, subobj);
134 evas_object_grid_unpack(wd->grd, subobj);
138 elm_grid_clear(Evas_Object *obj, Eina_Bool clear)
142 ELM_CHECK_WIDTYPE(obj, widtype);
143 Widget_Data *wd = elm_widget_data_get(obj);
145 chld = evas_object_grid_children_get(wd->grd);
146 EINA_LIST_FREE(chld, o) elm_widget_sub_object_del(obj, o);
147 evas_object_grid_clear(wd->grd, clear);
151 elm_grid_pack_set(Evas_Object *subobj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
153 Evas_Object *obj = elm_widget_parent_widget_get(subobj);
154 ELM_CHECK_WIDTYPE(obj, widtype);
155 Widget_Data *wd = elm_widget_data_get(obj);
157 evas_object_grid_pack(wd->grd, subobj, x, y, w, h);
161 elm_grid_pack_get(Evas_Object *subobj, int *x, int *y, int *w, int *h)
163 Evas_Object *obj = elm_widget_parent_widget_get(subobj);
164 ELM_CHECK_WIDTYPE(obj, widtype);
165 Widget_Data *wd = elm_widget_data_get(obj);
167 evas_object_grid_pack_get(wd->grd, subobj, x, y, w, h);
171 elm_grid_children_get(const Evas_Object *obj)
173 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
174 Widget_Data *wd = elm_widget_data_get(obj);
175 if (!wd) return NULL;
176 return evas_object_grid_children_get(wd->grd);