From eb475b53bd9dbb84100cebda1862dcb739a7bdee Mon Sep 17 00:00:00 2001 From: Tiago Rezende Campos Falcao Date: Thu, 1 Apr 2010 14:22:36 +0000 Subject: [PATCH] Added get functions in elm progressbar and added elm progressbar support in edje externals.By Fidencio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Author: Fabiano FidĂȘncio SVN revision: 47647 --- .../data/edje_externals/Makefile.am | 1 + .../data/edje_externals/ico_progressbar.png | Bin 0 -> 138 bytes .../elementary/data/edje_externals/icons.edc | 1 + .../elementary/src/edje_externals/Makefile.am | 1 + .../src/edje_externals/elm_progressbar.c | 242 ++++++++++++++++++ .../elementary/src/edje_externals/modules.inc | 1 + legacy/elementary/src/lib/Elementary.h.in | 7 + legacy/elementary/src/lib/elm_progressbar.c | 130 +++++++++- 8 files changed, 379 insertions(+), 4 deletions(-) create mode 100644 legacy/elementary/data/edje_externals/ico_progressbar.png create mode 100644 legacy/elementary/src/edje_externals/elm_progressbar.c diff --git a/legacy/elementary/data/edje_externals/Makefile.am b/legacy/elementary/data/edje_externals/Makefile.am index 54c304ce10..e1db7d48f9 100644 --- a/legacy/elementary/data/edje_externals/Makefile.am +++ b/legacy/elementary/data/edje_externals/Makefile.am @@ -18,6 +18,7 @@ ico_clock.png \ ico_fileselector.png \ ico_hoversel.png \ ico_notepad.png \ +ico_progressbar.png \ ico_radio.png \ ico_scrolled_entry.png \ ico_slider.png \ diff --git a/legacy/elementary/data/edje_externals/ico_progressbar.png b/legacy/elementary/data/edje_externals/ico_progressbar.png new file mode 100644 index 0000000000000000000000000000000000000000..202aeadb31c6017256fc16c52672a5d70750d1c9 GIT binary patch literal 138 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4ffu1goAr_~T6C_v{GsqgWwXwS! z85rm+-n27Nhlhvf^d#Y6&r7ED|7zMagO@#+a{koGh+{6R7f4jGZ8iV`o7!I`CK?&( k24{^base.label) + elm_progressbar_label_set(obj, p->base.label); + if (p->icon) + elm_progressbar_icon_set(obj, p->icon); + if (p->span_exists) + elm_progressbar_span_size_set(obj, p->span); + if (p->value_exists) + elm_progressbar_value_set(obj, p->value); + if (p->inverted_exists) + elm_progressbar_inverted_set(obj, p->inverted); + if (p->horizontal_exists) + elm_progressbar_horizontal_set(obj, p->horizontal); + if (p->unit) + elm_progressbar_unit_format_set(obj, p->unit); +} + +static Eina_Bool +external_progressbar_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param) +{ + if (!strcmp(param->name, "label")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + elm_progressbar_label_set(obj, param->s); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "icon")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + Evas_Object *icon = external_common_param_icon_get(obj, param); + if (icon) + { + elm_progressbar_icon_set(obj, icon); + return EINA_TRUE; + } + } + } + else if (!strcmp(param->name, "value")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + { + elm_progressbar_value_set(obj, param->d); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "horizontal")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) + { + elm_progressbar_horizontal_set(obj, param->i); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "inverted")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) + { + elm_progressbar_inverted_set(obj, param->i); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "span")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT) + { + elm_progressbar_span_size_set(obj, param->i); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "unit format")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + elm_progressbar_unit_format_set(obj, param->s); + return EINA_TRUE; + } + } + + ERR("unknown parameter '%s' of type '%s'", + param->name, edje_external_param_type_str(param->type)); + + return EINA_FALSE; +} + +static Eina_Bool +external_progressbar_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param) +{ + if (!strcmp(param->name, "label")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + param->s = elm_progressbar_label_get(obj); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "icon")) + { + /* not easy to get icon name back from live object */ + return EINA_FALSE; + } + else if (!strcmp(param->name, "value")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + { + param->d = elm_progressbar_value_get(obj); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "horizontal")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) + { + param->i = elm_progressbar_horizontal_get(obj); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "inverted")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) + { + param->i = elm_progressbar_inverted_get(obj); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "span")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT) + { + param->i = elm_progressbar_span_size_get(obj); + return EINA_TRUE; + } + } + else if (!strcmp(param->name, "unit format")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + param->s = elm_progressbar_unit_format_get(obj); + return EINA_TRUE; + } + } + + ERR("unknown parameter '%s' of type '%s'", + param->name, edje_external_param_type_str(param->type)); + + return EINA_FALSE; +} + +static void * +external_progressbar_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params) +{ + Elm_Params_Progressbar *mem; + Edje_External_Param *param; + const Eina_List *l; + + mem = external_common_params_parse(Elm_Params_Progressbar, data, obj, params); + if (!mem) + return NULL; + + external_common_icon_param_parse(&mem->icon, obj, params); + + EINA_LIST_FOREACH(params, l, param) + { + if (!strcmp(param->name, "span")) + { + mem->span = param->i; + mem->span_exists = EINA_TRUE; + } + else if (!strcmp(param->name, "value")) + { + mem->value = param->d; + mem->value_exists = EINA_TRUE; + } + else if (!strcmp(param->name, "inverted")) + { + mem->inverted = !!param->i; + mem->inverted_exists = EINA_TRUE; + } + else if (!strcmp(param->name, "horizontal")) + { + mem->horizontal = !!param->i; + mem->horizontal_exists = EINA_TRUE; + } + else if (!strcmp(param->name, "unit format")) + mem->unit = eina_stringshare_add(param->s); + } + + return mem; +} + +static void +external_progressbar_params_free(void *params) +{ + Elm_Params_Progressbar *mem = params; + + if (mem->icon) + evas_object_del(mem->icon); + if (mem->unit) + eina_stringshare_del(mem->unit); + external_common_params_free(params); +} + +static Edje_External_Param_Info external_progressbar_params[] = { + DEFINE_EXTERNAL_COMMON_PARAMS, + EDJE_EXTERNAL_PARAM_INFO_STRING("icon"), + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("value"), + EDJE_EXTERNAL_PARAM_INFO_BOOL("horizontal"), + EDJE_EXTERNAL_PARAM_INFO_BOOL("inverted"), + EDJE_EXTERNAL_PARAM_INFO_INT("span"), + EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("unit format", "%1.2f"), + EDJE_EXTERNAL_PARAM_INFO_SENTINEL +}; + +DEFINE_EXTERNAL_ICON_ADD(progressbar, "progressbar") +DEFINE_EXTERNAL_TYPE_SIMPLE(progressbar, "Progressbar") diff --git a/legacy/elementary/src/edje_externals/modules.inc b/legacy/elementary/src/edje_externals/modules.inc index dcfe3663b3..16484bcb51 100644 --- a/legacy/elementary/src/edje_externals/modules.inc +++ b/legacy/elementary/src/edje_externals/modules.inc @@ -7,6 +7,7 @@ DEFINE_TYPE(clock) DEFINE_TYPE(fileselector) DEFINE_TYPE(hoversel) DEFINE_TYPE(notepad) +DEFINE_TYPE(progressbar) DEFINE_TYPE(radio) DEFINE_TYPE(scrolled_entry) DEFINE_TYPE(slider) diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index b21ce6e248..2af8ed213f 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -1057,15 +1057,22 @@ extern "C" { EAPI Evas_Object *elm_progressbar_add(Evas_Object *parent); EAPI void elm_progressbar_pulse_set(Evas_Object *obj, Eina_Bool pulse); + EAPI Eina_Bool elm_progressbar_pulse_get(const Evas_Object *obj); EAPI void elm_progressbar_pulse(Evas_Object *obj, Eina_Bool state); EAPI void elm_progressbar_value_set(Evas_Object *obj, double val); EAPI double elm_progressbar_value_get(const Evas_Object *obj); EAPI void elm_progressbar_label_set(Evas_Object *obj, const char *label); + EAPI const char *elm_progressbar_label_get(const Evas_Object *obj); EAPI void elm_progressbar_icon_set(Evas_Object *obj, Evas_Object *icon); + EAPI Evas_Object *elm_progressbar_icon_get(const Evas_Object *obj); EAPI void elm_progressbar_span_size_set(Evas_Object *obj, Evas_Coord size); + EAPI Evas_Coord elm_progressbar_span_size_get(const Evas_Object *obj); EAPI void elm_progressbar_unit_format_set(Evas_Object *obj, const char *format); + EAPI const char *elm_progressbar_unit_format_get(const Evas_Object *obj); EAPI void elm_progressbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal); + EAPI Eina_Bool elm_progressbar_horizontal_get(const Evas_Object *obj); EAPI void elm_progressbar_inverted_set(Evas_Object *obj, Eina_Bool inverted); + EAPI Eina_Bool elm_progressbar_inverted_get(const Evas_Object *obj); /* smart callbacks called: */ /* available item styles: diff --git a/legacy/elementary/src/lib/elm_progressbar.c b/legacy/elementary/src/lib/elm_progressbar.c index 5412fba970..9fd6aac68b 100644 --- a/legacy/elementary/src/lib/elm_progressbar.c +++ b/legacy/elementary/src/lib/elm_progressbar.c @@ -229,7 +229,7 @@ elm_progressbar_add(Evas_Object *parent) * @ingroup Progressbar */ EAPI void -elm_progressbar_pulse_set (Evas_Object *obj, Eina_Bool pulse) +elm_progressbar_pulse_set(Evas_Object *obj, Eina_Bool pulse) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); @@ -246,12 +246,30 @@ elm_progressbar_pulse_set (Evas_Object *obj, Eina_Bool pulse) * (the cursor pulse right to left and left to right, and loop) if pulse is set to 1. * * @param obj The progressbar object - * @param state The pulse flag. 1 == pulse, 0 == normal + * @return The pulse flag + * (1 == pulse, 0 == normal) + * + * @ingroup Progressbar + */ +EAPI Eina_Bool +elm_progressbar_pulse_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; + 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) +elm_progressbar_pulse(Evas_Object *obj, Eina_Bool state) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); @@ -274,7 +292,7 @@ elm_progressbar_pulse (Evas_Object *obj, Eina_Bool state) * @ingroup Progressbar */ EAPI void -elm_progressbar_value_set (Evas_Object *obj, double val) +elm_progressbar_value_set(Evas_Object *obj, double val) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); @@ -334,6 +352,23 @@ elm_progressbar_label_set(Evas_Object *obj, const char *label) _sizing_eval(obj); } +/** + * Get the label of the progressbar + * + * @param obj The progressbar object + * @return The text label string in UTF-8 + * + * @ingroup Progressbar + */ +EAPI const char * +elm_progressbar_label_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->label; +} + /** * Set the icon object of the progressbar object * @@ -367,6 +402,23 @@ elm_progressbar_icon_set(Evas_Object *obj, Evas_Object *icon) } } +/** + * 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; +} + /** * Set the length of the progression region of the progressbar * @@ -396,6 +448,23 @@ 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) +{ + ELM_CHECK_WIDTYPE(obj, widtype) 0; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return 0; + return wd->size; +} + /** * Set the format string of the unit area * @@ -430,6 +499,23 @@ 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) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + return wd->units; +} + /** * Set orientation of the progressbar * @@ -450,6 +536,24 @@ 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) +{ + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; + return wd->horizontal; +} + /** * Invert the progressbar display * @@ -480,3 +584,21 @@ elm_progressbar_inverted_set(Evas_Object *obj, Eina_Bool inverted) _val_set(obj); _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) +{ + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; + return wd->inverted; +}