[WM_ROT] support for rotating prediction window without virtual keyboard
[platform/core/uifw/e17.git] / src / bin / e_widget_list.c
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 EAPI Evas_Object *
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 = e_box_add(evas);
35    wd->o_box = o;
36    e_box_orientation_set(o, horiz);
37    e_box_homogenous_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 EAPI void
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    e_box_pack_start(wd->o_box, sobj);
64    mw = mh = 0;
65    e_widget_size_min_get(sobj, &mw, &mh);
66    if (e_box_orientation_get(wd->o_box) == 1)
67      e_box_pack_options_set(sobj,
68                             1, fill, /* fill */
69                             expand, expand, /* expand */
70                             0.5, align, /* align */
71                             mw, mh, /* min */
72                             99999, 99999 /* max */
73                             );
74    else
75      e_box_pack_options_set(sobj,
76                             fill, 1, /* fill */
77                             expand, expand, /* expand */
78                             align, 0.5, /* align */
79                             mw, mh, /* min */
80                             99999, 99999 /* max */
81                             );
82    e_box_size_min_get(wd->o_box, &mw, &mh);
83    e_widget_size_min_set(obj, mw, mh);
84    e_widget_sub_object_add(obj, sobj);
85    evas_object_show(sobj);
86 }
87
88 /**  
89  * Append a widget to the list 
90  *
91  * @param obj the list widget to append the sub widget too
92  * @param sobj the sub widget
93  * @param fill DOCUMENT ME!
94  * @param expand DOCUMENT ME! 
95  * @param align who the sub widget to be aligned, to wards the center or sides
96  * @return the new list wdiget
97  */
98 EAPI void
99 e_widget_list_object_append(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align)
100 {
101    E_Widget_Data *wd;
102    Evas_Coord mw, mh;
103
104    wd = e_widget_data_get(obj);
105
106    e_box_pack_end(wd->o_box, sobj);
107    mw = mh = 0;
108    e_widget_size_min_get(sobj, &mw, &mh);
109    if (e_box_orientation_get(wd->o_box) == 1)
110      e_box_pack_options_set(sobj,
111                             1, fill, /* fill */
112                             expand, expand, /* expand */
113                             0.5, align, /* align */
114                             mw, mh, /* min */
115                             99999, 99999 /* max */
116                             );
117    else
118      e_box_pack_options_set(sobj,
119                             fill, 1, /* fill */
120                             expand, expand, /* expand */
121                             align, 0.5, /* align */
122                             mw, mh, /* min */
123                             99999, 99999 /* max */
124                             );
125    e_box_size_min_get(wd->o_box, &mw, &mh);
126    e_widget_size_min_set(obj, mw, mh);
127    e_widget_sub_object_add(obj, sobj);
128    evas_object_show(sobj);
129 }
130
131 EAPI void
132 e_widget_list_object_repack(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align)
133 {
134    E_Widget_Data *wd;
135    Evas_Coord mw, mh;
136
137    wd = e_widget_data_get(obj);
138
139    mw = mh = 0;
140    e_widget_size_min_get(sobj, &mw, &mh);
141    if (e_box_orientation_get(wd->o_box) == 1)
142      e_box_pack_options_set(sobj,
143                             1, fill, /* fill */
144                             expand, expand, /* expand */
145                             0.5, align, /* align */
146                             mw, mh, /* min */
147                             99999, 99999 /* max */
148                             );
149    else
150      e_box_pack_options_set(sobj,
151                             fill, 1, /* fill */
152                             expand, expand, /* expand */
153                             align, 0.5, /* align */
154                             mw, mh, /* min */
155                             99999, 99999 /* max */
156                             );
157    e_box_size_min_get(wd->o_box, &mw, &mh);
158    e_widget_size_min_set(obj, mw, mh);
159 }
160
161 EAPI void
162 e_widget_list_homogeneous_set(Evas_Object *obj, int homogenous)
163 {
164    E_Widget_Data *wd = e_widget_data_get(obj);
165    e_box_homogenous_set(wd->o_box, homogenous);
166 }
167
168 static void
169 _e_wid_del_hook(Evas_Object *obj)
170 {
171    E_Widget_Data *wd;
172
173    wd = e_widget_data_get(obj);
174    free(wd);
175 }