elementary/map - map supports language,changed
[framework/uifw/elementary.git] / src / lib / elm_widget_web.h
1 #ifndef ELM_WIDGET_WEB_H
2 #define ELM_WIDGET_WEB_H
3
4 #ifdef HAVE_ELEMENTARY_WEB
5 #ifdef USE_WEBKIT2
6 #include <EWebKit2.h>
7 #else
8 #include <EWebKit.h>
9 #endif
10 #endif
11
12 /**
13  * @addtogroup Widget
14  * @{
15  *
16  * @section elm-web-class The Elementary Web Class
17  *
18  * Elementary, besides having the @ref Web widget, exposes its
19  * foundation -- the Elementary Web Class -- in order to create other
20  * widgets which are a web view with some more logic on top.
21  */
22
23 /**
24  * @def ELM_WEB_CLASS
25  *
26  * Use this macro to cast whichever subclass of
27  * #Elm_Web_Smart_Class into it, so to access its fields.
28  *
29  * @ingroup Widget
30  */
31 #define ELM_WEB_CLASS(x) ((Elm_Web_Smart_Class *) x)
32
33 /**
34  * @def ELM_WEB_DATA
35  *
36  * Use this macro to cast whichever subdata of
37  * #Elm_Web_Smart_Data into it, so to access its fields.
38  *
39  * @ingroup Widget
40  */
41 #define ELM_WEB_DATA(x) ((Elm_Web_Smart_Data *) x)
42
43 /**
44  * @def ELM_WEB_SMART_CLASS_VERSION
45  *
46  * Current version for Elementary web @b base smart class, a value
47  * which goes to _Elm_Web_Smart_Class::version.
48  *
49  * @ingroup Widget
50  */
51 #define ELM_WEB_SMART_CLASS_VERSION 1
52
53 /**
54  * @def ELM_WEB_SMART_CLASS_INIT
55  *
56  * Initializer for a whole #Elm_Web_Smart_Class structure, with
57  * @c NULL values on its specific fields.
58  *
59  * @param smart_class_init initializer to use for the "base" field
60  * (#Evas_Smart_Class).
61  *
62  * @see EVAS_SMART_CLASS_INIT_NULL
63  * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
64  * @see ELM_WEB_SMART_CLASS_INIT_NULL
65  * @see ELM_WEB_SMART_CLASS_INIT_NAME_VERSION
66  *
67  * @ingroup Widget
68  */
69 #define ELM_WEB_SMART_CLASS_INIT(smart_class_init)                        \
70   {smart_class_init, ELM_WEB_SMART_CLASS_VERSION}
71
72 /**
73  * @def ELM_WEB_SMART_CLASS_INIT_NULL
74  *
75  * Initializer to zero out a whole #Elm_Web_Smart_Class structure.
76  *
77  * @see ELM_WEB_SMART_CLASS_INIT_NAME_VERSION
78  * @see ELM_WEB_SMART_CLASS_INIT
79  *
80  * @ingroup Widget
81  */
82 #define ELM_WEB_SMART_CLASS_INIT_NULL \
83   ELM_WEB_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
84
85 /**
86  * @def ELM_WEB_SMART_CLASS_INIT_NAME_VERSION
87  *
88  * Initializer to zero out a whole #Elm_Web_Smart_Class structure and
89  * set its name and version.
90  *
91  * This is similar to #ELM_WEB_SMART_CLASS_INIT_NULL, but it will
92  * also set the version field of #Elm_Web_Smart_Class (base field)
93  * to the latest #ELM_WEB_SMART_CLASS_VERSION and name it to the
94  * specific value.
95  *
96  * It will keep a reference to the name field as a <c>"const char *"</c>,
97  * i.e., the name must be available while the structure is
98  * used (hint: static or global variable!) and must not be modified.
99  *
100  * @see ELM_WEB_SMART_CLASS_INIT_NULL
101  * @see ELM_WEB_SMART_CLASS_INIT
102  *
103  * @ingroup Widget
104  */
105 #define ELM_WEB_SMART_CLASS_INIT_NAME_VERSION(name) \
106   ELM_WEB_SMART_CLASS_INIT(ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(name))
107
108 /**
109  * Elementary web base smart class. This inherits directly from
110  * #Elm_Widget_Smart_Class and is meant to build widgets extending the
111  * behavior of a web.
112  *
113  * All of the functions listed on @ref Web namespace will work for
114  * objects deriving from #Elm_Web_Smart_Class.
115  */
116 typedef struct _Elm_Web_Smart_Class
117 {
118    Elm_Widget_Smart_Class base;
119
120    int                    version; /**< Version of this smart class definition */
121 } Elm_Web_Smart_Class;
122
123 /**
124  * Base widget smart data extended with web instance data.
125  */
126 typedef struct _Elm_Web_Smart_Data Elm_Web_Smart_Data;
127 struct _Elm_Web_Smart_Data
128 {
129    Elm_Widget_Smart_Data base;    /* base widget smart data as
130                                    * first member obligatory, as
131                                    * we're inheriting from it */
132
133 #ifdef HAVE_ELEMENTARY_WEB
134    struct
135    {
136       Elm_Web_Window_Open          window_create;
137       void                        *window_create_data;
138       Elm_Web_Dialog_Alert         alert;
139       void                        *alert_data;
140       Elm_Web_Dialog_Confirm       confirm;
141       void                        *confirm_data;
142       Elm_Web_Dialog_Prompt        prompt;
143       void                        *prompt_data;
144       Elm_Web_Dialog_File_Selector file_selector;
145       void                        *file_selector_data;
146       Elm_Web_Console_Message      console_message;
147       void                        *console_message_data;
148    } hook;
149
150    Elm_Win_Keyboard_Mode input_method;
151
152    struct
153    {
154       Elm_Web_Zoom_Mode mode;
155       float             current;
156       float             min, max;
157       Eina_Bool         no_anim;
158       Ecore_Timer      *timer;
159    } zoom;
160
161    struct
162    {
163       struct
164       {
165          int x, y;
166       } start, end;
167       Ecore_Animator *animator;
168    } bring_in;
169
170    Eina_Bool tab_propagate : 1;
171    Eina_Bool inwin_mode : 1;
172 #endif
173 };
174
175 enum Dialog_Type
176 {
177    DIALOG_ALERT,
178    DIALOG_CONFIRM,
179    DIALOG_PROMPT,
180    DIALOG_FILE_SELECTOR
181 };
182
183 typedef struct _Dialog_Data Dialog_Data;
184 struct _Dialog_Data
185 {
186    enum Dialog_Type type;
187
188    Evas_Object     *dialog;
189    Evas_Object     *box;
190    Evas_Object     *bt_ok, *bt_cancel;
191    Evas_Object     *entry;
192    Evas_Object     *file_sel;
193
194    Eina_Bool       *response;
195    const char     **entry_value;
196    Eina_List      **selected_files;
197 };
198
199 struct _Elm_Web_Callback_Proxy_Context
200 {
201    const char  *name;
202    Evas_Object *obj;
203 };
204 typedef struct _Elm_Web_Callback_Proxy_Context Elm_Web_Callback_Proxy_Context;
205
206 #ifdef HAVE_ELEMENTARY_WEB
207
208 typedef struct _View_Smart_Data View_Smart_Data;
209 struct _View_Smart_Data
210 {
211    Ewk_View_Smart_Data base;
212    struct
213    {
214       Evas_Event_Mouse_Down event;
215       Evas_Coord            x, y;
216       unsigned int          move_count;
217       Ecore_Timer          *longpress_timer;
218       Ecore_Animator       *pan_anim;
219    } mouse;
220 };
221
222 #endif
223
224 /**
225  * @}
226  */
227
228 EAPI extern const char ELM_WEB_SMART_NAME[];
229 EAPI const Elm_Web_Smart_Class *elm_web_smart_class_get(void);
230
231 #define ELM_WEB_DATA_GET(o, sd) \
232   Elm_Web_Smart_Data * sd = evas_object_smart_data_get(o)
233
234 #define ELM_WEB_DATA_GET_OR_RETURN(o, ptr)           \
235   ELM_WEB_DATA_GET(o, ptr);                          \
236   if (!ptr)                                          \
237     {                                                \
238        CRITICAL("No widget data for object %p (%s)", \
239                 o, evas_object_type_get(o));         \
240        return;                                       \
241     }
242
243 #define ELM_WEB_DATA_GET_OR_RETURN_VAL(o, ptr, val)  \
244   ELM_WEB_DATA_GET(o, ptr);                          \
245   if (!ptr)                                          \
246     {                                                \
247        CRITICAL("No widget data for object %p (%s)", \
248                 o, evas_object_type_get(o));         \
249        return val;                                   \
250     }
251
252 #define ELM_WEB_CHECK(obj)                                                 \
253   if (!obj || !elm_widget_type_check((obj), ELM_WEB_SMART_NAME, __func__)) \
254     return
255
256 #endif