Added get functions in elm clock and added elm clock support in edje externals. By Fidencio

Author: Fabiano Fidêncio <fidencio at profusion.mobi>

SVN revision: 47645
This commit is contained in:
Tiago Rezende Campos Falcao 2010-04-01 14:22:26 +00:00
parent 147ae448e0
commit c8823541a4
7 changed files with 300 additions and 1 deletions

View File

@ -14,6 +14,7 @@ ico_anchorview.png \
ico_bubble.png \
ico_button.png \
ico_check.png \
ico_clock.png \
ico_fileselector.png \
ico_hoversel.png \
ico_notepad.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -15,6 +15,7 @@ ICON("anchorview")
ICON("bubble")
ICON("button")
ICON("check")
ICON("clock")
ICON("fileselector")
ICON("hoversel")
ICON("notepad")

View File

@ -31,6 +31,7 @@ elm_anchorview.c \
elm_bubble.c \
elm_button.c \
elm_check.c \
elm_clock.c \
elm_fileselector.c \
elm_hoversel.c \
elm_notepad.c \

View File

@ -0,0 +1,232 @@
#include "private.h"
typedef struct _Elm_Params_Clock
{
int hrs, min, sec;
Eina_Bool hrs_exists:1;
Eina_Bool min_exists:1;
Eina_Bool sec_exists:1;
Eina_Bool edit:1;
Eina_Bool ampm:1;
Eina_Bool seconds:1;
} Elm_Params_Clock;
static void
external_clock_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
{
const Elm_Params_Clock *p;
if (to_params) p = to_params;
else if (from_params) p = from_params;
else return;
if ((p->hrs_exists) && (p->min_exists) && (p->sec_exists))
elm_clock_time_set(obj, p->hrs, p->min, p->sec);
else if ((p->hrs_exists) || (p->min_exists) || (p->sec_exists))
{
int hrs, min, sec;
elm_clock_time_get(obj, &hrs, &min, &sec);
if (p->hrs_exists)
hrs = p->hrs;
if (p->min_exists)
min = p->min;
if (p->sec_exists)
sec = p->sec;
elm_clock_time_set(obj, hrs, min, sec);
}
if (p->edit)
elm_clock_edit_set(obj, p->edit);
if (p->ampm)
elm_clock_show_am_pm_set(obj, p->ampm);
if (p->seconds)
elm_clock_show_seconds_set(obj, p->seconds);
}
static Eina_Bool
external_clock_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
{
if (!strcmp(param->name, "hours"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
{
int hrs, min, sec;
elm_clock_time_get(obj, &hrs, &min, &sec);
elm_clock_time_set(obj, param->d, min, sec);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "minutes"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
{
int hrs, min, sec;
elm_clock_time_get(obj, &hrs, &min, &sec);
elm_clock_time_set(obj, hrs, param->d, sec);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "seconds"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
{
int hrs, min, sec;
elm_clock_time_get(obj, &hrs, &min, &sec);
elm_clock_time_set(obj, hrs, min, param->d);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "editable"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
elm_clock_edit_set(obj, param->i);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "am/pm"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
elm_clock_show_am_pm_set(obj, param->i);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "show seconds"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
elm_clock_show_seconds_set(obj, param->i);
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_clock_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
{
if (!strcmp(param->name, "hours"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
{
int hrs, min, sec;
elm_clock_time_get(obj, &hrs, &min, &sec);
param->i = hrs;
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "minutes"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
{
int hrs, min, sec;
elm_clock_time_get(obj, &hrs, &min, &sec);
param->i = min;
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "seconds"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_INT)
{
int hrs, min, sec;
elm_clock_time_get(obj, &hrs, &min, &sec);
param->i = sec;
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "editable"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
param->i = elm_clock_edit_get(obj);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "am/pm"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
param->i = elm_clock_show_am_pm_get(obj);
return EINA_TRUE;
}
}
else if (!strcmp(param->name, "show seconds"))
{
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
{
param->i = elm_clock_show_seconds_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_clock_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
{
Elm_Params_Clock *mem;
Edje_External_Param *param;
const Eina_List *l;
mem = calloc(1, sizeof(Elm_Params_Clock));
if (!mem)
return NULL;
EINA_LIST_FOREACH(params, l, param)
{
if (!strcmp(param->name, "hours"))
{
mem->hrs = param->i;
mem->hrs_exists = EINA_TRUE;
}
else if (!strcmp(param->name, "minutes"))
{
mem->min = param->i;
mem->min_exists = EINA_TRUE;
}
else if (!strcmp(param->name, "seconds"))
{
mem->sec = param->i;
mem->sec_exists = EINA_TRUE;
}
else if (!strcmp(param->name, "editable"))
mem->edit = !!param->i;
else if (!strcmp(param->name, "am/pm"))
mem->ampm = !!param->i;
else if (!strcmp(param->name, "show seconds"))
mem->seconds = !!param->i;
}
return mem;
}
static void
external_clock_params_free(void *params)
{
Elm_Params_Clock *mem = params;
free(mem);
}
static Edje_External_Param_Info external_clock_params[] = {
EDJE_EXTERNAL_PARAM_INFO_INT("hours"),
EDJE_EXTERNAL_PARAM_INFO_INT("minutes"),
EDJE_EXTERNAL_PARAM_INFO_INT("seconds"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("editable"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("am/pm"),
EDJE_EXTERNAL_PARAM_INFO_BOOL("show seconds"),
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
};
DEFINE_EXTERNAL_ICON_ADD(clock, "clock")
DEFINE_EXTERNAL_TYPE_SIMPLE(clock, "Clock")

View File

@ -3,6 +3,7 @@ DEFINE_TYPE(anchorview)
DEFINE_TYPE(bubble)
DEFINE_TYPE(button)
DEFINE_TYPE(check)
DEFINE_TYPE(clock)
DEFINE_TYPE(fileselector)
DEFINE_TYPE(hoversel)
DEFINE_TYPE(notepad)

View File

@ -438,7 +438,7 @@ elm_clock_time_set(Evas_Object *obj, int hrs, int min, int sec)
/**
* Get clock time
*
* @param obj The clock object
* @param obj The clock object
* @param hrs Pointer to the variable to get the hour of this clock
* object
* @param min Pointer to the variable to get the minute of this clock
@ -482,6 +482,25 @@ elm_clock_edit_set(Evas_Object *obj, Eina_Bool edit)
_time_update(obj);
}
/**
* Get if the clock settings can be edited
*
* @param obj The clock object
* @return Bool option for edited (1 = yes, 0 = no)
*
* This function gets if the clock settings can be edited or not.
*
* @ingroup Clock
*/
EAPI Eina_Bool
elm_clock_edit_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->edit;
}
/**
* Set if the clock show hours in military or am/pm mode
*
@ -506,6 +525,29 @@ elm_clock_show_am_pm_set(Evas_Object *obj, Eina_Bool am_pm)
_time_update(obj);
}
/**
* Get if the clock show hours in military or am/pm mode
*
* @param obj The clock object
* @return Bool option for the hours mode
* (1 = am/pm, 0 = military)
*
* This function gets if the clock show hours in military or am/pm
* mode. Some countries like Brazil the military mode (00-24h-format)
* is used in opposition to the USA where the am/pm mode is more
* common used.
*
* @ingroup Clock
*/
EAPI Eina_Bool
elm_clock_show_am_pm_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->am_pm;
}
/**
* Set if the clock show hour with the seconds
*
@ -527,3 +569,24 @@ elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds)
wd->seconds = seconds;
_time_update(obj);
}
/**
* Get if the clock show hour with the seconds
*
* @param obj The clock object
* @return Bool option for the show seconds
* (1 = show seconds, 0 = not show seconds)
*
* This function gets if the clock show or not show the elapsed
* seconds.
*
* @ingroup Clock
*/
EAPI Eina_Bool
elm_clock_show_seconds_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->seconds;
}