1 #include "e.h"
2
3 typedef struct _E_Widget_Data E_Widget_Data;
4 struct _E_Widget_Data
5 {
6 Evas_Object *o_box;
7 };
8
9 static void _e_wid_del_hook(Evas_Object *obj);
10
11 /* local subsystem functions */
12
13 /* externally accessible functions */
14 /**
15 * Creates a new list widget
16 *
17 * @param evas the evas pointer
18 * @param homogenous should widgets append to the list be evenly spaced out
19 * @param horiz the direction the list should be displayed
20 * @return the new list wdiget
21 */
22 E_API Evas_Object *
e_widget_list_add(Evas * evas,int homogenous,int horiz)23 e_widget_list_add(Evas *evas, int homogenous, int horiz)
24 {
25 Evas_Object *obj, *o;
26 E_Widget_Data *wd;
27
28 obj = e_widget_add(evas);
29
30 e_widget_del_hook_set(obj, _e_wid_del_hook);
31 wd = calloc(1, sizeof(E_Widget_Data));
32 e_widget_data_set(obj, wd);
33
34 o = elm_box_add(e_win_evas_win_get(evas));
35 wd->o_box = o;
36 elm_box_horizontal_set(o, horiz);
37 elm_box_homogeneous_set(o, homogenous);
38 evas_object_show(o);
39 e_widget_sub_object_add(obj, o);
40 e_widget_resize_object_set(obj, o);
41
42 return obj;
43 }
44
45 /**
46 * Prepend a widget to the list
47 *
48 * @param obj the list widget to prepend the sub widget too
49 * @param sobj the sub widget
50 * @param fill DOCUMENT ME!
51 * @param expand DOCUMENT ME!
52 * @param align who the sub widget to be aligned, to wards the center or sides
53 * @return the new list wdiget
54 */
55 E_API void
e_widget_list_object_prepend(Evas_Object * obj,Evas_Object * sobj,int fill,int expand,double align)56 e_widget_list_object_prepend(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align)
57 {
58 E_Widget_Data *wd;
59 Evas_Coord mw, mh;
60
61 wd = e_widget_data_get(obj);
62
63 mw = mh = 0;
64 if (fill) align = -1;
65 if (elm_box_horizontal_get(wd->o_box) == 1)
66 {
67 E_ALIGN(sobj, -1, align);
68 E_WEIGHT(sobj, expand, 1);
69 }
70 else
71 {
72 E_ALIGN(sobj, align, -1);
73 E_WEIGHT(sobj, 1, expand);
74 }
75 elm_box_pack_start(wd->o_box, sobj);
76 elm_box_recalculate(wd->o_box);
77 evas_object_size_hint_min_get(wd->o_box, &mw, &mh);
78 e_widget_size_min_set(obj, mw, mh);
79 e_widget_sub_object_add(obj, sobj);
80 evas_object_show(sobj);
81 }
82
83 /**
84 * Append a widget to the list
85 *
86 * @param obj the list widget to append the sub widget too
87 * @param sobj the sub widget
88 * @param fill DOCUMENT ME!
89 * @param expand DOCUMENT ME!
90 * @param align who the sub widget to be aligned, to wards the center or sides
91 * @return the new list wdiget
92 */
93 E_API void
e_widget_list_object_append(Evas_Object * obj,Evas_Object * sobj,int fill,int expand,double align)94 e_widget_list_object_append(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align)
95 {
96 E_Widget_Data *wd;
97 Evas_Coord mw, mh;
98
99 wd = e_widget_data_get(obj);
100
101 mw = mh = 0;
102 if (fill) align = -1;
103 if (elm_box_horizontal_get(wd->o_box) == 1)
104 {
105 E_ALIGN(sobj, -1, align);
106 E_WEIGHT(sobj, expand, 1);
107 }
108 else
109 {
110 E_ALIGN(sobj, align, -1);
111 E_WEIGHT(sobj, 1, expand);
112 }
113 elm_box_pack_end(wd->o_box, sobj);
114 elm_box_recalculate(wd->o_box);
115 evas_object_size_hint_min_get(wd->o_box, &mw, &mh);
116 e_widget_size_min_set(obj, mw, mh);
117 e_widget_sub_object_add(obj, sobj);
118 evas_object_show(sobj);
119 }
120
121 E_API void
e_widget_list_object_repack(Evas_Object * obj,Evas_Object * sobj,int fill,int expand,double align)122 e_widget_list_object_repack(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align)
123 {
124 E_Widget_Data *wd;
125 Evas_Coord mw, mh;
126
127 wd = e_widget_data_get(obj);
128
129 mw = mh = 0;
130 if (fill) align = -1;
131 if (elm_box_horizontal_get(wd->o_box) == 1)
132 {
133 E_ALIGN(sobj, -1, align);
134 E_WEIGHT(sobj, expand, 1);
135 }
136 else
137 {
138 E_ALIGN(sobj, align, -1);
139 E_WEIGHT(sobj, 1, expand);
140 }
141 elm_box_recalculate(wd->o_box);
142 evas_object_size_hint_min_get(wd->o_box, &mw, &mh);
143 e_widget_size_min_set(obj, mw, mh);
144 }
145
146 E_API void
e_widget_list_homogeneous_set(Evas_Object * obj,int homogenous)147 e_widget_list_homogeneous_set(Evas_Object *obj, int homogenous)
148 {
149 E_Widget_Data *wd = e_widget_data_get(obj);
150 elm_box_homogeneous_set(wd->o_box, homogenous);
151 }
152
153 static void
_e_wid_del_hook(Evas_Object * obj)154 _e_wid_del_hook(Evas_Object *obj)
155 {
156 E_Widget_Data *wd;
157
158 wd = e_widget_data_get(obj);
159 free(wd);
160 }
161
162