tizen 2.3.1 release
[framework/uifw/elementary.git] / src / lib / elm_widget_progressbar.h
1 #ifndef ELM_WIDGET_PROGRESSBAR_H
2 #define ELM_WIDGET_PROGRESSBAR_H
3
4 #include "elm_widget_layout.h"
5
6 /**
7  * @internal
8  * @addtogroup Widget
9  * @{
10  *
11  * @section elm-progressbar-class The Elementary Progressbar Class
12  *
13  * Elementary, besides having the @ref Progressbar widget, exposes its
14  * foundation -- the Elementary Progressbar Class -- in order to create other
15  * widgets which are a progressbar with some more logic on top.
16  */
17
18 /**
19  * @def ELM_PROGRESSBAR_CLASS
20  *
21  * Use this macro to cast whichever subclass of
22  * #Elm_Progressbar_Smart_Class into it, so to access its fields.
23  *
24  * @ingroup Widget
25  */
26 #define ELM_PROGRESSBAR_CLASS(x) ((Elm_Progressbar_Smart_Class *)x)
27
28 /**
29  * @def ELM_PROGRESSBAR_DATA
30  *
31  * Use this macro to cast whichever subdata of
32  * #Elm_Progressbar_Smart_Data into it, so to access its fields.
33  *
34  * @ingroup Widget
35  */
36 #define ELM_PROGRESSBAR_DATA(x)  ((Elm_Progressbar_Smart_Data *)x)
37
38 /**
39  * @def ELM_PROGRESSBAR_SMART_CLASS_VERSION
40  *
41  * Current version for Elementary progressbar @b base smart class, a value
42  * which goes to _Elm_Progressbar_Smart_Class::version.
43  *
44  * @ingroup Widget
45  */
46 #define ELM_PROGRESSBAR_SMART_CLASS_VERSION 1
47
48 /**
49  * @def ELM_PROGRESSBAR_SMART_CLASS_INIT
50  *
51  * Initializer for a whole #Elm_Progressbar_Smart_Class structure, with
52  * @c NULL values on its specific fields.
53  *
54  * @param smart_class_init initializer to use for the "base" field
55  * (#Evas_Smart_Class).
56  *
57  * @see EVAS_SMART_CLASS_INIT_NULL
58  * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
59  * @see ELM_PROGRESSBAR_SMART_CLASS_INIT_NULL
60  * @see ELM_PROGRESSBAR_SMART_CLASS_INIT_NAME_VERSION
61  *
62  * @ingroup Widget
63  */
64 #define ELM_PROGRESSBAR_SMART_CLASS_INIT(smart_class_init) \
65   {smart_class_init, ELM_PROGRESSBAR_SMART_CLASS_VERSION}
66
67 /**
68  * @def ELM_PROGRESSBAR_SMART_CLASS_INIT_NULL
69  *
70  * Initializer to zero out a whole #Elm_Progressbar_Smart_Class structure.
71  *
72  * @see ELM_PROGRESSBAR_SMART_CLASS_INIT_NAME_VERSION
73  * @see ELM_PROGRESSBAR_SMART_CLASS_INIT
74  *
75  * @ingroup Widget
76  */
77 #define ELM_PROGRESSBAR_SMART_CLASS_INIT_NULL \
78   ELM_PROGRESSBAR_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
79
80 /**
81  * @def ELM_PROGRESSBAR_SMART_CLASS_INIT_NAME_VERSION
82  *
83  * Initializer to zero out a whole #Elm_Progressbar_Smart_Class structure and
84  * set its name and version.
85  *
86  * This is similar to #ELM_PROGRESSBAR_SMART_CLASS_INIT_NULL, but it will
87  * also set the version field of #Elm_Progressbar_Smart_Class (base field)
88  * to the latest #ELM_PROGRESSBAR_SMART_CLASS_VERSION and name it to the
89  * specific value.
90  *
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.
94  *
95  * @see ELM_PROGRESSBAR_SMART_CLASS_INIT_NULL
96  * @see ELM_PROGRESSBAR_SMART_CLASS_INIT
97  *
98  * @ingroup Widget
99  */
100 #define ELM_PROGRESSBAR_SMART_CLASS_INIT_NAME_VERSION(name) \
101   ELM_PROGRESSBAR_SMART_CLASS_INIT                          \
102     (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
103
104 /**
105  * Elementary progressbar base smart class. This inherits directly from
106  * #Elm_Layout_Smart_Class and is meant to build widgets extending the
107  * behavior of a progressbar.
108  *
109  * All of the functions listed on @ref Progressbar namespace will work for
110  * objects deriving from #Elm_Progressbar_Smart_Class.
111  */
112 typedef struct _Elm_Progressbar_Smart_Class
113 {
114    Elm_Layout_Smart_Class base;
115
116    int                    version;    /**< Version of this smart class definition */
117 } Elm_Progressbar_Smart_Class;
118
119 /**
120  * Base layout smart data extended with progressbar instance data.
121  */
122 typedef struct _Elm_Progressbar_Smart_Data Elm_Progressbar_Smart_Data;
123 struct _Elm_Progressbar_Smart_Data
124 {
125    Elm_Layout_Smart_Data base;
126
127    Evas_Object          *spacer;
128    const char           *units;
129
130    Evas_Coord            size;
131    double                val;
132
133    Eina_Bool             horizontal : 1;
134    Eina_Bool             inverted : 1;
135    Eina_Bool             pulse : 1;
136    Eina_Bool             pulse_state : 1;
137
138    char                 *(*unit_format_func)(double val);
139    void                  (*unit_format_free)(char *str);
140 };
141
142 /**
143  * @}
144  */
145
146 EAPI extern const char ELM_PROGRESSBAR_SMART_NAME[];
147 EAPI const Elm_Progressbar_Smart_Class *elm_progressbar_smart_class_get(void);
148
149 #define ELM_PROGRESSBAR_DATA_GET(o, sd) \
150   Elm_Progressbar_Smart_Data * sd = evas_object_smart_data_get(o)
151
152 #define ELM_PROGRESSBAR_DATA_GET_OR_RETURN(o, ptr)        \
153   ELM_PROGRESSBAR_DATA_GET(o, ptr);                       \
154   if (!ptr)                                          \
155     {                                                \
156        CRITICAL("No widget data for object %p (%s)", \
157                 o, evas_object_type_get(o));         \
158        return;                                       \
159     }
160
161 #define ELM_PROGRESSBAR_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
162   ELM_PROGRESSBAR_DATA_GET(o, ptr);                         \
163   if (!ptr)                                            \
164     {                                                  \
165        CRITICAL("No widget data for object %p (%s)",   \
166                 o, evas_object_type_get(o));           \
167        return val;                                     \
168     }
169
170 #define ELM_PROGRESSBAR_CHECK(obj)                                      \
171   if (!obj || !elm_widget_type_check((obj), ELM_PROGRESSBAR_SMART_NAME, \
172                                      __func__))                    \
173     return
174
175 #endif