summaryrefslogtreecommitdiff
path: root/src/bin/e_widget_list.c
blob: c84fb6dcad2b35fa4ea6622cd933bbba946e8e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include "e.h"

typedef struct _E_Widget_Data E_Widget_Data;
struct _E_Widget_Data
{
   Evas_Object *o_box;
};

static void _e_wid_del_hook(Evas_Object *obj);

/* local subsystem functions */

/* externally accessible functions */
/**
 * Creates a new list widget
 *
 * @param evas the evas pointer
 * @param  homogenous should widgets append to the list be evenly spaced out
 * @param horiz the direction the list should be displayed
 * @return the new list wdiget
 */
EAPI Evas_Object *
e_widget_list_add(Evas *evas, int homogenous, int horiz)
{
   Evas_Object *obj, *o;
   E_Widget_Data *wd;

   obj = e_widget_add(evas);

   e_widget_del_hook_set(obj, _e_wid_del_hook);
   wd = calloc(1, sizeof(E_Widget_Data));
   e_widget_data_set(obj, wd);

   o = e_box_add(evas);
   wd->o_box = o;
   e_box_orientation_set(o, horiz);
   e_box_homogenous_set(o, homogenous);
   evas_object_show(o);
   e_widget_sub_object_add(obj, o);
   e_widget_resize_object_set(obj, o);

   return obj;
}

/**
 * Prepend a widget to the list
 *
 * @param obj the list widget to prepend the sub widget too
 * @param sobj the sub widget
 * @param fill DOCUMENT ME!
 * @param expand DOCUMENT ME!
 * @param align who the sub widget to be aligned, to wards the center or sides
 * @return the new list wdiget
 */
EAPI void
e_widget_list_object_prepend(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align)
{
   E_Widget_Data *wd;
   Evas_Coord mw, mh;

   wd = e_widget_data_get(obj);

   e_box_pack_start(wd->o_box, sobj);
   mw = mh = 0;
   e_widget_size_min_get(sobj, &mw, &mh);
   if (e_box_orientation_get(wd->o_box) == 1)
     e_box_pack_options_set(sobj,
                            1, fill, /* fill */
                            expand, expand, /* expand */
                            0.5, align, /* align */
                            mw, mh, /* min */
                            99999, 99999 /* max */
                            );
   else
     e_box_pack_options_set(sobj,
                            fill, 1, /* fill */
                            expand, expand, /* expand */
                            align, 0.5, /* align */
                            mw, mh, /* min */
                            99999, 99999 /* max */
                            );
   e_box_size_min_get(wd->o_box, &mw, &mh);
   e_widget_size_min_set(obj, mw, mh);
   e_widget_sub_object_add(obj, sobj);
   evas_object_show(sobj);
}

/**
 * Append a widget to the list
 *
 * @param obj the list widget to append the sub widget too
 * @param sobj the sub widget
 * @param fill DOCUMENT ME!
 * @param expand DOCUMENT ME!
 * @param align who the sub widget to be aligned, to wards the center or sides
 * @return the new list wdiget
 */
EAPI void
e_widget_list_object_append(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align)
{
   E_Widget_Data *wd;
   Evas_Coord mw, mh;

   wd = e_widget_data_get(obj);

   e_box_pack_end(wd->o_box, sobj);
   mw = mh = 0;
   e_widget_size_min_get(sobj, &mw, &mh);
   if (e_box_orientation_get(wd->o_box) == 1)
     e_box_pack_options_set(sobj,
                            1, fill, /* fill */
                            expand, expand, /* expand */
                            0.5, align, /* align */
                            mw, mh, /* min */
                            99999, 99999 /* max */
                            );
   else
     e_box_pack_options_set(sobj,
                            fill, 1, /* fill */
                            expand, expand, /* expand */
                            align, 0.5, /* align */
                            mw, mh, /* min */
                            99999, 99999 /* max */
                            );
   e_box_size_min_get(wd->o_box, &mw, &mh);
   e_widget_size_min_set(obj, mw, mh);
   e_widget_sub_object_add(obj, sobj);
   evas_object_show(sobj);
}

EAPI void
e_widget_list_object_repack(Evas_Object *obj, Evas_Object *sobj, int fill, int expand, double align)
{
   E_Widget_Data *wd;
   Evas_Coord mw, mh;

   wd = e_widget_data_get(obj);

   mw = mh = 0;
   e_widget_size_min_get(sobj, &mw, &mh);
   if (e_box_orientation_get(wd->o_box) == 1)
     e_box_pack_options_set(sobj,
                            1, fill, /* fill */
                            expand, expand, /* expand */
                            0.5, align, /* align */
                            mw, mh, /* min */
                            99999, 99999 /* max */
                            );
   else
     e_box_pack_options_set(sobj,
                            fill, 1, /* fill */
                            expand, expand, /* expand */
                            align, 0.5, /* align */
                            mw, mh, /* min */
                            99999, 99999 /* max */
                            );
   e_box_size_min_get(wd->o_box, &mw, &mh);
   e_widget_size_min_set(obj, mw, mh);
}

EAPI void
e_widget_list_homogeneous_set(Evas_Object *obj, int homogenous)
{
   E_Widget_Data *wd = e_widget_data_get(obj);
   e_box_homogenous_set(wd->o_box, homogenous);
}

static void
_e_wid_del_hook(Evas_Object *obj)
{
   E_Widget_Data *wd;

   wd = e_widget_data_get(obj);
   free(wd);
}