Simple Text

Basic text

Creating a label object, a widget to display text, with simple html-like markup:

    //text_label
    Evas_Object *label_text;
    label_text = elm_label_add(win);
 
    elm_object_text_set(label_text,"My label");
 
    evas_object_resize(label_text, 90, 30);
    evas_object_show(label_text);

Sliding text

If your text is too long, you can have it set to slide. The duration of the slide is to be set: it is set to five seconds in the following example. You can also have several styles:

  1. default - No animation
  2. marker - Centers the text in the label and makes it bold by default
  3. slide_long - The entire text appears from the right of the screen and slides until it disappears in the left of the screen(reappearing on the right again).
  4. slide_short - The text appears in the left of the label and slides to the right to show the overflow. When all of the text has been shown the position is reset.
  5. slide_bounce - The text appears in the left of the label and slides to the right to show the overflow. When all of the text has been shown the animation reverses, moving the text to the left.
    //sliding text
    Evas_Object *label_slide;
    label_slide = elm_label_add(win);
 
    elm_object_text_set(label_slide, "Some long text for our label_slide, that is long but"
    "not too long.");
 
    elm_object_style_set(label_slide,"slide_bounce");
    elm_label_slide_duration_set(label_slide, 3);
    elm_label_slide_mode_set(label_slide, ELM_LABEL_SLIDE_MODE_ALWAYS);
 
    elm_label_slide_go(label_slide);
 
    evas_object_resize(label_slide, 200, 15);
    evas_object_move(label_slide,0,40);
    evas_object_show(label_slide);

If needed, you can respond to end of a slide thanks to the slide,end event.

Marker text

A marker is a text that is centered and bold by default. As the default color is white, we will also set a color, blue in this example.

elm_object_style_set(label, "marker");
evas_object_color_set(label, 0, 0, 255, 255);

Styling the text

You can apply basic styles to the text. If, for instance, you would like to have a bold text, you can do as follows.

elm_object_text_set(label, "<b>This text is bold.</b>");

The whole code: label.c

Next Part