summaryrefslogtreecommitdiff
path: root/src/edje_externals/elm_entry.c
diff options
context:
space:
mode:
authorMichael BOUCHAUD <michael.bouchaud@gmail.com>2011-07-05 11:30:46 +0000
committerMichael BOUCHAUD <michael.bouchaud@gmail.com>2011-07-05 11:30:46 +0000
commit6e3599a3118a333d30d8e01608941173bff569ab (patch)
tree942eac1b34a221bcc3937c220a0a583ca10ae36a /src/edje_externals/elm_entry.c
parenteeaebee706e5c507da46cf5be53f228ce0048edb (diff)
elementary: use line wrap for the edje_external entry object
SVN revision: 61046
Diffstat (limited to 'src/edje_externals/elm_entry.c')
-rw-r--r--src/edje_externals/elm_entry.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/edje_externals/elm_entry.c b/src/edje_externals/elm_entry.c
index 94f4734c3..d4d51b98e 100644
--- a/src/edje_externals/elm_entry.c
+++ b/src/edje_externals/elm_entry.c
@@ -1,3 +1,5 @@
1#include <assert.h>
2
1#include "private.h" 3#include "private.h"
2 4
3typedef struct _Elm_Params_Entry 5typedef struct _Elm_Params_Entry
@@ -18,13 +20,34 @@ typedef struct _Elm_Params_Entry
18 Eina_Bool vertical_bounce_exists:1; 20 Eina_Bool vertical_bounce_exists:1;
19 Eina_Bool editable:1; 21 Eina_Bool editable:1;
20 Eina_Bool editable_exists:1; 22 Eina_Bool editable_exists:1;
23 const char *line_wrap;
21} Elm_Params_Entry; 24} Elm_Params_Entry;
22 25
26#define CHOICE_GET(CHOICES, STR) \
27 unsigned int i; \
28 for (i = 0; i < sizeof(CHOICES); i++) \
29 if (strcmp(STR, CHOICES[i]) == 0) \
30 return i
31
32
33static const char *entry_line_wrap_choices[] = {"none", "char", "word",
34 "mixed", NULL};
35
36static Elm_Wrap_Type
37_entry_line_wrap_choices_setting_get(const char *line_wrap_str)
38{
39 assert(sizeof(entry_line_wrap_choices)/
40 sizeof(entry_line_wrap_choices[0]) == ELM_WRAP_LAST + 1);
41 CHOICE_GET(entry_line_wrap_choices, line_wrap_str);
42 return ELM_WRAP_LAST;
43}
44
23static void 45static void
24external_entry_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__) 46external_entry_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
25{ 47{
26 const Elm_Params_Entry *p; 48 const Elm_Params_Entry *p;
27 Eina_Bool hbounce, vbounce; 49 Eina_Bool hbounce, vbounce;
50 Elm_Wrap_Type line_wrap;
28 51
29 if (to_params) p = to_params; 52 if (to_params) p = to_params;
30 else if (from_params) p = from_params; 53 else if (from_params) p = from_params;
@@ -54,6 +77,11 @@ external_entry_state_set(void *data __UNUSED__, Evas_Object *obj, const void *fr
54 } 77 }
55 if (p->editable_exists) 78 if (p->editable_exists)
56 elm_entry_editable_set(obj, p->editable); 79 elm_entry_editable_set(obj, p->editable);
80 if (p->line_wrap)
81 {
82 line_wrap = _entry_line_wrap_choices_setting_get(p->line_wrap);
83 elm_entry_line_wrap_set(obj, line_wrap);
84 }
57} 85}
58 86
59static Eina_Bool 87static Eina_Bool
@@ -138,6 +166,17 @@ external_entry_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_Ext
138 return EINA_TRUE; 166 return EINA_TRUE;
139 } 167 }
140 } 168 }
169 else if (!strcmp(param->name, "line wrap"))
170 {
171 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
172 {
173 Elm_Wrap_Type line_wrap;
174 line_wrap = _entry_line_wrap_choices_setting_get(param->s);
175 if (line_wrap == ELM_WRAP_LAST) return EINA_FALSE;
176 elm_entry_line_wrap_set(obj, line_wrap);
177 return EINA_TRUE;
178 }
179 }
141 180
142 ERR("unknown parameter '%s' of type '%s'", 181 ERR("unknown parameter '%s' of type '%s'",
143 param->name, edje_external_param_type_str(param->type)); 182 param->name, edje_external_param_type_str(param->type));
@@ -221,6 +260,16 @@ external_entry_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_Ext
221 return EINA_TRUE; 260 return EINA_TRUE;
222 } 261 }
223 } 262 }
263 else if (!strcmp(param->name, "line wrap"))
264 {
265 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
266 {
267 Elm_Wrap_Type line_wrap;
268 line_wrap = elm_entry_line_wrap_get(obj);
269 param->s = entry_line_wrap_choices[line_wrap];
270 return EINA_TRUE;
271 }
272 }
224 273
225 ERR("unknown parameter '%s' of type '%s'", 274 ERR("unknown parameter '%s' of type '%s'",
226 param->name, edje_external_param_type_str(param->type)); 275 param->name, edje_external_param_type_str(param->type));
@@ -281,6 +330,8 @@ external_entry_params_parse(void *data __UNUSED__, Evas_Object *obj, const Eina_
281 mem->editable = !!param->i; 330 mem->editable = !!param->i;
282 mem->editable_exists = EINA_TRUE; 331 mem->editable_exists = EINA_TRUE;
283 } 332 }
333 else if (!strcmp(param->name, "line wrap"))
334 mem->line_wrap = eina_stringshare_add(param->s);
284 } 335 }
285 336
286 return mem; 337 return mem;
@@ -301,6 +352,8 @@ external_entry_params_free(void *params)
301 eina_stringshare_del(mem->label); 352 eina_stringshare_del(mem->label);
302 if (mem->entry) 353 if (mem->entry)
303 eina_stringshare_del(mem->entry); 354 eina_stringshare_del(mem->entry);
355 if (mem->line_wrap)
356 eina_stringshare_del(mem->line_wrap);
304 free(params); 357 free(params);
305} 358}
306 359
@@ -315,6 +368,7 @@ static Edje_External_Param_Info external_entry_params[] = {
315 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal bounce"), 368 EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal bounce"),
316 EDJE_EXTERNAL_PARAM_INFO_BOOL("vertical bounce"), 369 EDJE_EXTERNAL_PARAM_INFO_BOOL("vertical bounce"),
317 EDJE_EXTERNAL_PARAM_INFO_BOOL("editable"), 370 EDJE_EXTERNAL_PARAM_INFO_BOOL("editable"),
371 EDJE_EXTERNAL_PARAM_INFO_STRING("line_wrap"),
318 EDJE_EXTERNAL_PARAM_INFO_SENTINEL 372 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
319}; 373};
320 374