1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
11 static const char *widtype = NULL;
12 static void _del_hook(Evas_Object *obj);
13 static void _sizing_eval(Evas_Object *obj);
14 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
15 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
16 static void _theme_hook(Evas_Object *obj);
19 _del_pre_hook(Evas_Object *obj)
21 Widget_Data *wd = elm_widget_data_get(obj);
23 evas_object_event_callback_del_full
24 (wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
25 evas_object_del(wd->tbl);
29 _del_hook(Evas_Object *obj)
31 Widget_Data *wd = elm_widget_data_get(obj);
37 _elm_table_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
39 Widget_Data *wd = elm_widget_data_get(obj);
40 const Eina_List *items;
41 void *(*list_data_get) (const Eina_List *list);
42 Eina_List *(*list_free) (Eina_List *list);
44 if ((!wd) || (!wd->tbl))
48 /* TODO: Change this to use other chain */
49 if ((items = elm_widget_focus_custom_chain_get(obj)))
51 list_data_get = eina_list_data_get;
56 items = evas_object_table_children_get(wd->tbl);
57 list_data_get = eina_list_data_get;
58 list_free = eina_list_free;
60 if (!items) return EINA_FALSE;
63 Eina_Bool ret = elm_widget_focus_list_next_get(obj, items, list_data_get,
67 list_free((Eina_List *)items);
73 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
75 Widget_Data *wd = elm_widget_data_get(obj);
76 if ((!wd) || (!wd->tbl))
79 evas_object_table_mirrored_set(wd->tbl, rtl);
83 _theme_hook(Evas_Object *obj)
85 _elm_widget_mirrored_reload(obj);
86 _mirrored_set(obj, elm_widget_mirrored_get(obj));
90 _sizing_eval(Evas_Object *obj)
92 Widget_Data *wd = elm_widget_data_get(obj);
93 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
96 evas_object_size_hint_min_get(wd->tbl, &minw, &minh);
97 evas_object_size_hint_max_get(wd->tbl, &maxw, &maxh);
98 evas_object_size_hint_min_set(obj, minw, minh);
99 evas_object_size_hint_max_set(obj, maxw, maxh);
100 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
101 if (w < minw) w = minw;
102 if (h < minh) h = minh;
103 if ((maxw >= 0) && (w > maxw)) w = maxw;
104 if ((maxh >= 0) && (h > maxh)) h = maxh;
105 evas_object_resize(obj, w, h);
109 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
115 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
121 elm_table_add(Evas_Object *parent)
127 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
129 ELM_SET_WIDTYPE(widtype, "table");
130 elm_widget_type_set(obj, "table");
131 elm_widget_sub_object_add(parent, obj);
132 elm_widget_data_set(obj, wd);
133 elm_widget_del_hook_set(obj, _del_hook);
134 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
135 elm_widget_focus_next_hook_set(obj, _elm_table_focus_next_hook);
136 elm_widget_can_focus_set(obj, EINA_FALSE);
137 elm_widget_highlight_ignore_set(obj, EINA_FALSE);
138 elm_widget_theme_hook_set(obj, _theme_hook);
140 wd->tbl = evas_object_table_add(e);
141 evas_object_event_callback_add(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
142 _changed_size_hints, obj);
143 elm_widget_resize_object_set(obj, wd->tbl);
145 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
147 _mirrored_set(obj, elm_widget_mirrored_get(obj));
152 elm_table_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
154 ELM_CHECK_WIDTYPE(obj, widtype);
155 Widget_Data *wd = elm_widget_data_get(obj);
157 evas_object_table_homogeneous_set(wd->tbl, homogeneous);
161 elm_table_homogeneous_get(const Evas_Object *obj)
163 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
164 Widget_Data *wd = elm_widget_data_get(obj);
165 if (!wd) return EINA_FALSE;
166 return evas_object_table_homogeneous_get(wd->tbl);
170 elm_table_padding_set(Evas_Object *obj, Evas_Coord horizontal, Evas_Coord vertical)
172 ELM_CHECK_WIDTYPE(obj, widtype);
173 Widget_Data *wd = elm_widget_data_get(obj);
175 evas_object_table_padding_set(wd->tbl, horizontal, vertical);
179 elm_table_padding_get(const Evas_Object *obj, Evas_Coord *horizontal, Evas_Coord *vertical)
181 ELM_CHECK_WIDTYPE(obj, widtype);
182 Widget_Data *wd = elm_widget_data_get(obj);
184 evas_object_table_padding_get(wd->tbl, horizontal, vertical);
188 elm_table_pack(Evas_Object *obj, Evas_Object *subobj, int x, int y, int w, int h)
190 ELM_CHECK_WIDTYPE(obj, widtype);
191 Widget_Data *wd = elm_widget_data_get(obj);
193 elm_widget_sub_object_add(obj, subobj);
194 evas_object_table_pack(wd->tbl, subobj, x, y, w, h);
198 elm_table_unpack(Evas_Object *obj, Evas_Object *subobj)
200 ELM_CHECK_WIDTYPE(obj, widtype);
201 Widget_Data *wd = elm_widget_data_get(obj);
203 elm_widget_sub_object_del(obj, subobj);
204 evas_object_table_unpack(wd->tbl, subobj);
208 elm_table_pack_set(Evas_Object *subobj, int x, int y, int w, int h)
210 Evas_Object *obj = elm_widget_parent_widget_get(subobj);
211 ELM_CHECK_WIDTYPE(obj, widtype);
212 Widget_Data *wd = elm_widget_data_get(obj);
214 evas_object_table_pack(wd->tbl, subobj, x, y, w, h);
218 elm_table_pack_get(Evas_Object *subobj, int *x, int *y, int *w, int *h)
220 Evas_Object *obj = elm_widget_parent_widget_get(subobj);
221 unsigned short ix, iy, iw, ih;
222 ELM_CHECK_WIDTYPE(obj, widtype);
223 Widget_Data *wd = elm_widget_data_get(obj);
225 evas_object_table_pack_get(wd->tbl, subobj, &ix, &iy, &iw, &ih);
233 elm_table_clear(Evas_Object *obj, Eina_Bool clear)
237 ELM_CHECK_WIDTYPE(obj, widtype);
238 Widget_Data *wd = elm_widget_data_get(obj);
240 chld = evas_object_table_children_get(wd->tbl);
241 EINA_LIST_FREE(chld, o) elm_widget_sub_object_del(obj, o);
242 evas_object_table_clear(wd->tbl, clear);