summaryrefslogtreecommitdiff
path: root/src/edje_externals/elm_entry.c
diff options
context:
space:
mode:
authorMichael BOUCHAUD <michael.bouchaud@gmail.com>2011-07-05 10:33:24 +0000
committerMichael BOUCHAUD <michael.bouchaud@gmail.com>2011-07-05 10:33:24 +0000
commita0afbccf3a75d460b00b74cfb82bb26056c06f02 (patch)
treeba720c266aca809bd9e2b78d52bad9f608141fe2 /src/edje_externals/elm_entry.c
parentc452968e441d3b9d55d8978c50d0096325038797 (diff)
elementary: add entry widget in edje_external
SVN revision: 61037
Diffstat (limited to 'src/edje_externals/elm_entry.c')
-rw-r--r--src/edje_externals/elm_entry.c322
1 files changed, 322 insertions, 0 deletions
diff --git a/src/edje_externals/elm_entry.c b/src/edje_externals/elm_entry.c
new file mode 100644
index 000000000..94f4734c3
--- /dev/null
+++ b/src/edje_externals/elm_entry.c
@@ -0,0 +1,322 @@
1#include "private.h"
2
3typedef struct _Elm_Params_Entry
4{
5 Elm_Params base;
6 const char *label;
7 const char *entry;
8 Evas_Object *icon;
9 Eina_Bool scrollable:1;
10 Eina_Bool scrollable_exists:1;
11 Eina_Bool single_line:1;
12 Eina_Bool single_line_exists:1;
13 Eina_Bool password:1;
14 Eina_Bool password_exists:1;
15 Eina_Bool horizontal_bounce:1;
16 Eina_Bool horizontal_bounce_exists:1;
17 Eina_Bool vertical_bounce:1;
18 Eina_Bool vertical_bounce_exists:1;
19 Eina_Bool editable:1;
20 Eina_Bool editable_exists:1;
21} Elm_Params_Entry;
22
23static void
24external_entry_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
25{
26 const Elm_Params_Entry *p;
27 Eina_Bool hbounce, vbounce;
28
29 if (to_params) p = to_params;
30 else if (from_params) p = from_params;
31 else return;
32
33 if (p->label)
34 elm_object_text_set(obj, p->label);
35 if (p->icon)
36 elm_entry_icon_set(obj, p->icon);
37 if (p->entry)
38 elm_entry_entry_set(obj, p->entry);
39 if (p->scrollable_exists)
40 elm_entry_scrollable_set(obj, p->scrollable);
41 if (p->single_line_exists)
42 elm_entry_single_line_set(obj, p->single_line);
43 if (p->password_exists)
44 elm_entry_password_set(obj, p->password);
45 if (p->horizontal_bounce_exists && p->vertical_bounce_exists)
46 elm_entry_bounce_set(obj, p->horizontal_bounce, p->vertical_bounce);
47 else if (p->horizontal_bounce_exists || p->vertical_bounce_exists)
48 {
49 elm_entry_bounce_get(obj, &hbounce, &vbounce);
50 if (p->horizontal_bounce_exists)
51 elm_entry_bounce_set(obj, p->horizontal_bounce, vbounce);
52 else
53 elm_entry_bounce_set(obj, hbounce, p->vertical_bounce);
54 }
55 if (p->editable_exists)
56 elm_entry_editable_set(obj, p->editable);
57}
58
59static Eina_Bool
60external_entry_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
61{
62 if (!strcmp(param->name, "label"))
63 {
64 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
65 {
66 elm_object_text_set(obj, param->s);
67 return EINA_TRUE;
68 }
69 }
70 else if (!strcmp(param->name, "icon"))
71 {
72 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
73 {
74 Evas_Object *icon = external_common_param_icon_get(obj, param);
75 elm_entry_icon_set(obj, icon);
76 return EINA_TRUE;
77 }
78 }
79 else if (!strcmp(param->name, "entry"))
80 {
81 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
82 {
83 elm_entry_entry_set(obj, param->s);
84 return EINA_TRUE;
85 }
86 }
87 else if (!strcmp(param->name, "scrollable"))
88 {
89 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
90 {
91 elm_entry_scrollable_set(obj, param->i);
92 return EINA_TRUE;
93 }
94 }
95 else if (!strcmp(param->name, "single line"))
96 {
97 if(param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
98 {
99 elm_entry_single_line_set(obj, param->i);
100 return EINA_TRUE;
101 }
102 }
103 else if (!strcmp(param->name, "password"))
104 {
105 if(param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
106 {
107 elm_entry_password_set(obj, param->i);
108 return EINA_TRUE;
109 }
110 }
111 else if (!strcmp(param->name, "horizontal bounce"))
112 {
113 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
114 {
115 Eina_Bool hbounce, vbounce;
116 elm_entry_bounce_get(obj, NULL, &vbounce);
117 hbounce = !!param->i;
118 elm_entry_bounce_set(obj, hbounce, vbounce);
119 return EINA_TRUE;
120 }
121 }
122 else if (!strcmp(param->name, "vertical bounce"))
123 {
124 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
125 {
126 Eina_Bool hbounce, vbounce;
127 elm_entry_bounce_get(obj, &hbounce, NULL);
128 vbounce = !!param->i;
129 elm_entry_bounce_set(obj, hbounce, vbounce);
130 return EINA_TRUE;
131 }
132 }
133 else if (!strcmp(param->name, "editable"))
134 {
135 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
136 {
137 elm_entry_editable_set(obj, param->i);
138 return EINA_TRUE;
139 }
140 }
141
142 ERR("unknown parameter '%s' of type '%s'",
143 param->name, edje_external_param_type_str(param->type));
144
145 return EINA_FALSE;
146}
147
148static Eina_Bool
149external_entry_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
150{
151 if (!strcmp(param->name, "label"))
152 {
153 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
154 {
155 param->s = elm_object_text_get(obj);
156 return EINA_TRUE;
157 }
158 }
159 else if (!strcmp(param->name, "icon"))
160 {
161 /* not easy to get icon name back from live object */
162 return EINA_FALSE;
163 }
164 else if (!strcmp(param->name, "entry"))
165 {
166 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
167 {
168 param->s = elm_entry_entry_get(obj);
169 return EINA_TRUE;
170 }
171 }
172 else if (!strcmp(param->name, "scrollable"))
173 {
174 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
175 {
176 param->i = elm_entry_scrollable_get(obj);
177 return EINA_TRUE;
178 }
179 }
180 else if (!strcmp(param->name, "single line"))
181 {
182 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
183 {
184 param->i = elm_entry_single_line_get(obj);
185 return EINA_TRUE;
186 }
187 }
188 else if (!strcmp(param->name, "password"))
189 {
190 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
191 {
192 param->i = elm_entry_password_get(obj);
193 return EINA_TRUE;
194 }
195 }
196 else if (!strcmp(param->name, "horizontal bounce"))
197 {
198 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
199 {
200 Eina_Bool hbounce;
201 elm_entry_bounce_get(obj, &hbounce, NULL);
202 param->i = hbounce;
203 return EINA_TRUE;
204 }
205 }
206 else if (!strcmp(param->name, "vertical bounce"))
207 {
208 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
209 {
210 Eina_Bool vbounce;
211 elm_entry_bounce_get(obj, NULL, &vbounce);
212 param->i = vbounce;
213 return EINA_TRUE;
214 }
215 }
216 else if (!strcmp(param->name, "editable"))
217 {
218 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
219 {
220 param->i = elm_entry_editable_get(obj);
221 return EINA_TRUE;
222 }
223 }
224
225 ERR("unknown parameter '%s' of type '%s'",
226 param->name, edje_external_param_type_str(param->type));
227
228 return EINA_FALSE;
229}
230
231static void *
232external_entry_params_parse(void *data __UNUSED__, Evas_Object *obj, const Eina_List *params)
233{
234 Elm_Params_Entry *mem;
235 Edje_External_Param *param;
236 const Eina_List *l;
237
238 mem = ELM_NEW(Elm_Params_Entry);
239 if (!mem)
240 return NULL;
241
242 external_common_icon_param_parse(&mem->icon, obj, params);
243
244 EINA_LIST_FOREACH(params, l, param)
245 {
246 if (!strcmp(param->name, "label"))
247 {
248 mem->label = eina_stringshare_add(param->s);
249 }
250 else if (!strcmp(param->name, "entry"))
251 {
252 mem->entry = eina_stringshare_add(param->s);
253 }
254 else if (!strcmp(param->name, "scrollable"))
255 {
256 mem->scrollable = !!param->i;
257 mem->scrollable_exists = EINA_TRUE;
258 }
259 else if (!strcmp(param->name, "single line"))
260 {
261 mem->single_line = !!param->i;
262 mem->single_line_exists = EINA_TRUE;
263 }
264 else if (!strcmp(param->name, "password"))
265 {
266 mem->password = !!param->i;
267 mem->password_exists = EINA_TRUE;
268 }
269 else if (!strcmp(param->name, "horizontal bounce"))
270 {
271 mem->horizontal_bounce = !!param->i;
272 mem->horizontal_bounce_exists = EINA_TRUE;
273 }
274 else if (!strcmp(param->name, "vertical bounce"))
275 {
276 mem->vertical_bounce = !!param->i;
277 mem->vertical_bounce_exists = EINA_TRUE;
278 }
279 else if (!strcmp(param->name, "editable"))
280 {
281 mem->editable = !!param->i;
282 mem->editable_exists = EINA_TRUE;
283 }
284 }
285
286 return mem;
287}
288
289static Evas_Object *external_entry_content_get(void *data __UNUSED__,
290 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
291{
292 ERR("No content.");
293 return NULL;
294}
295
296static void
297external_entry_params_free(void *params)
298{
299 Elm_Params_Entry *mem = params;
300 if (mem->label)
301 eina_stringshare_del(mem->label);
302 if (mem->entry)
303 eina_stringshare_del(mem->entry);
304 free(params);
305}
306
307static Edje_External_Param_Info external_entry_params[] = {
308 DEFINE_EXTERNAL_COMMON_PARAMS,
309 EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
310 EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
311 EDJE_EXTERNAL_PARAM_INFO_STRING("entry"),
312 EDJE_EXTERNAL_PARAM_INFO_BOOL("scrollable"),
313 EDJE_EXTERNAL_PARAM_INFO_BOOL("single line"),
314 EDJE_EXTERNAL_PARAM_INFO_BOOL("password"),
315 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal bounce"),
316 EDJE_EXTERNAL_PARAM_INFO_BOOL("vertical bounce"),
317 EDJE_EXTERNAL_PARAM_INFO_BOOL("editable"),
318 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
319};
320
321DEFINE_EXTERNAL_ICON_ADD(entry, "entry");
322DEFINE_EXTERNAL_TYPE_SIMPLE(entry, "Entry");