struct _Widget_Data
{
Evas_Object *lbl;
- Evas_Object *bg;
const char *label;
const char *format;
Ecore_Job *deferred_recalc_job;
double slide_duration;
Evas_Coord lastw;
Evas_Coord wrap_w;
- Evas_Coord wrap_h;
Elm_Wrap_Type linewrap;
Eina_Bool changed : 1;
- Eina_Bool bgcolor : 1;
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);
-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
minw = ominw;
}
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_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);
- if (wd->bg) evas_object_del(wd->bg);
free(wd);
evas_event_thaw(evas_object_evas_get(obj));
evas_event_thaw_eval(evas_object_evas_get(obj));
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;
- 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_event_thaw(evas_object_evas_get(obj));
evas_event_thaw_eval(evas_object_evas_get(obj));
}
return 0;
}
-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);
- }
-
- while (_is_width_over(obj))
- {
- if (cur_fontsize > minfontsize)
- {
- cur_fontsize -= 3;
- if (cur_fontsize < minfontsize) cur_fontsize = minfontsize;
- _ellipsis_fontsize_set(obj, cur_fontsize);
- }
- else
- {
- break;
- }
- }
- evas_event_thaw(evas_object_evas_get(obj));
- evas_event_thaw_eval(evas_object_evas_get(obj));
-}
-
static void
_label_sliding_change(Evas_Object *obj)
{
elm_widget_text_get_hook_set(obj, _elm_label_label_get);
elm_widget_translate_hook_set(obj, _translate_hook);
- wd->bgcolor = EINA_FALSE;
- wd->bg = evas_object_rectangle_add(e);
- evas_object_color_set(wd->bg, 0, 0, 0, 0);
-
wd->linewrap = ELM_WRAP_NONE;
wd->ellipsis = EINA_FALSE;
wd->slidingmode = EINA_FALSE;
wd->slidingellipsis = EINA_FALSE;
wd->wrap_w = -1;
- wd->wrap_h = -1;
wd->slide_duration = 10;
wd->lbl = edje_object_add(e);
return wd->wrap_w;
}
-EAPI void
-elm_label_wrap_height_set(Evas_Object *obj,
- Evas_Coord h)
+EINA_DEPRECATED EAPI void
+elm_label_wrap_height_set(Evas_Object *obj __UNUSED__,
+ Evas_Coord h __UNUSED__)
{
- 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);
+ return;
}
-EAPI Evas_Coord
-elm_label_wrap_height_get(const Evas_Object *obj)
+EINA_DEPRECATED EAPI Evas_Coord
+elm_label_wrap_height_get(const Evas_Object *obj __UNUSED__)
{
- ELM_CHECK_WIDTYPE(obj, widtype) 0;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return 0;
- return wd->wrap_h;
+ return 0;
}
EINA_DEPRECATED EAPI void
-elm_label_fontsize_set(Evas_Object *obj, int fontsize)
+elm_label_fontsize_set(Evas_Object *obj __UNUSED__,
+ int fontsize __UNUSED__)
{
- 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);
+ return;
}
EINA_DEPRECATED EAPI void
-elm_label_text_align_set(Evas_Object *obj, const char *alignmode)
+elm_label_text_align_set(Evas_Object *obj __UNUSED__,
+ const char *alignmode __UNUSED__)
{
- 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);
+ return;
}
EINA_DEPRECATED EAPI void
-elm_label_text_color_set(Evas_Object *obj,
- unsigned int r,
- unsigned int g,
- unsigned int b,
- unsigned int a)
+elm_label_text_color_set(Evas_Object *obj __UNUSED__,
+ unsigned int r __UNUSED__,
+ unsigned int g __UNUSED__,
+ unsigned int b __UNUSED__,
+ unsigned int a __UNUSED__)
{
- 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);
+ return;
}
EINA_DEPRECATED EAPI void
-elm_label_background_color_set(Evas_Object *obj,
- unsigned int r,
- unsigned int g,
- unsigned int b,
- unsigned int a)
+elm_label_background_color_set(Evas_Object *obj __UNUSED__,
+ unsigned int r __UNUSED__,
+ unsigned int g __UNUSED__,
+ unsigned int b __UNUSED__,
+ unsigned int a __UNUSED__)
{
- 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);
- }
+ return;
}
EAPI void