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;
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 while (_is_width_over(obj))
473 if (cur_fontsize > minfontsize)
476 if (cur_fontsize < minfontsize) cur_fontsize = minfontsize;
477 _ellipsis_fontsize_set(obj, cur_fontsize);
487 _label_sliding_change(Evas_Object *obj)
489 Widget_Data *wd = elm_widget_data_get(obj);
494 // dosen't support multiline sliding effect
497 wd->slidingmode = EINA_FALSE;
501 plaintxt = _elm_util_mkup_to_text(edje_object_part_text_get(wd->lbl, "elm.text"));
502 if (plaintxt != NULL)
504 plainlen = strlen(plaintxt);
507 // too short to slide label
510 wd->slidingmode = EINA_TRUE;
516 Edje_Message_Float_Set *msg = alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
520 wd->slidingellipsis = EINA_TRUE;
521 elm_label_ellipsis_set(obj, EINA_FALSE);
525 msg->val[0] = wd->slide_duration;
527 edje_object_message_send(wd->lbl, EDJE_MESSAGE_FLOAT_SET, 0, msg);
528 edje_object_signal_emit(wd->lbl, "elm,state,slide,start", "elm");
532 edje_object_signal_emit(wd->lbl, "elm,state,slide,stop", "elm");
533 if (wd->slidingellipsis)
535 wd->slidingellipsis = EINA_FALSE;
536 elm_label_ellipsis_set(obj, EINA_TRUE);
542 _elm_label_label_set(Evas_Object *obj, const char *item, const char *label)
544 ELM_CHECK_WIDTYPE(obj, widtype);
545 Widget_Data *wd = elm_widget_data_get(obj);
547 if (item && strcmp(item, "default")) return;
548 if (!label) label = "";
549 eina_stringshare_replace(&wd->label, label);
550 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
551 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
557 _elm_label_label_get(const Evas_Object *obj, const char *item)
559 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
560 Widget_Data *wd = elm_widget_data_get(obj);
561 if (item && strcmp(item, "default")) return NULL;
562 if (!wd) return NULL;
567 * Add a new label to the parent
569 * @param parent The parent object
570 * @return The new object or NULL if it cannot be created
575 elm_label_add(Evas_Object *parent)
581 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
583 ELM_SET_WIDTYPE(widtype, "label");
584 elm_widget_type_set(obj, "label");
585 elm_widget_sub_object_add(parent, obj);
586 elm_widget_data_set(obj, wd);
587 elm_widget_del_hook_set(obj, _del_hook);
588 elm_widget_theme_hook_set(obj, _theme_hook);
589 elm_widget_can_focus_set(obj, EINA_FALSE);
590 elm_widget_text_set_hook_set(obj, _elm_label_label_set);
591 elm_widget_text_get_hook_set(obj, _elm_label_label_get);
593 wd->bgcolor = EINA_FALSE;
594 wd->bg = evas_object_rectangle_add(e);
595 evas_object_color_set(wd->bg, 0, 0, 0, 0);
597 wd->linewrap = EINA_FALSE;
598 wd->ellipsis = EINA_FALSE;
599 wd->slidingmode = EINA_FALSE;
600 wd->slidingellipsis = EINA_FALSE;
603 wd->slide_duration = 10;
605 wd->lbl = edje_object_add(e);
606 _elm_theme_object_set(obj, wd->lbl, "label", "base", "default");
607 wd->format = eina_stringshare_add("");
608 wd->label = eina_stringshare_add("<br>");
609 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
610 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
612 elm_widget_resize_object_set(obj, wd->lbl);
614 evas_object_event_callback_add(wd->lbl, EVAS_CALLBACK_RESIZE, _lbl_resize, obj);
616 _mirrored_set(obj, elm_widget_mirrored_get(obj));
623 * Set the label on the label object
625 * @param obj The label object
626 * @param label The label will be used on the label object
631 elm_label_label_set(Evas_Object *obj, const char *label)
633 _elm_label_label_set(obj, NULL, label);
637 * Get the label used on the label object
639 * @param obj The label object
640 * @return The string inside the label
645 elm_label_label_get(const Evas_Object *obj)
647 return _elm_label_label_get(obj, NULL);
651 * Set the wrapping behavior of the label
653 * @param obj The label object
654 * @param wrap To wrap text or not
659 elm_label_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
661 ELM_CHECK_WIDTYPE(obj, widtype);
662 Widget_Data *wd = elm_widget_data_get(obj);
663 const char *wrap_str;
667 if (wd->linewrap == wrap) return;
669 len = strlen(wd->label);
670 if (len <= 0) return;
688 if (_stringshare_key_value_replace(&wd->format,
689 "wrap", wrap_str, 0) == 0)
691 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
692 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
699 * Get the wrapping behavior of the label
701 * @param obj The label object
706 elm_label_line_wrap_get(const Evas_Object *obj)
708 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
709 Widget_Data *wd = elm_widget_data_get(obj);
710 if (!wd) return EINA_FALSE;
715 * Set wrap width of the label
717 * @param obj The label object
718 * @param w The wrap width in pixels at a minimum where words need to wrap
722 elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w)
724 ELM_CHECK_WIDTYPE(obj, widtype);
725 Widget_Data *wd = elm_widget_data_get(obj);
728 if (wd->wrap_w == w) 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 width in pixels at a minimum where words need to wrap
746 elm_label_wrap_width_get(const Evas_Object *obj)
748 ELM_CHECK_WIDTYPE(obj, widtype) 0;
749 Widget_Data *wd = elm_widget_data_get(obj);
755 * Set wrap height of the label
757 * @param obj The label object
758 * @param w The wrap width in pixels at a minimum where words need to wrap
762 elm_label_wrap_height_set(Evas_Object *obj,
765 ELM_CHECK_WIDTYPE(obj, widtype);
766 Widget_Data *wd = elm_widget_data_get(obj);
769 if (wd->wrap_h == h) return;
772 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
773 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
780 * get wrap width of the label
782 * @param obj The label object
783 * @return The wrap height in pixels at a minimum where words need to wrap
787 elm_label_wrap_height_get(const Evas_Object *obj)
789 ELM_CHECK_WIDTYPE(obj, widtype) 0;
790 Widget_Data *wd = elm_widget_data_get(obj);
796 * Set the font size on the label object.
798 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
799 * "big", "medium", "small" - or better name them by use:
800 * "title", "footnote", "quote" etc.
802 * @param obj The label object
803 * @param size font size
808 elm_label_fontsize_set(Evas_Object *obj, int fontsize)
810 ELM_CHECK_WIDTYPE(obj, widtype);
811 Widget_Data *wd = elm_widget_data_get(obj);
812 Eina_Strbuf *fontbuf = NULL;
813 int len, removeflag = 0;
816 _elm_dangerous_call_check(__FUNCTION__);
817 len = strlen(wd->label);
818 if (len <= 0) return;
819 fontbuf = eina_strbuf_new();
820 eina_strbuf_append_printf(fontbuf, "%d", fontsize);
822 if (fontsize == 0) removeflag = 1; // remove fontsize tag
824 if (_stringshare_key_value_replace(&wd->format, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
826 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
827 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
831 eina_strbuf_free(fontbuf);
835 * Set the text align on the label object
837 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
838 * "big", "medium", "small" - or better name them by use:
839 * "title", "footnote", "quote" etc.
841 * @param obj The label object
842 * @param align align mode ("left", "center", "right")
847 elm_label_text_align_set(Evas_Object *obj, const char *alignmode)
849 ELM_CHECK_WIDTYPE(obj, widtype);
850 Widget_Data *wd = elm_widget_data_get(obj);
854 _elm_dangerous_call_check(__FUNCTION__);
855 len = strlen(wd->label);
856 if (len <= 0) return;
858 if (_stringshare_key_value_replace(&wd->format, "align", alignmode, 0) == 0)
860 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
861 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
869 * Set the text color on the label object
871 * @param obj The label object
872 * @param r Red property background color of The label object
873 * @param g Green property background color of The label object
874 * @param b Blue property background color of The label object
875 * @param a Alpha property background color of The label object
880 elm_label_text_color_set(Evas_Object *obj,
886 ELM_CHECK_WIDTYPE(obj, widtype);
887 Widget_Data *wd = elm_widget_data_get(obj);
888 Eina_Strbuf *colorbuf = NULL;
892 _elm_dangerous_call_check(__FUNCTION__);
893 len = strlen(wd->label);
894 if (len <= 0) return;
895 colorbuf = eina_strbuf_new();
896 eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
898 if (_stringshare_key_value_replace(&wd->format, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
900 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
901 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
905 eina_strbuf_free(colorbuf);
909 * Set background color of the label
911 * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
912 * "big", "medium", "small" - or better name them by use:
913 * "title", "footnote", "quote" etc.
915 * @param obj The label object
916 * @param r Red property background color of The label object
917 * @param g Green property background color of The label object
918 * @param b Blue property background color of The label object
919 * @param a Alpha property background alpha of The label object
924 elm_label_background_color_set(Evas_Object *obj,
930 ELM_CHECK_WIDTYPE(obj, widtype);
931 Widget_Data *wd = elm_widget_data_get(obj);
933 evas_object_color_set(wd->bg, r, g, b, a);
936 _elm_dangerous_call_check(__FUNCTION__);
937 if (wd->bgcolor == EINA_FALSE)
940 edje_object_part_swallow(wd->lbl, "label.swallow.background", wd->bg);
945 * Set the wrapmode of the label
947 * @param obj The label object
948 * @param wrapmode 0 is charwrap, 1 is wordwrap
953 elm_label_wrap_mode_set(Evas_Object *obj,
960 * Set the ellipsis behavior of the label
962 * @param obj The label object
963 * @param ellipsis To ellipsis text or not
967 elm_label_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
969 ELM_CHECK_WIDTYPE(obj, widtype);
970 Widget_Data *wd = elm_widget_data_get(obj);
971 Eina_Strbuf *fontbuf = NULL;
972 int len, removeflag = 0;
975 if (wd->ellipsis == ellipsis) return;
976 wd->ellipsis = ellipsis;
977 len = strlen(wd->label);
978 if (len <= 0) return;
980 if (ellipsis == EINA_FALSE) removeflag = 1; // remove fontsize tag
982 fontbuf = eina_strbuf_new();
983 eina_strbuf_append_printf(fontbuf, "%f", 1.0);
985 if (_stringshare_key_value_replace(&wd->format,
986 "ellipsis", eina_strbuf_string_get(fontbuf), removeflag) == 0)
988 edje_object_part_text_set(wd->lbl, "elm.text", wd->format);
989 edje_object_part_text_append(wd->lbl, "elm.text", wd->label);
993 eina_strbuf_free(fontbuf);
998 * Set the text slide of the label
1000 * @param obj The label object
1001 * @param slide To start slide or stop
1005 elm_label_slide_set(Evas_Object *obj,
1008 ELM_CHECK_WIDTYPE(obj, widtype);
1009 Widget_Data *wd = elm_widget_data_get(obj);
1012 if (wd->slidingmode == slide) return;
1013 wd->slidingmode = slide;
1014 _label_sliding_change(obj);
1020 * get the text slide mode of the label
1022 * @param obj The label object
1023 * @return slide slide mode value
1027 elm_label_slide_get(Evas_Object *obj)
1029 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1030 Widget_Data *wd = elm_widget_data_get(obj);
1031 if (!wd) return EINA_FALSE;
1032 return wd->slidingmode;
1036 * set the slide duration(speed) of the label
1038 * @param obj The label object
1039 * @return The duration time in moving text from slide begin position to slide end position
1043 elm_label_slide_duration_set(Evas_Object *obj, double duration)
1045 ELM_CHECK_WIDTYPE(obj, widtype);
1046 Widget_Data *wd = elm_widget_data_get(obj);
1047 Edje_Message_Float_Set *msg = alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
1050 wd->slide_duration = duration;
1052 msg->val[0] = wd->slide_duration;
1053 edje_object_message_send(wd->lbl, EDJE_MESSAGE_FLOAT_SET, 0, msg);
1057 * get the slide duration(speed) of the label
1059 * @param obj The label object
1060 * @return The duration time in moving text from slide begin position to slide end position
1064 elm_label_slide_duration_get(Evas_Object *obj)
1066 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1067 Widget_Data *wd = elm_widget_data_get(obj);
1069 return wd->slide_duration;