tizen beta release
[framework/web/webkit-efl.git] / debian / libwebkit-engine-dev / usr / include / ewebkit-0 / ewk_contextmenu.h
1 /*
2     Copyright (C) 2010 ProFUSION embedded systems
3     Copyright (C) 2011 Samsung Electronics
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file    ewk_contextmenu.h
23  * @brief   Describes the context menu API.
24  *
25  * The following signals (see evas_object_smart_callback_add()) are emitted:
26  *
27  *  - "contextmenu,customize", Eina_List *: customize context menu is taken
28  *    and it gives a list with items of context menu as an argument.
29  *  - "contextmenu,free", Ewk_Context_Menu *: a context menu is freed.
30  *  - "contextmenu,item,appended", Ewk_Context_Menu *: a new item was added to
31  *    the context menu.
32  *  - "contextmenu,new", Ewk_Context_Menu *: a new context menu was created
33  *    and it gives the context menu as an argument.
34  *  - "contextmenu,show", Ewk_Context_Menu *: a context menu is shown.
35  */
36
37 #ifndef ewk_contextmenu_h
38 #define ewk_contextmenu_h
39
40 #include <Eina.h>
41 #include <Evas.h>
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 /**
48  * \enum    _Ewk_Context_Menu_Action
49  * @brief   Provides the actions of items for the context menu.
50  * @info    Keep this in sync with ContextMenuItem.h
51  */
52 enum _Ewk_Context_Menu_Action {
53     EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION = 0, // this item is not actually in web_uidelegate.h
54     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW = 1,
55     EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK,
56     EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD,
57     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW,
58     EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK,
59     EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD,
60     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW,
61     EWK_CONTEXT_MENU_ITEM_TAG_COPY,
62     EWK_CONTEXT_MENU_ITEM_TAG_GO_BACK,
63     EWK_CONTEXT_MENU_ITEM_TAG_GO_FORWARD,
64     EWK_CONTEXT_MENU_ITEM_TAG_STOP,
65     EWK_CONTEXT_MENU_ITEM_TAG_RELOAD,
66     EWK_CONTEXT_MENU_ITEM_TAG_CUT,
67     EWK_CONTEXT_MENU_ITEM_TAG_PASTE,
68     EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_GUESS,
69     EWK_CONTEXT_MENU_ITEM_TAG_NO_GUESSES_FOUND,
70     EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_SPELLING,
71     EWK_CONTEXT_MENU_ITEM_TAG_LEARN_SPELLING,
72     EWK_CONTEXT_MENU_ITEM_TAG_OTHER,
73     EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_IN_SPOTLIGHT,
74     EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB,
75     EWK_CONTEXT_MENU_ITEM_TAG_LOOK_UP_IN_DICTIONARY,
76     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_WITH_DEFAULT_APPLICATION,
77     EWK_CONTEXT_MENU_ITEM_PDFACTUAL_SIZE,
78     EWK_CONTEXT_MENU_ITEM_PDFZOOM_IN,
79     EWK_CONTEXT_MENU_ITEM_PDFZOOM_OUT,
80     EWK_CONTEXT_MENU_ITEM_PDFAUTO_SIZE,
81     EWK_CONTEXT_MENU_ITEM_PDFSINGLE_PAGE,
82     EWK_CONTEXT_MENU_ITEM_PDFFACING_PAGES,
83     EWK_CONTEXT_MENU_ITEM_PDFCONTINUOUS,
84     EWK_CONTEXT_MENU_ITEM_PDFNEXT_PAGE,
85     EWK_CONTEXT_MENU_ITEM_PDFPREVIOUS_PAGE,
86     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK = 2000,
87     EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_GRAMMAR,
88     EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_MENU, /**< spelling or spelling/grammar sub-menu */
89     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_SPELLING_PANEL,
90     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING,
91     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING_WHILE_TYPING,
92     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_GRAMMAR_WITH_SPELLING,
93     EWK_CONTEXT_MENU_ITEM_TAG_FONT_MENU, /**< font sub-menu */
94     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_FONTS,
95     EWK_CONTEXT_MENU_ITEM_TAG_BOLD,
96     EWK_CONTEXT_MENU_ITEM_TAG_ITALIC,
97     EWK_CONTEXT_MENU_ITEM_TAG_UNDERLINE,
98     EWK_CONTEXT_MENU_ITEM_TAG_OUTLINE,
99     EWK_CONTEXT_MENU_ITEM_TAG_STYLES,
100     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_COLORS,
101     EWK_CONTEXT_MENU_ITEM_TAG_SPEECH_MENU, /**< speech sub-menu */
102     EWK_CONTEXT_MENU_ITEM_TAG_START_SPEAKING,
103     EWK_CONTEXT_MENU_ITEM_TAG_STOP_SPEAKING,
104     EWK_CONTEXT_MENU_ITEM_TAG_WRITING_DIRECTION_MENU, /**< writing direction sub-menu */
105     EWK_CONTEXT_MENU_ITEM_TAG_DEFAULT_DIRECTION,
106     EWK_CONTEXT_MENU_ITEM_TAG_LEFT_TO_RIGHT,
107     EWK_CONTEXT_MENU_ITEM_TAG_RIGHT_TO_LEFT,
108     EWK_CONTEXT_MENU_ITEM_TAG_PDFSINGLE_PAGE_SCROLLING,
109     EWK_CONTEXT_MENU_ITEM_TAG_PDFFACING_PAGES_SCROLLING,
110     // EWK_CONTEXT_MENU_ITEM_TAG_INSPECT_ELEMENT, /**< This feature is disabled in WebKit-EFL - it is a subject to INSPECTOR build variable */
111     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_MENU, /**< text direction sub-menu */
112     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_DEFAULT,
113     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_LEFT_TO_RIGHT,
114     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_RIGHT_TO_LEFT,
115     EWK_CONTEXT_MENU_ITEM_TAG_SEND_VIA_EMAIL = 3000, //
116     EWK_CONTEXT_MENU_ITEM_TAG_SEND_VIA_MESSAGE,
117     /* This feature may not be available in all versions of webkit component - it is a subject to TIZEN_COPY_IMAGE_LOCATION build variable */
118     EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_LOCATION_TO_CLIPBOARD = 3100,
119     EWK_CONTEXT_MENU_ITEM_OPEN_MEDIA_IN_NEW_WINDOW,
120     EWK_CONTEXT_MENU_ITEM_TAG_COPY_MEDIA_LINK_TO_CLIPBOARD,
121     EWK_CONTEXT_MENU_ITEM_TAG_TOGGLE_MEDIA_CONTROLS,
122     EWK_CONTEXT_MENU_ITEM_TAG_TOGGLE_MEDIA_LOOP,
123     EWK_CONTEXT_MENU_ITEM_TAG_ENTER_VIDEO_FULLSCREEN,
124     EWK_CONTEXT_MENU_ITEM_TAG_MEDIA_PLAY_PAUSE,
125     EWK_CONTEXT_MENU_ITEM_TAG_MEDIA_MUTE,
126 /* #if ENABLE(TIZEN_CONTEXT_MENU_SELECT) */
127     EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL = 3200,
128     EWK_CONTEXT_MENU_ITEM_TAG_SELECT_WORD,
129 /* #endif */
130     EWK_CONTEXT_MENU_ITEM_BASE_CUSTOM_TAG = 5000,
131     EWK_CONTEXT_MENU_ITEM_CUSTOM_TAG_NO_ACTION = 5998,
132     EWK_CONTEXT_MENU_ITEM_LAST_CUSTOM_TAG = 5999,
133     EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG = 10000
134 };
135 /** Creates a type name for _Ewk_Context_Menu_Action */
136 typedef enum _Ewk_Context_Menu_Action Ewk_Context_Menu_Action;
137
138 /**
139  * \enum    _Ewk_Context_Menu_Item_Type
140  * @brief   Defines the types of the items for the context menu.
141  * @info    Keep this in sync with ContextMenuItem.h
142  */
143 enum _Ewk_Context_Menu_Item_Type {
144     EWK_ACTION_TYPE,
145     EWK_CHECKABLE_ACTION_TYPE,
146     EWK_SEPARATOR_TYPE,
147     EWK_SUBMENU_TYPE
148 };
149 /** Creates a type name for _Ewk_Context_Menu_Item_Type */
150 typedef enum _Ewk_Context_Menu_Item_Type    Ewk_Context_Menu_Item_Type;
151
152 /** Creates a type name for _Ewk_Context_Menu */
153 typedef struct _Ewk_Context_Menu            Ewk_Context_Menu;
154
155 /** Creates a type name for _Ewk_Context_Menu_Item */
156 typedef struct _Ewk_Context_Menu_Item       Ewk_Context_Menu_Item;
157
158
159
160 /************************** Exported functions ***********************/
161
162 /**
163  * Increases the reference count of the given object.
164  *
165  * @param menu the context menu object to increase the reference count
166  */
167 EAPI void                        ewk_context_menu_ref(Ewk_Context_Menu *menu);
168
169 /**
170  * Decreases the reference count of the given object, possibly freeing it.
171  *
172  * When the reference count it's reached 0, the menu with all items are freed.
173  *
174  * @param menu the context menu object to decrease the reference count
175  */
176 EAPI void                        ewk_context_menu_unref(Ewk_Context_Menu *menu);
177
178 /**
179  * Destroys the context menu object.
180  *
181  * @param menu the context menu object to destroy
182  * @return @c EINA_TRUE on success, @c EINA_FALSE on failure
183  *
184  * @see ewk_context_menu_item_free
185  */
186 EAPI Eina_Bool                   ewk_context_menu_destroy(Ewk_Context_Menu *menu);
187
188 /**
189  * Gets the list of items.
190  *
191  * @param o the context menu object to get list of the items
192  * @return the list of the items on success or @c 0 on failure
193  */
194 EAPI const Eina_List            *ewk_context_menu_item_list_get(const Ewk_Context_Menu *o);
195
196 /**
197  * Creates a new item of the context menu.
198  *
199  * @param type specifies a type of the item
200  * @param action specifies a action of the item
201  * @param submenu specifies a submenu of the item
202  * @param title specifies a title of the item
203  * @param checked @c EINA_TRUE if the item should be toggled or @c EINA_FALSE if not
204  * @param enabled @c EINA_TRUE to enable the item or @c EINA_FALSE to disable
205  * @return the pointer to the new item on success or @c 0 on failure
206  *
207  * @note The return value @b should @b be freed after use.
208  */
209 EAPI Ewk_Context_Menu_Item      *ewk_context_menu_item_new(Ewk_Context_Menu_Item_Type type, Ewk_Context_Menu_Action action, Ewk_Context_Menu *submenu, const char *title, Eina_Bool checked, Eina_Bool enabled);
210
211 /**
212  * Destroys the item of the context menu object.
213  *
214  * @param item the item to destroy
215  *
216  * @see ewk_context_menu_destroy
217  * @see ewk_context_menu_unref
218  */
219 EAPI void                        ewk_context_menu_item_free(Ewk_Context_Menu_Item *item);
220
221 /**
222  * Selects the item from the context menu object.
223  *
224  * @param menu the context menu object
225  * @param item the item is selected
226  * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
227  */
228 EAPI Eina_Bool                   ewk_context_menu_item_select(Ewk_Context_Menu *menu, Ewk_Context_Menu_Item *item);
229
230 /**
231  * Gets type of the item.
232  *
233  * @param o the item to get the type
234  * @return type of the item on success or @c EWK_ACTION_TYPE on failure
235  *
236  * @see ewk_context_menu_item_type_set
237  */
238 EAPI Ewk_Context_Menu_Item_Type  ewk_context_menu_item_type_get(const Ewk_Context_Menu_Item *o);
239
240 /**
241  * Sets the type of item.
242  *
243  * @param o the item to set the type
244  * @param type a new type for the item object
245  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
246  *
247  * @see ewk_context_menu_item_type_get
248  */
249 EAPI Eina_Bool                   ewk_context_menu_item_type_set(Ewk_Context_Menu_Item *o, Ewk_Context_Menu_Item_Type type);
250
251 /**
252  * Gets an action of the item.
253  *
254  * @param o the item to get the action
255  * @return an action of the item on success or @c EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION on failure
256  *
257  * @see ewk_context_menu_item_action_set
258  */
259 EAPI Ewk_Context_Menu_Action     ewk_context_menu_item_action_get(const Ewk_Context_Menu_Item *o);
260
261 /**
262  * Sets an action of the item.
263  *
264  * @param o the item to set the action
265  * @param action a new action for the item object
266  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
267  *
268  * @see ewk_context_menu_item_action_get
269  */
270 EAPI Eina_Bool                   ewk_context_menu_item_action_set(Ewk_Context_Menu_Item *o, Ewk_Context_Menu_Action action);
271
272 /**
273  * Gets a title of the item.
274  *
275  * @param o the item to get the title
276  * @return a title of the item on success, or @c 0 on failure
277  *
278  * @see ewk_context_menu_item_title_set
279  */
280 EAPI const char                 *ewk_context_menu_item_title_get(const Ewk_Context_Menu_Item *o);
281
282 /**
283  * Sets a title of the item.
284  *
285  * @param o the item to set the title
286  * @param title a new title for the item object
287  * @return a new title of the item on success or @c 0 on failure
288  *
289  * @see ewk_context_menu_item_title_get
290  */
291 EAPI const char                 *ewk_context_menu_item_title_set(Ewk_Context_Menu_Item *o, const char *title);
292
293 /**
294  * Queries if the item is toggled.
295  *
296  * @param o the item to query if the item is toggled
297  * @return @c EINA_TRUE if the item is toggled or @c EINA_FALSE if not or on failure
298  */
299 EAPI Eina_Bool                   ewk_context_menu_item_checked_get(const Ewk_Context_Menu_Item *o);
300
301 /**
302  * Sets if the item should be toggled.
303  *
304  * @param o the item to be toggled
305  * @param checked @c EINA_TRUE if the item should be toggled or @c EINA_FALSE if not
306  * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
307  */
308 EAPI Eina_Bool                   ewk_context_menu_item_checked_set(Ewk_Context_Menu_Item *o, Eina_Bool checked);
309
310 /**
311  * Gets if the item is enabled.
312  *
313  * @param o the item to get enabled state
314  * @return @c EINA_TRUE if it's enabled, @c EINA_FALSE if not or on failure
315  *
316  * @see ewk_context_menu_item_enabled_set
317  */
318 EAPI Eina_Bool                   ewk_context_menu_item_enabled_get(const Ewk_Context_Menu_Item *o);
319
320 /**
321  * Enables/disables the item.
322  *
323  * @param o the item to enable/disable
324  * @param enabled @c EINA_TRUE to enable the item or @c EINA_FALSE to disable
325  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
326  *
327  * @see ewk_context_menu_item_enabled_get
328  */
329 EAPI Eina_Bool                   ewk_context_menu_item_enabled_set(Ewk_Context_Menu_Item *o, Eina_Bool enabled);
330
331 /** TIZEN APIs */
332 EAPI Ewk_Context_Menu*           ewk_context_menu_item_parent_get(Ewk_Context_Menu_Item* o);
333 EAPI int                         ewk_context_menu_cached_image_save(const char* image_name);
334 #ifdef __cplusplus
335 }
336 #endif
337 #endif // ewk_contextmenu_h