1 #ifndef ELM_WIDGET_BUTTON_H
2 #define ELM_WIDGET_BUTTON_H
4 #include "elm_widget_layout.h"
10 * @section elm-button-class The Elementary Button Class
12 * Elementary, besides having the @ref Button widget, exposes its
13 * foundation -- the Elementary Button Class -- in order to create
14 * other widgets which are, basically, a button with some more logic
19 * @def ELM_BUTTON_CLASS
21 * Use this macro to cast whichever subclass of
22 * #Elm_Button_Smart_Class into it, so to access its fields.
26 #define ELM_BUTTON_CLASS(x) ((Elm_Button_Smart_Class *)x)
29 * @def ELM_BUTTON_DATA
31 * Use this macro to cast whichever subdata of
32 * #Elm_Button_Smart_Data into it, so to access its fields.
36 #define ELM_BUTTON_DATA(x) ((Elm_Button_Smart_Data *)x)
39 * @def ELM_BUTTON_SMART_CLASS_VERSION
41 * Current version for Elementary button @b base smart class, a value
42 * which goes to _Elm_Button_Smart_Class::version.
46 #define ELM_BUTTON_SMART_CLASS_VERSION 1
49 * @def ELM_BUTTON_SMART_CLASS_INIT
51 * Initializer for a whole #Elm_Button_Smart_Class structure, with
52 * @c NULL values on its specific fields.
54 * @param smart_class_init initializer to use for the "base" field
55 * (#Evas_Smart_Class).
57 * @see EVAS_SMART_CLASS_INIT_NULL
58 * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
59 * @see ELM_BUTTON_SMART_CLASS_INIT_NULL
60 * @see ELM_BUTTON_SMART_CLASS_INIT_NAME_VERSION
64 #define ELM_BUTTON_SMART_CLASS_INIT(smart_class_init) \
65 {smart_class_init, ELM_BUTTON_SMART_CLASS_VERSION, EINA_TRUE}
68 * @def ELM_BUTTON_SMART_CLASS_INIT_NULL
70 * Initializer to zero out a whole #Elm_Button_Smart_Class structure.
72 * @see ELM_BUTTON_SMART_CLASS_INIT_NAME_VERSION
73 * @see ELM_BUTTON_SMART_CLASS_INIT
77 #define ELM_BUTTON_SMART_CLASS_INIT_NULL \
78 ELM_BUTTON_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
81 * @def ELM_BUTTON_SMART_CLASS_INIT_NAME_VERSION
83 * Initializer to zero out a whole #Elm_Button_Smart_Class structure and
84 * set its name and version.
86 * This is similar to #ELM_BUTTON_SMART_CLASS_INIT_NULL, but it will
87 * also set the version field of #Elm_Button_Smart_Class (base field)
88 * to the latest #ELM_BUTTON_SMART_CLASS_VERSION and name it to the
91 * It will keep a reference to the name field as a <c>"const char *"</c>,
92 * i.e., the name must be available while the structure is
93 * used (hint: static or global variable!) and must not be modified.
95 * @see ELM_BUTTON_SMART_CLASS_INIT_NULL
96 * @see ELM_BUTTON_SMART_CLASS_INIT
100 #define ELM_BUTTON_SMART_CLASS_INIT_NAME_VERSION(name) \
101 ELM_BUTTON_SMART_CLASS_INIT(ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
104 * Elementary button base smart class. This inherits directly from
105 * #Elm_Layout_Smart_Class and is meant to build widgets extending the
106 * behavior of a button.
108 * All of the functions listed on @ref Button namespace will work for
109 * objects deriving from #Elm_Button_Smart_Class.
111 typedef struct _Elm_Button_Smart_Class
113 Elm_Layout_Smart_Class base; /**< Layout widget class struct, since we're inheriting from it */
115 int version; /**< Version of this smart class definition */
117 Eina_Bool admits_autorepeat : 1; /**< Whether the button objects of this class admit auto-repetition of click events, when one holds the click on them. This is true by default. */
118 } Elm_Button_Smart_Class;
121 * Base widget smart data extended with button instance data.
123 typedef struct _Elm_Button_Smart_Data
125 Elm_Layout_Smart_Data base; /**< Base widget smart data as first member obligatory, as we're inheriting from it */
127 /* auto-repeat stuff */
128 double ar_threshold; /**< Time to wait until first auto-repeated click is generated */
129 double ar_interval; /**< Time frame for subsequent auto-repeated clicks, after the first automatic one is triggerred */
131 Ecore_Timer *timer; /**< Internal timer object for auto-repeat behavior */
133 Eina_Bool autorepeat : 1; /**< Whether auto-repetition of clicks is enabled or not (bound to _Elm_Button_Smart_Class::admits_autorepeat) */
134 Eina_Bool repeating : 1; /**< Whether auto-repetition is going on */
135 } Elm_Button_Smart_Data;
141 EAPI const Elm_Button_Smart_Class *elm_button_smart_class_get(void);
143 #define ELM_BUTTON_DATA_GET(o, sd) \
144 Elm_Button_Smart_Data * sd = evas_object_smart_data_get(o)
146 #define ELM_BUTTON_DATA_GET_OR_RETURN(o, ptr) \
147 ELM_BUTTON_DATA_GET(o, ptr); \
150 CRITICAL("No widget data for object %p (%s)", \
151 o, evas_object_type_get(o)); \
155 #define ELM_BUTTON_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
156 ELM_BUTTON_DATA_GET(o, ptr); \
159 CRITICAL("No widget data for object %p (%s)", \
160 o, evas_object_type_get(o)); \
164 #define ELM_BUTTON_CHECK(obj) \
165 if (!obj || !elm_widget_type_check \
166 ((obj), ELM_BUTTON_SMART_NAME, __func__)) \