#include <Elementary.h>
#include "elm_priv.h"
-/**
- * @defgroup Progressbar Progressbar
- *
- * The progressbar adds a widget for representing current progress
- * of a job status
- *
- * A progressbar can be horizontal or vertical. It can contain an Icon and has a
- * primary label as well as a units label (that is formatted with floating
- * point values and thus accepts a printf-style format string, like
- * “%1.2f units”.
- *
- * Label, Icon and Unit strings/objects are optional.
- *
- * A progressbar may be inverted which means values invert, with high vales being
- * on the left or top and low values on the right or bottom (as opposed to
- * normally being low on the left or top and high on the bottom and right).
- *
- * The span of the progressbar is its length (horizontally or vertically).
- * This will be scaled by the object or applications scaling factor. At any point
- * code can query the progressbar for its value with elm_progressbar_value_get().
- */
-
#define MIN_RATIO_LVL 0.0
#define MAX_RATIO_LVL 1.0
}
if (wd->label)
{
- edje_object_part_text_set(wd->progressbar, "elm.text", wd->label);
+ edje_object_part_text_escaped_set(wd->progressbar, "elm.text", wd->label);
edje_object_signal_emit(wd->progressbar, "elm,state,text,visible", "elm");
}
if (wd->pulse)
{
char buf[1024];
snprintf(buf, sizeof(buf), wd->units, 100 * wd->val);
- edje_object_part_text_set(wd->progressbar, "elm.text.status", buf);
+ edje_object_part_text_escaped_set(wd->progressbar, "elm.text.status", buf);
}
else
- edje_object_part_text_set(wd->progressbar, "elm.text.status", NULL);
+ edje_object_part_text_escaped_set(wd->progressbar, "elm.text.status", NULL);
}
static void
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- if (item) return;
+ if (item && strcmp(item, "default")) return;
if (!wd) return;
eina_stringshare_replace(&wd->label, label);
if (label)
edje_object_signal_emit(wd->progressbar, "elm,state,text,hidden", "elm");
edje_object_message_signal_process(wd->progressbar);
}
- edje_object_part_text_set(wd->progressbar, "elm.text", label);
+ edje_object_part_text_escaped_set(wd->progressbar, "elm.text", label);
_sizing_eval(obj);
}
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
- if (item) return NULL;
+ if (item && strcmp(item, "default")) return NULL;
if (!wd) return NULL;
return wd->label;
}
-/**
- * Add a new progressbar to the parent
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup Progressbar
- */
+static void
+_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd;
+ if (part && strcmp(part, "icon")) return;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (wd->icon == content) return;
+ if (wd->icon) evas_object_del(wd->icon);
+ wd->icon = content;
+ if (content)
+ {
+ elm_widget_sub_object_add(obj, content);
+ evas_object_event_callback_add(content,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ edje_object_part_swallow(wd->progressbar, "elm.swallow.content", content);
+ edje_object_signal_emit(wd->progressbar, "elm,state,icon,visible", "elm");
+ edje_object_message_signal_process(wd->progressbar);
+ }
+ _sizing_eval(obj);
+}
+
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd;
+ if (part && strcmp(part, "icon")) return NULL;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return wd->icon;
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd;
+ Evas_Object *icon;
+ if (part && strcmp(part, "icon")) return NULL;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ if (!wd->icon) return NULL;
+ icon = wd->icon;
+ elm_widget_sub_object_del(obj, wd->icon);
+ evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ edje_object_part_unswallow(wd->progressbar, wd->icon);
+ wd->icon = NULL;
+ return icon;
+}
+
+
EAPI Evas_Object *
elm_progressbar_add(Evas_Object *parent)
{
elm_widget_can_focus_set(obj, EINA_FALSE);
elm_widget_text_set_hook_set(obj, _elm_progressbar_label_set);
elm_widget_text_get_hook_set(obj, _elm_progressbar_label_get);
+ elm_widget_content_set_hook_set(obj, _content_set_hook);
+ elm_widget_content_get_hook_set(obj, _content_get_hook);
+ elm_widget_content_unset_hook_set(obj, _content_unset_hook);
wd->horizontal = EINA_TRUE;
wd->inverted = EINA_FALSE;
return obj;
}
-/**
- * Normally the progressbar will display and interpret values from low to high.
- * This display a progressbar for jobs with unknow state of progression,
- * (the cursor pulse right to left and left to right, and loop) if pulse is set to 1.
- *
- * @param obj The progressbar object
- * @param pulse The pulse flag. 1 == pulse, 0 == normal
- *
- * @ingroup Progressbar
- */
EAPI void
elm_progressbar_pulse_set(Evas_Object *obj, Eina_Bool pulse)
{
_theme_hook(obj);
}
-/**
- * Normally the progressbar will display and interpret values from low to high.
- * This display a progressbar for jobs with unknow state of progression,
- * (the cursor pulse right to left and left to right, and loop) if pulse is set to 1.
- *
- * @param obj The progressbar object
- * @return The pulse flag
- * (1 == pulse, 0 == normal)
- *
- * @ingroup Progressbar
- */
EAPI Eina_Bool
elm_progressbar_pulse_get(const Evas_Object *obj)
{
return wd->pulse;
}
-/**
- * Stat/Stop de pulse action
- *
- * @param obj The progressbar object
- * @param state The pulse flag. 1 == start pulse, 0 == stop pulse
- *
- * @ingroup Progressbar
- */
EAPI void
elm_progressbar_pulse(Evas_Object *obj, Eina_Bool state)
{
edje_object_signal_emit(wd->progressbar, "elm,state,pulse,stop", "elm");
}
-/**
- * Set the value the progressbar indicates
- *
- * @param obj The progressbar object
- * @param val The fraction value (must be between 0.0 and 1.0)
- *
- * @ingroup Progressbar
- */
EAPI void
elm_progressbar_value_set(Evas_Object *obj, double val)
{
_units_set(obj);
}
-
-/**
- * Get the value the progressbar has
- *
- * @param obj The progressbar object
- * @return The value of the progressbar
- *
- * @ingroup Progressbar
- */
EAPI double
elm_progressbar_value_get(const Evas_Object *obj)
{
return wd->val;
}
-/**
- * Set the label of the progressbar
- *
- * @param obj The progressbar object
- * @param label The text label string in UTF-8
- *
- * @ingroup Progressbar
- * @deprecated use elm_object_text_set() instead.
- */
-EAPI void
-elm_progressbar_label_set(Evas_Object *obj, const char *label)
-{
- _elm_progressbar_label_set(obj, NULL, label);
-}
-
-/**
- * Get the label of the progressbar
- *
- * @param obj The progressbar object
- * @return The text label string in UTF-8
- *
- * @ingroup Progressbar
- * @deprecated use elm_object_text_set() instead.
- */
-EAPI const char *
-elm_progressbar_label_get(const Evas_Object *obj)
-{
- return _elm_progressbar_label_get(obj, NULL);
-}
-
-/**
- * Set the icon object of the progressbar object
- *
- * Once the icon object is set, a previously set one will be deleted.
- * If you want to keep that old content object, use the
- * elm_progressbar_icon_unset() function.
- *
- * @param obj The progressbar object
- * @param icon The icon object
- *
- * @ingroup Progressbar
- */
-EAPI void
-elm_progressbar_icon_set(Evas_Object *obj, Evas_Object *icon)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- if (wd->icon == icon) return;
- if (wd->icon) evas_object_del(wd->icon);
- wd->icon = icon;
- if (icon)
- {
- elm_widget_sub_object_add(obj, icon);
- evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
- _changed_size_hints, obj);
- edje_object_part_swallow(wd->progressbar, "elm.swallow.content", icon);
- edje_object_signal_emit(wd->progressbar, "elm,state,icon,visible", "elm");
- edje_object_message_signal_process(wd->progressbar);
- }
- _sizing_eval(obj);
-}
-
-/**
- * Get the icon object of the progressbar object
- *
- * @param obj The progressbar object
- * @return The icon object
- *
- * @ingroup Progressbar
- */
-EAPI Evas_Object *
-elm_progressbar_icon_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- return wd->icon;
-}
-
-/**
- * Unset the icon used for the progressbar object
- *
- * Unparent and return the icon object which was set for this widget.
- *
- * @param obj The progressbar object
- * @return The icon object that was being used
- *
- * @ingroup Progressbar
- */
-EAPI Evas_Object *
-elm_progressbar_icon_unset(Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- if (!wd->icon) return NULL;
- Evas_Object *icon = wd->icon;
- elm_widget_sub_object_del(obj, wd->icon);
- edje_object_part_unswallow(wd->progressbar, wd->icon);
- wd->icon = NULL;
- return icon;
-}
-
-/**
- * Set the length of the progression region of the progressbar
- *
- * This sets the minimum width or height (depending on orientation) of the
- * area of the progressbar that allows the progressbar to be dragged around. This in
- * turn affects the objects minimum size (along with icon label and unit
- * text).
- *
- * @param obj The progressbar object
- * @param size The length of the progressbar area
- *
- * @ingroup Progressbar
- */
EAPI void
elm_progressbar_span_size_set(Evas_Object *obj, Evas_Coord size)
{
_sizing_eval(obj);
}
-/**
- * Get the length of the progression region of the progressbar
- *
- * @param obj The progressbar object
- * @return The length of the progressbar area
- *
- * @ingroup Progressbar
- */
EAPI Evas_Coord
elm_progressbar_span_size_get(const Evas_Object *obj)
{
return wd->size;
}
-/**
- * Set the format string of the unit area
- *
- * If NULL, this disabls the unit area display. If not it sets the format
- * string for the unit text. The unit text is provided a floating point
- * value, so the unit text can display up to 1 floating point falue. Note that
- * this is optional. Use a format string such as "%1.2f meters" for example.
- *
- * @param obj The progressbar object
- * @param units The format string for the units display
- *
- * @ingroup Progressbar
- */
EAPI void
elm_progressbar_unit_format_set(Evas_Object *obj, const char *units)
{
_sizing_eval(obj);
}
-/**
- * Get the format string of the unit area
- *
- * @param obj The progressbar object
- * @return The format string for the units display
- *
- * @ingroup Progressbar
- */
EAPI const char *
elm_progressbar_unit_format_get(const Evas_Object *obj)
{
return wd->units;
}
-/**
- * Set orientation of the progressbar
- *
- * @param obj The progressbar object
- * @param horizontal If set, the progressbar will be horizontal
- *
- * @ingroup Progressbar
- */
EAPI void
elm_progressbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
{
_theme_hook(obj);
}
-/**
- * Gets orientation of the progressbar
- *
- * @param obj The progressbar object
- * @return The orientation
- * (0 = vertical, 1 = horizontal)
- *
- * @ingroup Progressbar
- */
EAPI Eina_Bool
elm_progressbar_horizontal_get(const Evas_Object *obj)
{
return wd->horizontal;
}
-/**
- * Invert the progressbar display
- *
- * Normally the progressbar will display and interpret values from low to high
- * and when horizontal that is left to right. When vertical that is top
- * to bottom. This inverts this (so from right to left or bottom to top) if
- * inverted is set to 1.
- *
- * @param obj The progressbar object
- * @param inverted The inverted flag. 1 == inverted, 0 == normal
- *
- * @ingroup Progressbar
- */
EAPI void
elm_progressbar_inverted_set(Evas_Object *obj, Eina_Bool inverted)
{
_units_set(obj);
}
-/**
- * Gets if the progressbar will displayed inverted
- *
- * @param obj The progressbar object
- * @return The inverted flag
- * (1 == inverted, 0 == normal)
- *
- * @ingroup Progressbar
- */
EAPI Eina_Bool
elm_progressbar_inverted_get(const Evas_Object *obj)
{