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 * Add a new label to the parent
521 * @param parent The parent object
522 * @return The new object or NULL if it cannot be created
527 elm_label_add(Evas_Object *parent)
533 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
535 ELM_SET_WIDTYPE(widtype, "label");
536 elm_widget_type_set(obj, "label");
537 elm_widget_sub_object_add(parent, obj);
538 elm_widget_data_set(obj, wd);
539 elm_widget_del_hook_set(obj, _del_hook);
540 elm_widget_theme_hook_set(obj, _theme_hook);
541 elm_widget_can_focus_set(obj, EINA_FALSE);
543 wd->bgcolor = EINA_FALSE;
544 wd->bg = evas_object_rectangle_add(e);
545 evas_object_color_set(wd->bg, 0, 0, 0, 0);
547 wd->linewrap = EINA_FALSE;
548 wd->ellipsis = EINA_FALSE;
549 wd->slidingmode = EINA_FALSE;
550 wd->slidingellipsis = EINA_FALSE;
553 wd->slide_duration = 10;
555 wd->lbl = edje_object_add(e);
556 _elm_theme_object_set(obj, wd->lbl, "label", "base", "default");
557 wd->format = eina_stringshare_add("");
558 wd->label = eina_stringshare_add("<br>");
559 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
560 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
562 elm_widget_resize_object_set(obj, wd->lbl);
564 evas_object_event_callback_add(wd->lbl, EVAS_CALLBACK_RESIZE, _lbl_resize, obj);
566 _mirrored_set(obj, elm_widget_mirrored_get(obj));
573 * Set the label on the label object
575 * @param obj The label object
576 * @param label The label will be used on the label object
581 elm_label_label_set(Evas_Object *obj, const char *label)
583 ELM_CHECK_WIDTYPE(obj, widtype);
584 Widget_Data *wd = elm_widget_data_get(obj);
586 if (!label) label = "";
587 eina_stringshare_replace(&wd->label, label);
588 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
589 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
595 * Get the label used on the label object
597 * @param obj The label object
598 * @return The string inside the label
602 elm_label_label_get(const Evas_Object *obj)
604 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
605 Widget_Data *wd = elm_widget_data_get(obj);
606 if (!wd) return NULL;
611 * Set the wrapping behavior of the label
613 * @param obj The label object
614 * @param wrap To wrap text or not
618 elm_label_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
620 ELM_CHECK_WIDTYPE(obj, widtype);
621 Widget_Data *wd = elm_widget_data_get(obj);
622 const char *wrap_str;
626 if (wd->linewrap == wrap) return;
628 len = strlen(wd->label);
629 if (len <= 0) return;
647 if (_stringshare_key_value_replace(&wd->format,
648 "wrap", wrap_str, 0) == 0)
650 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
651 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
658 * Get the wrapping behavior of the label
660 * @param obj The label object
665 elm_label_line_wrap_get(const Evas_Object *obj)
667 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
668 Widget_Data *wd = elm_widget_data_get(obj);
669 if (!wd) return EINA_FALSE;
674 * Set wrap width of the label
676 * @param obj The label object
677 * @param w The wrap width in pixels at a minimum where words need to wrap
681 elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w)
683 ELM_CHECK_WIDTYPE(obj, widtype);
684 Widget_Data *wd = elm_widget_data_get(obj);
687 if (wd->wrap_w == w) return;
690 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
691 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
698 * get wrap width of the label
700 * @param obj The label object
701 * @return The wrap width in pixels at a minimum where words need to wrap
705 elm_label_wrap_width_get(const Evas_Object *obj)
707 ELM_CHECK_WIDTYPE(obj, widtype) 0;
708 Widget_Data *wd = elm_widget_data_get(obj);
714 * Set wrap height of the label
716 * @param obj The label object
717 * @param w The wrap width in pixels at a minimum where words need to wrap
721 elm_label_wrap_height_set(Evas_Object *obj,
724 ELM_CHECK_WIDTYPE(obj, widtype);
725 Widget_Data *wd = elm_widget_data_get(obj);
728 if (wd->wrap_h == h) return;
731 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
732 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
739 * get wrap width of the label
741 * @param obj The label object
742 * @return The wrap height in pixels at a minimum where words need to wrap
746 elm_label_wrap_height_get(const Evas_Object *obj)
748 ELM_CHECK_WIDTYPE(obj, widtype) 0;
749 Widget_Data *wd = elm_widget_data_get(obj);
755 * Set the font size on the label object.
757 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
758 * "big", "medium", "small" - or better name them by use:
759 * "title", "footnote", "quote" etc.
761 * @param obj The label object
762 * @param size font size
767 elm_label_fontsize_set(Evas_Object *obj, int fontsize)
769 ELM_CHECK_WIDTYPE(obj, widtype);
770 Widget_Data *wd = elm_widget_data_get(obj);
771 Eina_Strbuf *fontbuf = NULL;
772 int len, removeflag = 0;
775 _elm_dangerous_call_check(__FUNCTION__);
776 len = strlen(wd->label);
777 if (len <= 0) return;
778 fontbuf = eina_strbuf_new();
779 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
781 if (fontsize == 0) removeflag = 1; // remove fontsize tag
783 if (_stringshare_key_value_replace(&wd->format, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
785 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
786 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
790 eina_strbuf_free(fontbuf);
794 * Set the text align on the label object
796 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
797 * "big", "medium", "small" - or better name them by use:
798 * "title", "footnote", "quote" etc.
800 * @param obj The label object
801 * @param align align mode ("left", "center", "right")
806 elm_label_text_align_set(Evas_Object *obj, const char *alignmode)
808 ELM_CHECK_WIDTYPE(obj, widtype);
809 Widget_Data *wd = elm_widget_data_get(obj);
813 _elm_dangerous_call_check(__FUNCTION__);
814 len = strlen(wd->label);
815 if (len <= 0) return;
817 if (_stringshare_key_value_replace(&wd->format, "align", alignmode, 0) == 0)
819 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
820 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
828 * Set the text color on the label object
830 * @param obj The label object
831 * @param r Red property background color of The label object
832 * @param g Green property background color of The label object
833 * @param b Blue property background color of The label object
834 * @param a Alpha property background color of The label object
839 elm_label_text_color_set(Evas_Object *obj,
845 ELM_CHECK_WIDTYPE(obj, widtype);
846 Widget_Data *wd = elm_widget_data_get(obj);
847 Eina_Strbuf *colorbuf = NULL;
851 _elm_dangerous_call_check(__FUNCTION__);
852 len = strlen(wd->label);
853 if (len <= 0) return;
854 colorbuf = eina_strbuf_new();
855 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
857 if (_stringshare_key_value_replace(&wd->format, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
859 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
860 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
864 eina_strbuf_free(colorbuf);
868 * Set background color of the label
870 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
871 * "big", "medium", "small" - or better name them by use:
872 * "title", "footnote", "quote" etc.
874 * @param obj The label object
875 * @param r Red property background color of The label object
876 * @param g Green property background color of The label object
877 * @param b Blue property background color of The label object
878 * @param a Alpha property background alpha of The label object
883 elm_label_background_color_set(Evas_Object *obj,
889 ELM_CHECK_WIDTYPE(obj, widtype);
890 Widget_Data *wd = elm_widget_data_get(obj);
892 evas_object_color_set(wd->bg, r, g, b, a);
895 _elm_dangerous_call_check(__FUNCTION__);
896 if (wd->bgcolor == EINA_FALSE)
899 edje_object_part_swallow(wd->lbl, "label.swallow.background", wd->bg);
904 * Set the ellipsis behavior of the label
906 * @param obj The label object
907 * @param ellipsis To ellipsis text or not
911 elm_label_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
913 ELM_CHECK_WIDTYPE(obj, widtype);
914 Widget_Data *wd = elm_widget_data_get(obj);
915 Eina_Strbuf *fontbuf = NULL;
916 int len, removeflag = 0;
919 if (wd->ellipsis == ellipsis) return;
920 wd->ellipsis = ellipsis;
921 len = strlen(wd->label);
922 if (len <= 0) return;
924 if (ellipsis == EINA_FALSE) removeflag = 1; // remove fontsize tag
926 fontbuf = eina_strbuf_new();
927 eina_strbuf_append_printf(fontbuf, "%f", 1.0);
929 if (_stringshare_key_value_replace(&wd->format,
930 "ellipsis", eina_strbuf_string_get(fontbuf), removeflag) == 0)
932 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
933 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
937 eina_strbuf_free(fontbuf);
942 * Set the text slide of the label
944 * @param obj The label object
945 * @param slide To start slide or stop
949 elm_label_slide_set(Evas_Object *obj,
952 ELM_CHECK_WIDTYPE(obj, widtype);
953 Widget_Data *wd = elm_widget_data_get(obj);
956 if (wd->slidingmode == slide) return;
957 wd->slidingmode = slide;
958 _label_sliding_change(obj);
964 * get the text slide mode of the label
966 * @param obj The label object
967 * @return slide slide mode value
971 elm_label_slide_get(Evas_Object *obj)
973 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
974 Widget_Data *wd = elm_widget_data_get(obj);
975 if (!wd) return EINA_FALSE;
976 return wd->slidingmode;
980 * set the slide duration(speed) of the label
982 * @param obj The label object
983 * @return The duration time in moving text from slide begin position to slide end position
987 elm_label_slide_duration_set(Evas_Object *obj, double duration)
989 ELM_CHECK_WIDTYPE(obj, widtype);
990 Widget_Data *wd = elm_widget_data_get(obj);
991 Edje_Message_Float_Set *msg = alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
994 wd->slide_duration = duration;
996 msg->val[0] = wd->slide_duration;
997 edje_object_message_send(wd->lbl, EDJE_MESSAGE_FLOAT_SET, 0, msg);
1001 * get the slide duration(speed) of the label
1003 * @param obj The label object
1004 * @return The duration time in moving text from slide begin position to slide end position
1008 elm_label_slide_duration_get(Evas_Object *obj)
1010 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1011 Widget_Data *wd = elm_widget_data_get(obj);
1013 return wd->slide_duration;