#include <Elementary.h>
#include "elm_priv.h"
-/**
- * @defgroup Clock Clock
- *
- * It's a widget to show clock with animation. The update of time is
- * shown in an animation like the flip of a sheet.
- *
- */
-
+#define DEFAULT_FIRST_INTERVAL 0.85
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
Eina_Bool seconds : 1;
Eina_Bool am_pm : 1;
Eina_Bool edit : 1;
- Elm_Clock_Digedit digedit;
+ Elm_Clock_Edit_Mode digedit;
int hrs, min, sec, timediff;
Evas_Object *digit[6];
Evas_Object *ampm;
Evas_Object *sel_obj;
Ecore_Timer *ticker, *spin;
struct
- {
- int hrs, min, sec;
- char ampm;
- Eina_Bool seconds : 1;
- Eina_Bool am_pm : 1;
- Eina_Bool edit : 1;
- Elm_Clock_Digedit digedit;
- } cur;
+ {
+ int hrs, min, sec;
+ char ampm;
+ Eina_Bool seconds : 1;
+ Eina_Bool am_pm : 1;
+ Eina_Bool edit : 1;
+ Elm_Clock_Edit_Mode digedit;
+ } cur;
};
static const char *widtype = NULL;
static Eina_Bool _signal_clock_val_down(void *data);
static void _time_update(Evas_Object *obj);
+static const char SIG_CHANGED[] = "changed";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+ {SIG_CHANGED, ""},
+ {NULL, NULL}
+};
+
+
static void
_del_hook(Evas_Object *obj)
{
}
static void
-_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
+_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
{
Widget_Data *wd = elm_widget_data_get(obj);
int i;
}
static void
-_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
+_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
{
Widget_Data *wd = elm_widget_data_get(obj);
int i;
wd->interval = wd->interval / 1.05;
ecore_timer_interval_set(wd->spin, wd->interval);
_time_update(data);
- evas_object_smart_callback_call(data, "changed", NULL);
+ evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
return ECORE_CALLBACK_RENEW;
clock_val_up_cancel:
wd->spin = NULL;
wd->interval = wd->interval / 1.05;
ecore_timer_interval_set(wd->spin, wd->interval);
_time_update(data);
- evas_object_smart_callback_call(data, "changed", NULL);
+ evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
return ECORE_CALLBACK_RENEW;
clock_val_down_cancel:
wd->spin = NULL;
wd->cur.ampm = -1;
}
-/**
- * Add a new clock to the parent
- *
- * @param parent The parent object
- *
- * This function inserts a clock widget on a given canvas to show a
- * animated clock.
- *
- * @ingroup Clock
- */
EAPI Evas_Object *
elm_clock_add(Evas_Object *parent)
{
wd->cur.seconds = EINA_TRUE;
wd->cur.am_pm = EINA_TRUE;
wd->cur.edit = EINA_TRUE;
- wd->cur.digedit = ELM_CLOCK_NONE;
- wd->first_interval = 0.85;
+ wd->cur.digedit = ELM_CLOCK_EDIT_DEFAULT;
+ wd->first_interval = DEFAULT_FIRST_INTERVAL;
wd->timediff = 0;
_time_update(obj);
_ticker(obj);
+ evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
return obj;
}
-/**
- * Set the clock time
- *
- * @param obj The clock object
- * @param hrs The hours to set
- * @param min The minutes to set
- * @param sec The secondes to set
- *
- * This function updates the time that is showed by the clock widget
- *
- * @ingroup Clock
- */
EAPI void
elm_clock_time_set(Evas_Object *obj, int hrs, int min, int sec)
{
_time_update(obj);
}
-/**
- * Get clock time
- *
- * @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
- * object
- * @param sec Pointer to the variable to get the second of this clock
- * object
- *
- * This function gets the time set of the clock widget and returns it
- * on the variables passed as the arguments to function
- *
- * @ingroup Clock
- */
EAPI void
elm_clock_time_get(const Evas_Object *obj, int *hrs, int *min, int *sec)
{
if (sec) *sec = wd->sec;
}
-/**
- * Set if the clock settings can be edited
- *
- * @param obj The clock object
- * @param edit Bool option for edited (1 = yes, 0 = no)
- *
- * This function sets if the clock settings can be edited or not.
- * By default or if digit_edit option was previously set to ELM_CLOCK_NONE,
- * all digits are editable. To choose what digits to make editable
- * use elm_clock_digit_edit_set().
- *
- * @ingroup Clock
- */
EAPI void
elm_clock_edit_set(Evas_Object *obj, Eina_Bool edit)
{
wd->edit = edit;
if (!edit)
_timediff_set(wd);
- if ((edit) && (wd->digedit == ELM_CLOCK_NONE))
- elm_clock_digit_edit_set(obj, ELM_CLOCK_ALL);
+ if ((edit) && (wd->digedit == ELM_CLOCK_EDIT_DEFAULT))
+ elm_clock_edit_mode_set(obj, ELM_CLOCK_EDIT_ALL);
else
_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)
{
return wd->edit;
}
-/**
- * Set what digits of the clock are editable
- *
- * @param obj The clock object
- * @param digedit Bit mask indicating the digits to edit
- *
- * If the digedit param is ELM_CLOCK_NONE, editing will be disabled.
- *
- * @ingroup Clock
- */
EAPI void
-elm_clock_digit_edit_set(Evas_Object *obj, Elm_Clock_Digedit digedit)
+elm_clock_edit_mode_set(Evas_Object *obj, Elm_Clock_Edit_Mode digedit)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->digedit = digedit;
- if (digedit == ELM_CLOCK_NONE)
+ if (digedit == ELM_CLOCK_EDIT_DEFAULT)
elm_clock_edit_set(obj, EINA_FALSE);
else
_time_update(obj);
}
-/**
- * Get what digits of the clock are editable
- *
- * @param obj The clock object
- * @return Bit mask indicating the digits.
- *
- * @ingroup Clock
- */
-EAPI Elm_Clock_Digedit
-elm_clock_digit_edit_get(const Evas_Object *obj)
+EAPI Elm_Clock_Edit_Mode
+elm_clock_edit_mode_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) 0;
Widget_Data *wd = elm_widget_data_get(obj);
return wd->digedit;
}
-/**
- * Set if the clock shows hours in military or am/pm mode
- *
- * @param obj The clock object
- * @param am_pm Bool option for the hours mode
- * (1 = am/pm, 0 = military)
- *
- * This function sets the clock to 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 void
elm_clock_show_am_pm_set(Evas_Object *obj, Eina_Bool am_pm)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- wd->am_pm = am_pm;
+ wd->am_pm = !!am_pm;
_time_update(obj);
}
-/**
- * Get if the clock shows 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)
{
return wd->am_pm;
}
-/**
- * Set if the clock shows hour with the seconds
- *
- * @param obj The clock object
- * @param seconds Bool option for the show seconds
- * (1 = show seconds, 0 = not show seconds)
- *
- * This function sets the clock to show or not to show the elapsed
- * seconds.
- *
- * @ingroup Clock
- */
EAPI void
elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- wd->seconds = seconds;
+ wd->seconds = !!seconds;
_time_update(obj);
}
-/**
- * Get if the clock shows 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)
{
return wd->seconds;
}
-/**
- * Set the interval for the clock
- *
- * @param obj The clock object
- * @param interval The interval value in seconds
- *
- * The interval value is decreased while the user increments or decrements
- * the clock value. The next interval value is the previous interval / 1.05,
- * so it speed up a bit. Default value is 0.85 seconds.
- *
- * @ingroup Clock
- */
EAPI void
-elm_clock_interval_set(Evas_Object *obj, double interval)
+elm_clock_first_interval_set(Evas_Object *obj, double interval)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- wd->first_interval = interval;
+ wd->first_interval = !!interval;
}
-/**
- * Get the interval of the clock
- *
- * @param obj The clock object
- * @return The value of the first interval in seconds
- *
- * The interval value is decreased while the user increments or decrements
- * the clock value. The next interval value is the previous interval / 1.05,
- * so it speed up a bit. Default value is 0.85 seconds.
- *
- * @ingroup Clock
- */
EAPI double
-elm_clock_interval_get(const Evas_Object *obj)
+elm_clock_first_interval_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
Widget_Data *wd = elm_widget_data_get(obj);