2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-10-17 08:56:11 -07:00
|
|
|
#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
|
|
|
|
#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
|
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2012-05-03 15:41:42 -07:00
|
|
|
#include "elm_widget_button.h"
|
2012-11-25 22:32:53 -08:00
|
|
|
#include "elm_widget_layout.h"
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_CLASS ELM_BUTTON_CLASS
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
#define MY_CLASS_NAME "Elm_Button"
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_button"
|
2008-09-29 23:58:56 -07:00
|
|
|
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
|
|
|
static const char SIG_REPEATED[] = "repeated";
|
2011-06-30 16:43:24 -07:00
|
|
|
static const char SIG_PRESSED[] = "pressed";
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
static const char SIG_UNPRESSED[] = "unpressed";
|
2013-06-09 02:54:43 -07:00
|
|
|
|
|
|
|
/* smart callbacks coming from elm button objects (besides the ones
|
|
|
|
* coming from elm layout): */
|
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|
|
|
{SIG_CLICKED, ""},
|
|
|
|
{SIG_REPEATED, ""},
|
|
|
|
{SIG_PRESSED, ""},
|
|
|
|
{SIG_UNPRESSED, ""},
|
2014-02-05 23:18:57 -08:00
|
|
|
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
|
|
|
|
{SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
|
2013-06-09 02:54:43 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
|
|
|
{
|
|
|
|
{"icon", "elm.swallow.content"},
|
|
|
|
{NULL, NULL}
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
};
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
static const Elm_Layout_Part_Alias_Description _text_aliases[] =
|
2010-09-22 10:45:49 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
{"default", "elm.text"},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2011-09-14 02:53:11 -07:00
|
|
|
|
2014-03-31 05:28:05 -07:00
|
|
|
static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
|
2014-03-21 22:31:49 -07:00
|
|
|
|
|
|
|
static const Elm_Action key_actions[] = {
|
|
|
|
{"activate", _key_action_activate},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_activate(Evas_Object *obj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->repeating = EINA_FALSE;
|
|
|
|
|
|
|
|
if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
|
|
|
|
(_elm_access_2nd_click_timeout(obj)))
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
|
|
|
|
_elm_access_say(E_("Clicked"));
|
|
|
|
if (!elm_widget_disabled_get(obj) &&
|
|
|
|
!evas_object_freeze_events_get(obj))
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(obj, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, NULL);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
}
|
2009-08-16 04:35:55 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_button_elm_layout_sizing_eval(Eo *obj, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2013-10-05 01:13:39 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2012-05-03 15:41:42 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1;
|
2010-10-07 07:49:35 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
|
|
|
edje_object_size_min_restricted_calc
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, &minw, &minh, minw, minh);
|
2012-05-03 15:41:42 -07:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_button_elm_widget_activate(Eo *obj, Elm_Button_Data *_pd EINA_UNUSED, Elm_Activate act)
|
2012-09-03 01:49:45 -07:00
|
|
|
{
|
2014-03-19 23:40:43 -07:00
|
|
|
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
|
|
|
|
if (act != ELM_ACTIVATE_DEFAULT) return EINA_FALSE;
|
|
|
|
if (evas_object_freeze_events_get(obj)) return EINA_FALSE;
|
2012-09-16 20:01:46 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(obj, EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, NULL);
|
2013-11-08 04:49:52 -08:00
|
|
|
elm_layout_signal_emit(obj, "elm,anim,activate", "elm");
|
2012-09-16 20:01:46 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_TRUE;
|
2012-09-03 01:49:45 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
/* FIXME: replicated from elm_layout just because button's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_icon_signal_emit(Evas_Object *obj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
char buf[64];
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
snprintf(buf, sizeof(buf), "elm,state,icon,%s",
|
|
|
|
elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
elm_layout_signal_emit(obj, buf, "elm");
|
2012-07-12 04:11:21 -07:00
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(obj));
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_layout_sizing_eval(obj);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
/* FIXME: replicated from elm_layout just because button's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_button_elm_widget_theme_apply(Eo *obj, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
2013-02-20 21:57:05 -08:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
|
2014-03-19 23:40:43 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2012-05-03 15:41:42 -07:00
|
|
|
_icon_signal_emit(obj);
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
/* FIXME: replicated from elm_layout just because button's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_button_elm_widget_sub_object_del(Eo *obj, Elm_Button_Data *_pd EINA_UNUSED, Evas_Object *sobj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
int_ret = elm_obj_widget_sub_object_del(eo_super(obj, MY_CLASS), sobj);
|
2014-03-19 23:40:43 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2011-10-24 18:23:25 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
_icon_signal_emit(obj);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_TRUE;
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
/* FIXME: replicated from elm_layout just because button's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2016-04-19 22:55:26 -07:00
|
|
|
_elm_button_efl_container_content_set(Eo *obj, Elm_Button_Data *_pd EINA_UNUSED, const char *part, Evas_Object *content)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
|
2016-04-19 22:55:26 -07:00
|
|
|
int_ret = efl_content_set(eo_super(obj, MY_CLASS), part, content);
|
2014-03-19 23:40:43 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2008-10-06 23:55:11 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
_icon_signal_emit(obj);
|
2012-05-02 09:58:26 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2010-09-22 10:45:43 -07:00
|
|
|
|
2014-03-31 05:28:05 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
|
2014-03-21 22:31:49 -07:00
|
|
|
{
|
|
|
|
elm_layout_signal_emit(obj, "elm,anim,activate", "elm");
|
|
|
|
_activate(obj);
|
2014-03-31 05:28:05 -07:00
|
|
|
return EINA_TRUE;
|
2014-03-21 22:31:49 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_button_elm_widget_event(Eo *obj, Elm_Button_Data *_pd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2013-10-28 07:06:14 -07:00
|
|
|
(void) src;
|
2014-03-19 23:40:43 -07:00
|
|
|
Evas_Event_Key_Down *ev = event_info;
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2015-12-21 04:55:23 -08:00
|
|
|
if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions))
|
2014-03-22 00:25:34 -07:00
|
|
|
return EINA_FALSE;
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2013-11-12 16:54:37 -08:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_TRUE;
|
2010-09-22 10:45:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_clicked_signal(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-09-22 10:45:43 -07:00
|
|
|
{
|
|
|
|
_activate(data);
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2010-01-23 17:53:37 -08:00
|
|
|
_autorepeat_send(void *data)
|
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN_VAL(data, sd, ECORE_CALLBACK_CANCEL);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(data, EVAS_CLICKABLE_INTERFACE_EVENT_REPEATED, NULL);
|
2012-05-03 15:41:42 -07:00
|
|
|
if (!sd->repeating)
|
2010-04-08 08:15:22 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->timer = NULL;
|
2011-02-27 14:59:12 -08:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2010-04-08 08:15:22 -07:00
|
|
|
}
|
2010-01-23 17:53:37 -08:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2010-01-23 17:53:37 -08:00
|
|
|
_autorepeat_initial_send(void *data)
|
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN_VAL(data, sd, ECORE_CALLBACK_CANCEL);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->repeating = EINA_TRUE;
|
2010-01-23 17:53:37 -08:00
|
|
|
_autorepeat_send(data);
|
2014-04-12 20:43:41 -07:00
|
|
|
sd->timer = ecore_timer_add(sd->ar_gap_timeout, _autorepeat_send, data);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_pressed_signal(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(data, sd);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
if ((sd->autorepeat) && (!sd->repeating))
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2014-04-12 20:43:41 -07:00
|
|
|
if (sd->ar_initial_timeout <= 0.0)
|
2012-05-03 15:41:42 -07:00
|
|
|
_autorepeat_initial_send(data); /* call immediately */
|
2011-02-27 14:59:12 -08:00
|
|
|
else
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->timer = ecore_timer_add
|
2014-04-12 20:43:41 -07:00
|
|
|
(sd->ar_initial_timeout, _autorepeat_initial_send, data);
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
2011-06-30 16:43:24 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(data, EVAS_CLICKABLE_INTERFACE_EVENT_PRESSED, NULL);
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_unpressed_signal(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(data, sd);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->repeating = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
eo_event_callback_call
|
|
|
|
(data, EVAS_CLICKABLE_INTERFACE_EVENT_UNPRESSED, NULL);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2011-08-19 04:07:42 -07:00
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2011-08-19 04:07:42 -07:00
|
|
|
{
|
2011-08-25 19:02:15 -07:00
|
|
|
const char *txt = elm_widget_access_info_get(obj);
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
if (!txt) txt = elm_layout_text_get(obj, NULL);
|
2011-08-19 04:07:42 -07:00
|
|
|
if (txt) return strdup(txt);
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2011-08-25 19:02:15 -07:00
|
|
|
return NULL;
|
2011-08-19 04:07:42 -07:00
|
|
|
}
|
|
|
|
|
2011-08-19 04:20:45 -07:00
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2011-08-19 04:20:45 -07:00
|
|
|
{
|
|
|
|
if (elm_widget_disabled_get(obj))
|
2011-08-25 19:02:15 -07:00
|
|
|
return strdup(E_("State: Disabled"));
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2011-08-19 04:20:45 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:35:28 -07:00
|
|
|
_elm_button_evas_object_smart_add(Eo *obj, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-05-03 15:41:42 -07:00
|
|
|
{
|
2013-10-05 01:13:39 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
evas_obj_smart_add(eo_super(obj, MY_CLASS));
|
2013-09-24 21:33:39 -07:00
|
|
|
elm_widget_sub_object_parent_add(obj);
|
2013-02-20 21:57:05 -08:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
edje_object_signal_callback_add
|
2013-10-05 05:35:27 -07:00
|
|
|
(wd->resize_obj, "elm,action,click", "*",
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_clicked_signal, obj);
|
|
|
|
edje_object_signal_callback_add
|
2013-10-05 05:35:27 -07:00
|
|
|
(wd->resize_obj, "elm,action,press", "*",
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_pressed_signal, obj);
|
|
|
|
edje_object_signal_callback_add
|
2013-10-05 05:35:27 -07:00
|
|
|
(wd->resize_obj, "elm,action,unpress", "*",
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_unpressed_signal, obj);
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
_elm_access_object_register(obj, wd->resize_obj);
|
2012-05-03 15:41:42 -07:00
|
|
|
_elm_access_text_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("Button"));
|
2012-05-03 15:41:42 -07:00
|
|
|
_elm_access_callback_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
|
2012-05-03 15:41:42 -07:00
|
|
|
_elm_access_callback_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, obj);
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
2013-03-01 18:04:31 -08:00
|
|
|
if (!elm_layout_theme_set(obj, "button", "base", elm_widget_style_get(obj)))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2012-05-03 15:41:42 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static const Elm_Layout_Part_Alias_Description*
|
|
|
|
_elm_button_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-05-03 15:41:42 -07:00
|
|
|
{
|
2014-03-19 23:40:43 -07:00
|
|
|
return _content_aliases;
|
2012-05-03 15:41:42 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static const Elm_Layout_Part_Alias_Description*
|
|
|
|
_elm_button_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-05-03 15:41:42 -07:00
|
|
|
{
|
2014-03-19 23:40:43 -07:00
|
|
|
return _text_aliases;
|
2012-05-03 15:41:42 -07:00
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_button_add(Evas_Object *parent)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
2016-03-11 04:34:16 -08:00
|
|
|
Evas_Object *obj = eo_add(MY_CLASS, parent);
|
2012-11-25 22:32:53 -08:00
|
|
|
return obj;
|
|
|
|
}
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2014-03-19 23:40:43 -07:00
|
|
|
_elm_button_eo_base_constructor(Eo *obj, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2016-03-02 04:10:48 -08:00
|
|
|
obj = eo_constructor(eo_super(obj, MY_CLASS));
|
|
|
|
evas_obj_type_set(obj, MY_CLASS_NAME_LEGACY);
|
|
|
|
evas_obj_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
|
|
|
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_PUSH_BUTTON);
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_button_autorepeat_set(Eo *obj EINA_UNUSED, Elm_Button_Data *sd, Eina_Bool on)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->autorepeat = on;
|
|
|
|
sd->repeating = EINA_FALSE;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
#define _AR_CAPABLE(obj) \
|
2014-03-19 23:40:43 -07:00
|
|
|
(_internal_elm_button_admits_autorepeat_get(obj))
|
2012-11-25 22:32:53 -08:00
|
|
|
|
|
|
|
static Eina_Bool
|
2014-03-19 23:40:43 -07:00
|
|
|
_internal_elm_button_admits_autorepeat_get(const Evas_Object *obj)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2016-03-02 04:10:48 -08:00
|
|
|
ret = elm_obj_button_admits_autorepeat_get((Eo *) obj);
|
2012-11-25 22:32:53 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_button_admits_autorepeat_get(Eo *obj EINA_UNUSED, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_TRUE;
|
2010-10-27 07:38:45 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_button_autorepeat_get(Eo *obj, Elm_Button_Data *sd)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2014-03-19 23:40:43 -07:00
|
|
|
return (_AR_CAPABLE(obj) & sd->autorepeat);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_button_autorepeat_initial_timeout_set(Eo *obj, Elm_Button_Data *sd, double t)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
|
|
|
if (!_AR_CAPABLE(obj))
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ERR("this widget does not support auto repetition of clicks.");
|
|
|
|
return;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2014-04-12 20:43:41 -07:00
|
|
|
if (sd->ar_initial_timeout == t) return;
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2014-04-12 20:43:41 -07:00
|
|
|
sd->ar_initial_timeout = t;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static double
|
|
|
|
_elm_button_autorepeat_initial_timeout_get(Eo *obj, Elm_Button_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
|
|
|
if (!_AR_CAPABLE(obj))
|
2014-03-19 23:40:43 -07:00
|
|
|
return 0.0;
|
2012-11-25 22:32:53 -08:00
|
|
|
else
|
2014-04-12 20:43:41 -07:00
|
|
|
return sd->ar_initial_timeout;
|
2010-10-27 07:38:45 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_button_autorepeat_gap_timeout_set(Eo *obj, Elm_Button_Data *sd, double t)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
if (!_AR_CAPABLE(obj))
|
2012-05-03 15:41:42 -07:00
|
|
|
{
|
|
|
|
ERR("this widget does not support auto repetition of clicks.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-12 20:43:41 -07:00
|
|
|
if (sd->ar_gap_timeout == t) return;
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2014-04-12 20:43:41 -07:00
|
|
|
sd->ar_gap_timeout = t;
|
2012-05-03 15:41:42 -07:00
|
|
|
if ((sd->repeating) && (sd->timer)) ecore_timer_interval_set(sd->timer, t);
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
2010-10-27 07:38:45 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static double
|
|
|
|
_elm_button_autorepeat_gap_timeout_get(Eo *obj EINA_UNUSED, Elm_Button_Data *sd)
|
2010-10-27 07:38:45 -07:00
|
|
|
{
|
2014-04-12 20:43:41 -07:00
|
|
|
return sd->ar_gap_timeout;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_button_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_FALSE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_button_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Button_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_FALSE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-07-25 01:33:19 -07:00
|
|
|
EOLIAN const Elm_Atspi_Action *
|
2014-04-20 23:04:25 -07:00
|
|
|
_elm_button_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Button_Data *pd EINA_UNUSED)
|
|
|
|
{
|
2014-07-25 01:33:19 -07:00
|
|
|
static Elm_Atspi_Action atspi_actions[] = {
|
|
|
|
{ "activate", "activate", NULL, _key_action_activate },
|
|
|
|
{ NULL, NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
return &atspi_actions[0];
|
2014-04-20 23:04:25 -07:00
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
static void
|
2014-03-19 23:40:43 -07:00
|
|
|
_elm_button_class_constructor(Eo_Class *klass)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
#include "elm_button.eo.c"
|