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 Elm_Wrap_Type linewrap;
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;
49 Evas_Coord resw, resh;
52 wd->deferred_recalc_job = NULL;
54 evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
55 if (wd->wrap_w > resw)
57 if (wd->wrap_h > resh)
60 if (wd->wrap_h == -1) /* open source routine */
62 edje_object_size_min_restricted_calc(wd->lbl, &minw, &minh, resw, 0);
63 /* This is a hack to workaround the way min size hints are treated.
64 * If the minimum width is smaller than the restricted width, it means
65 * the mininmum doesn't matter. */
66 if ((minw <= resw) && (minw != wd->wrap_w))
68 Evas_Coord ominw = -1;
69 evas_object_size_hint_min_get(data, &ominw, NULL);
73 else /* ellipsis && linewrap && wrap_height_set routine */
75 edje_object_size_min_restricted_calc(wd->lbl, &minw, &minh, 0, resh);
76 if ((minh <= resh) && (minh != wd->wrap_h))
78 Evas_Coord ominh = -1;
79 evas_object_size_hint_min_get(data, NULL, &ominh);
83 evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
85 if (minh > wd->wrap_h)
89 evas_object_size_hint_min_set(data, minw, minh);
90 evas_object_size_hint_max_set(data, wd->wrap_w, wd->wrap_h);
92 if ((wd->ellipsis) && (wd->linewrap) && (wd->wrap_h > 0) &&
93 (_is_width_over(data) == 1))
94 _ellipsis_label_to_width(data);
98 _del_hook(Evas_Object *obj)
100 Widget_Data *wd = elm_widget_data_get(obj);
102 if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
103 if (wd->label) eina_stringshare_del(wd->label);
104 if (wd->bg) evas_object_del(wd->bg);
109 _theme_change(Evas_Object *obj)
111 Widget_Data *wd = elm_widget_data_get(obj);
114 _elm_theme_object_set(obj, wd->lbl, "label", "base",
115 elm_widget_style_get(obj));
119 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
121 Widget_Data *wd = elm_widget_data_get(obj);
123 edje_object_mirrored_set(wd->lbl, rtl);
127 _theme_hook(Evas_Object *obj)
129 Widget_Data *wd = elm_widget_data_get(obj);
131 _elm_widget_mirrored_reload(obj);
132 _mirrored_set(obj, elm_widget_mirrored_get(obj));
134 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
135 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
136 edje_object_scale_set(wd->lbl, elm_widget_scale_get(obj) *
138 _label_sliding_change(obj);
143 _sizing_eval(Evas_Object *obj)
145 Widget_Data *wd = elm_widget_data_get(obj);
146 Evas_Coord minw = -1, minh = -1;
147 Evas_Coord resw, resh;
152 evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
153 if ((resw == wd->lastw) && (!wd->changed)) return;
154 wd->changed = EINA_FALSE;
156 _elm_win_recalc_job(obj);
157 // FIXME: works ok. but NOT for genlist. what should genlist do?
158 // if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
159 // wd->deferred_recalc_job = ecore_job_add(_elm_win_recalc_job, obj);
163 evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
164 edje_object_size_min_calc(wd->lbl, &minw, &minh);
165 if (wd->wrap_w > 0 && minw > wd->wrap_w) minw = wd->wrap_w;
166 if (wd->wrap_h > 0 && minh > wd->wrap_h) minh = wd->wrap_h;
167 evas_object_size_hint_min_set(obj, minw, minh);
168 evas_object_size_hint_max_set(obj, wd->wrap_w, wd->wrap_h);
169 if ((wd->ellipsis) && (_is_width_over(obj) == 1))
170 _ellipsis_label_to_width(obj);
175 _lbl_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
177 Widget_Data *wd = elm_widget_data_get(data);
179 if (wd->linewrap) _sizing_eval(data);
183 _get_value_in_key_string(const char *oldstring, const char *key, char **value)
185 char *curlocater, *starttag, *endtag;
186 int firstindex = 0, foundflag = -1;
188 curlocater = strstr(oldstring, key);
191 int key_len = strlen(key);
192 starttag = curlocater;
193 endtag = curlocater + key_len;
194 if ((!endtag) || (*endtag != '='))
199 firstindex = abs(oldstring - curlocater);
200 firstindex += key_len + 1; // strlen("key") + strlen("=")
201 *value = (char *)oldstring + firstindex;
203 while (oldstring != starttag)
205 if (*starttag == '>')
210 if (*starttag == '<')
214 if (!starttag) break;
231 if ((foundflag) && (*starttag == '<') && (*endtag == '>'))
241 if (foundflag == 1) return 0;
248 _strbuf_key_value_replace(Eina_Strbuf *srcbuf, const char *key, const char *value, int deleteflag)
250 const char *srcstring = NULL;
251 Eina_Strbuf *repbuf = NULL, *diffbuf = NULL;
252 char *curlocater, *replocater;
253 char *starttag, *endtag;
254 int tagtxtlen = 0, insertflag = 0;
256 srcstring = eina_strbuf_string_get(srcbuf);
257 curlocater = strstr(srcstring, key);
263 int key_len = strlen(key);
266 starttag = strchr(srcstring, '<');
267 endtag = strchr(srcstring, '>');
268 tagtxtlen = endtag - starttag;
269 if (tagtxtlen <= 0) tagtxtlen = 0;
270 if ((starttag < curlocater) && (curlocater < endtag)) break;
271 if ((endtag) && ((endtag + 1)))
272 srcstring = endtag + 1;
275 } while (strlen(srcstring) > 1);
277 if ((starttag) && (endtag) && (tagtxtlen > key_len))
280 repbuf = eina_strbuf_new();
281 diffbuf = eina_strbuf_new();
282 eina_strbuf_append_n(repbuf, starttag, tagtxtlen);
283 srcstring = eina_strbuf_string_get(repbuf);
284 curlocater = strstr(srcstring, key);
287 eqchar = curlocater + key_len;
288 if ((curlocater) && (eqchar))
290 // some case at useless many whitespaces (key =value)
291 // find the separator(=) position
292 eqchar = strchr(curlocater + key_len, '=');
297 replocater = eqchar + 1;
298 while ((*replocater) &&
299 (*replocater != ' ') &&
300 (*replocater != '>'))
303 if ((replocater - curlocater) > key_len)
304 eina_strbuf_append_n(diffbuf, curlocater,
305 replocater-curlocater);
314 eina_strbuf_reset(repbuf);
320 if (!repbuf) repbuf = eina_strbuf_new();
321 if (!diffbuf) diffbuf = eina_strbuf_new();
325 eina_strbuf_append_printf(repbuf, "<%s=%s>", key, value);
326 eina_strbuf_prepend(srcbuf, eina_strbuf_string_get(repbuf));
332 eina_strbuf_prepend(diffbuf, "<");
333 eina_strbuf_append(diffbuf, ">");
334 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), "");
338 eina_strbuf_append_printf(repbuf, "%s=%s", key, value);
339 eina_strbuf_replace_first(srcbuf, eina_strbuf_string_get(diffbuf), eina_strbuf_string_get(repbuf));
343 if (repbuf) eina_strbuf_free(repbuf);
344 if (diffbuf) eina_strbuf_free(diffbuf);
350 _stringshare_key_value_replace(const char **srcstring, const char *key, const char *value, int deleteflag)
352 Eina_Strbuf *sharebuf = NULL;
354 sharebuf = eina_strbuf_new();
355 eina_strbuf_append(sharebuf, *srcstring);
356 _strbuf_key_value_replace(sharebuf, key, value, deleteflag);
357 eina_stringshare_del(*srcstring);
358 *srcstring = eina_stringshare_add(eina_strbuf_string_get(sharebuf));
359 eina_strbuf_free(sharebuf);
365 _is_width_over(Evas_Object *obj)
367 Evas_Coord x, y, w, h;
368 Evas_Coord vx, vy, vw, vh;
369 Widget_Data *wd = elm_widget_data_get(obj);
372 edje_object_part_geometry_get(wd->lbl, "elm.text", &x, &y, NULL, NULL);
373 /* Calc the formatted size with ellipsis turned off */
376 const Evas_Object *tb;
378 double ellipsis = 0.0;
379 Eina_Bool found_key = EINA_FALSE;
380 if (_get_value_in_key_string(wd->format, "ellipsis", &_kvalue) == 0)
382 ellipsis = atof(_kvalue);
383 found_key = EINA_TRUE;
386 if (_stringshare_key_value_replace(&wd->format,
387 "ellipsis", NULL, 1) == 0)
389 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
390 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
393 tb = edje_object_part_object_get(wd->lbl, "elm.text");
394 evas_object_textblock_size_formatted_get(tb, &w, &h);
399 elpbuf = eina_strbuf_new();
400 eina_strbuf_append_printf(elpbuf, "%f", ellipsis);
401 if (_stringshare_key_value_replace(&wd->format, "ellipsis",
402 eina_strbuf_string_get(elpbuf), 0) == 0)
404 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
405 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
407 eina_strbuf_free(elpbuf);
412 const Evas_Object *tb;
413 tb = edje_object_part_object_get(wd->lbl, "elm.text");
414 evas_object_textblock_size_formatted_get(tb, &w, &h);
416 evas_object_geometry_get(obj, &vx, &vy, &vw, &vh);
418 if (w > wd->wrap_w || h > wd->wrap_h)
425 _ellipsis_fontsize_set(Evas_Object *obj, int fontsize)
427 Widget_Data *wd = elm_widget_data_get(obj);
428 Eina_Strbuf *fontbuf = NULL;
432 fontbuf = eina_strbuf_new();
433 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
434 if (fontsize == 0) removeflag = 1; // remove fontsize tag
436 if (_stringshare_key_value_replace(&wd->format, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
438 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
439 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
441 eina_strbuf_free(fontbuf);
445 _ellipsis_label_to_width(Evas_Object *obj)
447 Widget_Data *wd = elm_widget_data_get(obj);
449 int cur_fontsize = 0;
451 const char *minfont, *deffont, *maxfont;
452 int minfontsize, maxfontsize;
454 minfont = edje_object_data_get(wd->lbl, "min_font_size");
455 if (minfont) minfontsize = atoi(minfont);
456 else minfontsize = 1;
457 maxfont = edje_object_data_get(wd->lbl, "max_font_size");
458 if (maxfont) maxfontsize = atoi(maxfont);
459 else maxfontsize = 1;
460 deffont = edje_object_data_get(wd->lbl, "default_font_size");
461 if (deffont) cur_fontsize = atoi(deffont);
462 else cur_fontsize = 1;
463 if (minfontsize > maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
464 if (eina_stringshare_strlen(wd->label) <= 0) return;
466 if (_get_value_in_key_string(wd->format, "font_size", &kvalue) == 0)
468 if (kvalue != NULL) cur_fontsize = atoi(kvalue);
471 /* TODO : Remove ellipsis logic in elm_lable and use ellipsis feature in evas textblock */
472 _ellipsis_fontsize_set(obj, cur_fontsize);
476 while (_is_width_over(obj))
478 if (cur_fontsize > minfontsize)
481 if (cur_fontsize < minfontsize) cur_fontsize = minfontsize;
482 _ellipsis_fontsize_set(obj, cur_fontsize);
493 _label_sliding_change(Evas_Object *obj)
495 Widget_Data *wd = elm_widget_data_get(obj);
500 // dosen't support multiline sliding effect
503 wd->slidingmode = EINA_FALSE;
507 plaintxt = _elm_util_mkup_to_text(edje_object_part_text_get(wd->lbl, "elm.text"));
508 if (plaintxt != NULL)
510 plainlen = strlen(plaintxt);
513 // too short to slide label
516 wd->slidingmode = EINA_TRUE;
522 Edje_Message_Float_Set *msg = alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
526 wd->slidingellipsis = EINA_TRUE;
527 elm_label_ellipsis_set(obj, EINA_FALSE);
531 msg->val[0] = wd->slide_duration;
533 edje_object_message_send(wd->lbl, EDJE_MESSAGE_FLOAT_SET, 0, msg);
534 edje_object_signal_emit(wd->lbl, "elm,state,slide,start", "elm");
538 edje_object_signal_emit(wd->lbl, "elm,state,slide,stop", "elm");
539 if (wd->slidingellipsis)
541 wd->slidingellipsis = EINA_FALSE;
542 elm_label_ellipsis_set(obj, EINA_TRUE);
548 _elm_label_label_set(Evas_Object *obj, const char *item, const char *label)
550 ELM_CHECK_WIDTYPE(obj, widtype);
551 Widget_Data *wd = elm_widget_data_get(obj);
553 if (item && strcmp(item, "default")) return;
554 if (!label) label = "";
555 eina_stringshare_replace(&wd->label, label);
556 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
557 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
563 _elm_label_label_get(const Evas_Object *obj, const char *item)
565 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
566 Widget_Data *wd = elm_widget_data_get(obj);
567 if (item && strcmp(item, "default")) return NULL;
568 if (!wd) return NULL;
573 * Add a new label to the parent
575 * @param parent The parent object
576 * @return The new object or NULL if it cannot be created
581 elm_label_add(Evas_Object *parent)
587 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
589 ELM_SET_WIDTYPE(widtype, "label");
590 elm_widget_type_set(obj, "label");
591 elm_widget_sub_object_add(parent, obj);
592 elm_widget_data_set(obj, wd);
593 elm_widget_del_hook_set(obj, _del_hook);
594 elm_widget_theme_hook_set(obj, _theme_hook);
595 elm_widget_can_focus_set(obj, EINA_FALSE);
596 elm_widget_text_set_hook_set(obj, _elm_label_label_set);
597 elm_widget_text_get_hook_set(obj, _elm_label_label_get);
599 wd->bgcolor = EINA_FALSE;
600 wd->bg = evas_object_rectangle_add(e);
601 evas_object_color_set(wd->bg, 0, 0, 0, 0);
603 wd->linewrap = ELM_WRAP_NONE;
604 wd->ellipsis = EINA_FALSE;
605 wd->slidingmode = EINA_FALSE;
606 wd->slidingellipsis = EINA_FALSE;
609 wd->slide_duration = 10;
611 wd->lbl = edje_object_add(e);
612 _elm_theme_object_set(obj, wd->lbl, "label", "base", "default");
613 wd->format = eina_stringshare_add("");
614 wd->label = eina_stringshare_add("<br>");
615 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
616 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
618 elm_widget_resize_object_set(obj, wd->lbl);
620 evas_object_event_callback_add(wd->lbl, EVAS_CALLBACK_RESIZE, _lbl_resize, obj);
622 _mirrored_set(obj, elm_widget_mirrored_get(obj));
629 * Set the label on the label object
631 * @param obj The label object
632 * @param label The label will be used on the label object
637 elm_label_label_set(Evas_Object *obj, const char *label)
639 _elm_label_label_set(obj, NULL, label);
643 * Get the label used on the label object
645 * @param obj The label object
646 * @return The string inside the label
651 elm_label_label_get(const Evas_Object *obj)
653 return _elm_label_label_get(obj, NULL);
657 * Set the wrapping behavior of the label
659 * @param obj The label object
660 * @param wrap To wrap text or not
665 elm_label_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
667 ELM_CHECK_WIDTYPE(obj, widtype);
668 Widget_Data *wd = elm_widget_data_get(obj);
669 const char *wrap_str;
673 if (wd->linewrap == wrap) return;
675 len = strlen(wd->label);
676 if (len <= 0) return;
694 if (_stringshare_key_value_replace(&wd->format,
695 "wrap", wrap_str, 0) == 0)
697 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
698 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
705 * Get the wrapping behavior of the label
707 * @param obj The label object
712 elm_label_line_wrap_get(const Evas_Object *obj)
714 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
715 Widget_Data *wd = elm_widget_data_get(obj);
716 if (!wd) return EINA_FALSE;
721 * Set wrap width of the label
723 * @param obj The label object
724 * @param w The wrap width in pixels at a minimum where words need to wrap
728 elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w)
730 ELM_CHECK_WIDTYPE(obj, widtype);
731 Widget_Data *wd = elm_widget_data_get(obj);
734 if (wd->wrap_w == w) return;
737 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
738 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
745 * get wrap width of the label
747 * @param obj The label object
748 * @return The wrap width in pixels at a minimum where words need to wrap
752 elm_label_wrap_width_get(const Evas_Object *obj)
754 ELM_CHECK_WIDTYPE(obj, widtype) 0;
755 Widget_Data *wd = elm_widget_data_get(obj);
761 * Set wrap height of the label
763 * @param obj The label object
764 * @param w The wrap width in pixels at a minimum where words need to wrap
768 elm_label_wrap_height_set(Evas_Object *obj,
771 ELM_CHECK_WIDTYPE(obj, widtype);
772 Widget_Data *wd = elm_widget_data_get(obj);
775 if (wd->wrap_h == h) return;
778 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
779 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
786 * get wrap width of the label
788 * @param obj The label object
789 * @return The wrap height in pixels at a minimum where words need to wrap
793 elm_label_wrap_height_get(const Evas_Object *obj)
795 ELM_CHECK_WIDTYPE(obj, widtype) 0;
796 Widget_Data *wd = elm_widget_data_get(obj);
802 * Set the font size on the label object.
804 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
805 * "big", "medium", "small" - or better name them by use:
806 * "title", "footnote", "quote" etc.
808 * @param obj The label object
809 * @param size font size
814 elm_label_fontsize_set(Evas_Object *obj, int fontsize)
816 ELM_CHECK_WIDTYPE(obj, widtype);
817 Widget_Data *wd = elm_widget_data_get(obj);
818 Eina_Strbuf *fontbuf = NULL;
819 int len, removeflag = 0;
822 _elm_dangerous_call_check(__FUNCTION__);
823 len = strlen(wd->label);
824 if (len <= 0) return;
825 fontbuf = eina_strbuf_new();
826 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
828 if (fontsize == 0) removeflag = 1; // remove fontsize tag
830 if (_stringshare_key_value_replace(&wd->format, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
832 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
833 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
837 eina_strbuf_free(fontbuf);
841 * Set the text align on the label object
843 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
844 * "big", "medium", "small" - or better name them by use:
845 * "title", "footnote", "quote" etc.
847 * @param obj The label object
848 * @param align align mode ("left", "center", "right")
853 elm_label_text_align_set(Evas_Object *obj, const char *alignmode)
855 ELM_CHECK_WIDTYPE(obj, widtype);
856 Widget_Data *wd = elm_widget_data_get(obj);
860 _elm_dangerous_call_check(__FUNCTION__);
861 len = strlen(wd->label);
862 if (len <= 0) return;
864 if (_stringshare_key_value_replace(&wd->format, "align", alignmode, 0) == 0)
866 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
867 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
875 * Set the text color on the label object
877 * @param obj The label object
878 * @param r Red property background color of The label object
879 * @param g Green property background color of The label object
880 * @param b Blue property background color of The label object
881 * @param a Alpha property background color of The label object
886 elm_label_text_color_set(Evas_Object *obj,
892 ELM_CHECK_WIDTYPE(obj, widtype);
893 Widget_Data *wd = elm_widget_data_get(obj);
894 Eina_Strbuf *colorbuf = NULL;
898 _elm_dangerous_call_check(__FUNCTION__);
899 len = strlen(wd->label);
900 if (len <= 0) return;
901 colorbuf = eina_strbuf_new();
902 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
904 if (_stringshare_key_value_replace(&wd->format, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
906 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
907 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
911 eina_strbuf_free(colorbuf);
915 * Set background color of the label
917 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
918 * "big", "medium", "small" - or better name them by use:
919 * "title", "footnote", "quote" etc.
921 * @param obj The label object
922 * @param r Red property background color of The label object
923 * @param g Green property background color of The label object
924 * @param b Blue property background color of The label object
925 * @param a Alpha property background alpha of The label object
930 elm_label_background_color_set(Evas_Object *obj,
936 ELM_CHECK_WIDTYPE(obj, widtype);
937 Widget_Data *wd = elm_widget_data_get(obj);
939 evas_object_color_set(wd->bg, r, g, b, a);
941 _elm_dangerous_call_check(__FUNCTION__);
942 if (wd->bgcolor == EINA_FALSE)
945 edje_object_part_swallow(wd->lbl, "label.swallow.background", wd->bg);
950 * Set the wrapmode of the label
952 * @param obj The label object
953 * @param wrapmode 0 is charwrap, 1 is wordwrap
958 elm_label_wrap_mode_set(Evas_Object *obj,
965 * Set the ellipsis behavior of the label
967 * @param obj The label object
968 * @param ellipsis To ellipsis text or not
972 elm_label_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
974 ELM_CHECK_WIDTYPE(obj, widtype);
975 Widget_Data *wd = elm_widget_data_get(obj);
976 Eina_Strbuf *fontbuf = NULL;
977 int len, removeflag = 0;
980 if (wd->ellipsis == ellipsis) return;
981 wd->ellipsis = ellipsis;
982 len = strlen(wd->label);
983 if (len <= 0) return;
985 if (ellipsis == EINA_FALSE) removeflag = 1; // remove fontsize tag
987 fontbuf = eina_strbuf_new();
988 eina_strbuf_append_printf(fontbuf, "%f", 1.0);
990 if (_stringshare_key_value_replace(&wd->format,
991 "ellipsis", eina_strbuf_string_get(fontbuf), removeflag) == 0)
993 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
994 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
998 eina_strbuf_free(fontbuf);
1003 * Set the text slide of the label
1005 * @param obj The label object
1006 * @param slide To start slide or stop
1010 elm_label_slide_set(Evas_Object *obj,
1013 ELM_CHECK_WIDTYPE(obj, widtype);
1014 Widget_Data *wd = elm_widget_data_get(obj);
1017 if (wd->slidingmode == slide) return;
1018 wd->slidingmode = slide;
1019 _label_sliding_change(obj);
1025 * get the text slide mode of the label
1027 * @param obj The label object
1028 * @return slide slide mode value
1032 elm_label_slide_get(Evas_Object *obj)
1034 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1035 Widget_Data *wd = elm_widget_data_get(obj);
1036 if (!wd) return EINA_FALSE;
1037 return wd->slidingmode;
1041 * set the slide duration(speed) of the label
1043 * @param obj The label object
1044 * @return The duration time in moving text from slide begin position to slide end position
1048 elm_label_slide_duration_set(Evas_Object *obj, double duration)
1050 ELM_CHECK_WIDTYPE(obj, widtype);
1051 Widget_Data *wd = elm_widget_data_get(obj);
1052 Edje_Message_Float_Set *msg = alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
1055 wd->slide_duration = duration;
1057 msg->val[0] = wd->slide_duration;
1058 edje_object_message_send(wd->lbl, EDJE_MESSAGE_FLOAT_SET, 0, msg);
1062 * get the slide duration(speed) of the label
1064 * @param obj The label object
1065 * @return The duration time in moving text from slide begin position to slide end position
1069 elm_label_slide_duration_get(Evas_Object *obj)
1071 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1072 Widget_Data *wd = elm_widget_data_get(obj);
1074 return wd->slide_duration;