[access] call a callback function with information
[framework/uifw/elementary.git] / src / lib / elm_widget_icon.h
1 #ifndef ELM_WIDGET_ICON_H
2 #define ELM_WIDGET_ICON_H
3
4 #include "elm_widget_image.h"
5
6 /**
7  * @addtogroup Widget
8  * @{
9  *
10  * @section elm-icon-class The Elementary Icon Class
11  *
12  * This class defines a common interface for @b icon objects having
13  * an icon as their basic graphics.
14  */
15
16  /**
17   * @def ELM_ICON_CLASS
18   *
19   * Use this macro to cast whichever subclass of
20   * #Elm_Icon_Smart_Class into it, so to access its fields.
21   *
22   * @ingroup Widget
23   */
24  #define ELM_ICON_CLASS(x) ((Elm_Icon_Smart_Class *) x)
25
26 /**
27  * @def ELM_ICON_DATA
28  *
29  * Use this macro to cast whichever subdata of
30  * #Elm_Icon_Smart_Data into it, so to access its fields.
31  *
32  * @ingroup Widget
33  */
34 #define ELM_ICON_DATA(x) ((Elm_Icon_Smart_Data *) x)
35
36 /**
37  * @def ELM_ICON_SMART_CLASS_VERSION
38  *
39  * Current version for Elementary icon @b base smart class, a value
40  * which goes to _Elm_Icon_Smart_Class::version.
41  *
42  * @ingroup Widget
43  */
44 #define ELM_ICON_SMART_CLASS_VERSION 1
45
46 /**
47  * @def ELM_ICON_SMART_CLASS_INIT
48  *
49  * Initializer for a whole #Elm_Icon_Smart_Class structure, with
50  * @c NULL values on its specific fields.
51  *
52  * @param smart_class_init initializer to use for the "base" field
53  * (#Evas_Smart_Class).
54  *
55  * @see EVAS_SMART_CLASS_INIT_NULL
56  * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
57  * @see ELM_ICON_SMART_CLASS_INIT_NULL
58  * @see ELM_ICON_SMART_CLASS_INIT_NAME_VERSION
59  *
60  * @ingroup Widget
61  */
62 #define ELM_ICON_SMART_CLASS_INIT(smart_class_init)                        \
63     {smart_class_init, ELM_ICON_SMART_CLASS_VERSION}
64
65 /**
66  * @def ELM_ICON_SMART_CLASS_INIT_NULL
67  *
68  * Initializer to zero out a whole #Elm_Icon_Smart_Class structure.
69  *
70  * @see ELM_ICON_SMART_CLASS_INIT_NAME_VERSION
71  * @see ELM_ICON_SMART_CLASS_INIT
72  *
73  * @ingroup Widget
74  */
75 #define ELM_ICON_SMART_CLASS_INIT_NULL \
76   ELM_ICON_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
77
78 /**
79  * @def ELM_ICON_SMART_CLASS_INIT_NAME_VERSION
80  *
81  * Initializer to zero out a whole #Elm_Icon_Smart_Class structure and
82  * set its name and version.
83  *
84  * This is similar to #ELM_ICON_SMART_CLASS_INIT_NULL, but it will
85  * also set the version field of #Elm_Icon_Smart_Class (base field)
86  * to the latest #ELM_ICON_SMART_CLASS_VERSION and name it to the
87  * specific value.
88  *
89  * It will keep a reference to the name field as a <c>"const char *"</c>,
90  * i.e., the name must be available while the structure is
91  * used (hint: static or global variable!) and must not be modified.
92  *
93  * @see ELM_ICON_SMART_CLASS_INIT_NULL
94  * @see ELM_ICON_SMART_CLASS_INIT
95  *
96  * @ingroup Widget
97  */
98 #define ELM_ICON_SMART_CLASS_INIT_NAME_VERSION(name) \
99   ELM_ICON_SMART_CLASS_INIT(ELM_IMAGE_SMART_CLASS_INIT_NAME_VERSION(name))
100
101 /**
102  * Elementary icon base smart class. This inherits directly from
103  * #Elm_Image_Smart_Class and is meant to build widgets relying on an
104  * icon as the building block of its visuals.
105  */
106 typedef struct _Elm_Icon_Smart_Class
107 {
108    Elm_Image_Smart_Class base;
109
110    int                    version; /**< Version of this smart class definition */
111 } Elm_Icon_Smart_Class;
112
113 typedef struct _Elm_Icon_Smart_Data Elm_Icon_Smart_Data;
114 struct _Elm_Icon_Smart_Data
115 {
116    Elm_Image_Smart_Data  base;
117
118    const char           *stdicon;
119    Elm_Icon_Lookup_Order lookup_order;
120
121 #ifdef HAVE_ELEMENTARY_ETHUMB
122    struct
123    {
124       struct
125       {
126          const char *path;
127          const char *key;
128       } file, thumb;
129
130       Ecore_Event_Handler *eeh;
131
132       Ethumb_Thumb_Format  format;
133
134       Ethumb_Client_Async *request;
135
136       Eina_Bool            retry : 1;
137    } thumb;
138 #endif
139
140 #ifdef ELM_EFREET
141    struct
142    {
143       int       requested_size;
144       Eina_Bool use : 1;
145    } freedesktop;
146 #endif
147
148    int        in_eval;
149
150    /* WARNING: to be deprecated */
151    Eina_List *edje_signals;
152
153    Eina_Bool  is_video : 1;
154 };
155
156 /**
157  * @}
158  */
159
160 EAPI extern const char ELM_ICON_SMART_NAME[];
161 EAPI const Elm_Icon_Smart_Class *elm_icon_smart_class_get(void);
162
163 #define ELM_ICON_DATA_GET(o, sd) \
164   Elm_Icon_Smart_Data * sd = evas_object_smart_data_get(o)
165
166 #define ELM_ICON_DATA_GET_OR_RETURN(o, ptr)          \
167   ELM_ICON_DATA_GET(o, ptr);                         \
168   if (!ptr)                                          \
169     {                                                \
170        CRITICAL("No widget data for object %p (%s)", \
171                 o, evas_object_type_get(o));         \
172        return;                                       \
173     }
174
175 #define ELM_ICON_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
176   ELM_ICON_DATA_GET(o, ptr);                         \
177   if (!ptr)                                          \
178     {                                                \
179        CRITICAL("No widget data for object %p (%s)", \
180                 o, evas_object_type_get(o));         \
181        return val;                                   \
182     }
183
184 #define ELM_ICON_CHECK(obj)                                                 \
185   if (!obj || !elm_widget_type_check((obj), ELM_ICON_SMART_NAME, __func__)) \
186     return
187
188 #endif