and now add a "clicked" say... when u click.
[framework/uifw/elementary.git] / src / lib / elm_button.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 typedef struct _Widget_Data Widget_Data;
5
6 enum
7 {
8    DEFAULT = 0,
9    HIGHLIGHTED,
10    FOCUSED,
11    DISABLED,
12 };
13
14 struct _Widget_Data
15 {
16    Evas_Object *btn, *icon;
17    const char *label;
18    double ar_threshold;
19    double ar_interval;
20    Ecore_Timer *timer;
21    const char *statelabel[4];
22    int statetype[4];
23    Eina_Bool autorepeat : 1;
24    Eina_Bool repeating : 1;
25    Eina_Bool delete_me : 1;
26 };
27
28 static const char *widtype = NULL;
29 static void _del_hook(Evas_Object *obj);
30 static void _del_pre_hook(Evas_Object *obj);
31 static void _theme_hook(Evas_Object *obj);
32 static void _disable_hook(Evas_Object *obj);
33 static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
34 static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
35 static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
36 static void _sizing_eval(Evas_Object *obj);
37 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
38 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
39 static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
40 static void _signal_pressed(void *data, Evas_Object *obj, const char *emission, const char *source);
41 static void _signal_unpressed(void *data, Evas_Object *obj, const char *emission, const char *source);
42 static void _on_focus_hook(void *data, Evas_Object *obj);
43 static void _activate(Evas_Object *obj);
44 static void _activate_hook(Evas_Object *obj);
45 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
46                              Evas_Callback_Type type, void *event_info);
47
48 static void _set_label(Evas_Object *obj, const char *label);
49 static void _signal_default_text_set(void *data, Evas_Object *obj, const char *emission, const char *source);
50
51 static const char SIG_CLICKED[] = "clicked";
52 static const char SIG_REPEATED[] = "repeated";
53 static const char SIG_PRESSED[] = "pressed";
54 static const char SIG_UNPRESSED[] = "unpressed";
55 static const Evas_Smart_Cb_Description _signals[] = {
56        {SIG_CLICKED, ""},
57        {SIG_REPEATED, ""},
58        {SIG_PRESSED, ""},
59        {SIG_UNPRESSED, ""},
60        {NULL, NULL}
61 };
62
63 static Eina_Bool
64 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
65 {
66    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
67    Evas_Event_Key_Down *ev = event_info;
68    Widget_Data *wd = elm_widget_data_get(obj);
69    if (!wd) return EINA_FALSE;
70    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
71    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
72    if ((strcmp(ev->keyname, "Return")) &&
73        (strcmp(ev->keyname, "KP_Enter")) &&
74        (strcmp(ev->keyname, "space")))
75      return EINA_FALSE;
76    _activate(obj);
77    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
78    edje_object_signal_emit(wd->btn, "elm,anim,activate", "elm");
79    return EINA_TRUE;
80 }
81
82 static void
83 _del_pre_hook(Evas_Object *obj)
84 {
85    Widget_Data *wd = elm_widget_data_get(obj);
86    if (!wd) return;
87    wd->delete_me = EINA_TRUE;
88 }
89
90 static void
91 _del_hook(Evas_Object *obj)
92 {
93    Widget_Data *wd = elm_widget_data_get(obj);
94    if (!wd) return;
95    if (wd->label) eina_stringshare_del(wd->label);
96    if (wd->statelabel[DEFAULT]) eina_stringshare_del(wd->statelabel[DEFAULT]);
97    if (wd->statelabel[HIGHLIGHTED]) eina_stringshare_del(wd->statelabel[HIGHLIGHTED]);
98    if (wd->statelabel[FOCUSED]) eina_stringshare_del(wd->statelabel[FOCUSED]);
99    if (wd->statelabel[DISABLED]) eina_stringshare_del(wd->statelabel[DISABLED]);
100    free(wd);
101 }
102
103 static void
104 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
105 {
106    Widget_Data *wd = elm_widget_data_get(obj);
107    if (!wd) return;
108    if (elm_widget_focus_get(obj))
109      {
110         if (wd->statelabel[FOCUSED])
111           {
112              _set_label(obj, wd->statelabel[FOCUSED]);
113           }
114         edje_object_signal_emit(wd->btn, "elm,action,focus", "elm");
115         evas_object_focus_set(wd->btn, EINA_TRUE);
116      }
117    else
118      {
119         if (wd->statelabel[DEFAULT])
120           _set_label(obj, wd->statelabel[DEFAULT]);
121         edje_object_signal_emit(wd->btn, "elm,action,unfocus", "elm");
122         evas_object_focus_set(wd->btn, EINA_FALSE);
123      }
124 }
125
126 static void
127 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
128 {
129    Widget_Data *wd = elm_widget_data_get(obj);
130    if (!wd) return;
131    edje_object_mirrored_set(wd->btn, rtl);
132 }
133
134 static void
135 _theme_hook(Evas_Object *obj)
136 {
137    Widget_Data *wd = elm_widget_data_get(obj);
138    const char *str;
139    if (!wd) return;
140    _elm_widget_mirrored_reload(obj);
141    _mirrored_set(obj, elm_widget_mirrored_get(obj));
142    _elm_theme_object_set(obj, wd->btn, "button", "base", elm_widget_style_get(obj));
143    if (elm_object_disabled_get(obj))
144      edje_object_signal_emit(wd->btn, "elm,state,disabled", "elm");
145    if (wd->icon)
146      edje_object_part_swallow(wd->btn, "elm.swallow.content", wd->icon);
147    if (wd->label)
148      edje_object_signal_emit(wd->btn, "elm,state,text,visible", "elm");
149    else
150      edje_object_signal_emit(wd->btn, "elm,state,text,hidden", "elm");
151    if (wd->icon)
152      edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
153    else
154      edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
155    edje_object_part_text_set(wd->btn, "elm.text", wd->label);
156    edje_object_message_signal_process(wd->btn);
157    edje_object_scale_set(wd->btn, elm_widget_scale_get(obj) * _elm_config->scale);
158    str = edje_object_data_get(wd->btn, "focus_highlight");
159    if ((str) && (!strcmp(str, "on")))
160      elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
161    else
162      elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
163    _sizing_eval(obj);
164 }
165
166 static void
167 _disable_hook(Evas_Object *obj)
168 {
169    Widget_Data *wd = elm_widget_data_get(obj);
170    if (!wd) return;
171    if (elm_widget_disabled_get(obj))
172      {
173         if (wd->statelabel[DISABLED] )
174           {
175              _set_label(obj, wd->statelabel[DISABLED]);
176           }
177         edje_object_signal_emit(wd->btn, "elm,state,disabled", "elm");
178      }
179    else
180      {
181         if (wd->statelabel[DEFAULT])
182           _set_label(obj, wd->statelabel[DEFAULT]);
183         edje_object_signal_emit(wd->btn, "elm,state,enabled", "elm");
184      }
185 }
186
187 static void
188 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
189 {
190    Widget_Data *wd = elm_widget_data_get(obj);
191    if (!wd) return;
192    edje_object_signal_emit(wd->btn, emission, source);
193 }
194
195 static void
196 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
197 {
198    Widget_Data *wd = elm_widget_data_get(obj);
199    if (!wd) return;
200    edje_object_signal_callback_add(wd->btn, emission, source, func_cb, data);
201 }
202
203 static void
204 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
205 {
206    Widget_Data *wd = elm_widget_data_get(obj);
207    edje_object_signal_callback_del_full(wd->btn, emission, source, func_cb,
208                                         data);
209 }
210
211 static void
212 _content_set_hook(Evas_Object *obj, const char *part __UNUSED__, Evas_Object *content)
213 {
214    ELM_CHECK_WIDTYPE(obj, widtype);
215    Widget_Data *wd = elm_widget_data_get(obj);
216    if (!wd) return;
217    if (wd->icon == content) return;
218    if (wd->icon) evas_object_del(wd->icon);
219    wd->icon = content;
220    if (content)
221      {
222         elm_widget_sub_object_add(obj, content);
223         evas_object_event_callback_add(content,
224                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
225                                        _changed_size_hints, obj);
226         edje_object_part_swallow(wd->btn, "elm.swallow.content", content);
227         edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
228         edje_object_message_signal_process(wd->btn);
229      }
230    _sizing_eval(obj);
231 }
232
233 static Evas_Object *
234 _content_get_hook(const Evas_Object *obj, const char *part __UNUSED__)
235 {
236    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
237    Widget_Data *wd = elm_widget_data_get(obj);
238    if (!wd) return NULL;
239    return wd->icon;
240 }
241
242 static Evas_Object *
243 _content_unset_hook(Evas_Object *obj, const char *part __UNUSED__)
244 {
245    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
246    Widget_Data *wd = elm_widget_data_get(obj);
247    if (!wd) return NULL;
248    if (!wd->icon) return NULL;
249    Evas_Object *icon = wd->icon;
250    elm_widget_sub_object_del(obj, wd->icon);
251    evas_object_event_callback_del_full(wd->icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
252                                        _changed_size_hints, obj);
253    edje_object_part_unswallow(wd->btn, wd->icon);
254    wd->icon = NULL;
255    return icon;
256 }
257
258 static void
259 _sizing_eval(Evas_Object *obj)
260 {
261    Widget_Data *wd = elm_widget_data_get(obj);
262    Evas_Coord minw = -1, minh = -1;
263
264    if (!wd) return;
265    if (wd->delete_me) return;
266    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
267    edje_object_size_min_restricted_calc(wd->btn, &minw, &minh, minw, minh);
268    elm_coords_finger_size_adjust(1, &minw, 1, &minh);
269    evas_object_size_hint_min_set(obj, minw, minh);
270 }
271
272 static void
273 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
274 {
275    Widget_Data *wd = elm_widget_data_get(data);
276    if (!wd) return;
277    if (obj != wd->icon) return;
278    _sizing_eval(data);
279 }
280
281 static void
282 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
283 {
284    Widget_Data *wd = elm_widget_data_get(obj);
285    Evas_Object *sub = event_info;
286    if (!wd) return;
287    if (sub == wd->icon)
288      {
289         edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
290         evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
291                                             _changed_size_hints, obj);
292         wd->icon = NULL;
293         edje_object_message_signal_process(wd->btn);
294         _sizing_eval(obj);
295      }
296 }
297
298 static void
299 _activate(Evas_Object *obj)
300 {
301    Widget_Data *wd = elm_widget_data_get(obj);
302    if (!wd) return;
303    if (wd->timer)
304      {
305         ecore_timer_del(wd->timer);
306         wd->timer = NULL;
307      }
308    wd->repeating = EINA_FALSE;
309    _elm_access_say(E_("Clicked"));
310    evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
311 }
312
313 static void
314 _activate_hook(Evas_Object *obj)
315 {
316    _activate(obj);
317 }
318
319 static void
320 _signal_clicked(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
321 {
322    _activate(data);
323 }
324
325 static Eina_Bool
326 _autorepeat_send(void *data)
327 {
328    Widget_Data *wd = elm_widget_data_get(data);
329    if (!wd) return ECORE_CALLBACK_CANCEL;
330
331    evas_object_smart_callback_call(data, SIG_REPEATED, NULL);
332    if (!wd->repeating)
333      {
334         wd->timer = NULL;
335         return ECORE_CALLBACK_CANCEL;
336      }
337
338    return ECORE_CALLBACK_RENEW;
339 }
340
341 static Eina_Bool
342 _autorepeat_initial_send(void *data)
343 {
344    Widget_Data *wd = elm_widget_data_get(data);
345    if (!wd) return ECORE_CALLBACK_CANCEL;
346
347    if (wd->timer) ecore_timer_del(wd->timer);
348    wd->repeating = EINA_TRUE;
349    _autorepeat_send(data);
350    wd->timer = ecore_timer_add(wd->ar_interval, _autorepeat_send, data);
351
352    return ECORE_CALLBACK_CANCEL;
353 }
354
355 static void
356 _signal_pressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
357 {
358    Widget_Data *wd = elm_widget_data_get(data);
359    if (!wd) return;
360
361    if (wd->statelabel[HIGHLIGHTED])
362      {
363         _set_label(data, wd->statelabel[HIGHLIGHTED]);
364      }
365    if ((wd->autorepeat) && (!wd->repeating))
366      {
367         if (wd->ar_threshold <= 0.0)
368           _autorepeat_initial_send(data); /* call immediately */
369         else
370           wd->timer = ecore_timer_add(wd->ar_threshold, _autorepeat_initial_send, data);
371      }
372
373    evas_object_smart_callback_call(data, SIG_PRESSED, NULL);
374 }
375
376 static void
377 _signal_unpressed(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
378 {
379    Widget_Data *wd = elm_widget_data_get(data);
380    if (!wd) return;
381    if (wd->statelabel[DEFAULT])
382      _set_label(data, wd->statelabel[DEFAULT]);
383
384    if (wd->timer)
385      {
386         ecore_timer_del(wd->timer);
387         wd->timer = NULL;
388      }
389    wd->repeating = EINA_FALSE;
390    evas_object_smart_callback_call(data, SIG_UNPRESSED, NULL);
391 }
392
393 static void
394 _signal_default_text_set(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
395 {
396    Widget_Data *wd = elm_widget_data_get(data);
397    if (!wd) return;
398    if (wd->statelabel[DEFAULT])
399      _set_label(data, wd->statelabel[DEFAULT]);
400 }
401
402 static void
403 _elm_button_label_set(Evas_Object *obj, const char *item, const char *label)
404 {
405    ELM_CHECK_WIDTYPE(obj, widtype);
406    Widget_Data *wd = elm_widget_data_get(obj);
407    if (item && strcmp(item, "default")) return;
408    if (!wd) return;
409    eina_stringshare_replace(&wd->label, label);
410    if (label)
411      edje_object_signal_emit(wd->btn, "elm,state,text,visible", "elm");
412    else
413      edje_object_signal_emit(wd->btn, "elm,state,text,hidden", "elm");
414    edje_object_message_signal_process(wd->btn);
415    edje_object_part_text_set(wd->btn, "elm.text", label);
416    _sizing_eval(obj);
417 }
418
419 static const char *
420 _elm_button_label_get(const Evas_Object *obj, const char *item)
421 {
422    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
423    Widget_Data *wd = elm_widget_data_get(obj);
424    if (item && strcmp(item, "default")) return NULL;
425    if (!wd) return NULL;
426    return wd->label;
427 }
428
429 static char *
430 _access_info_cb(const void *data, Evas_Object *obj, Elm_Widget_Item *item)
431 {
432    char *txt = (char *)elm_widget_access_info_get(obj);
433    if (!txt) txt = (char *)_elm_button_label_get(obj, NULL);
434    if (txt) return strdup(txt);
435    return txt;
436 }
437
438 EAPI Evas_Object *
439 elm_button_add(Evas_Object *parent)
440 {
441    Evas_Object *obj;
442    Evas *e;
443    Widget_Data *wd;
444
445    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
446
447    ELM_SET_WIDTYPE(widtype, "button");
448    elm_widget_type_set(obj, "button");
449    elm_widget_sub_object_add(parent, obj);
450    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
451    elm_widget_data_set(obj, wd);
452    elm_widget_del_hook_set(obj, _del_hook);
453    elm_widget_del_pre_hook_set(obj, _del_pre_hook);
454    elm_widget_theme_hook_set(obj, _theme_hook);
455    elm_widget_disable_hook_set(obj, _disable_hook);
456    elm_widget_can_focus_set(obj, EINA_TRUE);
457    elm_widget_activate_hook_set(obj, _activate_hook);
458    elm_widget_event_hook_set(obj, _event_hook);
459    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
460    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
461    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
462    elm_widget_text_set_hook_set(obj, _elm_button_label_set);
463    elm_widget_text_get_hook_set(obj, _elm_button_label_get);
464    elm_widget_content_set_hook_set(obj, _content_set_hook);
465    elm_widget_content_get_hook_set(obj, _content_get_hook);
466    elm_widget_content_unset_hook_set(obj, _content_unset_hook);
467
468    wd->btn = edje_object_add(e);
469    _elm_theme_object_set(obj, wd->btn, "button", "base", "default");
470    wd->statetype[DEFAULT] = 0;
471    wd->statetype[HIGHLIGHTED] = 0;
472    wd->statetype[FOCUSED] = 0;
473    wd->statetype[DISABLED] = 0;
474    wd->statelabel[DEFAULT] = 0;
475    wd->statelabel[HIGHLIGHTED] = 0;
476    wd->statelabel[FOCUSED] = 0;
477    wd->statelabel[DISABLED] = 0;
478    edje_object_signal_callback_add(wd->btn, "elm,action,click", "",
479                                    _signal_clicked, obj);
480    edje_object_signal_callback_add(wd->btn, "elm,action,press", "",
481                                    _signal_pressed, obj);
482    edje_object_signal_callback_add(wd->btn, "elm,action,unpress", "",
483                                    _signal_unpressed, obj);
484    edje_object_signal_callback_add(wd->btn, "elm,action,default,text,set", "",
485                                    _signal_default_text_set, obj);
486    elm_widget_resize_object_set(obj, wd->btn);
487
488    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
489
490    _theme_hook(obj);
491
492    // TODO: convert Elementary to subclassing of Evas_Smart_Class
493    // TODO: and save some bytes, making descriptions per-class and not instance!
494    evas_object_smart_callbacks_descriptions_set(obj, _signals);
495    
496    _elm_access_object_register(obj, wd->btn);
497    _elm_access_text_set(_elm_access_object_get(obj),
498                         ELM_ACCESS_TYPE, E_("Button"));
499    _elm_access_callback_set(_elm_access_object_get(obj),
500                             ELM_ACCESS_INFO, _access_info_cb, obj);
501    return obj;
502 }
503
504 static void
505 _set_label(Evas_Object *obj, const char *label)
506 {
507    Widget_Data *wd = elm_widget_data_get(obj);
508
509    edje_object_part_text_set(wd->btn, "elm.text", label);
510    _sizing_eval(obj);
511 }
512
513 EAPI void
514 elm_button_label_set_for_state(Evas_Object *obj, const char *label, UIControlState state)
515 {
516    Widget_Data *wd = elm_widget_data_get(obj);
517
518    if (!wd) return;
519    if (label == NULL) return;
520
521    if (state == UIControlStateDefault)
522      {
523         wd->statetype[DEFAULT] = UIControlStateDefault;
524         eina_stringshare_replace(&wd->statelabel[DEFAULT], label);
525         return;
526      }
527    if (state == UIControlStateHighlighted)
528      {
529         wd->statetype[HIGHLIGHTED] = UIControlStateHighlighted;
530         eina_stringshare_replace(&wd->statelabel[HIGHLIGHTED], label);
531         return;
532      }
533    if (state == UIControlStateFocused)
534      {
535         wd->statetype[FOCUSED] = UIControlStateFocused;
536         eina_stringshare_replace(&wd->statelabel[FOCUSED], label);
537         return;
538      }
539    if (state == UIControlStateDisabled)
540      {
541         wd->statetype[DISABLED] = UIControlStateDisabled;
542         eina_stringshare_replace(&wd->statelabel[DISABLED], label);
543         return;
544      }
545 }
546
547 EAPI const char*
548 elm_button_label_get_for_state(const Evas_Object *obj, UIControlState state)
549 {
550    Widget_Data *wd = elm_widget_data_get(obj);
551    if (!wd) return NULL;
552
553    if (state == UIControlStateDefault)
554      return wd->statelabel[DEFAULT];
555    else if (state == UIControlStateHighlighted)
556      return wd->statelabel[HIGHLIGHTED];
557    else if (state == UIControlStateFocused)
558      return wd->statelabel[FOCUSED];
559    else if (state == UIControlStateDisabled)
560      return wd->statelabel[DISABLED];
561    else
562      return NULL;
563 }
564
565 EAPI void
566 elm_button_label_set(Evas_Object *obj, const char *label)
567 {
568    _elm_button_label_set(obj, NULL, label);
569 }
570
571 EAPI const char *
572 elm_button_label_get(const Evas_Object *obj)
573 {
574    return _elm_button_label_get(obj, NULL);
575 }
576
577
578 EAPI void
579 elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
580 {
581    _content_set_hook(obj, NULL, icon);
582 }
583
584 EAPI Evas_Object *
585 elm_button_icon_get(const Evas_Object *obj)
586 {
587    return _content_get_hook(obj, NULL);
588 }
589
590 EAPI Evas_Object *
591 elm_button_icon_unset(Evas_Object *obj)
592 {
593    return _content_unset_hook(obj, NULL);
594 }
595
596 EAPI void
597 elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on)
598 {
599    ELM_CHECK_WIDTYPE(obj, widtype);
600    Widget_Data *wd = elm_widget_data_get(obj);
601    if (!wd) return;
602    if (wd->timer)
603      {
604         ecore_timer_del(wd->timer);
605         wd->timer = NULL;
606      }
607    wd->autorepeat = on;
608    wd->repeating = EINA_FALSE;
609 }
610
611 EAPI Eina_Bool
612 elm_button_autorepeat_get(const Evas_Object *obj)
613 {
614    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
615    Widget_Data *wd = elm_widget_data_get(obj);
616    if (!wd) return EINA_FALSE;
617    return wd->autorepeat;
618 }
619
620 EAPI void
621 elm_button_autorepeat_initial_timeout_set(Evas_Object *obj, double t)
622 {
623    ELM_CHECK_WIDTYPE(obj, widtype);
624    Widget_Data *wd = elm_widget_data_get(obj);
625    if (!wd) return;
626    if (wd->ar_threshold == t) return;
627    if (wd->timer)
628      {
629         ecore_timer_del(wd->timer);
630         wd->timer = NULL;
631      }
632    wd->ar_threshold = t;
633 }
634
635 EAPI double
636 elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj)
637 {
638    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
639    Widget_Data *wd = elm_widget_data_get(obj);
640    if (!wd) return 0.0;
641    return wd->ar_threshold;
642 }
643
644 EAPI void
645 elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t)
646 {
647    ELM_CHECK_WIDTYPE(obj, widtype);
648    Widget_Data *wd = elm_widget_data_get(obj);
649    if (!wd) return;
650    if (wd->ar_interval == t) return;
651
652    wd->ar_interval = t;
653    if ((wd->repeating) && (wd->timer)) ecore_timer_interval_set(wd->timer, t);
654 }
655
656 EAPI double
657 elm_button_autorepeat_gap_timeout_get(const Evas_Object *obj)
658 {
659    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
660    Widget_Data *wd = elm_widget_data_get(obj);
661    if (!wd) return 0.0;
662    return wd->ar_interval;
663 }