summaryrefslogtreecommitdiff
path: root/legacy/edje/src/lib/edje_text.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2003-07-07 07:55:18 +0000
committerCarsten Haitzler <raster@rasterman.com>2003-07-07 07:55:18 +0000
commit1b587fd598a8ee227002cf3737c12d9fa128a151 (patch)
treed59932e8e86c1f954404ca8bd45efd6f9fa8e27b /legacy/edje/src/lib/edje_text.c
parentf54245420a08b452b2451ae9f955e4eef299b41a (diff)
work has been done while i've been away. i just need to put this in cvs. many
fixem's have been fixed. text parts work fully now, ALONG with all their respective effect modes, fits, alignments and "chopping". a few more api calls have been added and cleaned up. you'll need to update eet too for this to work. SVN revision: 7113
Diffstat (limited to 'legacy/edje/src/lib/edje_text.c')
-rw-r--r--legacy/edje/src/lib/edje_text.c519
1 files changed, 519 insertions, 0 deletions
diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c
new file mode 100644
index 0000000..1ac3b18
--- /dev/null
+++ b/legacy/edje/src/lib/edje_text.c
@@ -0,0 +1,519 @@
1#include "Edje.h"
2#include "edje_private.h"
3
4Ejde_Text_Style _edje_text_styles[EDJE_TEXT_EFFECT_LAST];
5
6void
7_edje_text_init(void)
8{
9 int i, j, n;
10 const vals[5][5] =
11 {
12 {0, 1, 2, 1, 0},
13 {1, 3, 4, 3, 1},
14 {2, 4, 5, 4, 2},
15 {1, 3, 4, 3, 1},
16 {0, 1, 2, 1, 0}
17 };
18
19 memset(_edje_text_styles, 0, sizeof(_edje_text_styles));
20
21 _edje_text_styles[EDJE_TEXT_EFFECT_NONE].num = 1;
22 _edje_text_styles[EDJE_TEXT_EFFECT_NONE].members[0].alpha = 255;
23
24 _edje_text_styles[EDJE_TEXT_EFFECT_PLAIN].num = 1;
25 _edje_text_styles[EDJE_TEXT_EFFECT_PLAIN].members[0].alpha = 255;
26
27 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].offset.x = 1;
28 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].offset.y = 1;
29 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].pad.l = 1;
30 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].pad.r = 1;
31 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].pad.t = 1;
32 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].pad.b = 1;
33 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].num = 5;
34 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[0].alpha = 255;
35 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[1].color = 1;
36 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[1].x = 0;
37 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[1].y = -1;
38 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[1].alpha = 255;
39 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[2].color = 1;
40 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[2].x = 0;
41 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[2].y = 1;
42 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[2].alpha = 255;
43 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[3].color = 1;
44 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[3].x = -1;
45 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[3].y = 0;
46 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[3].alpha = 255;
47 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[4].color = 1;
48 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[4].x = 1;
49 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[4].y = 0;
50 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE].members[4].alpha = 255;
51
52 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].offset.x = 2;
53 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].offset.y = 2;
54 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].pad.l = 2;
55 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].pad.r = 2;
56 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].pad.t = 2;
57 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].pad.b = 2;
58 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].num = 1;
59 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[0].alpha = 255;
60 for (j = 0; j < 5; j++)
61 {
62 for (i = 0; i < 5; i++)
63 {
64 if (((i == 2) && (j == 2)) || (vals[i][j] == 0)) continue;
65 n = _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].num;
66 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[n].color = 1;
67 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[n].x = i - 2;
68 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[n].y = j - 2;
69 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].members[n].alpha = vals[i][j] * 50;
70 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_OUTLINE].num = n + 1;
71 }
72 }
73
74 _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].pad.r = 1;
75 _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].pad.b = 1;
76 _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].num = 2;
77 _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[0].alpha = 255;
78 _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[1].color = 2;
79 _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[1].x = 1;
80 _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[1].y = 1;
81 _edje_text_styles[EDJE_TEXT_EFFECT_SHADOW].members[1].alpha = 255;
82
83 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].offset.x = 1;
84 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].offset.y = 1;
85 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].pad.l = 1;
86 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].pad.r = 3;
87 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].pad.t = 1;
88 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].pad.b = 3;
89 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].num = 1;
90 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[0].alpha = 255;
91 for (j = 0; j < 5; j++)
92 {
93 for (i = 0; i < 5; i++)
94 {
95 if (vals[i][j] == 0) continue;
96 n = _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].num;
97 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[n].color = 2;
98 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[n].x = i - 1;
99 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[n].y = j - 1;
100 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].members[n].alpha = vals[i][j] * 50;
101 _edje_text_styles[EDJE_TEXT_EFFECT_SOFT_SHADOW].num = n + 1;
102 }
103 }
104
105 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].offset.x = 1;
106 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].offset.y = 1;
107 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].pad.l = 1;
108 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].pad.r = 2;
109 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].pad.t = 1;
110 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].pad.b = 2;
111 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].num = 6;
112 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[0].alpha = 255;
113 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[1].color = 2;
114 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[1].x = 2;
115 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[1].y = 2;
116 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[1].alpha = 255;
117 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[2].color = 1;
118 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[2].x = 0;
119 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[2].y = -1;
120 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[2].alpha = 255;
121 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[3].color = 1;
122 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[3].x = 0;
123 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[3].y = 1;
124 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[3].alpha = 255;
125 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[4].color = 1;
126 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[4].x = -1;
127 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[4].y = 0;
128 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[4].alpha = 255;
129 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[5].color = 1;
130 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[5].x = 1;
131 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[5].y = 0;
132 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SHADOW].members[5].alpha = 255;
133
134 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].offset.x = 1;
135 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].offset.y = 1;
136 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].pad.l = 1;
137 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].pad.r = 3;
138 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].pad.t = 1;
139 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].pad.b = 3;
140 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].num = 1;
141 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[0].alpha = 255;
142 for (j = 0; j < 5; j++)
143 {
144 for (i = 0; i < 5; i++)
145 {
146 if (vals[i][j] == 0) continue;
147 n = _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].num;
148 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n].color = 2;
149 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n].x = i - 1;
150 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n].y = j - 1;
151 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n].alpha = vals[i][j] * 50;
152 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].num = n + 1;
153 }
154 }
155 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 1].color = 1;
156 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 1].x = 0;
157 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 1].y = -1;
158 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 1].alpha = 255;
159 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 2].color = 1;
160 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 2].x = 0;
161 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 2].y = 1;
162 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 2].alpha = 255;
163 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 3].color = 1;
164 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 3].x = -1;
165 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 3].y = 0;
166 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 3].alpha = 255;
167 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 4].color = 1;
168 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 4].x = 1;
169 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 4].y = 0;
170 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].members[n + 4].alpha = 255;
171 _edje_text_styles[EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW].num += 4;
172}
173
174void
175_edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep)
176{
177 int i;
178
179 if (ep->part->type != EDJE_PART_TYPE_TEXT) return;
180 if (ep->part->effect >= EDJE_TEXT_EFFECT_LAST) return;
181 for (i = 1; i < _edje_text_styles[ep->part->effect].num; i++)
182 {
183 Evas_Object *o;
184
185 o = evas_object_text_add(ed->evas);
186 evas_object_smart_member_add(o, ed->obj);
187 evas_object_pass_events_set(o, 1);
188 evas_object_clip_set(o, ed->clipper);
189 evas_object_show(o);
190 ep->extra_objects = evas_list_append(ep->extra_objects, o);
191 }
192}
193
194void
195_edje_text_part_on_add_clippers(Edje *ed, Edje_Real_Part *ep)
196{
197 Evas_List *l;
198
199 for (l = ep->extra_objects; l; l = l->next)
200 {
201 Evas_Object *o;
202
203 o = l->data;
204 if (ep->part->clip_to_id >= 0)
205 {
206 ep->clip_to = evas_list_nth(ed->parts, ep->part->clip_to_id);
207 if (ep->clip_to)
208 {
209 evas_object_pass_events_set(ep->clip_to->object, 1);
210 evas_object_clip_set(o, ep->clip_to->object);
211 }
212 }
213
214 }
215}
216
217void
218_edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep)
219{
220 while (ep->extra_objects)
221 {
222 Evas_Object *o;
223
224 o = ep->extra_objects->data;
225 ep->extra_objects = evas_list_remove(ep->extra_objects, o);
226 evas_object_del(o);
227 }
228}
229
230void
231_edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
232 Edje_Calc_Params *params,
233 Edje_Part_Description *chosen_desc)
234{
235 char *text;
236 char *font;
237 int size;
238 double tw, th;
239 double ox, oy, sw, sh;
240 char *buf = NULL;
241
242 text = chosen_desc->text.text;
243 font = chosen_desc->text.font;
244 size = chosen_desc->text.size;
245 if (ep->text.text) text = ep->text.text;
246 if (ep->text.font) font = ep->text.font;
247 if (ep->text.size > 0) size = ep->text.size;
248 ox = _edje_text_styles[ep->part->effect].offset.x;
249 oy = _edje_text_styles[ep->part->effect].offset.y;
250 sw = params->w - (_edje_text_styles[ep->part->effect].pad.l + _edje_text_styles[ep->part->effect].pad.r);
251 sh = params->h - (_edje_text_styles[ep->part->effect].pad.t + _edje_text_styles[ep->part->effect].pad.b);
252 if ((ep->text.cache.in_size == size) &&
253 (ep->text.cache.in_w == sw) &&
254 (ep->text.cache.in_h == sh) &&
255 (ep->text.cache.in_str) &&
256 (text) &&
257 (!strcmp(ep->text.cache.in_str, text)))
258 {
259 text = ep->text.cache.out_str;
260 size = ep->text.cache.out_size;
261 goto arrange_text;
262 }
263 if (ep->text.cache.in_str) free(ep->text.cache.in_str);
264 ep->text.cache.in_str = strdup(text);
265 ep->text.cache.in_size = size;
266 if (chosen_desc->text.fit_x)
267 {
268 evas_object_text_font_set(ep->object, font, size);
269 evas_object_text_text_set(ep->object, text);
270 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
271 if (tw > sw)
272 {
273 int psize;
274
275 psize = size;
276 while ((tw > sw) && (size > 0))
277 {
278 psize = size;
279 size = (size * sw) / tw;
280 if ((psize - size) <= 0) size = psize - 1;
281 evas_object_text_font_set(ep->object, font, size);
282 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
283 }
284 }
285 else if (tw < sw)
286 {
287 int psize;
288
289 psize = size;
290 while ((tw < sw) && (size > 0))
291 {
292 psize = size;
293 size = (size * sw) / tw;
294 if ((psize - size) >= 0) size = psize + 1;
295 evas_object_text_font_set(ep->object, font, size);
296 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
297 }
298 size = psize;
299 }
300 }
301 if (chosen_desc->text.fit_y)
302 {
303 size = sh;
304 evas_object_text_font_set(ep->object, font, size);
305 evas_object_text_text_set(ep->object, text);
306 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
307 if (th < sh)
308 {
309 int dif;
310
311 dif = (th - sh) / 4;
312 if (dif < 1) dif = 1;
313 while ((th < sh) && (sw > 0.0))
314 {
315 size += dif;
316 evas_object_text_font_set(ep->object, font, size);
317 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
318 }
319 size -= dif;
320 }
321 else if (th > sh)
322 {
323 int dif;
324
325 dif = (th - sh) / 4;
326 if (dif < 1) dif = 1;
327 while ((th < sh) && (sw >= 0.0))
328 {
329 size -= dif;
330 evas_object_text_font_set(ep->object, font, size);
331 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
332 }
333 }
334 }
335 if (size < 1) size = 1;
336 if (!chosen_desc->text.fit_x)
337 {
338 double p;
339 int c1, c2;
340 int loop;
341 int orig_len;
342
343 evas_object_text_font_set(ep->object, font, size);
344 evas_object_text_text_set(ep->object, text);
345 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
346 p = ((sw - tw) * chosen_desc->text.align.x);
347 c1 = -1;
348 c2 = -1;
349 /* chop chop */
350 if (tw > sw)
351 {
352 if (chosen_desc->text.align.x != 0.0)
353 c1 = evas_object_text_char_coords_get(ep->object,
354 -p, th / 2,
355 NULL, NULL, NULL, NULL);
356 if (chosen_desc->text.align.x != 1.0)
357 c2 = evas_object_text_char_coords_get(ep->object,
358 -p + sw, th / 2,
359 NULL, NULL, NULL, NULL);
360 if ((c1 < 0) && (c2 < 0))
361 {
362 c1 = 0;
363 c2 = 0;
364 }
365 }
366 loop = 0;
367 buf = malloc(strlen(text) + 1 + 3 + 3);
368 orig_len = strlen(text);
369 while (((c1 >= 0) || (c2 >= 0)) && (tw > sw))
370 {
371 loop++;
372 if (sw <= 0.0)
373 {
374 buf[0] = 0;
375 break;
376 }
377 if ((c1 >= 0) && (c2 >= 0))
378 {
379 if ((loop & 0x1))
380 {
381 if (c1 >= 0)
382 c1 = evas_string_char_next_get(text, c1, NULL);
383 }
384 else
385 {
386 if (c2 >= 0)
387 {
388 c2 = evas_string_char_prev_get(text, c2, NULL);
389 if (c2 < 0)
390 {
391 buf[0] = 0;
392 break;
393 }
394 }
395 }
396 }
397 else
398 {
399 if (c1 >= 0)
400 c1 = evas_string_char_next_get(text, c1, NULL);
401 else if (c2 >= 0)
402 {
403 c2 = evas_string_char_prev_get(text, c2, NULL);
404 if (c2 < 0)
405 {
406 buf[0] = 0;
407 break;
408 }
409 }
410 }
411 if ((c1 >= 0) && (c2 >= 0))
412 {
413 if (c1 >= c2)
414 {
415 buf[0] = 0;
416 break;
417 }
418 }
419 else
420 {
421 if (c1 >= orig_len)
422 {
423 buf[0] = 0;
424 break;
425 }
426 else if (c2 == 0)
427 {
428 buf[0] = 0;
429 break;
430 }
431 }
432 buf[0] = 0;
433 if (c1 >= 0)
434 {
435 strcpy(buf, "...");
436 if (c2 >= 0)
437 {
438 strncat(buf, text + c1, c2 - c1);
439 strcat(buf, "...");
440 }
441 else
442 strcat(buf, text + c1);
443 }
444 else
445 {
446 if (c2 >= 0)
447 {
448 strncpy(buf, text, c2);
449 buf[c2] = 0;
450 strcat(buf, "...");
451 }
452 else strcpy(buf, text);
453 }
454 evas_object_text_text_set(ep->object, buf);
455 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
456 }
457 if (loop > 0) text = buf;
458 }
459 if (ep->text.cache.out_str) free(ep->text.cache.out_str);
460 ep->text.cache.out_str = strdup(text);
461 ep->text.cache.in_w = sw;
462 ep->text.cache.in_h = sh;
463 ep->text.cache.out_size = size;
464
465 arrange_text:
466
467 evas_object_text_font_set(ep->object, font, size);
468 evas_object_text_text_set(ep->object, text);
469 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
470 ep->offset.x = ox + ((sw - tw) * chosen_desc->text.align.x);
471 ep->offset.y = oy + ((sh - th) * chosen_desc->text.align.y);
472 evas_object_move(ep->object,
473 ed->x + params->x + ep->offset.x,
474 ed->y + params->y + ep->offset.y);
475 evas_object_color_set(ep->object,
476 params->color.r,
477 params->color.g,
478 params->color.b,
479 (params->color.a * (_edje_text_styles[ep->part->effect].members[0].alpha + 1)) / 256);
480 if (params->visible) evas_object_show(ep->object);
481 else evas_object_hide(ep->object);
482 {
483 Evas_List *l;
484 int i;
485
486 for (i = 1, l = ep->extra_objects; l; l = l->next, i++)
487 {
488 Evas_Object *o;
489
490 o = l->data;
491 evas_object_text_font_set(o, font, size);
492 evas_object_text_text_set(o, text);
493 evas_object_move(o,
494 ed->x + params->x + ep->offset.x + _edje_text_styles[ep->part->effect].members[i].x,
495 ed->y + params->y + ep->offset.y + _edje_text_styles[ep->part->effect].members[i].y);
496 if (_edje_text_styles[ep->part->effect].members[i].color == 0)
497 evas_object_color_set(o,
498 params->color.r,
499 params->color.g,
500 params->color.b,
501 (params->color.a * (_edje_text_styles[ep->part->effect].members[i].alpha + 1)) / 256);
502 else if (_edje_text_styles[ep->part->effect].members[i].color == 1)
503 evas_object_color_set(o,
504 params->color2.r,
505 params->color2.g,
506 params->color2.b,
507 (params->color2.a * (_edje_text_styles[ep->part->effect].members[i].alpha + 1)) / 256);
508 else if (_edje_text_styles[ep->part->effect].members[i].color == 2)
509 evas_object_color_set(o,
510 params->color3.r,
511 params->color3.g,
512 params->color3.b,
513 (params->color3.a * (_edje_text_styles[ep->part->effect].members[i].alpha + 1)) / 256);
514 if (params->visible) evas_object_show(o);
515 else evas_object_hide(o);
516 }
517 }
518 if (buf) free(buf);
519}