2004-10-30 05:12:02 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
#include "Edje.h"
|
|
|
|
#include "edje_private.h"
|
|
|
|
|
2004-11-12 07:44:38 -08:00
|
|
|
#ifdef HAVE_STDINT_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif
|
2004-10-30 10:56:50 -07:00
|
|
|
#include <assert.h>
|
2004-10-30 08:51:55 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
void
|
|
|
|
_edje_text_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep)
|
|
|
|
{
|
2003-11-03 22:15:19 -08:00
|
|
|
Evas_List *tmp;
|
|
|
|
Edje_Part *pt = ep->part;
|
2003-07-07 00:55:18 -07:00
|
|
|
|
|
|
|
if (ep->part->type != EDJE_PART_TYPE_TEXT) return;
|
2003-11-03 22:15:19 -08:00
|
|
|
|
2005-04-03 04:43:00 -07:00
|
|
|
if ((pt->default_desc) && (pt->default_desc->text.text_class))
|
|
|
|
_edje_text_class_member_add(ed, pt->default_desc->text.text_class);
|
2003-11-03 22:15:19 -08:00
|
|
|
for (tmp = pt->other_desc; tmp; tmp = tmp->next)
|
|
|
|
{
|
|
|
|
Edje_Part_Description *desc;
|
|
|
|
|
|
|
|
desc = tmp->data;
|
|
|
|
if ((desc) && (desc->text.text_class)) _edje_text_class_member_add(ed, desc->text.text_class);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_text_part_on_add_clippers(Edje *ed, Edje_Real_Part *ep)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = ep->extra_objects; l; l = l->next)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
|
|
|
|
o = l->data;
|
|
|
|
if (ep->part->clip_to_id >= 0)
|
|
|
|
{
|
|
|
|
ep->clip_to = evas_list_nth(ed->parts, ep->part->clip_to_id);
|
|
|
|
if (ep->clip_to)
|
|
|
|
{
|
|
|
|
evas_object_pass_events_set(ep->clip_to->object, 1);
|
|
|
|
evas_object_clip_set(o, ep->clip_to->object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-11-24 23:22:19 -08:00
|
|
|
_edje_text_part_on_del(Edje *ed, Edje_Part *pt)
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
2003-11-03 22:15:19 -08:00
|
|
|
Evas_List *tmp;
|
|
|
|
|
2003-11-24 23:22:19 -08:00
|
|
|
if ((pt->default_desc) && (pt->default_desc->text.text_class))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
2003-11-24 23:22:19 -08:00
|
|
|
_edje_text_class_member_del(ed, pt->default_desc->text.text_class);
|
2005-11-30 07:36:34 -08:00
|
|
|
evas_stringshare_del(pt->default_desc->text.text_class);
|
2005-04-03 04:43:00 -07:00
|
|
|
pt->default_desc->text.text_class = NULL;
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
2006-01-29 08:50:30 -08:00
|
|
|
|
2003-11-03 22:15:19 -08:00
|
|
|
for (tmp = pt->other_desc; tmp; tmp = tmp->next)
|
|
|
|
{
|
|
|
|
Edje_Part_Description *desc;
|
|
|
|
|
|
|
|
desc = tmp->data;
|
2003-11-24 23:22:19 -08:00
|
|
|
if (desc->text.text_class)
|
|
|
|
{
|
|
|
|
_edje_text_class_member_del(ed, desc->text.text_class);
|
2005-11-30 07:36:34 -08:00
|
|
|
evas_stringshare_del(desc->text.text_class);
|
2003-11-24 23:22:19 -08:00
|
|
|
desc->text.text_class = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_text_real_part_on_del(Edje *ed, Edje_Real_Part *ep)
|
|
|
|
{
|
|
|
|
while (ep->extra_objects)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
|
|
|
|
o = ep->extra_objects->data;
|
|
|
|
ep->extra_objects = evas_list_remove(ep->extra_objects, o);
|
|
|
|
evas_object_del(o);
|
2003-11-03 22:15:19 -08:00
|
|
|
}
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
|
2004-10-30 12:18:32 -07:00
|
|
|
static void
|
|
|
|
_edje_text_fit_set(char *buf, char *text, int c1, int c2)
|
|
|
|
{
|
|
|
|
/* helper function called from _edje_text_fit_x().
|
|
|
|
* note that we can use strcpy()/strcat() safely, the buffer lengths
|
|
|
|
* are checked in the caller.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (c1 >= 0)
|
|
|
|
{
|
|
|
|
strcpy(buf, "...");
|
|
|
|
|
|
|
|
if (c2 >= 0)
|
|
|
|
{
|
|
|
|
strncat(buf, text + c1, c2 - c1);
|
|
|
|
strcat(buf, "...");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcat(buf, text + c1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (c2 >= 0)
|
|
|
|
{
|
|
|
|
strncpy(buf, text, c2);
|
|
|
|
buf[c2] = 0;
|
|
|
|
strcat(buf, "...");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy(buf, text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-30 09:54:58 -07:00
|
|
|
static char *
|
2004-10-30 08:51:55 -07:00
|
|
|
_edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
|
|
|
|
Edje_Calc_Params *params,
|
|
|
|
char *text, char *font, int size,
|
2004-10-30 09:54:58 -07:00
|
|
|
Evas_Coord sw, int *free_text)
|
2004-10-30 08:51:55 -07:00
|
|
|
{
|
|
|
|
Evas_Coord tw = 0, th = 0, p;
|
|
|
|
char *buf;
|
|
|
|
int c1 = -1, c2 = -1, loop = 0, extra;
|
|
|
|
size_t orig_len;
|
|
|
|
|
2004-10-30 09:54:58 -07:00
|
|
|
*free_text = 0;
|
|
|
|
|
2004-10-30 08:51:55 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
evas_object_text_text_set(ep->object, text);
|
|
|
|
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
|
|
|
|
2005-11-05 19:32:01 -08:00
|
|
|
p = ((sw - tw) * params->text.elipsis);
|
2004-10-30 08:51:55 -07:00
|
|
|
|
|
|
|
/* chop chop */
|
|
|
|
if (tw > sw)
|
|
|
|
{
|
2005-11-05 19:32:01 -08:00
|
|
|
if (params->text.elipsis != 0.0)
|
2004-10-30 08:51:55 -07:00
|
|
|
c1 = evas_object_text_char_coords_get(ep->object,
|
|
|
|
-p, th / 2,
|
|
|
|
NULL, NULL, NULL, NULL);
|
2005-11-05 19:32:01 -08:00
|
|
|
if (params->text.elipsis != 1.0)
|
2004-10-30 08:51:55 -07:00
|
|
|
c2 = evas_object_text_char_coords_get(ep->object,
|
|
|
|
-p + sw, th / 2,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if ((c1 < 0) && (c2 < 0))
|
|
|
|
{
|
|
|
|
c1 = 0;
|
|
|
|
c2 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-30 09:54:58 -07:00
|
|
|
if (!((c1 >= 0 || c2 >= 0) && (tw > sw)))
|
|
|
|
return text;
|
2004-10-30 08:51:55 -07:00
|
|
|
|
|
|
|
orig_len = strlen(text);
|
|
|
|
|
|
|
|
/* don't overflow orig_len by adding extra
|
|
|
|
* FIXME: we might want to set a max string length somewhere...
|
|
|
|
*/
|
2004-10-30 09:54:58 -07:00
|
|
|
extra = 1 + 3 + 3; /* terminator, leading and trailing ellipsis */
|
2004-11-30 20:59:41 -08:00
|
|
|
orig_len = MIN(orig_len, 8192 - extra);
|
2004-10-30 08:51:55 -07:00
|
|
|
|
|
|
|
if (!(buf = malloc(orig_len + extra)))
|
2004-10-30 09:54:58 -07:00
|
|
|
return text;
|
2004-10-30 08:51:55 -07:00
|
|
|
|
|
|
|
while (((c1 >= 0) || (c2 >= 0)) && (tw > sw))
|
|
|
|
{
|
|
|
|
loop++;
|
|
|
|
if (sw <= 0.0)
|
|
|
|
{
|
|
|
|
buf[0] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((c1 >= 0) && (c2 >= 0))
|
|
|
|
{
|
|
|
|
if ((loop & 0x1))
|
|
|
|
{
|
|
|
|
if (c1 >= 0)
|
|
|
|
c1 = evas_string_char_next_get(text, c1, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (c2 >= 0)
|
|
|
|
{
|
|
|
|
c2 = evas_string_char_prev_get(text, c2, NULL);
|
|
|
|
if (c2 < 0)
|
|
|
|
{
|
|
|
|
buf[0] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (c1 >= 0)
|
|
|
|
c1 = evas_string_char_next_get(text, c1, NULL);
|
|
|
|
else if (c2 >= 0)
|
|
|
|
{
|
|
|
|
c2 = evas_string_char_prev_get(text, c2, NULL);
|
|
|
|
if (c2 < 0)
|
|
|
|
{
|
|
|
|
buf[0] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((c1 >= 0) && (c2 >= 0))
|
|
|
|
{
|
|
|
|
if (c1 >= c2)
|
|
|
|
{
|
|
|
|
buf[0] = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-10-30 12:23:39 -07:00
|
|
|
else if ((c1 > 0 && c1 >= orig_len) || c2 == 0)
|
2004-10-30 08:51:55 -07:00
|
|
|
{
|
2004-10-30 11:25:51 -07:00
|
|
|
buf[0] = 0;
|
|
|
|
break;
|
2004-10-30 08:51:55 -07:00
|
|
|
}
|
2004-10-30 11:25:51 -07:00
|
|
|
|
2004-10-30 08:51:55 -07:00
|
|
|
buf[0] = 0;
|
2004-10-30 11:25:51 -07:00
|
|
|
|
2004-10-30 12:18:32 -07:00
|
|
|
_edje_text_fit_set(buf, text, c1, c2);
|
|
|
|
|
2004-10-30 08:51:55 -07:00
|
|
|
evas_object_text_text_set(ep->object, buf);
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
|
|
|
}
|
2004-10-30 09:54:58 -07:00
|
|
|
|
|
|
|
*free_text = 1;
|
|
|
|
|
|
|
|
return buf;
|
2004-10-30 08:51:55 -07:00
|
|
|
}
|
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
void
|
|
|
|
_edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
|
|
|
Edje_Calc_Params *params,
|
|
|
|
Edje_Part_Description *chosen_desc)
|
|
|
|
{
|
|
|
|
char *text;
|
2005-03-20 08:49:10 -08:00
|
|
|
char *font, *font2 = NULL;
|
2003-07-07 00:55:18 -07:00
|
|
|
int size;
|
2003-10-17 20:34:54 -07:00
|
|
|
Evas_Coord tw, th;
|
2005-11-26 05:33:09 -08:00
|
|
|
Evas_Coord sw, sh;
|
2004-10-30 08:04:51 -07:00
|
|
|
char font_buf[4096];
|
2004-10-30 09:54:58 -07:00
|
|
|
int inlined_font = 0, free_text = 0;
|
2004-08-30 01:07:00 -07:00
|
|
|
|
2003-07-12 19:06:46 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
text = chosen_desc->text.text;
|
|
|
|
font = chosen_desc->text.font;
|
|
|
|
size = chosen_desc->text.size;
|
2005-11-23 04:56:06 -08:00
|
|
|
|
2005-11-03 23:56:13 -08:00
|
|
|
if ((chosen_desc->text.text_class) && (chosen_desc->text.text_class[0] != 0))
|
2003-07-12 19:06:46 -07:00
|
|
|
{
|
2003-10-29 20:45:18 -08:00
|
|
|
Edje_Text_Class *tc;
|
2003-07-12 19:06:46 -07:00
|
|
|
|
2003-10-30 21:07:39 -08:00
|
|
|
tc = _edje_text_class_find(ed, chosen_desc->text.text_class);
|
2003-11-03 22:15:19 -08:00
|
|
|
if (tc)
|
|
|
|
{
|
|
|
|
if (tc->font) font = tc->font;
|
|
|
|
if (tc->size > 0) size = tc->size;
|
|
|
|
}
|
2003-07-12 19:06:46 -07:00
|
|
|
}
|
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
if (ep->text.text) text = ep->text.text;
|
|
|
|
if (ep->text.font) font = ep->text.font;
|
|
|
|
if (ep->text.size > 0) size = ep->text.size;
|
2005-03-20 08:49:10 -08:00
|
|
|
|
2005-11-24 00:10:22 -08:00
|
|
|
if (!text) text = "";
|
|
|
|
if (!font) font = "";
|
|
|
|
|
2004-08-30 01:07:00 -07:00
|
|
|
/* check if the font is embedded in the .eet */
|
|
|
|
/* FIXME: we should cache this result */
|
|
|
|
if (ed->file->font_dir)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = ed->file->font_dir->entries; l; l = l->next)
|
|
|
|
{
|
|
|
|
Edje_Font_Directory_Entry *fnt = l->data;
|
|
|
|
|
|
|
|
if ((fnt->entry) && (!strcmp(fnt->entry, font)))
|
|
|
|
{
|
2004-11-02 09:05:37 -08:00
|
|
|
strcpy(font_buf, "fonts/");
|
|
|
|
strncpy(font_buf + 6, font, sizeof(font_buf) - 7);
|
|
|
|
font_buf[sizeof(font_buf) - 1] = 0;
|
2004-10-30 08:04:51 -07:00
|
|
|
font = font_buf;
|
2004-08-30 01:07:00 -07:00
|
|
|
inlined_font = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-03-20 08:49:10 -08:00
|
|
|
|
|
|
|
if ((_edje_fontset_append) && (font))
|
|
|
|
{
|
|
|
|
font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1);
|
|
|
|
if (font2)
|
|
|
|
{
|
|
|
|
strcpy(font2, font);
|
|
|
|
strcat(font2, ",");
|
|
|
|
strcat(font2, _edje_fontset_append);
|
|
|
|
font = font2;
|
|
|
|
}
|
|
|
|
}
|
2005-11-26 00:14:34 -08:00
|
|
|
{
|
|
|
|
int l, r, t, b;
|
2005-11-26 05:33:09 -08:00
|
|
|
|
2005-11-26 00:14:34 -08:00
|
|
|
evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b);
|
2005-11-26 05:58:43 -08:00
|
|
|
sw = params->w;
|
|
|
|
sh = params->h;
|
2005-11-26 00:14:34 -08:00
|
|
|
}
|
2003-07-07 00:55:18 -07:00
|
|
|
if ((ep->text.cache.in_size == size) &&
|
|
|
|
(ep->text.cache.in_w == sw) &&
|
|
|
|
(ep->text.cache.in_h == sh) &&
|
|
|
|
(ep->text.cache.in_str) &&
|
|
|
|
(text) &&
|
2004-03-26 01:10:05 -08:00
|
|
|
(!strcmp(ep->text.cache.in_str, text)) &&
|
2004-10-26 23:07:50 -07:00
|
|
|
(ep->text.cache.align_x == params->text.align.x) &&
|
2005-11-05 19:32:01 -08:00
|
|
|
(ep->text.cache.align_y == params->text.align.y) &&
|
|
|
|
(ep->text.cache.elipsis == params->text.elipsis))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
text = ep->text.cache.out_str;
|
|
|
|
size = ep->text.cache.out_size;
|
2005-11-24 00:10:22 -08:00
|
|
|
|
|
|
|
if (!text) text = "";
|
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
goto arrange_text;
|
|
|
|
}
|
2005-11-30 01:56:15 -08:00
|
|
|
if (ep->text.cache.in_str) evas_stringshare_del(ep->text.cache.in_str);
|
|
|
|
ep->text.cache.in_str = evas_stringshare_add(text);
|
2003-07-07 00:55:18 -07:00
|
|
|
ep->text.cache.in_size = size;
|
|
|
|
if (chosen_desc->text.fit_x)
|
|
|
|
{
|
2004-08-30 01:07:00 -07:00
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
2004-09-07 07:48:41 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
evas_object_text_text_set(ep->object, text);
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
|
|
|
if (tw > sw)
|
|
|
|
{
|
|
|
|
int psize;
|
|
|
|
|
|
|
|
psize = size;
|
2004-05-17 21:21:22 -07:00
|
|
|
while ((tw > sw) && (size > 0) && (tw != 0))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
psize = size;
|
|
|
|
size = (size * sw) / tw;
|
|
|
|
if ((psize - size) <= 0) size = psize - 1;
|
2004-08-30 01:07:00 -07:00
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
2004-09-07 07:48:41 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
2003-07-14 19:21:58 -07:00
|
|
|
if ((size > 0) && (tw == 0)) break;
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (tw < sw)
|
|
|
|
{
|
|
|
|
int psize;
|
|
|
|
|
|
|
|
psize = size;
|
2004-05-17 21:21:22 -07:00
|
|
|
while ((tw < sw) && (size > 0) && (tw != 0))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
psize = size;
|
|
|
|
size = (size * sw) / tw;
|
|
|
|
if ((psize - size) >= 0) size = psize + 1;
|
2004-08-30 01:07:00 -07:00
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
2004-09-07 07:48:41 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
2003-07-14 19:21:58 -07:00
|
|
|
if ((size > 0) && (tw == 0)) break;
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (chosen_desc->text.fit_y)
|
|
|
|
{
|
2005-03-20 14:16:24 -08:00
|
|
|
/* if we fit in the x axis, too, size already has a somewhat
|
|
|
|
* meaningful value, so don't overwrite it with the starting
|
|
|
|
* value in that case
|
|
|
|
*/
|
|
|
|
if (!chosen_desc->text.fit_x) size = sh;
|
|
|
|
|
2004-08-30 01:07:00 -07:00
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
2004-09-07 07:48:41 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
evas_object_text_text_set(ep->object, text);
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
2005-03-20 14:16:24 -08:00
|
|
|
|
|
|
|
/* only grow the font size if we didn't already reach the max size
|
|
|
|
* for the x axis
|
|
|
|
*/
|
|
|
|
if (!chosen_desc->text.fit_x && th < sh)
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
int dif;
|
|
|
|
|
|
|
|
dif = (th - sh) / 4;
|
|
|
|
if (dif < 1) dif = 1;
|
2003-10-17 20:34:54 -07:00
|
|
|
while ((th < sh) && (sw > 0))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
size += dif;
|
2004-05-24 01:40:21 -07:00
|
|
|
if (size <= 0) break;
|
2004-08-30 01:07:00 -07:00
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
2004-09-07 07:48:41 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
2003-07-14 19:21:58 -07:00
|
|
|
if ((size > 0) && (th == 0)) break;
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
size -= dif;
|
|
|
|
}
|
|
|
|
else if (th > sh)
|
|
|
|
{
|
|
|
|
int dif;
|
|
|
|
|
|
|
|
dif = (th - sh) / 4;
|
|
|
|
if (dif < 1) dif = 1;
|
2003-07-15 22:15:15 -07:00
|
|
|
while ((th > sh) && (sw >= 0.0))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
size -= dif;
|
2004-05-24 01:40:21 -07:00
|
|
|
if (size <= 0) break;
|
2004-08-30 01:07:00 -07:00
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
2004-09-07 07:48:41 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
2003-07-14 19:21:58 -07:00
|
|
|
if ((size > 0) && (th == 0)) break;
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (size < 1) size = 1;
|
2004-10-30 08:51:55 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
if (!chosen_desc->text.fit_x)
|
|
|
|
{
|
2004-10-30 08:51:55 -07:00
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
2004-08-30 01:07:00 -07:00
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
2004-10-30 08:51:55 -07:00
|
|
|
|
2004-10-30 09:54:58 -07:00
|
|
|
text = _edje_text_fit_x(ed, ep, params, text, font, size, sw,
|
|
|
|
&free_text);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
2004-10-30 08:51:55 -07:00
|
|
|
|
2005-11-30 01:56:15 -08:00
|
|
|
if (ep->text.cache.out_str) evas_stringshare_del(ep->text.cache.out_str);
|
|
|
|
ep->text.cache.out_str = evas_stringshare_add(text);
|
2003-07-07 00:55:18 -07:00
|
|
|
ep->text.cache.in_w = sw;
|
|
|
|
ep->text.cache.in_h = sh;
|
|
|
|
ep->text.cache.out_size = size;
|
2004-10-26 23:07:50 -07:00
|
|
|
ep->text.cache.align_x = params->text.align.x;
|
|
|
|
ep->text.cache.align_y = params->text.align.y;
|
2005-11-05 19:32:01 -08:00
|
|
|
ep->text.cache.elipsis = params->text.elipsis;
|
2003-07-07 00:55:18 -07:00
|
|
|
arrange_text:
|
|
|
|
|
2004-08-30 01:07:00 -07:00
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
2004-09-07 07:48:41 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
evas_object_text_text_set(ep->object, text);
|
|
|
|
evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
|
2005-11-26 05:33:09 -08:00
|
|
|
ep->offset.x = ((sw - tw) * params->text.align.x);
|
|
|
|
ep->offset.y = ((sh - th) * params->text.align.y);
|
2004-04-27 01:16:13 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_move(ep->object,
|
|
|
|
ed->x + params->x + ep->offset.x,
|
|
|
|
ed->y + params->y + ep->offset.y);
|
2005-11-26 00:14:34 -08:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
if (params->visible) evas_object_show(ep->object);
|
|
|
|
else evas_object_hide(ep->object);
|
|
|
|
{
|
2005-11-26 00:14:34 -08:00
|
|
|
Evas_Text_Style_Type style;
|
|
|
|
|
|
|
|
evas_object_color_set(ep->object,
|
|
|
|
params->color.r,
|
|
|
|
params->color.g,
|
|
|
|
params->color.b,
|
|
|
|
params->color.a);
|
2004-10-30 10:56:50 -07:00
|
|
|
|
2005-11-26 00:14:34 -08:00
|
|
|
if ((ep->part->effect == EDJE_TEXT_EFFECT_NONE) ||
|
|
|
|
(ep->part->effect == EDJE_TEXT_EFFECT_PLAIN))
|
|
|
|
{
|
|
|
|
style = EVAS_TEXT_STYLE_PLAIN;
|
|
|
|
}
|
|
|
|
else if (ep->part->effect == EDJE_TEXT_EFFECT_OUTLINE)
|
|
|
|
{
|
|
|
|
style = EVAS_TEXT_STYLE_OUTLINE;
|
|
|
|
evas_object_text_outline_color_set(ep->object,
|
|
|
|
params->color2.r,
|
|
|
|
params->color2.g,
|
|
|
|
params->color2.b,
|
|
|
|
params->color2.a);
|
|
|
|
}
|
|
|
|
else if (ep->part->effect == EDJE_TEXT_EFFECT_SOFT_OUTLINE)
|
|
|
|
{
|
|
|
|
style = EVAS_TEXT_STYLE_SOFT_OUTLINE;
|
|
|
|
evas_object_text_outline_color_set(ep->object,
|
|
|
|
params->color2.r,
|
|
|
|
params->color2.g,
|
|
|
|
params->color2.b,
|
|
|
|
params->color2.a);
|
|
|
|
}
|
|
|
|
else if (ep->part->effect == EDJE_TEXT_EFFECT_SHADOW)
|
|
|
|
{
|
|
|
|
style = EVAS_TEXT_STYLE_SHADOW;
|
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
|
|
|
params->color3.r,
|
|
|
|
params->color3.g,
|
|
|
|
params->color3.b,
|
|
|
|
params->color3.a);
|
|
|
|
}
|
|
|
|
else if (ep->part->effect == EDJE_TEXT_EFFECT_SOFT_SHADOW)
|
|
|
|
{
|
|
|
|
style = EVAS_TEXT_STYLE_SOFT_SHADOW;
|
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
|
|
|
params->color3.r,
|
|
|
|
params->color3.g,
|
|
|
|
params->color3.b,
|
|
|
|
params->color3.a);
|
|
|
|
}
|
|
|
|
else if (ep->part->effect == EDJE_TEXT_EFFECT_OUTLINE_SHADOW)
|
|
|
|
{
|
|
|
|
style = EVAS_TEXT_STYLE_OUTLINE_SHADOW;
|
|
|
|
evas_object_text_outline_color_set(ep->object,
|
|
|
|
params->color2.r,
|
|
|
|
params->color2.g,
|
|
|
|
params->color2.b,
|
|
|
|
params->color2.a);
|
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
|
|
|
params->color3.r,
|
|
|
|
params->color3.g,
|
|
|
|
params->color3.b,
|
|
|
|
params->color3.a);
|
|
|
|
}
|
|
|
|
else if (ep->part->effect == EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW)
|
|
|
|
{
|
|
|
|
style = EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW;
|
|
|
|
evas_object_text_outline_color_set(ep->object,
|
|
|
|
params->color2.r,
|
|
|
|
params->color2.g,
|
|
|
|
params->color2.b,
|
|
|
|
params->color2.a);
|
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
|
|
|
params->color3.r,
|
|
|
|
params->color3.g,
|
|
|
|
params->color3.b,
|
|
|
|
params->color3.a);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
2005-11-26 00:14:34 -08:00
|
|
|
evas_object_text_style_set(ep->object, style);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
2004-10-30 09:54:58 -07:00
|
|
|
|
|
|
|
if (free_text)
|
|
|
|
free(text);
|
2005-03-20 08:49:10 -08:00
|
|
|
if (font2)
|
|
|
|
free(font2);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|