0

I want to change a programmatically created label's style with EDC:

style {
  name: "list_text_title_normal";
  base: "font=Tizen:style=Bold font_size=32 color=#FF9100FF text_class=tizen ellipsis=1.0";
}

I tried to include my EDJ with this line:

elm_theme_extension_add(NULL, PATH_TO_EDJ);

Then apply the style for the label:

elm_object_style_set(label, "list_text_title_normal");

But the label is not respecting the style, how can I do this? I don't want to put style definitions into C/C++ code (although I know it's possible to set color and font by HTML-like formatting in the text).

Daniel
  • 2,318
  • 2
  • 22
  • 53

1 Answers1

2

(1) style in your EDC

style {
  name: "list_text_title_normal";
  base: "font=Tizen:style=Bold font_size=32 color=#FF9100FF text_class=tizen ellipsis=1.0";
}

The above style, actually it is a Textblock Style, in EDC is for Textblock parts in your EDC file. As I know, there is no way to get this style from out of the EDC file. If you want to use this in your EDC, you need to add a group which includes a Textblock part with the style. (note: you can't use elm_label APIs on elm_layout object.)

eg) in EDC

group { "my_edc_group";
   parts {
       ...
       textblock { "elm.text"; // your part name...
          desc { "default";
             ...
             text {
                style: "list_text_title_normal";
                ...
             }
             ...
          }
       }
       ...
   }
}

in your C/C++ Code

Evas_Object *layout = elm_layout_add(parent);
elm_layout_file_set(layout, YOUR_PATH_FOR_EDJ_FILE, "my_edc_group");
elm_object_part_text_set(layout, "elm.text", "Hello World");

(2) elm_object_style_set in your c/c++ code

elm_object_style_set(label, "list_text_title_normal");

The above style means a theme style of a widget. There are some pre-defined set of theme styles for a widget in Tizen/EFL. It is totally different thing from what you added in your EDC file. Adding a new style in a widget is quite difficult and hard to maintain your code. I don't recommend you to customize or add your theme style.

(3) An easier way without using EDC.

// note: You should not set ellipsis and text_class as markup tag in a text for Elm_Label widget
// string from a file:
// eg. "font=Tizen:style=Bold font_size=32 color=#FF9100FF"
const char *textblockStyle = readLineFromFile(file);  // your readLineFromFile function
Eina_Strbuf *buf = eina_strbuf_new();
eina_strbuf_append_printf(buf, "<%s>%s", textblockStyle, text);
elm_object_text_set(label, eina_strbuf_string_get(buf));
eina_strbuf_free(buf);
Shin
  • 36
  • 2