1 #include <Elementary.h>
5 * @defgroup Label Label
7 * Display text, with simple html-like markup. The theme of course
8 * can invent new markup tags and style them any way it likes
11 typedef struct _Widget_Data Widget_Data;
19 Ecore_Job *deferred_recalc_job;
20 double slide_duration;
24 Eina_Bool linewrap : 1;
25 Eina_Bool changed : 1;
26 Eina_Bool bgcolor : 1;
27 Eina_Bool ellipsis : 1;
28 Eina_Bool slidingmode : 1;
29 Eina_Bool slidingellipsis : 1;
32 static const char *widtype = NULL;
33 static void _del_hook(Evas_Object *obj);
34 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
35 static void _theme_hook(Evas_Object *obj);
36 static void _sizing_eval(Evas_Object *obj);
37 static int _get_value_in_key_string(const char *oldstring, const char *key, char **value);
38 static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, const char *key, const char *value, int deleteflag);
39 static int _stringshare_key_value_replace(const char **srcstring, const char *key, const char *value, int deleteflag);
40 static int _is_width_over(Evas_Object *obj);
41 static void _ellipsis_label_to_width(Evas_Object *obj);
42 static void _label_sliding_change(Evas_Object *obj);
45 _elm_win_recalc_job(void *data)
47 Widget_Data *wd = elm_widget_data_get(data);
48 Evas_Coord minw = -1, minh = -1;
51 wd->deferred_recalc_job = NULL;
52 evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, NULL);
53 if (wd->wrap_w > resw)
56 edje_object_size_min_restricted_calc(wd->lbl, &minw, &minh, resw, 0);
57 /* This is a hack to workaround the way min size hints are treated.
58 * If the minimum width is smaller than the restricted width, it means
59 * the mininmum doesn't matter. */
60 if ((minw <= resw) && (minw != wd->wrap_w))
62 Evas_Coord ominw = -1;
63 evas_object_size_hint_min_get(data, &ominw, NULL);
66 evas_object_size_hint_min_set(data, minw, minh);
67 evas_object_size_hint_max_set(data, wd->wrap_w, wd->wrap_h);
69 if ((wd->ellipsis) && (wd->linewrap) && (wd->wrap_h > 0) &&
70 (_is_width_over(data) == 1))
71 _ellipsis_label_to_width(data);
75 _del_hook(Evas_Object *obj)
77 Widget_Data *wd = elm_widget_data_get(obj);
79 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
80 if (wd->label) eina_stringshare_del(wd->label);
81 if (wd->bg) evas_object_del(wd->bg);
86 _theme_change(Evas_Object *obj)
88 Widget_Data *wd = elm_widget_data_get(obj);
91 _elm_theme_object_set(obj, wd->lbl, "label", "base",
92 elm_widget_style_get(obj));
96 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
98 Widget_Data *wd = elm_widget_data_get(obj);
100 edje_object_mirrored_set(wd->lbl, rtl);
104 _theme_hook(Evas_Object *obj)
106 Widget_Data *wd = elm_widget_data_get(obj);
108 _elm_widget_mirrored_reload(obj);
109 _mirrored_set(obj, elm_widget_mirrored_get(obj));
111 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
112 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
113 edje_object_scale_set(wd->lbl, elm_widget_scale_get(obj) *
115 _label_sliding_change(obj);
120 _sizing_eval(Evas_Object *obj)
122 Widget_Data *wd = elm_widget_data_get(obj);
123 Evas_Coord minw = -1, minh = -1;
124 Evas_Coord resw, resh;
129 evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
130 if ((resw == wd->lastw) && (!wd->changed)) return;
131 wd->changed = EINA_FALSE;
133 _elm_win_recalc_job(obj);
134 // FIXME: works ok. but NOT for genlist. what should genlist do?
135 // if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
136 // wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
140 evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
141 edje_object_size_min_calc(wd->lbl, &minw, &minh);
142 if (wd->wrap_w > 0 && minw > wd->wrap_w) minw = wd->wrap_w;
143 if (wd->wrap_h > 0 && minh > wd->wrap_h) minh = wd->wrap_h;
144 evas_object_size_hint_min_set(obj, minw, minh);
145 evas_object_size_hint_max_set(obj, wd->wrap_w, wd->wrap_h);
146 if ((wd->ellipsis) && (_is_width_over(obj) == 1))
147 _ellipsis_label_to_width(obj);
152 _lbl_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
154 Widget_Data *wd = elm_widget_data_get(data);
156 if (wd->linewrap) _sizing_eval(data);
160 _get_value_in_key_string(const char *oldstring, const char *key, char **value)
162 char *curlocater, *starttag, *endtag;
163 int firstindex = 0, foundflag = -1;
165 curlocater = strstr(oldstring, key);
168 int key_len = strlen(key);
169 starttag = curlocater;
170 endtag = curlocater + key_len;
171 if ((!endtag) || (*endtag != '='))
176 firstindex = abs(oldstring - curlocater);
177 firstindex += key_len + 1; // strlen("key") + strlen("=")
178 *value = (char *)oldstring + firstindex;
180 while (oldstring != starttag)
182 if (*starttag == '>')
187 if (*starttag == '<')
191 if (!starttag) break;
208 if ((foundflag) && (*starttag == '<') && (*endtag == '>'))
218 if (foundflag == 1) return 0;
225 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, const char *key, const char *value, int deleteflag)
227 const char *srcstring = NULL;
228 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
229 char *curlocater, *replocater;
230 char *starttag, *endtag;
231 int tagtxtlen = 0, insertflag = 0;
233 srcstring = eina_strbuf_string_get(srcbuf);
234 curlocater = strstr(srcstring, key);
240 int key_len = strlen(key);
243 starttag = strchr(srcstring, '<');
244 endtag = strchr(srcstring, '>');
245 tagtxtlen = endtag - starttag;
246 if (tagtxtlen <= 0) tagtxtlen = 0;
247 if ((starttag < curlocater) && (curlocater < endtag)) break;
248 if ((endtag) && ((endtag + 1)))
249 srcstring = endtag + 1;
252 } while (strlen(srcstring) > 1);
254 if ((starttag) && (endtag) && (tagtxtlen > key_len))
257 repbuf = eina_strbuf_new();
258 diffbuf = eina_strbuf_new();
259 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
260 srcstring = eina_strbuf_string_get(repbuf);
261 curlocater = strstr(srcstring, key);
264 eqchar = curlocater + key_len;
265 if ((curlocater) && (eqchar))
267 // some case at useless many whitespaces (key =value)
268 // find the separator(=) position
269 eqchar = strchr(curlocater + key_len, '=');
274 replocater = eqchar + 1;
275 while ((*replocater) &&
276 (*replocater != ' ') &&
277 (*replocater != '>'))
280 if ((replocater - curlocater) > key_len)
281 eina_strbuf_append_n(diffbuf, curlocater,
282 replocater-curlocater);
291 eina_strbuf_reset(repbuf);
297 if (!repbuf) repbuf = eina_strbuf_new();
298 if (!diffbuf) diffbuf = eina_strbuf_new();
302 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
303 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
309 eina_strbuf_prepend(diffbuf, "<");
310 eina_strbuf_append(diffbuf, ">");
311 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
315 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
316 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
320 if (repbuf) eina_strbuf_free(repbuf);
321 if (diffbuf) eina_strbuf_free(diffbuf);
327 _stringshare_key_value_replace(const char **srcstring, const char *key, const char *value, int deleteflag)
329 Eina_Strbuf *sharebuf = NULL;
331 sharebuf = eina_strbuf_new();
332 eina_strbuf_append(sharebuf, *srcstring);
333 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
334 eina_stringshare_del(*srcstring);
335 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
336 eina_strbuf_free(sharebuf);
342 _is_width_over(Evas_Object *obj)
344 Evas_Coord x, y, w, h;
345 Evas_Coord vx, vy, vw, vh;
346 Widget_Data *wd = elm_widget_data_get(obj);
349 edje_object_part_geometry_get(wd->lbl, "elm.text", &x, &y, NULL, NULL);
350 /* Calc the formatted size with ellipsis turned off */
353 const Evas_Object *tb;
355 double ellipsis = 0.0;
356 Eina_Bool found_key = EINA_FALSE;
357 if (_get_value_in_key_string(wd->format, "ellipsis", &_kvalue) == 0)
359 ellipsis = atof(_kvalue);
360 found_key = EINA_TRUE;
363 if (_stringshare_key_value_replace(&wd->format,
364 "ellipsis", NULL, 1) == 0)
366 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
367 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
370 tb = edje_object_part_object_get(wd->lbl, "elm.text");
371 evas_object_textblock_size_formatted_get(tb, &w, &h);
376 elpbuf = eina_strbuf_new();
377 eina_strbuf_append_printf(elpbuf, "%f", ellipsis);
378 if (_stringshare_key_value_replace(&wd->format, "ellipsis",
379 eina_strbuf_string_get(elpbuf), 0) == 0)
381 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
382 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
384 eina_strbuf_free(elpbuf);
389 const Evas_Object *tb;
390 tb = edje_object_part_object_get(wd->lbl, "elm.text");
391 evas_object_textblock_size_formatted_get(tb, &w, &h);
393 evas_object_geometry_get(obj, &vx, &vy, &vw, &vh);
395 if (w > wd->wrap_w || h > wd->wrap_h)
402 _ellipsis_fontsize_set(Evas_Object *obj, int fontsize)
404 Widget_Data *wd = elm_widget_data_get(obj);
405 Eina_Strbuf *fontbuf = NULL;
409 fontbuf = eina_strbuf_new();
410 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
411 if (fontsize == 0) removeflag = 1; // remove fontsize tag
413 if (_stringshare_key_value_replace(&wd->format, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
415 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
416 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
418 eina_strbuf_free(fontbuf);
422 _ellipsis_label_to_width(Evas_Object *obj)
424 Widget_Data *wd = elm_widget_data_get(obj);
426 int cur_fontsize = 0;
428 const char *minfont, *deffont, *maxfont;
429 int minfontsize, maxfontsize;
431 minfont = edje_object_data_get(wd->lbl, "min_font_size");
432 if (minfont) minfontsize = atoi(minfont);
433 else minfontsize = 1;
434 maxfont = edje_object_data_get(wd->lbl, "max_font_size");
435 if (maxfont) maxfontsize = atoi(maxfont);
436 else maxfontsize = 1;
437 deffont = edje_object_data_get(wd->lbl, "default_font_size");
438 if (deffont) cur_fontsize = atoi(deffont);
439 else cur_fontsize = 1;
440 if (minfontsize > maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
441 if (eina_stringshare_strlen(wd->label) <= 0) return;
443 if (_get_value_in_key_string(wd->format, "font_size", &kvalue) == 0)
445 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
448 while (_is_width_over(obj))
450 if (cur_fontsize > minfontsize)
453 if (cur_fontsize < minfontsize) cur_fontsize = minfontsize;
454 _ellipsis_fontsize_set(obj, cur_fontsize);
464 _label_sliding_change(Evas_Object *obj)
466 Widget_Data *wd = elm_widget_data_get(obj);
471 // dosen't support multiline sliding effect
474 wd->slidingmode = EINA_FALSE;
478 plaintxt = _elm_util_mkup_to_text(edje_object_part_text_get(wd->lbl, "elm.text"));
479 if (plaintxt != NULL)
481 plainlen = strlen(plaintxt);
484 // too short to slide label
487 wd->slidingmode = EINA_TRUE;
493 Edje_Message_Float_Set *msg = alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
497 wd->slidingellipsis = EINA_TRUE;
498 elm_label_ellipsis_set(obj, EINA_FALSE);
502 msg->val[0] = wd->slide_duration;
504 edje_object_message_send(wd->lbl, EDJE_MESSAGE_FLOAT_SET, 0, msg);
505 edje_object_signal_emit(wd->lbl, "elm,state,slide,start", "elm");
509 edje_object_signal_emit(wd->lbl, "elm,state,slide,stop", "elm");
510 if (wd->slidingellipsis)
512 wd->slidingellipsis = EINA_FALSE;
513 elm_label_ellipsis_set(obj, EINA_TRUE);
519 _elm_label_label_set(Evas_Object *obj, const char *item, const char *label)
521 ELM_CHECK_WIDTYPE(obj, widtype);
522 Widget_Data *wd = elm_widget_data_get(obj);
525 if (!label) label = "";
526 eina_stringshare_replace(&wd->label, label);
527 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
528 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
534 _elm_label_label_get(const Evas_Object *obj, const char *item)
536 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
537 Widget_Data *wd = elm_widget_data_get(obj);
538 if (item) return NULL;
539 if (!wd) return NULL;
544 * Add a new label to the parent
546 * @param parent The parent object
547 * @return The new object or NULL if it cannot be created
552 elm_label_add(Evas_Object *parent)
558 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
560 ELM_SET_WIDTYPE(widtype, "label");
561 elm_widget_type_set(obj, "label");
562 elm_widget_sub_object_add(parent, obj);
563 elm_widget_data_set(obj, wd);
564 elm_widget_del_hook_set(obj, _del_hook);
565 elm_widget_theme_hook_set(obj, _theme_hook);
566 elm_widget_can_focus_set(obj, EINA_FALSE);
567 elm_widget_text_set_hook_set(obj, _elm_label_label_set);
568 elm_widget_text_get_hook_set(obj, _elm_label_label_get);
570 wd->bgcolor = EINA_FALSE;
571 wd->bg = evas_object_rectangle_add(e);
572 evas_object_color_set(wd->bg, 0, 0, 0, 0);
574 wd->linewrap = EINA_FALSE;
575 wd->ellipsis = EINA_FALSE;
576 wd->slidingmode = EINA_FALSE;
577 wd->slidingellipsis = EINA_FALSE;
580 wd->slide_duration = 10;
582 wd->lbl = edje_object_add(e);
583 _elm_theme_object_set(obj, wd->lbl, "label", "base", "default");
584 wd->format = eina_stringshare_add("");
585 wd->label = eina_stringshare_add("<br>");
586 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
587 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
589 elm_widget_resize_object_set(obj, wd->lbl);
591 evas_object_event_callback_add(wd->lbl, EVAS_CALLBACK_RESIZE, _lbl_resize, obj);
593 _mirrored_set(obj, elm_widget_mirrored_get(obj));
600 * Set the label on the label object
602 * @param obj The label object
603 * @param label The label will be used on the label object
608 elm_label_label_set(Evas_Object *obj, const char *label)
610 _elm_label_label_set(obj, NULL, label);
614 * Get the label used on the label object
616 * @param obj The label object
617 * @return The string inside the label
622 elm_label_label_get(const Evas_Object *obj)
624 return _elm_label_label_get(obj, NULL);
628 * Set the wrapping behavior of the label
630 * @param obj The label object
631 * @param wrap To wrap text or not
636 elm_label_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
638 ELM_CHECK_WIDTYPE(obj, widtype);
639 Widget_Data *wd = elm_widget_data_get(obj);
640 const char *wrap_str;
644 if (wd->linewrap == wrap) return;
646 len = strlen(wd->label);
647 if (len <= 0) return;
665 if (_stringshare_key_value_replace(&wd->format,
666 "wrap", wrap_str, 0) == 0)
668 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
669 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
676 * Get the wrapping behavior of the label
678 * @param obj The label object
683 elm_label_line_wrap_get(const Evas_Object *obj)
685 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
686 Widget_Data *wd = elm_widget_data_get(obj);
687 if (!wd) return EINA_FALSE;
692 * Set wrap width of the label
694 * @param obj The label object
695 * @param w The wrap width in pixels at a minimum where words need to wrap
699 elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w)
701 ELM_CHECK_WIDTYPE(obj, widtype);
702 Widget_Data *wd = elm_widget_data_get(obj);
705 if (wd->wrap_w == w) return;
708 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
709 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
716 * get wrap width of the label
718 * @param obj The label object
719 * @return The wrap width in pixels at a minimum where words need to wrap
723 elm_label_wrap_width_get(const Evas_Object *obj)
725 ELM_CHECK_WIDTYPE(obj, widtype) 0;
726 Widget_Data *wd = elm_widget_data_get(obj);
732 * Set wrap height of the label
734 * @param obj The label object
735 * @param w The wrap width in pixels at a minimum where words need to wrap
739 elm_label_wrap_height_set(Evas_Object *obj,
742 ELM_CHECK_WIDTYPE(obj, widtype);
743 Widget_Data *wd = elm_widget_data_get(obj);
746 if (wd->wrap_h == h) return;
749 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
750 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
757 * get wrap width of the label
759 * @param obj The label object
760 * @return The wrap height in pixels at a minimum where words need to wrap
764 elm_label_wrap_height_get(const Evas_Object *obj)
766 ELM_CHECK_WIDTYPE(obj, widtype) 0;
767 Widget_Data *wd = elm_widget_data_get(obj);
773 * Set the font size on the label object.
775 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
776 * "big", "medium", "small" - or better name them by use:
777 * "title", "footnote", "quote" etc.
779 * @param obj The label object
780 * @param size font size
785 elm_label_fontsize_set(Evas_Object *obj, int fontsize)
787 ELM_CHECK_WIDTYPE(obj, widtype);
788 Widget_Data *wd = elm_widget_data_get(obj);
789 Eina_Strbuf *fontbuf = NULL;
790 int len, removeflag = 0;
793 _elm_dangerous_call_check(__FUNCTION__);
794 len = strlen(wd->label);
795 if (len <= 0) return;
796 fontbuf = eina_strbuf_new();
797 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
799 if (fontsize == 0) removeflag = 1; // remove fontsize tag
801 if (_stringshare_key_value_replace(&wd->format, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
803 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
804 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
808 eina_strbuf_free(fontbuf);
812 * Set the text align on the label object
814 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
815 * "big", "medium", "small" - or better name them by use:
816 * "title", "footnote", "quote" etc.
818 * @param obj The label object
819 * @param align align mode ("left", "center", "right")
824 elm_label_text_align_set(Evas_Object *obj, const char *alignmode)
826 ELM_CHECK_WIDTYPE(obj, widtype);
827 Widget_Data *wd = elm_widget_data_get(obj);
831 _elm_dangerous_call_check(__FUNCTION__);
832 len = strlen(wd->label);
833 if (len <= 0) return;
835 if (_stringshare_key_value_replace(&wd->format, "align", alignmode, 0) == 0)
837 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
838 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
846 * Set the text color on the label object
848 * @param obj The label object
849 * @param r Red property background color of The label object
850 * @param g Green property background color of The label object
851 * @param b Blue property background color of The label object
852 * @param a Alpha property background color of The label object
857 elm_label_text_color_set(Evas_Object *obj,
863 ELM_CHECK_WIDTYPE(obj, widtype);
864 Widget_Data *wd = elm_widget_data_get(obj);
865 Eina_Strbuf *colorbuf = NULL;
869 _elm_dangerous_call_check(__FUNCTION__);
870 len = strlen(wd->label);
871 if (len <= 0) return;
872 colorbuf = eina_strbuf_new();
873 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
875 if (_stringshare_key_value_replace(&wd->format, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
877 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
878 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
882 eina_strbuf_free(colorbuf);
886 * Set background color of the label
888 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
889 * "big", "medium", "small" - or better name them by use:
890 * "title", "footnote", "quote" etc.
892 * @param obj The label object
893 * @param r Red property background color of The label object
894 * @param g Green property background color of The label object
895 * @param b Blue property background color of The label object
896 * @param a Alpha property background alpha of The label object
901 elm_label_background_color_set(Evas_Object *obj,
907 ELM_CHECK_WIDTYPE(obj, widtype);
908 Widget_Data *wd = elm_widget_data_get(obj);
910 evas_object_color_set(wd->bg, r, g, b, a);
913 _elm_dangerous_call_check(__FUNCTION__);
914 if (wd->bgcolor == EINA_FALSE)
917 edje_object_part_swallow(wd->lbl, "label.swallow.background", wd->bg);
922 * Set the ellipsis behavior of the label
924 * @param obj The label object
925 * @param ellipsis To ellipsis text or not
929 elm_label_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
931 ELM_CHECK_WIDTYPE(obj, widtype);
932 Widget_Data *wd = elm_widget_data_get(obj);
933 Eina_Strbuf *fontbuf = NULL;
934 int len, removeflag = 0;
937 if (wd->ellipsis == ellipsis) return;
938 wd->ellipsis = ellipsis;
939 len = strlen(wd->label);
940 if (len <= 0) return;
942 if (ellipsis == EINA_FALSE) removeflag = 1; // remove fontsize tag
944 fontbuf = eina_strbuf_new();
945 eina_strbuf_append_printf(fontbuf, "%f", 1.0);
947 if (_stringshare_key_value_replace(&wd->format,
948 "ellipsis", eina_strbuf_string_get(fontbuf), removeflag) == 0)
950 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
951 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
955 eina_strbuf_free(fontbuf);
960 * Set the text slide of the label
962 * @param obj The label object
963 * @param slide To start slide or stop
967 elm_label_slide_set(Evas_Object *obj,
970 ELM_CHECK_WIDTYPE(obj, widtype);
971 Widget_Data *wd = elm_widget_data_get(obj);
974 if (wd->slidingmode == slide) return;
975 wd->slidingmode = slide;
976 _label_sliding_change(obj);
982 * get the text slide mode of the label
984 * @param obj The label object
985 * @return slide slide mode value
989 elm_label_slide_get(Evas_Object *obj)
991 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
992 Widget_Data *wd = elm_widget_data_get(obj);
993 if (!wd) return EINA_FALSE;
994 return wd->slidingmode;
998 * set the slide duration(speed) of the label
1000 * @param obj The label object
1001 * @return The duration time in moving text from slide begin position to slide end position
1005 elm_label_slide_duration_set(Evas_Object *obj, double duration)
1007 ELM_CHECK_WIDTYPE(obj, widtype);
1008 Widget_Data *wd = elm_widget_data_get(obj);
1009 Edje_Message_Float_Set *msg = alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
1012 wd->slide_duration = duration;
1014 msg->val[0] = wd->slide_duration;
1015 edje_object_message_send(wd->lbl, EDJE_MESSAGE_FLOAT_SET, 0, msg);
1019 * get the slide duration(speed) of the label
1021 * @param obj The label object
1022 * @return The duration time in moving text from slide begin position to slide end position
1026 elm_label_slide_duration_get(Evas_Object *obj)
1028 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1029 Widget_Data *wd = elm_widget_data_get(obj);
1031 return wd->slide_duration;