2003-07-07 00:55:18 -07:00
|
|
|
#include "edje_private.h"
|
2011-02-03 00:55:40 -08:00
|
|
|
#define _ELLIP_STR "\xE2\x80\xA6"
|
2004-10-30 08:51:55 -07:00
|
|
|
|
2007-03-30 16:39:41 -07:00
|
|
|
/* returns with and height for this part.
|
|
|
|
*
|
|
|
|
* depending on the value of the use_alternate_font_metrics flag, it will
|
|
|
|
* either use evas_object_geometry_get() or the _advance_get() functions.
|
|
|
|
*
|
|
|
|
* The latter is useful if you want to make sure that width and height
|
|
|
|
* are the same value for the same number of characters in the text.
|
|
|
|
* This usually only makes sense for monospaced fonts.
|
|
|
|
*
|
|
|
|
* In future changes to this file, you probably should use this wrapper
|
|
|
|
* function everywhere instead of calling evas_object_geometry_get()
|
|
|
|
* directly.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h)
|
|
|
|
{
|
|
|
|
if (!rp->part->use_alternate_font_metrics)
|
|
|
|
evas_object_geometry_get(rp->object, NULL, NULL, w, h);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (w) *w = evas_object_text_horiz_advance_get(rp->object);
|
|
|
|
if (h) *h = evas_object_text_vert_advance_get(rp->object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
Edje_Part *pt = ep->part;
|
2010-07-29 05:02:36 -07:00
|
|
|
Edje_Part_Description_Text *desc;
|
|
|
|
unsigned int i;
|
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
|
|
|
|
2006-03-18 20:22:35 -08:00
|
|
|
/* if text class exists for this part, add the edje to the tc member list */
|
2010-07-29 05:02:36 -07:00
|
|
|
desc = (Edje_Part_Description_Text *) pt->default_desc;
|
|
|
|
if ((pt->default_desc) && (desc->text.text_class))
|
|
|
|
_edje_text_class_member_add(ed, desc->text.text_class);
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2006-03-27 23:45:54 -08:00
|
|
|
/* If any other classes exist add them */
|
2010-08-09 10:34:03 -07:00
|
|
|
for (i = 0; i < pt->other.desc_count; ++i)
|
2010-07-29 05:02:36 -07:00
|
|
|
{
|
2010-08-09 10:34:03 -07:00
|
|
|
desc = (Edje_Part_Description_Text *) pt->other.desc[i];
|
2010-07-29 05:02:36 -07:00
|
|
|
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
|
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
|
|
|
{
|
2010-07-29 05:02:36 -07:00
|
|
|
Edje_Part_Description_Text *desc;
|
|
|
|
unsigned int i;
|
|
|
|
|
2011-04-08 22:48:47 -07:00
|
|
|
if (!pt) return;
|
2010-07-29 05:02:36 -07:00
|
|
|
if (pt->type != EDJE_PART_TYPE_TEXT
|
|
|
|
&& pt->type != EDJE_PART_TYPE_TEXTBLOCK)
|
|
|
|
return ;
|
2003-11-03 22:15:19 -08:00
|
|
|
|
2010-07-29 05:02:36 -07:00
|
|
|
desc = (Edje_Part_Description_Text *) pt->default_desc;
|
|
|
|
if ((pt->default_desc) && (desc->text.text_class))
|
|
|
|
_edje_text_class_member_del(ed, desc->text.text_class);
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-08-09 10:34:03 -07:00
|
|
|
for (i = 0; i < pt->other.desc_count; ++i)
|
2010-07-29 05:02:36 -07:00
|
|
|
{
|
2010-08-09 10:34:03 -07:00
|
|
|
desc = (Edje_Part_Description_Text *) pt->other.desc[i];
|
2010-07-29 05:02:36 -07:00
|
|
|
if (desc->text.text_class)
|
|
|
|
_edje_text_class_member_del(ed, desc->text.text_class);
|
|
|
|
}
|
2003-11-24 23:22:19 -08:00
|
|
|
}
|
|
|
|
|
2004-10-30 12:18:32 -07:00
|
|
|
static void
|
2006-03-18 20:22:35 -08:00
|
|
|
_edje_text_fit_set(char *buf, const char *text, int c1, int c2)
|
2004-10-30 12:18:32 -07:00
|
|
|
{
|
|
|
|
/* 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)
|
|
|
|
{
|
2011-02-03 00:55:40 -08:00
|
|
|
strcpy(buf, _ELLIP_STR);
|
2004-10-30 12:18:32 -07:00
|
|
|
|
|
|
|
if (c2 >= 0)
|
|
|
|
{
|
|
|
|
strncat(buf, text + c1, c2 - c1);
|
2011-02-03 00:55:40 -08:00
|
|
|
strcat(buf, _ELLIP_STR);
|
2004-10-30 12:18:32 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
strcat(buf, text + c1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (c2 >= 0)
|
|
|
|
{
|
|
|
|
strncpy(buf, text, c2);
|
|
|
|
buf[c2] = 0;
|
2011-02-03 00:55:40 -08:00
|
|
|
strcat(buf, _ELLIP_STR);
|
2004-10-30 12:18:32 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy(buf, text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-18 20:22:35 -08:00
|
|
|
static const char *
|
2004-10-30 08:51:55 -07:00
|
|
|
_edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
|
|
|
|
Edje_Calc_Params *params,
|
2006-03-18 20:22:35 -08:00
|
|
|
const char *text, const 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;
|
2007-06-18 09:48:43 -07:00
|
|
|
int l, r;
|
2010-10-12 05:22:43 -07:00
|
|
|
int i;
|
2004-10-30 08:51:55 -07:00
|
|
|
char *buf;
|
2010-10-12 05:22:43 -07:00
|
|
|
int uc1 = -1, uc2 = -1, c1 = -1, c2 = -1;
|
|
|
|
int loop = 0, extra;
|
2004-10-30 08:51:55 -07:00
|
|
|
size_t orig_len;
|
2009-12-09 07:44:54 -08:00
|
|
|
FLOAT_T sc;
|
2004-10-30 08:51:55 -07:00
|
|
|
|
2009-02-02 21:07:58 -08:00
|
|
|
sc = ed->scale;
|
2009-12-09 07:44:54 -08:00
|
|
|
if (sc == ZERO) sc = _edje_scale;
|
2010-06-24 09:16:50 -07:00
|
|
|
|
2004-10-30 09:54:58 -07:00
|
|
|
*free_text = 0;
|
2008-10-01 21:01:54 -07:00
|
|
|
if (sw <= 1) return "";
|
2004-10-30 09:54:58 -07:00
|
|
|
|
2009-12-09 07:44:54 -08:00
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
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);
|
|
|
|
|
2007-03-30 16:39:41 -07:00
|
|
|
part_get_geometry(ep, &tw, &th);
|
2007-06-18 09:48:43 -07:00
|
|
|
evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
|
2004-10-30 08:51:55 -07:00
|
|
|
|
2009-08-10 02:56:19 -07:00
|
|
|
p = ((sw - tw) * params->type.text.elipsis);
|
2004-10-30 08:51:55 -07:00
|
|
|
|
|
|
|
/* chop chop */
|
|
|
|
if (tw > sw)
|
|
|
|
{
|
2009-08-10 02:56:19 -07:00
|
|
|
if (params->type.text.elipsis != 0.0)
|
2009-11-21 17:49:44 -08:00
|
|
|
/* should be the last in text! not the rightmost */
|
2010-10-12 05:22:43 -07:00
|
|
|
uc1 = evas_object_text_last_up_to_pos(ep->object,
|
2009-11-21 17:49:44 -08:00
|
|
|
-p + l, th / 2);
|
2009-08-10 02:56:19 -07:00
|
|
|
if (params->type.text.elipsis != 1.0)
|
2011-06-12 07:12:52 -07:00
|
|
|
{
|
|
|
|
/* should be the last in text! not the rightmost */
|
|
|
|
if ((-p + sw -r) < 0)
|
|
|
|
uc2 = evas_object_text_last_up_to_pos(ep->object, 0, th / 2);
|
|
|
|
else
|
|
|
|
uc2 = evas_object_text_last_up_to_pos(ep->object,
|
|
|
|
-p + sw - r, th / 2);
|
|
|
|
}
|
2010-10-12 05:22:43 -07:00
|
|
|
if ((uc1 < 0) && (uc2 < 0))
|
2004-10-30 08:51:55 -07:00
|
|
|
{
|
2010-10-12 05:22:43 -07:00
|
|
|
uc1 = 0;
|
|
|
|
uc2 = 0;
|
2004-10-30 08:51:55 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 05:22:43 -07:00
|
|
|
if (!(((uc1 >= 0) || (uc2 >= 0)) && (tw > sw)))
|
2008-04-05 19:08:21 -07:00
|
|
|
return text;
|
|
|
|
|
2010-10-12 05:22:43 -07:00
|
|
|
if ((uc1 == 0) && (uc2 == 0))
|
2004-10-30 09:54:58 -07:00
|
|
|
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 */
|
2010-06-24 09:16:50 -07:00
|
|
|
orig_len = MIN(orig_len, ((size_t) 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
|
|
|
|
2010-10-12 05:22:43 -07:00
|
|
|
/* Convert uc1, uc2 -> c1, c2 */
|
|
|
|
i = 0;
|
2011-05-09 10:23:03 -07:00
|
|
|
if (uc1 >= 0)
|
2010-10-12 05:22:43 -07:00
|
|
|
{
|
|
|
|
c1 = 0;
|
|
|
|
for ( ; i < uc1 ; i++)
|
|
|
|
{
|
|
|
|
c1 = evas_string_char_next_get(text, c1, NULL);
|
|
|
|
}
|
|
|
|
}
|
2011-05-09 10:23:03 -07:00
|
|
|
if (uc2 >= 0)
|
2010-10-12 05:22:43 -07:00
|
|
|
{
|
2011-07-19 04:21:35 -07:00
|
|
|
if (c1 >= 0)
|
|
|
|
{
|
|
|
|
c2 = c1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
c2 = 0;
|
|
|
|
}
|
2010-10-12 05:22:43 -07:00
|
|
|
for ( ; i < uc2 ; i++)
|
|
|
|
{
|
|
|
|
c2 = evas_string_char_next_get(text, c2, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-02 08:03:22 -08:00
|
|
|
buf[0] = '\0';
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2010-06-24 09:16:50 -07:00
|
|
|
else if ((c1 > 0 && (size_t) 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);
|
2007-03-30 16:39:41 -07:00
|
|
|
part_get_geometry(ep, &tw, &th);
|
2004-10-30 08:51:55 -07:00
|
|
|
}
|
2004-10-30 09:54:58 -07:00
|
|
|
|
|
|
|
*free_text = 1;
|
|
|
|
|
|
|
|
return buf;
|
2004-10-30 08:51:55 -07:00
|
|
|
}
|
|
|
|
|
2008-02-29 13:43:55 -08:00
|
|
|
static const char *
|
|
|
|
_edje_text_font_get(const char *base, const char *new, char **free_later)
|
|
|
|
{
|
|
|
|
const char *base_style, *new_style, *aux;
|
2010-12-13 22:19:30 -08:00
|
|
|
size_t font_len, style_len;
|
2008-02-29 13:43:55 -08:00
|
|
|
|
|
|
|
if (base && (!new))
|
|
|
|
return base;
|
2009-10-07 03:55:48 -07:00
|
|
|
else if (!base)
|
2008-02-29 13:43:55 -08:00
|
|
|
return new;
|
|
|
|
|
|
|
|
base_style = strstr(base, ":style=");
|
|
|
|
if (!base_style)
|
|
|
|
return new;
|
|
|
|
|
|
|
|
new_style = strstr(new, ":style=");
|
|
|
|
if (new_style)
|
|
|
|
return new;
|
|
|
|
|
|
|
|
font_len = strlen(new);
|
|
|
|
aux = strchr(base_style, ',');
|
2011-01-15 19:31:05 -08:00
|
|
|
style_len = (aux) ? (size_t)(aux - base_style) : strlen(base_style);
|
2008-02-29 13:43:55 -08:00
|
|
|
|
|
|
|
*free_later = malloc(font_len + style_len + 1);
|
|
|
|
memcpy(*free_later, new, font_len);
|
|
|
|
memcpy(*free_later + font_len, base_style, style_len);
|
|
|
|
(*free_later)[font_len + style_len] = '\0';
|
|
|
|
|
|
|
|
return *free_later;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2010-07-29 05:02:36 -07:00
|
|
|
_edje_text_class_font_get(Edje *ed, Edje_Part_Description_Text *chosen_desc, int *size, char **free_later)
|
2008-02-29 13:43:55 -08:00
|
|
|
{
|
|
|
|
Edje_Text_Class *tc;
|
|
|
|
const char *text_class_name, *font;
|
|
|
|
|
2010-08-12 05:58:54 -07:00
|
|
|
font = edje_string_get(&chosen_desc->text.font);
|
2008-02-29 13:43:55 -08:00
|
|
|
*size = chosen_desc->text.size;
|
|
|
|
|
|
|
|
text_class_name = chosen_desc->text.text_class;
|
|
|
|
if ((!text_class_name) || (!text_class_name[0]))
|
|
|
|
return font;
|
|
|
|
|
|
|
|
tc = _edje_text_class_find(ed, text_class_name);
|
|
|
|
if (!tc)
|
|
|
|
return font;
|
|
|
|
|
2010-08-12 05:58:54 -07:00
|
|
|
font = _edje_text_font_get(edje_string_get(&chosen_desc->text.font), tc->font, free_later);
|
2008-02-29 13:43:55 -08:00
|
|
|
*size = _edje_text_size_calc(*size, tc);
|
|
|
|
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
void
|
|
|
|
_edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
|
|
|
Edje_Calc_Params *params,
|
2010-07-29 05:02:36 -07:00
|
|
|
Edje_Part_Description_Text *chosen_desc)
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
2011-02-02 08:03:22 -08:00
|
|
|
const char *text = NULL;
|
|
|
|
const char *str;
|
2006-03-18 20:22:35 -08:00
|
|
|
const char *font;
|
|
|
|
char *font2 = NULL;
|
2007-09-16 22:07:35 -07:00
|
|
|
char *sfont = NULL;
|
2006-03-18 20:22:35 -08:00
|
|
|
int size;
|
|
|
|
Evas_Coord tw, th;
|
|
|
|
Evas_Coord sw, sh;
|
|
|
|
int inlined_font = 0, free_text = 0;
|
2009-12-09 07:44:54 -08:00
|
|
|
FLOAT_T sc;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2009-02-02 21:07:58 -08:00
|
|
|
sc = ed->scale;
|
|
|
|
if (sc == 0.0) sc = _edje_scale;
|
2010-08-12 05:58:54 -07:00
|
|
|
text = edje_string_get(&chosen_desc->text.text);
|
2008-02-29 13:43:55 -08:00
|
|
|
font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2006-03-18 20:22:35 -08:00
|
|
|
if (ep->text.text) text = (char *) ep->text.text;
|
2003-07-07 00:55:18 -07:00
|
|
|
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
|
|
|
|
2007-10-14 16:54:27 -07:00
|
|
|
if (ep->text.text_source)
|
|
|
|
{
|
2010-08-12 05:58:54 -07:00
|
|
|
text = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.text_source->chosen_description)->text.text));
|
2007-10-14 16:54:27 -07:00
|
|
|
if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
|
|
|
|
}
|
|
|
|
if (ep->text.source)
|
|
|
|
{
|
2010-08-12 05:58:54 -07:00
|
|
|
font = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.font));
|
2010-07-29 05:02:36 -07:00
|
|
|
size = ((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.size;
|
2007-10-14 16:54:27 -07:00
|
|
|
if (ep->text.source->text.font) font = ep->text.source->text.font;
|
|
|
|
if (ep->text.source->text.size > 0) size = ep->text.source->text.size;
|
|
|
|
}
|
2008-03-24 01:22:01 -07:00
|
|
|
|
2005-11-24 00:10:22 -08:00
|
|
|
if (!text) text = "";
|
|
|
|
if (!font) font = "";
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2004-08-30 01:07:00 -07:00
|
|
|
/* check if the font is embedded in the .eet */
|
2010-06-28 06:56:30 -07:00
|
|
|
if (ed->file->fonts)
|
2004-08-30 01:07:00 -07:00
|
|
|
{
|
2010-06-28 06:56:30 -07:00
|
|
|
Edje_Font_Directory_Entry *fnt = eina_hash_find(ed->file->fonts, font);
|
2007-04-04 06:25:55 -07:00
|
|
|
|
|
|
|
if (fnt)
|
2004-08-30 01:07:00 -07:00
|
|
|
{
|
2010-10-11 00:24:46 -07:00
|
|
|
char *font2;
|
|
|
|
|
2010-12-13 22:19:30 -08:00
|
|
|
size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
|
2010-10-11 00:24:46 -07:00
|
|
|
font2 = alloca(len);
|
2010-10-11 00:31:12 -07:00
|
|
|
sprintf(font2, "edje/fonts/%s", font);
|
2010-10-11 00:24:46 -07:00
|
|
|
font = font2;
|
2007-04-04 06:25:55 -07:00
|
|
|
inlined_font = 1;
|
2004-08-30 01:07:00 -07:00
|
|
|
}
|
|
|
|
}
|
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;
|
2007-09-08 11:31:56 -07: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
|
|
|
}
|
2009-02-05 10:15:34 -08:00
|
|
|
|
2009-08-10 02:56:19 -07:00
|
|
|
size = params->type.text.size;
|
2009-02-05 10:15: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)) &&
|
2009-08-10 02:56:19 -07:00
|
|
|
(ep->text.cache.align_x == params->type.text.align.x) &&
|
|
|
|
(ep->text.cache.align_y == params->type.text.align.y) &&
|
|
|
|
(ep->text.cache.elipsis == params->type.text.elipsis) &&
|
2006-06-28 11:31:56 -07:00
|
|
|
(ep->text.cache.fit_x == chosen_desc->text.fit_x) &&
|
|
|
|
(ep->text.cache.fit_y == chosen_desc->text.fit_y))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
2007-10-14 16:54:27 -07:00
|
|
|
text = (char *)ep->text.cache.out_str;
|
2003-07-07 00:55:18 -07:00
|
|
|
size = ep->text.cache.out_size;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2005-11-24 00:10:22 -08:00
|
|
|
if (!text) text = "";
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
goto arrange_text;
|
|
|
|
}
|
2008-10-15 07:11:11 -07:00
|
|
|
if (ep->text.cache.in_str) eina_stringshare_del(ep->text.cache.in_str);
|
|
|
|
ep->text.cache.in_str = eina_stringshare_add(text);
|
2003-07-07 00:55:18 -07:00
|
|
|
ep->text.cache.in_size = size;
|
2010-08-21 06:52:25 -07:00
|
|
|
if (chosen_desc->text.fit_x && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
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);
|
2006-03-18 20:22:35 -08:00
|
|
|
|
2009-12-09 07:44:54 -08:00
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
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);
|
2007-03-30 16:39:41 -07:00
|
|
|
part_get_geometry(ep, &tw, &th);
|
2011-02-27 10:09:00 -08:00
|
|
|
/* Find the wanted font size */
|
|
|
|
if ((tw > sw) && (size > 0) && (tw != 0))
|
|
|
|
{
|
|
|
|
size = (size * sw) / tw;
|
|
|
|
|
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
|
|
|
|
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
part_get_geometry(ep, &tw, &th);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
2011-02-27 10:09:00 -08:00
|
|
|
else if ((tw < sw) && (size > 0) && (tw != 0))
|
|
|
|
{
|
|
|
|
size = (size * sw) / tw;
|
|
|
|
|
|
|
|
if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
|
|
|
|
else evas_object_text_font_source_set(ep->object, NULL);
|
|
|
|
|
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
|
|
|
part_get_geometry(ep, &tw, &th);
|
|
|
|
}
|
|
|
|
/* FIXME: This should possibly be replaced by more proper handling,
|
|
|
|
* but it's still way better than what was here before. */
|
|
|
|
if (tw > sw) size--;
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
2010-08-21 06:52:25 -07:00
|
|
|
if (chosen_desc->text.fit_y && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0))
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
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);
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2009-12-09 07:44:54 -08:00
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
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);
|
2007-03-30 16:39:41 -07:00
|
|
|
part_get_geometry(ep, &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;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
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);
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2009-12-09 07:44:54 -08:00
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, size);
|
2007-03-30 16:39:41 -07:00
|
|
|
part_get_geometry(ep, &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)
|
|
|
|
{
|
Fix calculation of font size when text.fit_y is set.
Before it was using a linear search with initial step proportional to
difference bettwen desired and current height, but the way it was
implemented it was giving incorrect values, for example: a text in
an animation that enlarges height was getting size_{n} < size_{n-1},
where it should be always the oposite (the sequence was like: 31, 32,
33, 34, 31, 33, 34, 35, ...).
One way to avoid that was to recalculate "dif" based on new "th",
but it quickly drop to 1.
The current implementation now uses a binary search to find the first
size that matches the desired height and then a linear search to
search the largest font doing that (differents sizes may result in the
same height). This linear search is often an extra lookup and can be
avoided if we want just something that fits (instead of the largest).
SVN revision: 32146
2007-10-22 15:31:13 -07:00
|
|
|
int current;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2009-12-09 07:44:54 -08:00
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
Fix calculation of font size when text.fit_y is set.
Before it was using a linear search with initial step proportional to
difference bettwen desired and current height, but the way it was
implemented it was giving incorrect values, for example: a text in
an animation that enlarges height was getting size_{n} < size_{n-1},
where it should be always the oposite (the sequence was like: 31, 32,
33, 34, 31, 33, 34, 35, ...).
One way to avoid that was to recalculate "dif" based on new "th",
but it quickly drop to 1.
The current implementation now uses a binary search to find the first
size that matches the desired height and then a linear search to
search the largest font doing that (differents sizes may result in the
same height). This linear search is often an extra lookup and can be
avoided if we want just something that fits (instead of the largest).
SVN revision: 32146
2007-10-22 15:31:13 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, 10);
|
|
|
|
part_get_geometry(ep, &tw, &th);
|
|
|
|
|
|
|
|
if (th == sh)
|
|
|
|
current = 10;
|
|
|
|
else
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
Fix calculation of font size when text.fit_y is set.
Before it was using a linear search with initial step proportional to
difference bettwen desired and current height, but the way it was
implemented it was giving incorrect values, for example: a text in
an animation that enlarges height was getting size_{n} < size_{n-1},
where it should be always the oposite (the sequence was like: 31, 32,
33, 34, 31, 33, 34, 35, ...).
One way to avoid that was to recalculate "dif" based on new "th",
but it quickly drop to 1.
The current implementation now uses a binary search to find the first
size that matches the desired height and then a linear search to
search the largest font doing that (differents sizes may result in the
same height). This linear search is often an extra lookup and can be
avoided if we want just something that fits (instead of the largest).
SVN revision: 32146
2007-10-22 15:31:13 -07:00
|
|
|
int bottom, top;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-07-30 22:00:42 -07:00
|
|
|
if (th < sh) bottom = 10;
|
|
|
|
else if (th > sh) bottom = 1;
|
2008-12-05 19:08:17 -08:00
|
|
|
else bottom = 0; /* XXX shut up GCC, th == sh is handled before! */
|
Fix calculation of font size when text.fit_y is set.
Before it was using a linear search with initial step proportional to
difference bettwen desired and current height, but the way it was
implemented it was giving incorrect values, for example: a text in
an animation that enlarges height was getting size_{n} < size_{n-1},
where it should be always the oposite (the sequence was like: 31, 32,
33, 34, 31, 33, 34, 35, ...).
One way to avoid that was to recalculate "dif" based on new "th",
but it quickly drop to 1.
The current implementation now uses a binary search to find the first
size that matches the desired height and then a linear search to
search the largest font doing that (differents sizes may result in the
same height). This linear search is often an extra lookup and can be
avoided if we want just something that fits (instead of the largest).
SVN revision: 32146
2007-10-22 15:31:13 -07:00
|
|
|
|
|
|
|
top = size;
|
|
|
|
/* search one that fits (binary search) */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
current = (top + bottom) / 2;
|
|
|
|
|
2009-12-09 07:44:54 -08:00
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
Fix calculation of font size when text.fit_y is set.
Before it was using a linear search with initial step proportional to
difference bettwen desired and current height, but the way it was
implemented it was giving incorrect values, for example: a text in
an animation that enlarges height was getting size_{n} < size_{n-1},
where it should be always the oposite (the sequence was like: 31, 32,
33, 34, 31, 33, 34, 35, ...).
One way to avoid that was to recalculate "dif" based on new "th",
but it quickly drop to 1.
The current implementation now uses a binary search to find the first
size that matches the desired height and then a linear search to
search the largest font doing that (differents sizes may result in the
same height). This linear search is often an extra lookup and can be
avoided if we want just something that fits (instead of the largest).
SVN revision: 32146
2007-10-22 15:31:13 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, current);
|
|
|
|
part_get_geometry(ep, &tw, &th);
|
|
|
|
|
|
|
|
if (th < sh) bottom = current + 1;
|
|
|
|
else if (th > sh) top = current - 1;
|
|
|
|
} while ((bottom < top) && (th != sh));
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
Fix calculation of font size when text.fit_y is set.
Before it was using a linear search with initial step proportional to
difference bettwen desired and current height, but the way it was
implemented it was giving incorrect values, for example: a text in
an animation that enlarges height was getting size_{n} < size_{n-1},
where it should be always the oposite (the sequence was like: 31, 32,
33, 34, 31, 33, 34, 35, ...).
One way to avoid that was to recalculate "dif" based on new "th",
but it quickly drop to 1.
The current implementation now uses a binary search to find the first
size that matches the desired height and then a linear search to
search the largest font doing that (differents sizes may result in the
same height). This linear search is often an extra lookup and can be
avoided if we want just something that fits (instead of the largest).
SVN revision: 32146
2007-10-22 15:31:13 -07:00
|
|
|
|
|
|
|
/* search the larger one that fits (linear search) */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
current++;
|
|
|
|
|
2009-12-09 07:44:54 -08:00
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
Fix calculation of font size when text.fit_y is set.
Before it was using a linear search with initial step proportional to
difference bettwen desired and current height, but the way it was
implemented it was giving incorrect values, for example: a text in
an animation that enlarges height was getting size_{n} < size_{n-1},
where it should be always the oposite (the sequence was like: 31, 32,
33, 34, 31, 33, 34, 35, ...).
One way to avoid that was to recalculate "dif" based on new "th",
but it quickly drop to 1.
The current implementation now uses a binary search to find the first
size that matches the desired height and then a linear search to
search the largest font doing that (differents sizes may result in the
same height). This linear search is often an extra lookup and can be
avoided if we want just something that fits (instead of the largest).
SVN revision: 32146
2007-10-22 15:31:13 -07:00
|
|
|
evas_object_text_font_set(ep->object, font, current);
|
|
|
|
part_get_geometry(ep, &tw, &th);
|
|
|
|
} while (th <= sh);
|
|
|
|
size = current - 1;
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
}
|
2004-10-30 08:51:55 -07:00
|
|
|
|
2011-02-27 10:09:03 -08:00
|
|
|
/* Make sure the size is in range */
|
|
|
|
if (size < 1)
|
|
|
|
size = 1;
|
|
|
|
else if ((size > chosen_desc->text.size_range_max) &&
|
|
|
|
(chosen_desc->text.size_range_max > 0))
|
|
|
|
size = chosen_desc->text.size_range_max;
|
|
|
|
else if (size < chosen_desc->text.size_range_min)
|
|
|
|
size = chosen_desc->text.size_range_min;
|
|
|
|
|
|
|
|
/* Handle ellipsis */
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
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
|
|
|
|
2006-03-18 20:22:35 -08: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
|
|
|
|
2010-12-04 19:12:34 -08:00
|
|
|
str = eina_stringshare_add(text);
|
2008-10-15 07:11:11 -07:00
|
|
|
if (ep->text.cache.out_str) eina_stringshare_del(ep->text.cache.out_str);
|
2010-12-04 19:12:34 -08:00
|
|
|
ep->text.cache.out_str = str;
|
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;
|
2009-08-10 02:56:19 -07:00
|
|
|
ep->text.cache.align_x = params->type.text.align.x;
|
|
|
|
ep->text.cache.align_y = params->type.text.align.y;
|
|
|
|
ep->text.cache.elipsis = params->type.text.elipsis;
|
2006-06-28 11:31:56 -07:00
|
|
|
ep->text.cache.fit_x = chosen_desc->text.fit_x;
|
|
|
|
ep->text.cache.fit_y = chosen_desc->text.fit_y;
|
2003-07-07 00:55:18 -07:00
|
|
|
arrange_text:
|
2007-09-08 11:31:56 -07:00
|
|
|
|
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);
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2009-12-09 07:44:54 -08:00
|
|
|
if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
|
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);
|
2007-03-30 16:39:41 -07:00
|
|
|
part_get_geometry(ep, &tw, &th);
|
2011-01-30 02:46:39 -08:00
|
|
|
/* Handle alignment */
|
|
|
|
{
|
|
|
|
double align_x;
|
|
|
|
if (params->type.text.align.x < 0.0)
|
|
|
|
{
|
|
|
|
if (evas_object_text_direction_get(ep->object) ==
|
|
|
|
EVAS_BIDI_DIRECTION_RTL)
|
|
|
|
{
|
|
|
|
align_x = 1.0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
align_x = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
align_x = params->type.text.align.x;
|
|
|
|
}
|
|
|
|
ep->text.offset.x = TO_INT(SCALE(align_x, (sw - tw)));
|
|
|
|
ep->text.offset.y = TO_INT(SCALE(params->type.text.align.y, (sh - th)));
|
|
|
|
}
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
evas_object_move(ep->object,
|
2009-08-11 03:32:21 -07:00
|
|
|
ed->x + params->x + ep->text.offset.x,
|
|
|
|
ed->y + params->y + ep->text.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;
|
2011-04-11 05:08:03 -07:00
|
|
|
Edje_Text_Effect effect;
|
2005-11-26 00:14:34 -08:00
|
|
|
|
2006-03-18 20:22:35 -08:00
|
|
|
style = EVAS_TEXT_STYLE_PLAIN;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2005-11-26 00:14:34 -08:00
|
|
|
evas_object_color_set(ep->object,
|
2006-09-30 03:18:37 -07:00
|
|
|
(params->color.r * params->color.a) / 255,
|
|
|
|
(params->color.g * params->color.a) / 255,
|
|
|
|
(params->color.b * params->color.a) / 255,
|
2005-11-26 00:14:34 -08:00
|
|
|
params->color.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
effect = ep->part->effect;
|
|
|
|
switch (effect & EDJE_TEXT_EFFECT_MASK_BASIC)
|
|
|
|
{
|
|
|
|
case EDJE_TEXT_EFFECT_NONE:
|
|
|
|
case EDJE_TEXT_EFFECT_PLAIN:
|
2005-11-26 00:14:34 -08:00
|
|
|
style = EVAS_TEXT_STYLE_PLAIN;
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_OUTLINE:
|
2005-11-26 00:14:34 -08:00
|
|
|
style = EVAS_TEXT_STYLE_OUTLINE;
|
|
|
|
evas_object_text_outline_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color2.r * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.g * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.b * params->type.text.color2.a) / 255,
|
|
|
|
params->type.text.color2.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SOFT_OUTLINE:
|
2005-11-26 00:14:34 -08:00
|
|
|
style = EVAS_TEXT_STYLE_SOFT_OUTLINE;
|
|
|
|
evas_object_text_outline_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color2.r * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.g * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.b * params->type.text.color2.a) / 255,
|
|
|
|
params->type.text.color2.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW:
|
2005-11-26 00:14:34 -08:00
|
|
|
style = EVAS_TEXT_STYLE_SHADOW;
|
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color3.r * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.g * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.b * params->type.text.color3.a) / 255,
|
|
|
|
params->type.text.color3.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SOFT_SHADOW:
|
2005-11-26 00:14:34 -08:00
|
|
|
style = EVAS_TEXT_STYLE_SOFT_SHADOW;
|
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color3.r * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.g * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.b * params->type.text.color3.a) / 255,
|
|
|
|
params->type.text.color3.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_OUTLINE_SHADOW:
|
2005-11-26 00:14:34 -08:00
|
|
|
style = EVAS_TEXT_STYLE_OUTLINE_SHADOW;
|
|
|
|
evas_object_text_outline_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color2.r * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.g * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.b * params->type.text.color2.a) / 255,
|
|
|
|
params->type.text.color2.a);
|
2005-11-26 00:14:34 -08:00
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color3.r * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.g * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.b * params->type.text.color3.a) / 255,
|
|
|
|
params->type.text.color3.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW:
|
2005-11-26 00:14:34 -08:00
|
|
|
style = EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW;
|
|
|
|
evas_object_text_outline_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color2.r * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.g * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.b * params->type.text.color2.a) / 255,
|
|
|
|
params->type.text.color2.a);
|
2005-11-26 00:14:34 -08:00
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color3.r * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.g * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.b * params->type.text.color3.a) / 255,
|
|
|
|
params->type.text.color3.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_FAR_SHADOW:
|
2007-07-06 16:33:42 -07:00
|
|
|
style = EVAS_TEXT_STYLE_FAR_SHADOW;
|
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color3.r * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.g * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.b * params->type.text.color3.a) / 255,
|
|
|
|
params->type.text.color3.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW:
|
2007-07-06 16:33:42 -07:00
|
|
|
style = EVAS_TEXT_STYLE_FAR_SOFT_SHADOW;
|
|
|
|
evas_object_text_shadow_color_set(ep->object,
|
2009-08-13 09:13:49 -07:00
|
|
|
(params->type.text.color3.r * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.g * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.b * params->type.text.color3.a) / 255,
|
|
|
|
params->type.text.color3.a);
|
2011-04-11 05:08:03 -07:00
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_GLOW:
|
2007-07-06 16:33:42 -07:00
|
|
|
style = EVAS_TEXT_STYLE_GLOW;
|
|
|
|
evas_object_text_glow_color_set(ep->object,
|
2011-04-11 05:08:03 -07:00
|
|
|
(params->type.text.color2.r * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.g * params->type.text.color2.a) / 255,
|
|
|
|
(params->type.text.color2.b * params->type.text.color2.a) / 255,
|
|
|
|
params->type.text.color2.a);
|
2007-07-06 16:33:42 -07:00
|
|
|
evas_object_text_glow2_color_set(ep->object,
|
2011-04-11 05:08:03 -07:00
|
|
|
(params->type.text.color3.r * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.g * params->type.text.color3.a) / 255,
|
|
|
|
(params->type.text.color3.b * params->type.text.color3.a) / 255,
|
|
|
|
params->type.text.color3.a);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
style = EVAS_TEXT_STYLE_PLAIN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION)
|
|
|
|
{
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT:
|
|
|
|
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
|
|
|
|
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT);
|
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM:
|
|
|
|
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
|
|
|
|
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM);
|
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT:
|
|
|
|
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
|
|
|
|
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT);
|
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT:
|
|
|
|
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
|
|
|
|
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT);
|
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT:
|
|
|
|
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
|
|
|
|
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT);
|
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP:
|
|
|
|
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
|
|
|
|
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP);
|
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT:
|
|
|
|
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
|
|
|
|
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT);
|
|
|
|
break;
|
|
|
|
case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT:
|
|
|
|
EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
|
|
|
|
(style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-11-26 00:14:34 -08:00
|
|
|
evas_object_text_style_set(ep->object, style);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
2011-04-11 05:08:03 -07:00
|
|
|
|
|
|
|
if (free_text) free((char *)text);
|
|
|
|
if (font2) free(font2);
|
|
|
|
if (sfont) free(sfont);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
2007-05-03 16:15:09 -07:00
|
|
|
|
|
|
|
Evas_Font_Size
|
|
|
|
_edje_text_size_calc(Evas_Font_Size size, Edje_Text_Class *tc)
|
|
|
|
{
|
|
|
|
int val;
|
|
|
|
|
|
|
|
if (tc->size == 0)
|
|
|
|
{
|
|
|
|
val = size;
|
|
|
|
}
|
|
|
|
else if (tc->size > 0.0)
|
|
|
|
{
|
|
|
|
val = tc->size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
val = (size * -tc->size) / 100;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|