Tizen Native API  8.0
Label example

In this example we are going to create 6 labels, set some properties on them and see what changes in appearance those properties cause.

We start with the setup code that by now you should be familiar with:

//Compile with:
//gcc -o label_example_01 label_example_01.c -g `pkg-config --cflags --libs elementary`

#include <Elementary.h>

EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
   Evas_Object *win, *label, *label2, *label3, *label4, *label5, *label6;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add("label", "Label");
   elm_win_autodel_set(win, EINA_TRUE);

For our first label we have a moderately long text(that doesn't fit in the label's width) so we will make it a sliding label. Since the text isn't too long we don't need the animation to be very long, 3 seconds should give us a nice speed:

   label = elm_label_add(win);
   elm_object_text_set(label, "Some long text for our label, that is long but "
                       "not too long.");
   elm_label_slide_duration_set(label, 3);
   elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_ALWAYS);
   elm_object_style_set(label, "slide_bounce");
   evas_object_move(label, 0, 10);
   evas_object_resize(label, 200, 15);
   evas_object_show(label);

For our second label we have the same text, but this time we aren't going to have it slide, we're going to ellipsize it. Because we ask our label widget to ellipsize the text it will first diminsh the fontsize so that it can show as much of the text as possible:

   label2 = elm_label_add(win);
   elm_object_text_set(label2, "This is the text for our second label, which is"
                       " much longer than the previous one, maybe even "
                       "too long, but maybe not.");
   elm_label_ellipsis_set(label2, EINA_TRUE);
   evas_object_resize(label2, 200, 15);
   evas_object_move(label2, 0, 30);
   evas_object_show(label2);

For the third label we are going to ellipsize the text again, however this time to make sure the fontsize isn't diminshed we will set a line wrap. The wrap won't actually cause a line break because we set the label to ellipsize:

   label3 = elm_label_add(win);
   elm_object_text_set(label3, "Some more long text much as before, long but "
                       "not too long.");
   elm_label_line_wrap_set(label3, ELM_WRAP_CHAR);
   elm_label_ellipsis_set(label3, EINA_TRUE);
   evas_object_resize(label3, 200, 15);
   evas_object_move(label3, 0, 50);
   evas_object_show(label3);

For our fourth label we will set line wrapping but won't set ellipsis, so that our text will indeed be wrapped instead of ellipsized. For this label we choose character wrap:

   label4 = elm_label_add(win);
   elm_object_text_set(label4, "And for this label we choose a different text, "
                       "for no reason other than that we can.");
   elm_label_line_wrap_set(label4, ELM_WRAP_CHAR);
   evas_object_resize(label4, 200, 30);
   evas_object_move(label4, 0, 80);
   evas_object_show(label4);

Just two more, for our fifth label we do the same as for the fourth except we set the wrap to word:

   label5 = elm_label_add(win);
   elm_object_text_set(label5, "And for this label we choose a different text, "
                       "for no reason other than that we can.");
   elm_label_line_wrap_set(label5, ELM_WRAP_WORD);
   evas_object_resize(label5, 200, 40);
   evas_object_move(label5, 0, 110);
   evas_object_show(label5);

And last but not least for our sixth label we set the style to "marker" and the color to red (the default color is white which would be hard to see on our white background):

   label6 = elm_label_add(win);
   elm_object_text_set(label6, "Short text");
   elm_object_style_set(label6, "marker");
   evas_object_color_set(label6, 255, 0, 0, 255);
   evas_object_resize(label6, 200, 15);
   evas_object_move(label6, 0, 140);
   evas_object_show(label6);