elementary - removed deprecated widgets & APIs.
[framework/uifw/elementary.git] / src / lib / elm_label.c
index fb2e40c..fc558f3 100644 (file)
@@ -1,13 +1,6 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 
-/**
- * @defgroup Label Label
- *
- * Display text, with simple html-like markup. The theme of course
- * can invent new markup tags and style them any way it likes
- */
-
 typedef struct _Widget_Data Widget_Data;
 
 struct _Widget_Data
@@ -21,7 +14,7 @@ struct _Widget_Data
    Evas_Coord lastw;
    Evas_Coord wrap_w;
    Evas_Coord wrap_h;
-   Eina_Bool linewrap : 1;
+   Elm_Wrap_Type linewrap;
    Eina_Bool changed : 1;
    Eina_Bool bgcolor : 1;
    Eina_Bool ellipsis : 1;
@@ -46,23 +39,46 @@ _elm_win_recalc_job(void *data)
 {
    Widget_Data *wd = elm_widget_data_get(data);
    Evas_Coord minw = -1, minh = -1;
-   Evas_Coord resw;
+   Evas_Coord resw, resh;
+
    if (!wd) return;
    wd->deferred_recalc_job = NULL;
-   evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, NULL);
+
+   evas_object_geometry_get(wd->lbl, NULL, NULL, &resw, &resh);
    if (wd->wrap_w > resw)
-      resw = wd->wrap_w;
+     resw = wd->wrap_w;
+   if (wd->wrap_h > resh)
+     resh = wd->wrap_h;
 
-   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))
+   if (wd->wrap_h == -1) /* open source routine */
      {
-        Evas_Coord ominw = -1;
-        evas_object_size_hint_min_get(data, &ominw, NULL);
-        minw = ominw;
+        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);
 
@@ -445,6 +461,11 @@ _ellipsis_label_to_width(Evas_Object *obj)
         if (kvalue != NULL) cur_fontsize = atoi(kvalue);
      }
 
+   /* TODO : Remove ellipsis logic in elm_lable and use ellipsis feature in evas textblock */
+   _ellipsis_fontsize_set(obj, cur_fontsize);
+   return;
+
+/*
    while (_is_width_over(obj))
      {
         if (cur_fontsize > minfontsize)
@@ -458,6 +479,7 @@ _ellipsis_label_to_width(Evas_Object *obj)
              break;
           }
      }
+*/
 }
 
 static void
@@ -540,14 +562,12 @@ _elm_label_label_get(const Evas_Object *obj, const char *item)
    return wd->label;
 }
 
-/**
- * Add a new label to the parent
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup Label
- */
+static void
+_translate_hook(Evas_Object *obj)
+{
+   evas_object_smart_callback_call(obj, "language,changed", NULL);
+}
+
 EAPI Evas_Object *
 elm_label_add(Evas_Object *parent)
 {
@@ -566,12 +586,13 @@ elm_label_add(Evas_Object *parent)
    elm_widget_can_focus_set(obj, EINA_FALSE);
    elm_widget_text_set_hook_set(obj, _elm_label_label_set);
    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 = EINA_FALSE;
+   wd->linewrap = ELM_WRAP_NONE;
    wd->ellipsis = EINA_FALSE;
    wd->slidingmode = EINA_FALSE;
    wd->slidingellipsis = EINA_FALSE;
@@ -596,42 +617,18 @@ elm_label_add(Evas_Object *parent)
    return obj;
 }
 
-/**
- * Set the label on the label object
- *
- * @param obj The label object
- * @param label The label will be used on the label object
- *
- * @ingroup Label
- */
 EAPI void
 elm_label_label_set(Evas_Object *obj, const char *label)
 {
   _elm_label_label_set(obj, NULL, label);
 }
 
-/**
- * Get the label used on the label object
- *
- * @param obj The label object
- * @return The string inside the label
- * @ingroup Label
- * @deprecated
- */
 EAPI const char *
 elm_label_label_get(const Evas_Object *obj)
 {
   return _elm_label_label_get(obj, NULL);
 }
 
-/**
- * Set the wrapping behavior of the label
- *
- * @param obj The label object
- * @param wrap To wrap text or not
- * @ingroup Label
- * @deprecated
- */
 EAPI void
 elm_label_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
 {
@@ -672,13 +669,6 @@ elm_label_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
      }
 }
 
-/**
- * Get the wrapping behavior of the label
- *
- * @param obj The label object
- * @return Wrap type
- * @ingroup Label
- */
 EAPI Elm_Wrap_Type
 elm_label_line_wrap_get(const Evas_Object *obj)
 {
@@ -688,13 +678,6 @@ elm_label_line_wrap_get(const Evas_Object *obj)
    return wd->linewrap;
 }
 
-/**
- * Set wrap width of the label
- *
- * @param obj The label object
- * @param w The wrap width in pixels at a minimum where words need to wrap
- * @ingroup Label
- */
 EAPI void
 elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w)
 {
@@ -712,13 +695,6 @@ elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w)
    _sizing_eval(obj);
 }
 
-/**
- * get wrap width of the label
- *
- * @param obj The label object
- * @return The wrap width in pixels at a minimum where words need to wrap
- * @ingroup Label
- */
 EAPI Evas_Coord
 elm_label_wrap_width_get(const Evas_Object *obj)
 {
@@ -728,13 +704,6 @@ elm_label_wrap_width_get(const Evas_Object *obj)
    return wd->wrap_w;
 }
 
