struct _Widget_Data
{
Evas_Object *lbl;
+<<<<<<< HEAD
+ Evas_Object *bg;
+=======
+>>>>>>> remotes/origin/upstream
const char *label;
const char *format;
Ecore_Job *deferred_recalc_job;
double slide_duration;
Evas_Coord lastw;
Evas_Coord wrap_w;
+<<<<<<< HEAD
+ Evas_Coord wrap_h;
Elm_Wrap_Type linewrap;
Eina_Bool changed : 1;
+ Eina_Bool bgcolor : 1;
+=======
+ Elm_Wrap_Type linewrap;
+ Eina_Bool changed : 1;
+>>>>>>> remotes/origin/upstream
Eina_Bool ellipsis : 1;
Eina_Bool slidingmode : 1;
Eina_Bool slidingellipsis : 1;
static int _get_value_in_key_string(const char *oldstring, const char *key, char **value);
static int _strbuf_key_value_replace(Eina_Strbuf *srcbuf, const char *key, const char *value, int deleteflag);
static int _stringshare_key_value_replace(const char **srcstring, const char *key, const char *value, int deleteflag);
+<<<<<<< HEAD
+static int _is_width_over(Evas_Object *obj);
+static void _ellipsis_label_to_width(Evas_Object *obj);
+static void _label_sliding_change(Evas_Object *obj);
+=======
static void _label_sliding_change(Evas_Object *obj);
static void _label_format_set(Evas_Object *obj, const char *format);
+>>>>>>> remotes/origin/upstream
static void
_elm_recalc_job(void *data)
{
Widget_Data *wd = elm_widget_data_get(data);
Evas_Coord minw = -1, minh = -1;
+<<<<<<< HEAD
+ Evas_Coord resw, resh;
+ if (!wd) return;
+ evas_event_freeze(evas_object_evas_get(data));
+ wd->deferred_recalc_job = NULL;
+ evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
+ if (wd->wrap_w > resw)
+ resw = wd->wrap_w;
+ if (wd->wrap_h > resh)
+ resh = wd->wrap_h;
+
+ if (wd->wrap_h == -1) /* open source routine */
+ {
+ edje_object_size_min_restricted_calc(wd->lbl, &minw, &minh, resw, 0);
+ /* This is a hack to workaround the way min size hints are treated.
+ * If the minimum width is smaller than the restricted width, it means
+ * the mininmum doesn't matter. */
+ if ((minw <= resw) && (minw != wd->wrap_w))
+ {
+ Evas_Coord ominw = -1;
+ evas_object_size_hint_min_get(data, &ominw, NULL);
+ minw = ominw;
+ }
+ }
+ else /* ellipsis && linewrap && wrap_height_set routine */
+ {
+ edje_object_size_min_restricted_calc(wd->lbl, &minw, &minh, 0, resh);
+ if ((minh <= resh) && (minh != wd->wrap_h))
+ {
+ Evas_Coord ominh = -1;
+ evas_object_size_hint_min_get(data, NULL, &ominh);
+ minh = ominh;
+ }
+ evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
+ minw = resw;
+ if (minh > wd->wrap_h)
+ minh = wd->wrap_h;
+
+ }
+ evas_object_size_hint_min_set(data, minw, minh);
+ evas_object_size_hint_max_set(data, wd->wrap_w, wd->wrap_h);
+
+ if ((wd->ellipsis) && (wd->linewrap) && (wd->wrap_h > 0) &&
+ (_is_width_over(data) == 1))
+ _ellipsis_label_to_width(data);
+=======
Evas_Coord resw;
if (!wd) return;
evas_event_freeze(evas_object_evas_get(data));
minw = ominw;
}
evas_object_size_hint_min_set(data, minw, minh);
+>>>>>>> remotes/origin/upstream
evas_event_thaw(evas_object_evas_get(data));
evas_event_thaw_eval(evas_object_evas_get(data));
}
evas_event_freeze(evas_object_evas_get(obj));
if (wd->deferred_recalc_job) ecore_job_del(wd->deferred_recalc_job);
if (wd->label) eina_stringshare_del(wd->label);
+<<<<<<< HEAD
+ if (wd->bg) evas_object_del(wd->bg);
+=======
+>>>>>>> remotes/origin/upstream
free(wd);
evas_event_thaw(evas_object_evas_get(obj));
evas_event_thaw_eval(evas_object_evas_get(obj));
_elm_widget_mirrored_reload(obj);
_mirrored_set(obj, elm_widget_mirrored_get(obj));
_theme_change(obj);
+<<<<<<< HEAD
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text", wd->format);
+=======
_label_format_set(wd->lbl, wd->format);
+>>>>>>> remotes/origin/upstream
edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
edje_object_scale_set(wd->lbl, elm_widget_scale_get(obj) *
_elm_config->scale);
evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
edje_object_size_min_calc(wd->lbl, &minw, &minh);
if (wd->wrap_w > 0 && minw > wd->wrap_w) minw = wd->wrap_w;
+<<<<<<< HEAD
+ if (wd->wrap_h > 0 && minh > wd->wrap_h) minh = wd->wrap_h;
+ evas_object_size_hint_min_set(obj, minw, minh);
+ evas_object_size_hint_max_set(obj, wd->wrap_w, wd->wrap_h);
+ if ((wd->ellipsis) && (_is_width_over(obj) == 1))
+ _ellipsis_label_to_width(obj);
+=======
evas_object_size_hint_min_set(obj, minw, minh);
+>>>>>>> remotes/origin/upstream
evas_event_thaw(evas_object_evas_get(obj));
evas_event_thaw_eval(evas_object_evas_get(obj));
}
if (wd->linewrap) _sizing_eval(data);
}
+<<<<<<< HEAD
+static int
+_get_value_in_key_string(const char *oldstring, const char *key, char **value)
+{
+ char *curlocater, *starttag, *endtag;
+=======
static void
_label_format_set(Evas_Object *obj, const char *format)
{
_get_value_in_key_string(const char *oldstring, const char *key, char **value)
{
char *curlocater, *endtag;
+>>>>>>> remotes/origin/upstream
int firstindex = 0, foundflag = -1;
curlocater = strstr(oldstring, key);
if (curlocater)
{
int key_len = strlen(key);
+<<<<<<< HEAD
+ starttag = curlocater;
+=======
+>>>>>>> remotes/origin/upstream
endtag = curlocater + key_len;
if ((!endtag) || (*endtag != '='))
{
firstindex += key_len + 1; // strlen("key") + strlen("=")
*value = (char *)oldstring + firstindex;
+<<<<<<< HEAD
+ while (oldstring != starttag)
+ {
+ if (*starttag == '>')
+ {
+ foundflag = 0;
+ break;
+ }
+ if (*starttag == '<')
+ break;
+ else
+ starttag--;
+ if (!starttag) break;
+ }
+
+ while (endtag)
+ {
+ if (*endtag == '<')
+ {
+ foundflag = 0;
+ break;
+ }
+ if (*endtag == '>')
+ break;
+ else
+ endtag++;
+ if (!endtag) break;
+ }
+
+ if ((foundflag) && (*starttag == '<') && (*endtag == '>'))
+ foundflag = 1;
+ else
+ foundflag = 0;
+=======
foundflag = 1;
+>>>>>>> remotes/origin/upstream
}
else
{
return -1;
}
+<<<<<<< HEAD
+=======
+>>>>>>> remotes/origin/upstream
static int
_strbuf_key_value_replace(Eina_Strbuf *srcbuf, const char *key, const char *value, int deleteflag)
{
return 0;
}
+<<<<<<< HEAD
+static int
+_is_width_over(Evas_Object *obj)
+{
+ Evas_Coord x, y, w, h;
+ Evas_Coord vx, vy, vw, vh;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return 0;
+
+ evas_event_freeze(evas_object_evas_get(obj));
+ edje_object_part_geometry_get(wd->lbl, "elm.text", &x, &y, NULL, NULL);
+ /* Calc the formatted size with ellipsis turned off */
+ if (wd->ellipsis)
+ {
+ const Evas_Object *tb;
+ char *_kvalue;
+ double ellipsis = 0.0;
+ Eina_Bool found_key = EINA_FALSE;
+ if (_get_value_in_key_string(wd->format, "ellipsis", &_kvalue) == 0)
+ {
+ ellipsis = atof(_kvalue);
+ found_key = EINA_TRUE;
+ }
+
+ if (_stringshare_key_value_replace(&wd->format,
+ "ellipsis", NULL, 1) == 0)
+ {
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+ edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
+ }
+
+ tb = edje_object_part_object_get(wd->lbl, "elm.text");
+ evas_object_textblock_size_formatted_get(tb, &w, &h);
+
+ if (found_key)
+ {
+ Eina_Strbuf *elpbuf;
+ elpbuf = eina_strbuf_new();
+ eina_strbuf_append_printf(elpbuf, "%f", ellipsis);
+ if (_stringshare_key_value_replace(&wd->format, "ellipsis",
+ eina_strbuf_string_get(elpbuf), 0) == 0)
+ {
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+ edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
+ }
+ eina_strbuf_free(elpbuf);
+ }
+ }
+ else
+ {
+ const Evas_Object *tb;
+ tb = edje_object_part_object_get(wd->lbl, "elm.text");
+ evas_object_textblock_size_formatted_get(tb, &w, &h);
+ }
+ evas_object_geometry_get(obj, &vx, &vy, &vw, &vh);
+ evas_event_thaw(evas_object_evas_get(obj));
+ evas_event_thaw_eval(evas_object_evas_get(obj));
+
+ if (w > wd->wrap_w || h > wd->wrap_h)
+ return 1;
+
+ return 0;
+}
+
+static void
+_ellipsis_fontsize_set(Evas_Object *obj, int fontsize)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ Eina_Strbuf *fontbuf = NULL;
+ int removeflag = 0;
+ if (!wd) return;
+
+ fontbuf = eina_strbuf_new();
+ eina_strbuf_append_printf(fontbuf, "%d", fontsize);
+ if (fontsize == 0) removeflag = 1; // remove fontsize tag
+
+ if (_stringshare_key_value_replace(&wd->format, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
+ {
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+ edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
+ }
+ eina_strbuf_free(fontbuf);
+}
+
+static void
+_ellipsis_label_to_width(Evas_Object *obj)
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ int cur_fontsize = 0;
+ char *kvalue;
+ const char *minfont, *deffont, *maxfont;
+ int minfontsize, maxfontsize;
+
+ evas_event_freeze(evas_object_evas_get(obj));
+ minfont = edje_object_data_get(wd->lbl, "min_font_size");
+ if (minfont) minfontsize = atoi(minfont);
+ else minfontsize = 1;
+ maxfont = edje_object_data_get(wd->lbl, "max_font_size");
+ if (maxfont) maxfontsize = atoi(maxfont);
+ else maxfontsize = 1;
+ deffont = edje_object_data_get(wd->lbl, "default_font_size");
+ if (deffont) cur_fontsize = atoi(deffont);
+ else cur_fontsize = 1;
+ if (minfontsize > maxfontsize || cur_fontsize == 1) return; // theme is not ready for ellipsis
+ if (eina_stringshare_strlen(wd->label) <= 0) return;
+
+ if (_get_value_in_key_string(wd->format, "font_size", &kvalue) == 0)
+ {
+ if (kvalue != NULL) cur_fontsize = atoi(kvalue);
+ }
+
+ evas_event_thaw(evas_object_evas_get(obj));
+ evas_event_thaw_eval(evas_object_evas_get(obj));
+}
+
+=======
+>>>>>>> remotes/origin/upstream
static void
_label_sliding_change(Evas_Object *obj)
{
if (item && strcmp(item, "default")) return;
if (!label) label = "";
eina_stringshare_replace(&wd->label, label);
+<<<<<<< HEAD
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+=======
_label_format_set(wd->lbl, wd->format);
+>>>>>>> remotes/origin/upstream
edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
wd->changed = 1;
_sizing_eval(obj);
elm_widget_text_get_hook_set(obj, _elm_label_label_get);
elm_widget_translate_hook_set(obj, _translate_hook);
+<<<<<<< HEAD
+ wd->bgcolor = EINA_FALSE;
+ wd->bg = evas_object_rectangle_add(e);
+ evas_object_color_set(wd->bg, 0, 0, 0, 0);
+
+=======
+>>>>>>> remotes/origin/upstream
wd->linewrap = ELM_WRAP_NONE;
wd->ellipsis = EINA_FALSE;
wd->slidingmode = EINA_FALSE;
wd->slidingellipsis = EINA_FALSE;
wd->wrap_w = -1;
+<<<<<<< HEAD
+ wd->wrap_h = -1;
+=======
+>>>>>>> remotes/origin/upstream
wd->slide_duration = 10;
wd->lbl = edje_object_add(e);
_elm_theme_object_set(obj, wd->lbl, "label", "base", "default");
wd->format = eina_stringshare_add("");
wd->label = eina_stringshare_add("<br>");
+<<<<<<< HEAD
+
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+ edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
+ elm_widget_resize_object_set(obj, wd->lbl);
+=======
_label_format_set(wd->lbl, wd->format);
edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
elm_widget_resize_object_set(obj, wd->lbl);
+>>>>>>> remotes/origin/upstream
evas_object_event_callback_add(wd->lbl, EVAS_CALLBACK_RESIZE, _lbl_resize, obj);
_mirrored_set(obj, elm_widget_mirrored_get(obj));
if (_stringshare_key_value_replace(&wd->format,
"wrap", wrap_str, 0) == 0)
{
+<<<<<<< HEAD
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+=======
_label_format_set(wd->lbl, wd->format);
+>>>>>>> remotes/origin/upstream
edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
wd->changed = 1;
_sizing_eval(obj);
if (wd->wrap_w == w) return;
if (wd->ellipsis)
{
+<<<<<<< HEAD
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+=======
_label_format_set(wd->lbl, wd->format);
+>>>>>>> remotes/origin/upstream
edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
}
wd->wrap_w = w;
return wd->wrap_w;
}
+<<<<<<< HEAD
+EAPI void
+elm_label_wrap_height_set(Evas_Object *obj,
+ Evas_Coord h)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (h < 0) h = 0;
+ if (wd->wrap_h == h) return;
+ if (wd->ellipsis)
+ {
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+ edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
+ }
+ wd->wrap_h = h;
+ _sizing_eval(obj);
+}
+
+EAPI Evas_Coord
+elm_label_wrap_height_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) 0;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return 0;
+ return wd->wrap_h;
+}
+
+EAPI void
+elm_label_fontsize_set(Evas_Object *obj, int fontsize)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ Eina_Strbuf *fontbuf = NULL;
+ int len, removeflag = 0;
+
+ if (!wd) return;
+ _elm_dangerous_call_check(__FUNCTION__);
+ len = strlen(wd->label);
+ if (len <= 0) return;
+ fontbuf = eina_strbuf_new();
+ eina_strbuf_append_printf(fontbuf, "%d", fontsize);
+
+ if (fontsize == 0) removeflag = 1; // remove fontsize tag
+
+ if (_stringshare_key_value_replace(&wd->format, "font_size", eina_strbuf_string_get(fontbuf), removeflag) == 0)
+ {
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+ edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
+ wd->changed = 1;
+ _sizing_eval(obj);
+ }
+ eina_strbuf_free(fontbuf);
+}
+
+EAPI void
+elm_label_text_align_set(Evas_Object *obj, const char *alignmode)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ int len;
+
+ if (!wd) return;
+ _elm_dangerous_call_check(__FUNCTION__);
+ len = strlen(wd->label);
+ if (len <= 0) return;
+
+ if (_stringshare_key_value_replace(&wd->format, "align", alignmode, 0) == 0)
+ {
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+ edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
+ }
+
+ wd->changed = 1;
+ _sizing_eval(obj);
+}
+
+EAPI void
+elm_label_text_color_set(Evas_Object *obj,
+ unsigned int r,
+ unsigned int g,
+ unsigned int b,
+ unsigned int a)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ Eina_Strbuf *colorbuf = NULL;
+ int len;
+
+ if (!wd) return;
+ _elm_dangerous_call_check(__FUNCTION__);
+ len = strlen(wd->label);
+ if (len <= 0) return;
+ colorbuf = eina_strbuf_new();
+ eina_strbuf_append_printf(colorbuf, "#%02X%02X%02X%02X", r, g, b, a);
+
+ if (_stringshare_key_value_replace(&wd->format, "color", eina_strbuf_string_get(colorbuf), 0) == 0)
+ {
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+ edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
+ wd->changed = 1;
+ _sizing_eval(obj);
+ }
+ eina_strbuf_free(colorbuf);
+}
+
+EAPI void
+elm_label_background_color_set(Evas_Object *obj,
+ unsigned int r,
+ unsigned int g,
+ unsigned int b,
+ unsigned int a)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ evas_object_color_set(wd->bg, r, g, b, a);
+
+ if (!wd) return;
+ _elm_dangerous_call_check(__FUNCTION__);
+ if (wd->bgcolor == EINA_FALSE)
+ {
+ wd->bgcolor = 1;
+ edje_object_part_swallow(wd->lbl, "label.swallow.background", wd->bg);
+ }
+=======
EINA_DEPRECATED EAPI void
elm_label_wrap_height_set(Evas_Object *obj __UNUSED__,
Evas_Coord h __UNUSED__)
unsigned int a __UNUSED__)
{
return;
+>>>>>>> remotes/origin/upstream
}
EAPI void
if (_stringshare_key_value_replace(&wd->format,
"ellipsis", eina_strbuf_string_get(fontbuf), removeflag) == 0)
{
+<<<<<<< HEAD
+ edje_object_part_text_style_user_set(wd->lbl, "elm.text",
+ wd->format);
+=======
_label_format_set(wd->lbl, wd->format);
+>>>>>>> remotes/origin/upstream
edje_object_part_text_set(wd->lbl, "elm.text", wd->label);
wd->changed = 1;
_sizing_eval(obj);
}
+<<<<<<< HEAD
+=======
EAPI Eina_Bool
elm_label_ellipsis_get(const Evas_Object *obj)
{
return wd->ellipsis;
}
+>>>>>>> remotes/origin/upstream
EAPI void
elm_label_slide_set(Evas_Object *obj,
Eina_Bool slide)
}
EAPI Eina_Bool
+<<<<<<< HEAD
+elm_label_slide_get(Evas_Object *obj)
+=======
elm_label_slide_get(const Evas_Object *obj)
+>>>>>>> remotes/origin/upstream
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
}
EAPI double
+<<<<<<< HEAD
+elm_label_slide_duration_get(Evas_Object *obj)
+=======
elm_label_slide_duration_get(const Evas_Object *obj)
+>>>>>>> remotes/origin/upstream
{
ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
Widget_Data *wd = elm_widget_data_get(obj);