1 #ifndef ELM_WIDGET_SPINNER_H
2 #define ELM_WIDGET_SPINNER_H
3 
4 #include "Elementary.h"
5 
6 #include <Eio.h>
7 
8 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
9  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
10  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
11  * IT AT RUNTIME.
12  */
13 
14 /**
15  * @addtogroup Widget
16  * @{
17  *
18  * @section elm-spinner-class The Elementary Spinner Class
19  *
20  * Elementary, besides having the @ref Spinner widget, exposes its
21  * foundation -- the Elementary Spinner Class -- in order to create other
22  * widgets which are a spinner with some more logic on top.
23  */
24 
25 /**
26  * Base layout smart data extended with spinner instance data.
27  */
28 
29 typedef enum _Elm_Spinner_Format_Type
30 {
31    SPINNER_FORMAT_FLOAT,
32    SPINNER_FORMAT_INT,
33    SPINNER_FORMAT_INVALID
34 } Elm_Spinner_Format_Type;
35 
36 typedef struct _Elm_Spinner_Data    Elm_Spinner_Data;
37 struct _Elm_Spinner_Data
38 {
39    Evas_Object          *ent, *inc_button, *dec_button, *text_button;
40    const char           *label;
41    double                val, val_min, val_max, val_base;
42    double                step; /**< step for the value change. 1 by default. */
43    double                drag_prev_pos, drag_val_step;
44    double                spin_speed, interval, first_interval;
45    int                   round;
46    int                   decimal_points;
47    Ecore_Timer          *delay_change_timer; /**< a timer for a delay,changed smart callback */
48    Ecore_Timer          *spin_timer; /**< a timer for a repeated spinner value change on mouse down */
49    Ecore_Timer          *longpress_timer; /**< a timer to detect long press. After longpress timeout,
50                                           start continuous change of values until mouse up */
51    Eina_List            *special_values;
52    Elm_Spinner_Format_Type format_type;
53 
54    Eina_Bool             entry_visible : 1;
55    Eina_Bool             entry_reactivate : 1;
56    Eina_Bool             dragging : 1;
57    Eina_Bool             editable : 1;
58    Eina_Bool             wrap : 1;
59    Eina_Bool             val_updated : 1;
60    Eina_Bool             button_layout : 1;
61    Eina_Bool             inc_btn_activated : 1;
62 };
63 
64 typedef struct _Elm_Spinner_Special_Value Elm_Spinner_Special_Value;
65 struct _Elm_Spinner_Special_Value
66 {
67    double      value;
68    const char *label;
69 };
70 
71 /**
72  * @}
73  */
74 
75 #define ELM_SPINNER_DATA_GET(o, sd) \
76   Elm_Spinner_Data * sd = efl_data_scope_get(o, ELM_SPINNER_CLASS)
77 
78 #define ELM_SPINNER_DATA_GET_OR_RETURN(o, ptr)       \
79   ELM_SPINNER_DATA_GET(o, ptr);                      \
80   if (EINA_UNLIKELY(!ptr))                           \
81     {                                                \
82        ERR("No widget data for object %p (%s)",      \
83            o, evas_object_type_get(o));              \
84        return;                                       \
85     }
86 
87 #define ELM_SPINNER_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
88   ELM_SPINNER_DATA_GET(o, ptr);                         \
89   if (EINA_UNLIKELY(!ptr))                              \
90     {                                                   \
91        ERR("No widget data for object %p (%s)",         \
92            o, evas_object_type_get(o));                 \
93        return val;                                      \
94     }
95 
96 #define ELM_SPINNER_CHECK(obj)                              \
97   if (EINA_UNLIKELY(!efl_isa((obj), ELM_SPINNER_CLASS))) \
98     return
99 
100 #endif
101