-/**
- * Set wrap height of the label
- *
- * @param obj The label object
- * @param w The wrap width in pixels at a minimum where words need to wrap
- * @ingroup Label
- */
 EAPI void
 elm_label_wrap_height_set(Evas_Object *obj,
                           Evas_Coord   h)
@@ -753,13 +722,6 @@ elm_label_wrap_height_set(Evas_Object *obj,
    _sizing_eval(obj);
 }
 
-/**
- * get wrap width of the label
- *
- * @param obj The label object
- * @return The wrap height in pixels at a minimum where words need to wrap
- * @ingroup Label
- */
 EAPI Evas_Coord
 elm_label_wrap_height_get(const Evas_Object *obj)
 {
@@ -769,18 +731,6 @@ elm_label_wrap_height_get(const Evas_Object *obj)
    return wd->wrap_h;
 }
 
-/**
- * Set the font size on the label object.
- *
- * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
- * "big", "medium", "small" - or better name them by use:
- * "title", "footnote", "quote" etc.
- *
- * @param obj The label object
- * @param size font size
- *
- * @ingroup Label
- */
 EAPI void
 elm_label_fontsize_set(Evas_Object *obj, int fontsize)
 {
@@ -808,18 +758,6 @@ elm_label_fontsize_set(Evas_Object *obj, int fontsize)
    eina_strbuf_free(fontbuf);
 }
 
-/**
- * Set the text align on the label object
- *
- * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
- * "big", "medium", "small" - or better name them by use:
- * "title", "footnote", "quote" etc.
- *
- * @param obj The label object
- * @param align align mode ("left", "center", "right")
- *
- * @ingroup Label
- */
 EAPI void
 elm_label_text_align_set(Evas_Object *obj, const char *alignmode)
 {
@@ -842,17 +780,6 @@ elm_label_text_align_set(Evas_Object *obj, const char *alignmode)
    _sizing_eval(obj);
 }
 
-/**
- * Set the text color on the label object
- *
- * @param obj The label object
- * @param r Red property background color of The label object
- * @param g Green property background color of The label object
- * @param b Blue property background color of The label object
- * @param a Alpha property background color of The label object
- *
- * @ingroup Label
- */
 EAPI void
 elm_label_text_color_set(Evas_Object *obj,
                          unsigned int r,
@@ -882,21 +809,6 @@ elm_label_text_color_set(Evas_Object *obj,
    eina_strbuf_free(colorbuf);
 }
 
-/**
- * Set background color of the label
- *
- * NEVER use this. It is for hyper-special cases only. use styles instead. e.g.
- * "big", "medium", "small" - or better name them by use:
- * "title", "footnote", "quote" etc.
- *
- * @param obj The label object
- * @param r Red property background color of The label object
- * @param g Green property background color of The label object
- * @param b Blue property background color of The label object
- * @param a Alpha property background alpha of The label object
- *
- * @ingroup Label
- */
 EAPI void
 elm_label_background_color_set(Evas_Object *obj,
                                unsigned int r,
@@ -909,7 +821,6 @@ elm_label_background_color_set(Evas_Object *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)
      {
@@ -918,28 +829,6 @@ elm_label_background_color_set(Evas_Object *obj,
      }
 }
 
-/**
- * Set the wrapmode of the label
- *
- * @param obj The label object
- * @param wrapmode 0 is charwrap, 1 is wordwrap
- * @ingroup Label
- * @deprecated 
-*/
-EAPI void
-elm_label_wrap_mode_set(Evas_Object *obj,
-                        Eina_Bool    wrapmode)
-{
-   return;
-}
-
-/**
- * Set the ellipsis behavior of the label
- *
- * @param obj The label object
- * @param ellipsis To ellipsis text or not
- * @ingroup Label
- */
 EAPI void
 elm_label_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
 {
@@ -971,13 +860,6 @@ elm_label_ellipsis_set(Evas_Object *obj, Eina_Bool ellipsis)
 
 }
 
-/**
- * Set the text slide of the label
- *
- * @param obj The label object
- * @param slide To start slide or stop
- * @ingroup Label
- */
 EAPI void
 elm_label_slide_set(Evas_Object *obj,
                     Eina_Bool    slide)
@@ -993,13 +875,6 @@ elm_label_slide_set(Evas_Object *obj,
    _sizing_eval(obj);
 }
 
-/**
- * get the text slide mode of the label
- *
- * @param obj The label object
- * @return slide slide mode value
- * @ingroup Label
- */
 EAPI Eina_Bool
 elm_label_slide_get(Evas_Object *obj)
 {
@@ -1009,13 +884,6 @@ elm_label_slide_get(Evas_Object *obj)
    return wd->slidingmode;
 }
 
-/**
- * set the slide duration(speed) of the label
- *
- * @param obj The label object
- * @return The duration time in moving text from slide begin position to slide end position
- * @ingroup Label
- */
 EAPI void
 elm_label_slide_duration_set(Evas_Object *obj, double duration)
 {
@@ -1030,13 +898,6 @@ elm_label_slide_duration_set(Evas_Object *obj, double duration)
    edje_object_message_send(wd->lbl, EDJE_MESSAGE_FLOAT_SET, 0, msg);
 }
 
-/**
- * get the slide duration(speed) of the label
- *
- * @param obj The label object
- * @return The duration time in moving text from slide begin position to slide end position
- * @ingroup Label
- */
 EAPI double
 elm_label_slide_duration_get(Evas_Object *obj)
 {