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
|
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
typedef struct _E_Widget_Data E_Widget_Data;
struct _E_Widget_Data
{
Evas_Object *img;
int minw, minh;
};
static void _e_wid_del_hook(Evas_Object *obj);
/* local subsystem functions */
/* externally accessible functions */
EAPI Evas_Object *
e_widget_image_add_from_object(Evas *evas, Evas_Object *object, int minw, int minh)
{
Evas_Object *obj, *o;
E_Widget_Data *wd;
int mw = 0, mh = 0;
obj = e_widget_add(evas);
e_widget_del_hook_set(obj, _e_wid_del_hook);
wd = calloc(1, sizeof(E_Widget_Data));
evas_object_show(object);
o = e_icon_add(evas);
e_icon_fill_inside_set(o, 1);
e_icon_object_set(o, object);
wd->img = o;
e_widget_data_set(obj, wd);
e_widget_can_focus_set(obj, 0);
wd->minw = minw <= 0 ? minw : 0;
wd->minh = minh <= 0 ? minh : 0;
edje_object_size_min_get(object, &mw, &mh);
if (minw || minh)
e_widget_size_min_set(obj, minw, minh);
else
e_widget_size_min_set(obj, mw, mh);
e_widget_sub_object_add(obj, o);
e_widget_resize_object_set(obj, o);
return obj;
}
EAPI Evas_Object *
e_widget_image_add_from_file(Evas *evas, const char *file, int minw, int minh)
{
Evas_Object *obj, *o, *o2;
E_Widget_Data *wd;
obj = e_widget_add(evas);
wd = calloc(1, sizeof(E_Widget_Data));
o = e_icon_add(evas);
e_icon_fill_inside_set(o, 1);
o2 = evas_object_image_add(evas);
evas_object_image_file_set(o2, file, NULL);
e_icon_object_set(o, o2);
wd->img = o;
evas_object_show(o);
e_widget_data_set(obj, wd);
e_widget_can_focus_set(obj, 0);
e_widget_size_min_set(obj, minw, minh);
e_widget_sub_object_add(obj, o);
e_widget_resize_object_set(obj, o);
return obj;
}
EAPI void
e_widget_image_edje_set(Evas_Object *obj, const char *file, const char *part)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
e_icon_file_edje_set(wd->img, file, part);
evas_object_show(wd->img);
}
EAPI void
e_widget_image_file_set(Evas_Object *obj, const char *file)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
e_icon_file_set(wd->img, file);
evas_object_show(wd->img);
}
EAPI void
e_widget_image_file_key_set(Evas_Object *obj, const char *file, const char *key)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
e_icon_file_key_set(wd->img, file, key);
evas_object_show(wd->img);
}
EAPI void
e_widget_image_object_set(Evas_Object *obj, Evas_Object *o)
{
E_Widget_Data *wd;
int mw, mh;
wd = e_widget_data_get(obj);
e_icon_object_set(wd->img, o);
edje_object_size_min_get(o, &mw, &mh);
if (wd->minw || wd->minh)
e_widget_size_min_set(obj, wd->minw, wd->minh);
else
e_widget_size_min_set(obj, mw, mh);
evas_object_show(wd->img);
}
static void
_e_wid_del_hook(Evas_Object *obj)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
free(wd);
}
|